:root {
  color-scheme: dark;
  --bg: #07131d;
  --panel: rgba(8, 22, 34, 0.9);
  --panel-2: rgba(13, 31, 46, 0.95);
  --line: rgba(255,255,255,0.08);
  --text: #eaf7ff;
  --muted: #9eb8c7;
  --accent: #78f0d5;
  --gold: #ffd37a;
  --danger: #ff9d88;
  --water: #14344d;
  --water-open: #24577d;
  --water-open-2: #2f7397;
  --shore: #0d2537;
  --rock: #596876;
  --highlight: rgba(120, 240, 213, 0.28);
}

* { 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(54, 119, 170, 0.28), transparent 40%),
    linear-gradient(180deg, #0a1c2b 0%, var(--bg) 42%, #051018 100%);
}
.wrap {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 20px 14px 32px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.24);
}
.topnav, .hero, .message, .intro { text-align: center; }
.topnav {
  color: var(--muted);
  margin-bottom: 16px;
}
.topnav a {
  color: var(--text);
  text-decoration: none;
}
.hero {
  padding: 18px 18px 16px;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 0.72rem;
}
h1 {
  margin: 8px 0;
  font-size: clamp(2rem, 7vw, 3.25rem);
}
.subtitle {
  color: var(--muted);
  margin: 0 auto;
  max-width: 34rem;
}
.hud {
  margin-top: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.hud > div,
.legend,
.controls,
.intro {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 18px;
}
.hud > div {
  text-align: center;
  padding: 11px 8px;
}
.label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--muted);
}
.chip {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: -1px;
}
.chip.boat { background: #96f4ff; box-shadow: 0 0 10px rgba(150, 244, 255, 0.8); }
.chip.beacon { background: var(--gold); }
.chip.harbour { background: #92ffb4; }
.chip.rock { background: var(--rock); }
.chip.tide-0 { background: #2e7fa6; }
.chip.tide-1 { background: #3c95bd; }
.chip.tide-2 { background: #5db9d9; }
.intro {
  margin-top: 14px;
  padding: 14px 16px;
  color: var(--muted);
}
.board {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)), var(--water);
}
.cell::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 14px;
  border: 1px dashed rgba(255,255,255,0.04);
}
.cell.open {
  background: linear-gradient(180deg, rgba(105, 202, 242, 0.18), rgba(255,255,255,0.02)), var(--water-open);
}
.cell.open::after {
  content: "";
  position: absolute;
  inset: auto 10% 16% 10%;
  height: 14%;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.cell.reachable {
  outline: 2px solid rgba(120, 240, 213, 0.8);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 999px var(--highlight);
}
.cell.goal {
  box-shadow: inset 0 0 0 2px rgba(255, 211, 122, 0.35);
}
.cell.harbour {
  box-shadow: inset 0 0 0 2px rgba(146, 255, 180, 0.35);
}
.cell.rocky {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.05)), var(--shore);
}
.cell.rocky::after {
  content: "🪨";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1rem, 3.6vw, 1.5rem);
  opacity: 0.9;
}
.cell button {
  position: absolute;
  inset: 0;
  border: none;
  background: transparent;
  padding: 0;
}
.entity, .hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.entity {
  font-size: clamp(1.2rem, 4.8vw, 2rem);
}
.entity.boat {
  filter: drop-shadow(0 0 10px rgba(150, 244, 255, 0.75));
}
.entity.beacon {
  color: #2c1e00;
  text-shadow: 0 0 16px rgba(255, 211, 122, 0.65);
}
.entity.harbour {
  filter: drop-shadow(0 0 10px rgba(146,255,180,0.4));
}
.hint {
  font-size: clamp(0.9rem, 3.2vw, 1.1rem);
  color: rgba(234, 247, 255, 0.85);
}
.phase-badge {
  position: absolute;
  top: 7px;
  right: 8px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(234, 247, 255, 0.72);
}
.controls {
  margin-top: 14px;
  padding: 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
}
button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #8ef8dd, #54d0b2);
  color: #05211a;
  font: inherit;
  font-weight: 800;
}
#nextBtn {
  background: linear-gradient(180deg, #a4d7ff, #6aaeff);
  color: #07192c;
}
.message {
  min-height: 1.8em;
  color: var(--muted);
  margin-top: 14px;
}
@media (min-width: 640px) {
  .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
