@font-face {
  font-family: Barlow;
  src: url('../../fonts/barlow-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #101b33;
  --ink: #f1f6ff;
  --muted: #b4c5e0;
  --tide: #99f0d2;
  --tide-deep: #70cbb9;
  --brass: #ffbf84;
  --panel: #192945;
  --line: #415477;
  --display: Barlow, system-ui, sans-serif;
  --body: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 280px; }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font: 1rem/1.5 var(--body);
  background: var(--background);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; }
button:disabled { cursor: default; }
.page { width: min(calc(100% - 32px), 790px); margin-inline: auto; padding: clamp(10px, 3vh, 28px) 0 18px; }
.topline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: clamp(4px, 2vw, 16px); align-items: center; min-height: 70px; padding-bottom: 9px; }
.topline h1 { grid-area: 1 / 1; font: 600 clamp(2.05rem, 4vw, 3.45rem)/1 Barlow, system-ui, sans-serif; letter-spacing: -.04em; }
.topline .back { grid-area: 1 / 2; }
.topline .sound-toggle { grid-area: 1 / 3; }
.back { min-height: 44px; display: inline-flex; align-items: center; gap: 11px; color: var(--muted); font-size: .86rem; font-weight: 600; text-decoration: none; }
.back::before { content: ''; width: 6px; height: 6px; border-left: 1px solid; border-bottom: 1px solid; transform: rotate(45deg); }
.back:hover { text-decoration: underline; text-underline-offset: .25em; }
.sound-toggle, .reset { border: 0; background: none; color: var(--muted); min-height: 44px; padding: 0 4px; }
.sound-toggle { display: grid; place-items: center; width: 44px; font-size: .86rem; font-weight: 600; }
.sound-toggle[aria-pressed="true"], .sound-toggle:hover, .reset:hover { color: var(--tide); }
.sound-icon { width: 15px; height: 13px; display: grid; align-items: center; position: relative; }
.sound-icon::before { content: ''; width: 9px; height: 12px; background: currentColor; clip-path: polygon(0 35%, 40% 35%, 100% 0%, 100% 100%, 40% 65%, 0 65%); }
.sound-icon::after { content: ''; position: absolute; left: 10px; top: 4px; width: 4px; height: 5px; border-right: 1px solid; border-radius: 50%; }
.sound-toggle[aria-pressed="false"] .sound-icon::after { left: 11px; top: 5px; height: 4px; transform: rotate(-45deg); border-radius: 0; opacity: .75; }
h1, h2, h3, p { margin: 0; }
.chart { position: relative; background: var(--panel); }
.chart-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: clamp(8px, 2.7vw, 24px); padding: 7px 16px; }
.chart-heading { display: flex; align-items: center; flex-wrap: wrap; column-gap: .6rem; }
.chart-picker { border: 0; padding: 0; min-height: 44px; text-align: left; background: none; font-size: clamp(.92rem, 1.6vw, 1.15rem); line-height: 1.2; font-weight: 700; }
.chart-picker::after { content: ''; display: inline-block; vertical-align: .2em; width: .35em; height: .35em; margin-inline: .52em .2em; border-bottom: 1px solid; border-right: 1px solid; transform: rotate(45deg); }
.chart-picker:hover { color: var(--tide); }
#depth { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.oxygen { width: clamp(72px, 14vw, 125px); padding-bottom: 3px; color: var(--tide); }
.oxygen-danger { color: var(--brass); }
.oxygen-readout { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; font-size: .79rem; color: var(--muted); }
.oxygen-readout > span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.oxygen-readout strong { display: inline-block; font-size: 1.34rem; font-weight: 600; color: var(--ink); line-height: 1; }
.oxygen-danger strong { color: var(--brass); }
.oxygen-meter { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 6px; }
.oxygen-meter i { height: 4px; border-radius: 1px; background: #3a4e71; }
.oxygen-meter i.filled { background: currentColor; }
.instrument-count { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: .79rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.instrument-count::before { content: ''; flex: none; width: 8px; height: 8px; border: 1.5px solid var(--tide); transform: rotate(45deg); }
.chart-fig { display: grid; grid-template-columns: 20px minmax(0, 1fr); padding: 0 12px 12px 5px; background: #14243e; }
.axis { color: var(--muted); font: .75rem/1 var(--mono); user-select: none; }
.axis-columns { grid-column: 2; display: grid; grid-template-columns: repeat(7, 1fr); place-items: center; min-height: 22px; padding-bottom: 2px; }
.axis-rows { grid-column: 1; display: grid; grid-template-rows: repeat(7, 1fr); place-items: center start; padding-left: 5px; }
.chart-plot { grid-column: 2; position: relative; isolation: isolate; border: 1px solid #486a9d; aspect-ratio: 1.38; background: #193760; }
.seabed, .trace, .board, .outcome { position: absolute; inset: 0; width: 100%; height: 100%; }
.seabed, .trace { pointer-events: none; }
.seabed { z-index: -2; }
.trace { z-index: -1; }
.board { touch-action: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(7, minmax(0, 1fr)); }
.tile {
  position: relative;
  border: 0;
  border-right: 1px solid #8eb9ef3b;
  border-bottom: 1px solid #8eb9ef3b;
  padding: 0;
  min-width: 0;
  min-height: 0;
  background: none;
  cursor: default;
  isolation: isolate;
}
.tile:nth-child(7n) { border-right: 0; }
.tile:nth-child(n + 43) { border-bottom: 0; }
.tile:focus-visible { outline: 2px solid var(--brass); outline-offset: -3px; z-index: 2; }
.tile.moveable { cursor: pointer; }
.tile.moveable::before { content: ''; inset: 0; position: absolute; border: 1px solid #bcdbff79; background: #a4d8ff1a; z-index: -1; }
.tile.moveable:hover::before, .tile.moveable:focus-visible::before { border-color: #d7edff; background: #a4d8ff44; }
.tile.rock {
  background: repeating-linear-gradient(135deg, #8ca0cb33 0 1px, transparent 1px 7px), #111c37;
  box-shadow: inset 0 0 0 1px #7186ac4d;
}
.tile.rock::after {
  content: '';
  display: block;
  width: clamp(11px, 29%, 24px);
  aspect-ratio: 1.1;
  margin: auto;
  background: #b2bcdb;
  clip-path: polygon(0 100%, 32% 18%, 51% 56%, 69% 34%, 100% 100%);
}
.tile.marker-possible { background: #65d0bb25; }
.tile.marker-possible::after { content: ''; display: block; width: clamp(7px, 22%, 18px); aspect-ratio: 1; margin: auto; border: 2px dotted #b4fbe0; border-radius: 50%; }
.tile.marker-sample::after { content: ''; display: block; width: 6px; height: 6px; margin: auto; background: var(--tide); box-shadow: 0 0 0 3px #8ee5ca40; animation: recovery .2s ease-out; }
@keyframes recovery {
  from { box-shadow: 0 0 0 12px #8ee5cab0, 0 0 22px 12px #8ee5ca8c; transform: rotate(45deg) scale(1.8); }
}
.tile.marker-buoy::after { content: ''; display: block; width: 12px; height: 12px; margin: auto; border: 2px solid var(--brass); transform: rotate(45deg); box-shadow: 0 0 10px #ffbf8470; }
.tile.player { z-index: 1; }
.tile.player.marker-buoy::after, .tile.player.marker-sample::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 7px;
  height: 7px;
}
.pilot { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.hull {
  position: relative;
  width: clamp(20px, 43%, 39px);
  height: clamp(10px, 33%, 17px);
  border-radius: 3px 60% 60% 3px;
  background: #f9f4d3;
  box-shadow: 0 2px 0 #0f264c;
}
.hull::before {
  content: '';
  position: absolute;
  width: 32%;
  aspect-ratio: 1;
  top: 50%;
  right: 16%;
  translate: 0 -50%;
  border: 1px solid #f9f4d3;
  border-radius: 50%;
  background: #256082;
}
.hull::after {
  content: '';
  position: absolute;
  inset: 17% 100% 17% -18%;
  background: #ffbf84;
  clip-path: polygon(0 0, 100% 32%, 100% 68%, 0 100%);
}
.pilot[data-heading="east"] .hull { rotate: 0deg; }
.pilot[data-heading="west"] .hull { rotate: 180deg; }
.pilot[data-heading="north"] .hull { rotate: -90deg; }
.pilot[data-heading="south"] .hull { rotate: 90deg; }
.tile.player.marker-buoy { box-shadow: inset 0 0 0 2px #ffbf84a6; }
.chart-legend { grid-column: 2; display: flex; flex-wrap: wrap; gap: 7px 18px; padding: 9px 0 10px; color: var(--muted); font-size: .77rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; }
.legend-possible { border: 1px dashed var(--tide); border-radius: 50%; }
.legend-buoy { border: 1px solid var(--brass); transform: rotate(45deg); }
.legend-rock { background: #b2bcdb; clip-path: polygon(0 100%, 32% 18%, 51% 56%, 69% 34%, 100% 100%); }
.chart-legend .legend-sample { width: 6px; height: 6px; background: var(--tide); }
.action-deck { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 9px 14px; }
.ping-button, .outcome-actions button { background: var(--tide); border: 1px solid transparent; color: #102d33; border-radius: 3px; font-weight: 750; }
.ping-button { min-height: 49px; padding: 7px 12px; display: flex; align-items: center; gap: 10px; font-size: .88rem; text-align: left; line-height: 1.16; white-space: nowrap; }
.ping-button:hover, .outcome-actions button:hover { background: #c4ffe9; }
.ping-button:active, .outcome-actions button:active { background: #65d8b6; }
.ping-button[aria-disabled="true"] { background: #2e4368; color: #b8c8e2; cursor: default; }
.ping-button small { display: block; font-size: .70rem; font-weight: 650; opacity: .89; margin-top: 3px; }
.ping-icon { width: 16px; height: 16px; margin: 0 3px; border: 1px solid; rotate: 45deg; position: relative; }
.ping-icon::before, .ping-icon::after { content: ''; position: absolute; border: 1px solid; }
.ping-icon::before { inset: 3px; }
.ping-icon::after { inset: 6px; background: currentColor; }
.status { min-width: 0; min-height: 3.2rem; display: flex; flex-direction: column; justify-content: center; line-height: 1.34; }
.status strong { display: block; font-size: .88rem; font-weight: 700; }
.status p { margin-top: 2px; font-size: .82rem; color: var(--muted); }
.pilot-controls { display: none; }
.utility { display: flex; justify-content: space-between; padding: 0 3px; }
dialog { width: min(430px, calc(100% - 26px)); max-height: calc(100% - 28px); color: var(--ink); background: var(--panel); padding: 15px 19px; border: 1px solid #5676a8; border-radius: 10px; }
dialog::backdrop { background: #0b1428cc; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.dialog-top h2 { font: 400 1.8rem/1 var(--display); }
.dive-rules { color: var(--muted); padding-left: 1.18em; }
.dive-rules li { margin-block: 7px; }
.dives { display: grid; gap: 5px; }
.dive {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: left;
  background: #14243e;
  padding: 6px 10px;
}
.dive:hover { background: #263b60; }
.dive[aria-current="true"] { background: #253e61; border-color: #70cbb9; }
.dive-number { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid #526d9a; border-radius: 50%; font: .72rem/1 var(--mono); color: var(--muted); }
.dive[aria-current="true"] .dive-number { border-color: var(--tide-deep); color: var(--tide); }
.dive-name { font-size: .84rem; font-weight: 650; }
.dive-record { color: var(--muted); font: .72rem/1.15 var(--mono); white-space: nowrap; }
.dive-record.cleared { color: var(--tide); }
.guide-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 13px; margin-top: 7px; }
.guide-actions span { color: var(--muted); margin-right: auto; font-size: .82rem; }
.reset { display: inline-flex; align-items: center; padding-inline: 4px; text-underline-offset: .23em; font-size: .8rem; }
.outcome {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 15px;
  text-align: center;
  z-index: 4;
  background: #101c35ed;
}
.outcome-mark { width: 35px; height: 35px; border: 1px solid var(--tide); border-radius: 50%; position: relative; color: var(--tide); margin-bottom: 10px; box-shadow: 0 0 24px #73e2c244; }
.outcome-mark::before { content: ''; position: absolute; inset: 6px; border: 1px dashed currentColor; border-radius: 50%; }
.outcome-mark::after { content: ''; position: absolute; inset: 14px; border: 1px solid currentColor; background: currentColor; transform: rotate(45deg); }
.outcome.failed .outcome-mark { border-color: var(--brass); color: var(--brass); animation: dive-stop .18s ease-out; }
.outcome.cleared .outcome-mark { animation: breach .2s ease-out; }
@keyframes dive-stop { from { transform: scale(1.22); opacity: .4; } }
@keyframes breach { from { transform: translateY(22px) scale(.75); opacity: .48; } }
.outcome h3 { font: 400 clamp(1.65rem, 5vw, 3rem)/1.05 var(--display); letter-spacing: -.04em; outline: none; }
.outcome p { color: #c5d3e9; margin-top: 9px; font-size: .88rem; max-width: 34ch; }
.outcome .outcome-score { color: var(--brass); max-width: 37ch; }
.outcome-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 17px; }
.outcome-actions button { min-height: 44px; padding: 5px 12px; font-size: .84rem; }
.outcome-actions #replay { background: transparent; color: var(--ink); border-color: #7ba3d2; }
.outcome-actions #replay:hover { background: #26416c; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 540px) {
  .page { width: calc(100% - 22px); padding-top: 3px; }
  .topline { min-height: 58px; padding-bottom: 4px; }
  .back { gap: 5px; }
  .sound-toggle { gap: 4px; }
  .chart-header { padding-inline: 10px; }
  .chart-fig { grid-template-columns: 16px minmax(0, 1fr); padding: 2px 7px 7px 2px; }
  .chart-plot { aspect-ratio: 1; }
  .axis-columns { min-height: 17px; }
  .action-deck { padding: 7px 9px 8px; gap: 8px; }
  .instrument-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .oxygen { width: 91px; }
}
@media (max-width: 365px) {
  .page { width: calc(100% - 16px); }
  .chart-plot { aspect-ratio: 1.04; }
  .chart-heading { column-gap: .32rem; }
  #depth { font-size: .68rem; }
  .instrument-count { font-size: .73rem; }
  .outcome { padding: 8px; }
  .outcome-mark { margin-bottom: 6px; }
  .outcome p { margin-top: 6px; font-size: .79rem; }
  .outcome-actions { margin-top: 8px; }
}
@media (max-width: 440px), (pointer: coarse) {
  .action-deck { grid-template-columns: minmax(0, 1fr) auto; }
  .ping-button { justify-self: start; }
  .pilot-controls { display: flex; grid-area: 1 / 2; gap: 4px; align-items: center; }
  .pilot-controls button {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid #5a77a5;
    border-radius: 2px;
    background: #233858;
    color: var(--tide);
    font-size: 1.22rem;
  }
  .pilot-controls button:active { background: #3b5f8a; }
  .pilot-controls button:disabled { opacity: .5; }
  .status { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
