:root {
  --bg: #0e1726;
  --panel: rgba(13, 25, 42, 0.86);
  --panel-border: rgba(180, 214, 255, 0.18);
  --text: #eaf4ff;
  --muted: #aac4df;
  --blue: #67c7ff;
  --amber: #ffbe55;
  --danger: #ff6b6b;
  --tile: #24364f;
  --tile-edge: #5d7696;
  --pipe: #d6e6f7;
  --cell: min(14vw, 72px);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(103,199,255,0.22), transparent 28%),
    linear-gradient(180deg, #13233a 0%, var(--bg) 50%, #09111d 100%);
}

a { color: #d9ecff; }
button { font: inherit; }

.shell {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

.topbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  color: var(--muted);
  margin-bottom: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
}

.hero, .sidebar { align-self: start; }
.eyebrow, .label { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; color: var(--muted); }
h1, h2, p { margin-top: 0; }
.subtitle, .tip, li { color: #d8e7f6; line-height: 1.45; }

.game-panel { display: flex; flex-direction: column; gap: 14px; }
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.hud > div {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px;
}
.hud strong { display: block; margin-top: 5px; font-size: 1.2rem; }

.message {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(103, 199, 255, 0.12);
  color: #eff8ff;
}

.board-wrap {
  padding: 16px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)),
    repeating-linear-gradient(150deg, rgba(255,255,255,0.03) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, #6c4734 0%, #513424 100%);
}

.sources, .barrels, .board {
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  justify-content: center;
  gap: 8px;
}

.sources, .barrels { margin: 0 auto; }
.source, .barrel {
  text-indent: -9999px;
  position: relative;
  width: var(--cell);
  height: 28px;
}
.source::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 50%;
  width: 18px;
  height: 100%;
  transform: translateX(-50%);
  border-radius: 10px 10px 0 0;
  background: currentColor;
  box-shadow: 0 8px 0 rgba(0,0,0,0.12);
}
.barrel::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 42px;
  height: 24px;
  transform: translateX(-50%);
  border-radius: 10px 10px 6px 6px;
  background: currentColor;
  border: 3px solid rgba(0,0,0,0.18);
}
.blue { color: var(--blue); }
.amber { color: var(--amber); }

.board {
  position: relative;
  margin: 8px auto;
}
.tile {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #314865 0%, var(--tile) 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08), 0 6px 14px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.tile:active { transform: scale(0.97); }
.tile.locked { filter: saturate(0.8); }
.tile::before, .tile::after, .pipe, .drop {
  position: absolute;
}
.tile::before {
  content: "";
  inset: 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}
.pipe {
  left: calc(50% - 7px);
  top: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--pipe);
  box-shadow: 0 0 12px rgba(255,255,255,0.18);
}
.pipe-arm {
  position: absolute;
  background: var(--pipe);
  border-radius: 999px;
}
.pipe-arm.north, .pipe-arm.south { left: calc(50% - 5px); width: 10px; height: 28px; }
.pipe-arm.north { top: 0; }
.pipe-arm.south { bottom: 0; }
.pipe-arm.east, .pipe-arm.west { top: calc(50% - 5px); width: 28px; height: 10px; }
.pipe-arm.east { right: 0; }
.pipe-arm.west { left: 0; }
.tile.spawn::after, .tile.exit::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  left: calc(50% - 6px);
}
.tile.spawn::after { top: 3px; background: rgba(255,255,255,0.8); }
.tile.exit::after { bottom: 3px; background: rgba(255,255,255,0.7); }
.drop {
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 58% 58%;
  border: 2px solid rgba(255,255,255,0.55);
  box-shadow: 0 0 18px currentColor;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #79d2ff 0%, #3b9ad1 100%);
  color: #05111e;
  font-weight: 700;
}
button.secondary {
  background: rgba(255,255,255,0.09);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}

ul { padding-left: 18px; margin-bottom: 0; }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .hero { order: -2; }
  .sidebar { order: 3; }
  .shell { width: min(760px, calc(100% - 16px)); }
}

@media (max-width: 560px) {
  :root { --cell: min(17vw, 62px); }
  .panel { padding: 14px; border-radius: 18px; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .board-wrap { padding: 10px 6px; }
  .message { font-size: 0.95rem; }
  .controls button { flex: 1 1 0; justify-content: center; }
}
