:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --paper: #101219;
  --paper-ink: #f7f7fb;
  --paper-muted: #aab0c0;
  --paper-line: #2b3040;
  --shell-panel: #191c26;
  --shell-accent: #f8d45d;
  --sea: #0e242c;
  --panel: #142f37;
  --line: #34515a;
  --ink: #f0f9f6;
  --muted: #abc3c5;
  --aqua: #6ef7ce;
  --warn: #ffc3af;
  --mono: "Cascadia Mono", Consolas, monospace;
  --content: 68rem;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--paper-ink); }
h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; }
button {
  min-height: 2.75rem;
  padding: .55rem .85rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--panel);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
}
button:hover { border-color: var(--aqua); color: var(--aqua); }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--shell-accent); outline-offset: 3px; }
.board :focus-visible, dialog :focus-visible { outline-color: var(--aqua); }

.top, .game-intro, .layout, .game-guide, .bottom {
  width: min(var(--content), calc(100% - 2rem));
  margin-inline: auto;
}
.site-header { border-bottom: 1px solid var(--paper-line); background: #14161e; }
.top { min-height: 4rem; display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.site-brand {
  display: inline-flex;
  align-items: center;
  color: var(--paper-ink);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 850;
  letter-spacing: -.06em;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  margin-right: .4rem;
  place-items: center;
  border-radius: .55rem;
  font-size: 1rem;
  letter-spacing: 0;
}
.brand-period { color: var(--shell-accent); }
.tools { display: flex; align-items: center; }
.tools button {
  min-height: 2.75rem;
  padding: .35rem .42rem;
  border-color: transparent;
  background: transparent;
  color: var(--paper-ink);
  font-size: .78rem;
  white-space: nowrap;
}
.tools button:hover { border-color: var(--paper-line); color: var(--shell-accent); }
.tools #help { background: #232736; }

.game-intro { margin-top: 1.05rem; }
.back-link {
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  gap: .35rem;
  color: var(--paper-muted);
  font-size: .84rem;
  font-weight: 680;
  text-decoration: none;
}
.back-link:hover { color: var(--shell-accent); text-decoration: underline; }
.game-intro h1 {
  margin-top: .2rem;
  font-size: clamp(2.25rem, 9vw, 4.55rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.072em;
}
.layout { display: grid; min-width: 0; margin-top: 1.1rem; }
.depth-panel, .board, dialog { color-scheme: dark; background: var(--sea); color: var(--ink); }
.depth-panel {
  position: relative;
  display: grid;
  gap: .35rem;
  padding: .75rem 1rem .65rem;
  border: 1px solid #2b5055;
  border-bottom: 0;
  border-radius: 1.18rem 1.18rem 0 0;
  background: #17363f;
}
#water, .sonar, .depth-footer, .ticks { display: none; }
.depth-caption { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.depth-caption > span { color: var(--muted); font-size: .83rem; font-weight: 650; }
.depth-caption strong { color: var(--aqua); font: 700 1.18rem var(--mono); font-variant-numeric: tabular-nums; }
.depth-caption strong span { color: var(--muted); font-size: .74rem; }
.depth-track { position: relative; width: 100%; height: .3rem; border-radius: 1rem; background: #34525a; }
#depth-fill {
  position: absolute;
  width: 0;
  height: 100%;
  border-radius: 1rem;
  background: linear-gradient(90deg, #39caac, var(--aqua));
  transition: width .28s ease;
}
#depth-marker {
  position: absolute;
  top: -.1rem;
  left: 0;
  width: .38rem;
  height: .5rem;
  border-radius: 1rem;
  background: var(--aqua);
  box-shadow: 0 0 .65rem #6ef7ce84;
  transform: translateX(-50%);
  transition: left .28s ease;
}
.board {
  min-width: 0;
  padding: .6rem 1rem 1.12rem;
  border: 1px solid #2b5055;
  border-radius: 0 0 1.18rem 1.18rem;
}
.board-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .45rem;
  margin-bottom: .48rem;
  color: var(--muted);
  font-size: .76rem;
}
.text-button { padding: .2rem .45rem; min-height: 2.3rem; background: transparent; font-size: .76rem; }
.challenge-notice {
  margin-bottom: .7rem;
  padding: .5rem .65rem;
  border: 1px solid #8c625b;
  border-radius: .55rem;
  background: #402e32;
  color: #ffe2d8;
  font-size: .85rem;
  line-height: 1.4;
}
.steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.steps li {
  display: grid;
  min-height: 1.6rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: .44rem;
  background: #163139;
  color: var(--muted);
  font: .75rem var(--mono);
}
.steps li.current { border-color: var(--aqua); color: var(--aqua); }
.steps li.done { background: #234941; color: #d2ffef; }
.steps li.miss { background: #432d31; color: var(--warn); }
#stage { padding-top: 1.1rem; }
#stage h2 {
  font-size: clamp(1.55rem, 6vw, 2.75rem);
  font-weight: 750;
  line-height: 1.14;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.eyebrow {
  margin-bottom: .45rem;
  color: var(--aqua);
  font: 650 .77rem var(--mono);
  letter-spacing: .03em;
}
.desc { margin-top: .48rem; max-width: 37ch; color: var(--muted); line-height: 1.5; }
.chips, .actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.chips span {
  padding: .28rem .52rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  color: var(--muted);
  font-size: .73rem;
}
.primary, .primary:hover, .primary:focus-visible { color: #102c24; }
.primary { padding-inline: .9rem; border-color: var(--aqua); background: var(--aqua); font-weight: 800; }
.primary:hover { background: #afffe8; }
.lobby-start .primary { width: 100%; }

.round-line { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.round-line .eyebrow { margin: 0; }
#time { min-width: 3rem; color: var(--aqua); font: 700 .95rem var(--mono); text-align: right; }
#time.danger { color: var(--warn); }
.clock { height: .23rem; margin-bottom: .85rem; overflow: hidden; border-radius: .3rem; background: #34525a; }
#clock-fill { width: 100%; height: 100%; background: var(--aqua); transform-origin: left; }
#clock-fill.danger { background: var(--warn); }
.answer-form { display: flex; gap: .45rem; margin-top: .94rem; }
.answer-form input, textarea {
  min-width: 0;
  flex: 1;
  padding: .65rem .7rem;
  border: 1px solid #527982;
  border-radius: .7rem;
  background: #081a22;
  color: var(--ink);
  font-size: 1rem;
}
.answer-form input::placeholder { color: var(--muted); }
.note { margin-top: .58rem; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.result-card {
  margin-top: .78rem;
  padding: .7rem .8rem;
  border: 1px solid #417b71;
  border-radius: .73rem;
  background: #173b3b;
  color: #e2fff6;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.result-card.miss { border-color: #8c625b; background: #402e32; color: #ffe2d8; }
#stage .final-score { color: var(--aqua); font-size: clamp(2.35rem, 9vw, 4.7rem); font-variant-numeric: tabular-nums; }
.result-symbols { max-width: fit-content; letter-spacing: .14em; }
.return-link { display: inline-block; margin-top: .85rem; color: var(--aqua); font-size: .87rem; }
.daily-status {
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}
.daily-status[hidden], .daily-status [hidden] { display: none; }
.refresh-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: .2rem .65rem;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.45;
}
.refresh-meta strong { color: var(--ink); }
.refresh-meta time { grid-column: 1 / -1; }
.refresh-countdown { color: var(--aqua); font: 650 .85rem var(--mono); font-variant-numeric: tabular-nums; }
.daily-status .return-link { margin-top: .5rem; }

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: .33rem;
  margin-top: .72rem;
}
.modes button {
  min-height: 2.75rem;
  padding-inline: .66rem;
  border-color: var(--paper-line);
  background: var(--shell-panel);
  color: var(--paper-muted);
  font-size: .8rem;
}
.modes button:hover { border-color: #555b70; color: var(--paper-ink); }
.modes button[aria-pressed=true] { border-color: #5a4c2b; background: #30291c; color: var(--shell-accent); }
.game-guide {
  margin-top: 1.25rem;
  padding-top: .95rem;
  border-top: 1px solid var(--paper-line);
  color: var(--paper-muted);
}
.game-guide summary { width: fit-content; color: var(--paper-ink); font-size: .9rem; font-weight: 700; cursor: pointer; }
.game-guide h2 { margin-top: 1.25rem; color: var(--paper-ink); font-size: 1.1rem; }
.game-guide p { max-width: 65ch; margin-top: .65rem; line-height: 1.55; }
.game-guide ol { max-width: 65ch; padding-inline-start: 1.35rem; line-height: 1.55; }
.game-guide li + li { margin-top: .45rem; }
.guide-links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .8rem; }
.guide-links a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--shell-accent); }
.bottom {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  margin-top: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--paper-muted);
  font-size: .79rem;
}
.bottom a { color: var(--paper-muted); }
dialog {
  width: min(34rem, calc(100% - 2rem));
  max-height: 86vh;
  padding: 1.2rem;
  border: 1px solid #527982;
  border-radius: 1rem;
}
dialog::backdrop { background: #081a22bf; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.dialog-head h2 { font-size: 1.23rem; }
#dialog-body { color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
#dialog-body ol { padding-left: 1.3rem; }
#dialog-body li + li { margin-top: .35rem; }
#dialog-body table { width: 100%; border-collapse: collapse; margin-top: .7rem; text-align: left; font-size: .84rem; }
#dialog-body td, #dialog-body th { padding: .4rem .23rem; border-bottom: 1px solid var(--line); }
#dialog-body textarea { width: 100%; min-height: 6rem; margin-top: .6rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 741px) {
  .top, .game-intro, .layout, .game-guide, .bottom { width: min(var(--content), calc(100% - 4rem)); }
  .top { min-height: 4.8rem; }
  .site-brand { font-size: 1.45rem; }
  .brand-mark { width: 2.25rem; height: 2.25rem; margin-right: .52rem; font-size: 1.12rem; }
  .tools { gap: .35rem; }
  .tools button { padding-inline: .85rem; font-size: .88rem; }
  .game-intro { margin-top: 1.6rem; }
  .game-intro h1 { margin-top: .3rem; }
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(13.75rem, 25%);
    grid-template-areas: "board depth" "modes modes";
    gap: .9rem;
    margin-top: 1.55rem;
  }
  .board { grid-area: board; min-height: 24.5rem; padding: 1.35rem 2rem 1.65rem; border-radius: 1.3rem; }
  .board-top { font-size: .87rem; }
  #stage { padding-top: 1.65rem; }
  .steps { gap: .5rem; }
  .steps li { min-height: 1.85rem; }
  .lobby-start .primary { width: auto; min-width: 10.5rem; }
  .depth-panel {
    grid-area: depth;
    grid-template-rows: auto auto 1fr auto;
    gap: .9rem;
    isolation: isolate;
    overflow: hidden;
    padding: 1.25rem 1.15rem .9rem;
    border: 1px solid #2b5055;
    border-radius: 1.3rem;
  }
  #water { position: absolute; z-index: -1; inset: 0; display: block; width: 100%; height: 100%; opacity: .72; pointer-events: none; }
  .depth-caption strong { font-size: 1.6rem; }
  .sonar {
    position: relative;
    display: block;
    justify-self: center;
    width: 7rem;
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid #50877d;
    border-radius: 50%;
    background: repeating-radial-gradient(circle, transparent 0 15px, #376d64 16px 17px, transparent 18px),
      linear-gradient(90deg, transparent 49.5%, #376d64 50%, transparent 50.5%),
      linear-gradient(transparent 49.5%, #376d64 50%, transparent 50.5%);
  }
  .sweep { position: absolute; inset: 0; background: conic-gradient(transparent 0 287deg, #61efe43d 359deg, #61efe4 360deg); animation: scan 8s linear infinite; }
  @keyframes scan { to { transform: rotate(360deg); } }
  .sonar i, .sonar b, .sonar em { position: absolute; left: 35%; top: 38%; width: 4px; height: 4px; border-radius: 50%; background: #a6ffe8; box-shadow: 0 0 9px #a6ffe8; }
  .sonar b { left: 65%; top: 59%; opacity: .7; }
  .sonar em { left: 58%; top: 25%; opacity: .49; }
  .depth-axis { display: flex; justify-content: center; gap: .63rem; min-height: 6rem; }
  .depth-track { width: .5rem; height: auto; }
  #depth-fill { width: 100%; height: 0; background: linear-gradient(var(--aqua), #39caac); transition: height .28s ease; }
  #depth-marker { left: -.14rem; top: 0; width: .78rem; height: .25rem; transform: translateY(-50%); transition: top .28s ease; }
  .ticks { display: flex; flex-direction: column; justify-content: space-between; color: var(--muted); font: .72rem var(--mono); }
  .depth-footer { display: flex; justify-content: space-between; gap: .35rem; padding-top: .65rem; border-top: 1px solid #3d5a63; color: var(--muted); font-size: .73rem; }
  .depth-footer span:first-child { color: var(--aqua); }
  .modes { grid-area: modes; gap: .5rem; margin-top: 0; }
  .modes button { padding-inline: .85rem; }
}

@media (max-width: 370px) {
  .top, .game-intro, .layout, .game-guide, .bottom { width: calc(100% - 1.25rem); }
  .tools button { padding-inline: .34rem; }
  .board, .depth-panel { padding-inline: .77rem; }
  .modes button { padding-inline: .51rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
