:root {
  color-scheme: dark;
  --background: #080808;
  --ink: #e8e8e8;
  --muted: #a5afaf;
  --line: #a9c2c540;
  --accent: #c8ff00;
  --display: Futura, "Century Gothic", "Trebuchet MS", sans-serif;
  --ui: system-ui, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); font: 14px/1.5 var(--ui); }
h1, h2, h3, p, ol, dl, dd { margin: 0; }
button, summary, input { font: inherit; color: inherit; }
button:not(:disabled), summary, input:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.dive-screen {
  --inset: max(clamp(16px, 4.2vw, 70px), env(safe-area-inset-left), env(safe-area-inset-right));
  --descent-time: 2.1s;
  --beam-length: 119%;
  --beam-height: 121%;
  --beam-core: #cdebc047;
  --beam-haze: #94d3be13;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(140px, 1fr) auto;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.waters, .seascape, .waters::before, .waters::after { position: absolute; inset: 0; }
.waters { z-index: -1; overflow: hidden; background: #08171e; }
.seascape {
  inset: -6%;
  background: url("assets/art/seascape.svg") center center / cover no-repeat;
  animation: seafloor-drift 25s ease-in-out infinite alternate;
  transition: filter 1.6s;
}
[data-mode="treetone"] .seascape { filter: brightness(.72) saturate(1.1); }
[data-mode="noise"] .seascape { filter: brightness(.83) saturate(1.1); }
[data-depth="1"] {
  --beam-length: 112%;
  --beam-height: 91%;
  --beam-core: #aecfe06b;
  --beam-haze: #6599c823;
}
[data-depth="1"] .seascape {
  background:
    radial-gradient(ellipse at 59% 47%, #142a49 0, #0a1c34 43%, transparent 72%),
    linear-gradient(#050c17, #091b32 55%, #02070f);
}
[data-depth="2"] {
  --beam-length: 95%;
  --beam-height: 72%;
  --beam-core: #b0cbc36e;
  --beam-haze: #87a9a02a;
}
[data-depth="2"] .seascape {
  background: url("assets/art/abyss.svg") center / 100% 100% no-repeat;
  animation-duration: 37s;
}
[data-depth="3"] {
  --beam-length: 63%;
  --beam-height: 58%;
  --beam-core: #c8d9c57d;
  --beam-haze: #a0b6a136;
}
[data-depth="3"] .seascape {
  background: url("assets/art/hadal.svg") center / 100% 100% no-repeat;
  animation: trench-drift 32s ease-in-out infinite alternate;
  filter: none;
}
.currents {
  position: absolute;
  inset: -24%;
  background:
    linear-gradient(112deg, transparent 33%, #6cbdc613 37%, transparent 43% 53%, #5aafab0e 58%, transparent 64%),
    radial-gradient(ellipse at 44% 12%, #62c7c026, transparent 55%);
  animation: currents 16s ease-in-out infinite alternate;
  pointer-events: none;
}
[data-depth="1"] .currents {
  inset: 0;
  background:
    radial-gradient(circle at 24% 32%, #7aaeea65 0 1px, #7aaeea14 2px 7px, transparent 9px),
    radial-gradient(circle at 73% 24%, #8b99cf68 0 .75px, transparent 2px),
    radial-gradient(circle at 84% 57%, #91ccdf7d 0 1px, #91ccdf21 3px 7px, transparent 10px),
    radial-gradient(circle at 19% 62%, #8eb1cc64 0 .75px, transparent 2px),
    radial-gradient(circle at 66% 72%, #a6c7ea59 0 .75px, transparent 2px);
  animation: distant-lights 8.5s ease-in-out infinite alternate;
}
[data-depth="2"] .currents {
  inset: -10%;
  background: radial-gradient(ellipse at 59% 61%, #8eaaa62b, transparent 50%);
  animation-duration: 29s;
}
[data-depth="3"] .currents { display: none; }
.waters::after {
  content: "";
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, #0000 18%, #02090c66 72%, #020507b0 100%),
    linear-gradient(to bottom, #010508b0, transparent 24%, transparent 60%, #03070bce 100%),
    url("assets/art/grain.svg");
}
[data-depth="3"] .waters::after {
  background:
    radial-gradient(ellipse at 54% 42%, transparent 16%, #0005 56%, #000c 100%),
    linear-gradient(transparent 39%, #0008 80%, #000d),
    url("assets/art/grain.svg");
}
.marine-snow {
  position: absolute;
  inset: -37px;
  background:
    radial-gradient(circle at 9% 43%, #9bccc5 0 1px, transparent 1.5px),
    radial-gradient(circle at 48% 12%, #a9d8c9 0 .65px, transparent 1.1px),
    radial-gradient(circle at 71% 68%, #82a9c5 0 .8px, transparent 1.3px),
    radial-gradient(circle at 90% 32%, #d0e2de 0 .55px, transparent 1.1px);
  background-size: 293px 237px;
  opacity: .27;
  animation: drift 24s ease-in-out infinite alternate;
  pointer-events: none;
}
.marine-snow-near {
  background-size: 191px 173px;
  background-position: 42px 81px;
  opacity: .18;
  animation: drift-near 14s ease-in-out infinite alternate;
}
[data-depth="1"] .marine-snow { opacity: .16; }
[data-depth="1"] .marine-snow-near { opacity: .08; }
[data-depth="2"] .marine-snow {
  background-size: 517px 401px;
  opacity: .15;
  animation-duration: 38s;
}
[data-depth="2"] .marine-snow-near { opacity: .04; }
[data-depth="3"] .marine-snow {
  background-size: 701px 553px;
  opacity: .10;
  animation-duration: 48s;
}
[data-depth="3"] .marine-snow-near { display: none; }
.frame-guide {
  position: absolute;
  inset: max(75px, 10%) var(--inset) max(104px, 15%);
  background:
    linear-gradient(to right, #98b1ac82 12px, transparent 12px) top left / 100% 1px no-repeat,
    linear-gradient(to bottom, #98b1ac82 12px, transparent 12px) top left / 1px 100% no-repeat,
    linear-gradient(to left, #98b1ac82 12px, transparent 12px) top right / 100% 1px no-repeat,
    linear-gradient(to bottom, #98b1ac82 12px, transparent 12px) top right / 1px 100% no-repeat,
    linear-gradient(to right, #98b1ac82 12px, transparent 12px) bottom left / 100% 1px no-repeat,
    linear-gradient(to top, #98b1ac82 12px, transparent 12px) bottom left / 1px 100% no-repeat,
    linear-gradient(to left, #98b1ac82 12px, transparent 12px) bottom right / 100% 1px no-repeat,
    linear-gradient(to top, #98b1ac82 12px, transparent 12px) bottom right / 1px 100% no-repeat;
}
.depth {
  position: absolute;
  top: 47%;
  left: var(--inset);
  display: grid;
  gap: 7px;
  color: #bdcecb;
  font: 11px/1 var(--mono);
  letter-spacing: .05em;
}
.depth-ticks {
  width: 11px;
  height: 41px;
  background:
    linear-gradient(var(--accent), var(--accent)) left center / 11px 1px no-repeat,
    repeating-linear-gradient(#8ea7a46e 0 1px, transparent 1px 8px) left top / 6px 100% no-repeat;
}
.depth-progress { display: flex; align-items: center; gap: 3px; }
.depth-pip {
  width: 9px;
  height: 3px;
  border: 1px solid #aac1b871;
}
.depth-pip[data-lit="true"] {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 7px #c8ff0070;
}
.depth-arrival {
  position: absolute;
  z-index: 3;
  top: 61%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: min(218px, 80%);
  padding: 9px 18px 12px;
  transform: translateX(-50%);
  border-block: 1px solid #aec9be52;
  background: linear-gradient(90deg, transparent, #040b0de0 18% 82%, transparent);
  text-align: center;
  text-shadow: 0 0 10px #000;
  pointer-events: none;
  animation: arrival-in .45s ease-out both;
}
.depth-arrival-index {
  color: #b4d4cd;
  font: 600 11px/1.4 var(--mono);
  letter-spacing: .19em;
}
.depth-arrival-name {
  color: var(--ink);
  font: 650 clamp(21px, 5vmin, 33px)/1.15 var(--ui);
  letter-spacing: .16em;
}
.sonar {
  --sonar-home-y: 43%;
  --sonar-found-y: 55%;
  position: absolute;
  top: var(--sonar-home-y);
  left: 50%;
  width: clamp(180px, 56vmin, 560px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  transition: transform 1s, top 1s, left 1s;
}
.sonar-ring, .sonar-pulse { position: absolute; border-radius: 50%; pointer-events: none; }
.sonar-ring { border: 1px solid #9bcab840; }
.sonar-ring-outer { inset: 0; border-style: dashed; border-color: #9bcab831; }
.sonar-ring-middle { inset: 15%; }
.sonar-ring-inner { inset: 30%; background: #bde7d108; }
[data-depth="1"] .sonar-ring { border-color: #93afc930; }
[data-depth="2"] .sonar-ring { border-color: #9eada22b; }
[data-depth="3"] .sonar-ring { border-color: #9ac0b721; }
[data-depth="3"] .sonar-ring-inner { background: #bde7d104; }
.sonar-pulse { inset: 32%; border: 1px solid #c8ff0099; opacity: 0; }
[data-scene="scanning"] .sonar-pulse { animation: sonar-scan 1.65s ease-out infinite; }
[data-scene="scanning"] .sonar-pulse-late { animation-delay: .55s; }
.submersible {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 41%;
  transform: translate(-50%, -50%);
  animation: pilot 11s ease-in-out infinite;
}
.submersible img { display: block; position: relative; width: 100%; filter: drop-shadow(0 0 18px #c5efd83c); }
.submersible::before {
  content: "";
  position: absolute;
  top: calc(61.5% - var(--beam-height) / 2);
  left: 96%;
  width: var(--beam-length);
  height: var(--beam-height);
  background: radial-gradient(ellipse at left center, var(--beam-core), var(--beam-haze) 44%, transparent 88%);
  clip-path: polygon(0 48%, 100% 0, 100% 100%, 0 57%);
  animation: lamp 4.8s ease-in-out infinite alternate;
}
[data-scene="discovered"] .sonar { top: var(--sonar-found-y); left: 28%; transform: translate(-50%, -50%) scale(.60); }
.creature-view {
  position: absolute;
  top: 43%;
  left: 60%;
  width: clamp(112px, 37vmin, 380px);
  transform: translate(-50%, -50%);
  animation: reveal 1.5s ease-out both;
}
.creature-view img { display: block; width: 100%; filter: drop-shadow(0 0 32px #8cf4ec8c); }
[data-complete="true"][data-scene="discovered"] .creature-view {
  background: radial-gradient(ellipse at center, #79e2ca33, transparent 65%);
}
[data-complete="true"][data-scene="discovered"] .creature-view img {
  filter: drop-shadow(0 0 46px #8df9e4c9);
}
.threat {
  position: absolute;
  top: 45%;
  left: 52%;
  z-index: 2;
  width: min(74vmin, 650px);
  filter: drop-shadow(0 0 35px #270e1c);
  animation: lunge 1s ease-in both;
}
.blackout { position: absolute; inset: 0; z-index: 3; background: #000; }
[data-scene="attack"] .blackout { animation: blackout 1.05s ease-in both; }
[data-scene="descending"] .waters::before {
  content: "";
  z-index: 1;
  background: radial-gradient(ellipse at 50% 39%, #071013 0, #020407 61%, #000 100%);
  pointer-events: none;
  animation: dive-through-dark var(--descent-time) linear both;
}
[data-scene="descending"] .depth { z-index: 2; }
[data-scene="descending"] .sonar {
  transition: none;
  animation: dive-course var(--descent-time) ease-in-out both;
}
[data-scene="descending"] .submersible { animation: dive-pitch var(--descent-time) ease-in-out both; }
[data-scene="descending"] .marine-snow { animation: dive-particles var(--descent-time) ease-in-out both; }
@keyframes sonar-scan { from { opacity: .8; transform: scale(.7); } to { opacity: 0; transform: scale(3.3); } }
@keyframes pilot {
  0%, 100% { transform: translate(-50%, -50%) rotate(-2deg); }
  30% { transform: translate(calc(-50% + 5.5vmin), calc(-50% - 2.2vmin)) rotate(3deg); }
  62% { transform: translate(calc(-50% - 6.3vmin), calc(-50% + 1.9vmin)) rotate(-4deg); }
}
@keyframes lamp { from { opacity: .45; } to { opacity: 1; } }
@keyframes reveal { from { opacity: 0; filter: blur(5px); } to { opacity: 1; filter: blur(0); } }
@keyframes drift { to { transform: translate(21px, -28px); } }
@keyframes drift-near { to { transform: translate(-34px, -35px); } }
@keyframes seafloor-drift { to { transform: translate(-3%, 2.5%) scale(1.04); } }
@keyframes trench-drift { to { transform: translate(1.6%, -1.2%) scale(1.03); } }
@keyframes currents { to { transform: translate(8%, 3%) rotate(8deg); opacity: .54; } }
@keyframes distant-lights {
  0%, 20% { opacity: .25; }
  57% { opacity: .88; }
  100% { opacity: .36; transform: translate(1.8%, -2%); }
}
@keyframes dive-through-dark {
  0%, 8% { opacity: 0; }
  33% { opacity: .52; }
  38%, 45% { opacity: 1; }
  70%, 100% { opacity: 0; }
}
@keyframes dive-course {
  0% { top: var(--sonar-found-y); left: 28%; transform: translate(-50%, -50%) scale(.60); opacity: 1; }
  29% { opacity: 1; }
  37% { top: calc(var(--sonar-home-y) + 37vh); left: 47%; transform: translate(-50%, -50%) scale(.83); opacity: .8; }
  40% { opacity: 0; }
  42% { top: calc(var(--sonar-home-y) - 13vh); left: 50%; transform: translate(-50%, -50%) scale(.93); opacity: 0; }
  62% { opacity: 1; }
  94%, 100% { top: var(--sonar-home-y); left: 50%; transform: translate(-50%, -50%); }
}
@keyframes dive-pitch {
  0%, 100% { transform: translate(-50%, -50%); }
  29%, 45% { transform: translate(-50%, -50%) rotate(24deg); }
  76% { transform: translate(-50%, -50%) rotate(5deg); }
}
@keyframes dive-particles {
  0%, 10% { transform: translateY(0); }
  37% { transform: translateY(-22vh); }
  41% { transform: translateY(5vh); }
  100% { transform: translateY(0); }
}
@keyframes arrival-in {
  from { opacity: 0; transform: translate(-50%, 7px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes lunge {
  from { opacity: 0; transform: translate(-50%, -48%) scale(.13) rotate(-8deg); }
  36% { opacity: .88; }
  to { opacity: 1; transform: translate(-53%, -52%) scale(1.48) rotate(5deg); }
}
@keyframes blackout { 0%, 40% { opacity: 0; } 90%, 100% { opacity: 1; } }

.hud {
  grid-row: 1;
  z-index: 2;
  margin: max(12px, env(safe-area-inset-top)) var(--inset) 0;
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #93acaf37;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  font: 700 18px/1.1 var(--display);
  letter-spacing: .09em;
}
.wordmark i, .log-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px #c8ff0070;
}
.tools, .console-actions, .practice-menu { display: flex; align-items: center; gap: 8px; }
.icon-button, .primary, .secondary {
  display: inline-grid;
  place-items: center;
  position: relative;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #080c10ba;
}
.icon-button { width: 42px; padding: 0; }
.hud .icon-button { background: transparent; border-color: transparent; }
.icon-button svg { width: 19px; height: 19px; stroke-width: 1.15; }
.icon-button:not(:disabled):hover, .audio-tools[open] summary, .secondary:hover,
.secondary[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.icon-button:disabled { opacity: .5; }
.log-dot { position: absolute; top: 7px; right: 7px; }
.audio-tools { position: relative; }
.audio-tools summary { list-style: none; }
.audio-tools summary::-webkit-details-marker { display: none; }
.volume {
  position: absolute;
  top: 48px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 12px;
  background: #080b0ef2;
  border: 1px solid var(--line);
  font: 12px var(--mono);
}
.volume input { width: 92px; height: 30px; }
.volume output { min-width: 34px; text-align: right; }

.console {
  grid-row: 3;
  justify-self: center;
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 8px;
  width: min(980px, calc(100% - 2 * var(--inset)));
  margin-bottom: max(clamp(21px, 5.5vh, 58px), env(safe-area-inset-bottom));
  text-shadow: 0 1px 9px #000;
}
.scan-phase { color: var(--accent); font: 600 12px/1.2 var(--display); letter-spacing: .17em; }
[data-scene="discovered"] .scan-phase { font: 600 19px/1.35 var(--ui); letter-spacing: .08em; color: var(--ink); }
[data-scene="gameover"] .console { grid-row: 1 / -1; align-self: center; margin-bottom: 0; gap: 17px; }
[data-scene="gameover"] .scan-phase { font-size: clamp(21px, 4vw, 34px); color: #e0b3b7; }
.result-score { color: var(--accent); font: 600 clamp(24px, 5vw, 42px)/1.1 var(--mono); }
.final-score-caption {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  text-align: center;
  font: 11px/1.2 var(--ui);
  letter-spacing: .1em;
}
.instruction, .feedback { color: #ced9d6; text-align: center; font-size: 12px; }
.feedback[data-tone="pass"] { color: var(--accent); }
.feedback[data-tone="retry"] { color: #ffd6a5; }
input[type="range"] { appearance: none; -webkit-appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: #88a5a97a; }
input[type="range"]::-moz-range-track { height: 1px; background: #88a5a97a; }
input[type="range"]::-moz-range-progress { background: transparent; }
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6.5px;
  background: #101f22;
  border: 1px solid var(--accent);
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: #101f22; border: 1px solid var(--accent); }
.readings {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  padding: 10px 4px 0;
  align-items: center;
}
.scan-slider, .eq-control { min-width: 0; }
.readings > :only-child {
  grid-column: 1 / -1;
  width: min(420px, 100%);
  justify-self: center;
  padding: 10px 14px 3px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #102429b0, #0711157a);
}
.reading-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 21px;
  color: var(--muted);
  font: 600 12px/1.35 var(--mono);
  letter-spacing: .06em;
}
.reading-value { color: var(--accent); font: 600 15px/1.35 var(--mono); letter-spacing: 0; }
.slider-row {
  --ruler-center: 18px;
  position: relative;
  padding-bottom: 12px;
}
.slider-row input { display: block; width: 100%; height: calc(var(--ruler-center) * 2); margin: 0; }
.slider-row input::-webkit-slider-thumb { background: transparent; border-color: transparent; }
.slider-row input::-moz-range-thumb { background: transparent; border-color: transparent; }
.slider-axis { position: absolute; inset: 0 7px; pointer-events: none; }
.slider-row input:disabled + .slider-axis { opacity: .55; }
[data-reviewed="true"] .slider-row input:disabled + .slider-axis { opacity: 1; }
.slider-reticle, .correct-reticle {
  position: absolute;
  top: var(--ruler-center);
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%) rotate(45deg);
}
.slider-reticle {
  z-index: 1;
  left: var(--position);
  background: #0d1b20;
  border: 1px solid var(--accent);
  box-shadow: 0 0 11px #c8ff0040;
}
.correct-reticle {
  z-index: 2;
  width: 16px;
  height: 16px;
  border: 1px dashed #78e3db;
  box-shadow: 0 0 9px #78e3db55;
}
.slider-mark {
  position: absolute;
  top: calc(var(--ruler-center) + 11px);
  transform: translateX(-50%);
  color: var(--muted);
  font: 10px/1.1 var(--mono);
  white-space: nowrap;
}
.slider-mark::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 1px;
  height: 6px;
  background: #88a5a97a;
}
.slider-mark[data-candidate="true"] { color: #d7e9b7; }
.slider-mark[data-candidate="true"]::before { background: #c8ff009c; }
.slider-mark:first-child { transform: none; }
.slider-mark:last-child { transform: translateX(-100%); }
.slider-mark:first-child::before { left: 0; }
.slider-mark:last-child::before { left: 100%; }
.console-actions { margin-top: 2px; }
.primary {
  min-width: 112px;
  display: inline-flex;
  justify-content: center;
  gap: 10px;
  color: var(--accent);
  border-color: #c8ff0094;
  font-size: 13px;
}
.primary:not(:disabled):hover { background: #c8ff00; color: #080808; }
.primary:disabled { opacity: .48; }
.secondary { color: var(--muted); font-size: 12px; }
.practice-menu { width: min(560px, 100%); }
.practice-menu .secondary {
  flex: 1;
  min-width: 0;
  gap: 4px;
  padding: 9px 7px;
  border-top-color: #9ac6af83;
  background: linear-gradient(155deg, #112328ce, #071013c9);
  color: var(--ink);
}
.practice-menu .secondary svg { width: min(45px, 100%); height: 23px; fill: none; stroke: var(--accent); stroke-width: 1.25; }
.practice-menu .secondary strong { font: 600 12px var(--mono); letter-spacing: .08em; }
.practice-menu .secondary span { color: var(--muted); font-size: 10px; }
.practice-depth { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.practice-depth select {
  min-height: 32px;
  max-width: 180px;
  border: 1px solid var(--line);
  padding: 3px 6px;
  background: #0b171b;
  color: var(--ink);
  font: 12px var(--ui);
}
[data-practice]:not([data-practice=""]) .scan-phase { color: #a7e3dd; }
.reading-result {
  min-height: 18px;
  color: #9ae7de;
  text-align: left;
  font: 11px/1.45 var(--ui);
}
.reading-result:empty { display: none; }
.eq-types { display: flex; gap: 4px; margin-bottom: 3px; }
.eq-types button {
  min-width: 48px;
  min-height: 28px;
  border: 1px solid var(--line);
  background: #091418ba;
  color: var(--muted);
  font: 600 11px var(--mono);
}
.eq-types button[aria-pressed="true"] { color: var(--accent); border-color: #c8ff008c; }
.eq-types button:not(:disabled):hover { border-color: var(--accent); }
.eq-plot {
  position: relative;
  height: 74px;
  margin: 0 7px;
  background: #07141892;
}
.eq-plot:focus-within { outline: 1px solid #c8ff008c; }
.eq-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.eq-plot path { fill: none; stroke-width: 1; vector-effect: non-scaling-stroke; }
.eq-plot .eq-grid { stroke: #7b9e9c35; }
.eq-plot .eq-guide { stroke: #c8ff0055; stroke-dasharray: 3 3; }
.eq-plot .eq-curve { stroke: var(--accent); stroke-width: 1.7; }
.eq-plot .eq-point { stroke: var(--accent); fill: #0c201f; stroke-width: 1.4; }
.eq-plot .eq-correct, .eq-plot .eq-correct-point { stroke: #78e3db; stroke-width: 1.6; fill: none; }
.eq-plot .eq-correct { stroke-dasharray: 4 3; }
.eq-plot input {
  position: absolute;
  inset: 0 -7px;
  width: calc(100% + 14px);
  height: 100%;
  margin: 0;
  opacity: 0;
}
.eq-frequencies {
  display: flex;
  justify-content: space-between;
  padding-top: 3px;
  margin: 0 4px 3px;
  color: var(--muted);
  font: 10px var(--mono);
}
.eq-audition { display: flex; gap: 5px; margin-top: 4px; }
.eq-audition button {
  --trace: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  background: #091418ba;
  color: var(--ink);
  font: 11px/1.2 var(--ui);
}
.eq-audition button::before {
  content: "";
  width: 12px;
  border-top: 1px solid var(--trace);
}
.eq-audition [data-audition="correct"] { --trace: #78e3db; }
.eq-audition [data-audition="correct"]::before { border-top-style: dashed; }
.eq-audition button:hover, .eq-audition button[aria-pressed="true"] {
  color: var(--trace);
  border-color: var(--trace);
}
.eq-audition button[aria-pressed="true"] { background: #1b322e; }
.eq-audition-error { color: #e7b5b9; font-size: 11px; }

.judgement {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  justify-items: center;
  align-items: end;
  background: radial-gradient(ellipse at 50% 40%, #02090b1f, #020507d9 81%);
  animation: judgement-dark 0.7s ease-out both;
}
.fractures { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fracture {
  position: absolute;
  top: 46%;
  left: 30%;
  width: clamp(190px, 39vmin, 420px);
  transform: translate(-50%, -50%) rotate(-14deg);
  filter: drop-shadow(0 0 7px #dbf0ce8c);
  animation: glass-crack 0.57s ease-out both;
}
.fracture:nth-child(2) { top: 50%; left: 51%; transform: translate(-50%, -50%) rotate(76deg); }
.fracture:nth-child(3) { top: 46%; left: 72%; transform: translate(-50%, -50%) rotate(156deg); }
.judgement-readout {
  position: relative;
  width: min(650px, calc(100% - 36px));
  margin-bottom: clamp(70px, 12vh, 122px);
  text-align: center;
}
.judgement-readout .scan-phase { color: #9eb6b2; }
.verdicts {
  min-height: 76px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin-top: 14px;
}
.verdicts li {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  align-content: center;
  padding: 6px 3px;
  border-top: 1px solid #a0878c80;
  background: linear-gradient(#1b121ab5, #08101591);
  color: #efdce0;
  animation: verdict-in 0.33s ease-out both;
}
.verdicts li[data-hit="true"] { border-color: #c8ff009c; background: linear-gradient(#192819ae, #09130f75); color: #edffcf; }
.verdicts span, .verdicts small { font: 600 11px var(--mono); }
.verdicts strong { font-size: clamp(12px, 3vw, 19px); }
.verdicts small { color: var(--muted); }
@keyframes judgement-dark { from { opacity: 0; } to { opacity: 1; } }
@keyframes glass-crack { from { opacity: .94; } to { opacity: .34; } }
@keyframes verdict-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

.dive-log {
  width: min(430px, calc(100% - 32px));
  border: 1px solid #4b6468;
  padding: 16px 20px 20px;
  background: #080e12;
  color: var(--ink);
}
.dive-log::backdrop { background: #030608b5; }
.log-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.log-header h2 { font: 700 20px var(--display); letter-spacing: .06em; }
.log-records {
  display: grid;
  gap: 12px;
  max-height: min(60dvh, 29rem);
  padding: 0 4px 0 0;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.log-records > * + * { border-top: 1px solid var(--line); padding-top: 12px; }
.log-entry { display: grid; grid-template-columns: 65px 1fr; gap: 12px; }
.log-entry h3 { font-size: 15px; }
.log-thumbnail { width: 65px; background: #14232a; }
.log-description { color: var(--muted); font-size: 12px; }
.log-observations { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; }
.log-observations dt { color: var(--muted); font-size: 10px; }
.log-observations dd { font-size: 12px; font-weight: 650; }
#log-notice { margin-top: 10px; }
.log-completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.share-dialog textarea {
  display: block;
  width: 100%;
  padding: 9px;
  resize: none;
  border: 1px solid var(--line);
  background: #081418;
  color: var(--ink);
  font: 14px/1.45 var(--ui);
}
.share-actions, .share-links { display: flex; flex-wrap: wrap; gap: 6px; }
.share-actions { margin-top: 10px; }
.share-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  font: 12px var(--ui);
  text-decoration: none;
}
.share-links a:hover { border-color: var(--accent); color: var(--accent); }
#share-status:not(:empty) { margin-top: 8px; }

.lab-dialog {
  --lab-accent: #93e5df;
  width: min(700px, calc(100% - 32px));
  width: min(700px, calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: clamp(14px, 3vw, 24px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #537a7c;
  border-top-color: var(--lab-accent);
  background: linear-gradient(150deg, #13262c, #0a141a 56%, #080e12);
  color: var(--ink);
  box-shadow: 0 14px 55px #000a;
}
.lab-dialog::backdrop { background: #03070bc4; }
.lab-dialog .log-header {
  position: sticky;
  top: 0;
  z-index: 1;
  gap: 12px;
  margin-bottom: 12px;
  background: #13262c;
}
.lab-dialog .log-header h2 { font: 650 20px/1.25 var(--ui); }
.lab-config, .lab-summary { display: grid; gap: 10px; }
.lab-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr));
  gap: 9px 12px;
}
.lab-fields label {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  color: #bcd0d0;
  font: 12px/1.4 var(--ui);
}
.lab-fields :is(select, input) {
  width: 100%;
  min-height: 38px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #081217;
  color: var(--ink);
  font: 14px/1.3 var(--ui);
  font-variant-numeric: tabular-nums;
}
.lab-fields :is(select, input):disabled { opacity: .58; }
.lab-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lab-hint { color: var(--muted); font: 12px/1.45 var(--ui); }
.lab-summary {
  min-width: 0;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.lab-summary h3 { color: var(--lab-accent); font: 650 14px/1.3 var(--ui); }
.lab-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(112px, 100%), 1fr));
  gap: 6px;
}
.lab-stat {
  min-width: 0;
  padding: 5px 8px;
  border-left: 2px solid #64b9b589;
  background: #122227;
  color: #d8ecea;
  font: 12px/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
}
.lab-stat dt { color: #bcd0d0; font-size: 11px; }
.lab-stat dd { color: var(--ink); font: 600 14px/1.4 var(--mono); }
.lab-results { min-width: 0; max-width: 100%; overflow-x: auto; }
.lab-results table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lab-results :is(th, td) {
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.lab-results th { color: #bcd0d0; font-weight: 600; }
.lab-results .secondary { min-height: 34px; padding-inline: 8px; }
.lab-exit { text-decoration: none; }
.hud .lab-hud-button {
  min-width: 42px;
  padding-inline: 3px;
  color: #a6e5df;
  font: 700 11px/1 var(--mono);
  letter-spacing: .06em;
}
[data-lab="true"] .scan-phase { color: #a6e5df; }
[data-lab="true"] .console-actions { flex-wrap: wrap; justify-content: center; }

@media (max-width: 600px) {
  .seascape { background-position: 48% center; }
  .depth { top: 42%; font-size: 10px; }
  .sonar { width: 64vmin; }
  .hud { min-height: 45px; }
  .console { margin-bottom: max(23px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  [data-lab="true"] .tools { gap: 2px; }
  [data-lab="true"] .wordmark { gap: 6px; font-size: 16px; letter-spacing: .055em; }
  .lab-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lab-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  .readings {
    width: min(420px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 7px 15px;
    padding-top: 5px;
  }
  .readings > :last-child { grid-column: 1 / -1; }
  .dive-screen { grid-template-rows: auto minmax(28px, 1fr) auto; }
  .console { gap: 6px; }
}
@media (max-width: 760px) and (max-height: 730px) and (orientation: portrait) {
  .sonar { --sonar-home-y: 32%; --sonar-found-y: 27%; }
  .depth { top: 24%; }
  .creature-view { top: 24%; }
  .eq-plot { height: 66px; }
}
@media (max-width: 760px) and (max-height: 620px) and (orientation: portrait) {
  .console { margin-bottom: max(13px, env(safe-area-inset-bottom)); }
  .readings { padding-top: 3px; }
  .slider-mark { font-size: 9px; }
  .eq-plot { height: 55px; }
  .depth { top: 20%; }
  .depth-ticks { height: 31px; }
  .sonar { --sonar-home-y: 29%; --sonar-found-y: 23%; width: 57vmin; }
  .creature-view { top: 19%; left: 73%; width: clamp(84px, 28vmin, 114px); }
}
@media (max-width: 460px) {
  [data-complete="true"] .console-actions { gap: 6px; flex-wrap: wrap; justify-content: center; }
  [data-complete="true"] .console-actions button { min-width: 0; padding-inline: 8px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .dive-screen { grid-template-rows: auto minmax(0, 1fr) auto; }
  .hud { min-height: 44px; margin-top: max(4px, env(safe-area-inset-top)); }
  .console { gap: 5px; margin-bottom: max(10px, env(safe-area-inset-bottom)); }
  .readings { gap: 18px; padding-top: 3px; }
  .slider-mark { font-size: 9px; }
  .eq-plot { height: 57px; }
  .depth { top: max(54px, calc(env(safe-area-inset-top) + 47px)); gap: 4px; }
  .depth-ticks { height: 25px; }
  .sonar { --sonar-home-y: 29%; --sonar-found-y: 22%; width: 39vmin; }
  .creature-view { top: 21%; left: 69%; width: clamp(79px, 25vmin, 115px); }
  .depth-arrival { top: 53%; }
  .judgement-readout { margin-bottom: 43px; }
  [data-scene="discovered"] .console { grid-template-columns: 1fr auto auto 1fr; }
  [data-scene="discovered"] .console > * { grid-column: 1 / -1; }
  [data-scene="discovered"] .scan-phase { grid-area: 1 / 2; }
  [data-scene="discovered"] .result-score { grid-area: 1 / 3; margin-left: 6px; }
  .final-score-caption { display: inline; margin: 0 5px 0 0; }
  [data-scene="discovered"] .console-actions { grid-area: 3 / 2 / 4 / 4; }
  [data-scene="discovered"] .feedback { grid-area: 3 / 4; justify-self: start; margin-left: 8px; }
  [data-lab="true"] .console {
    grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr);
    grid-template-areas:
      ". phase score ."
      "instruction instruction instruction instruction"
      "readings readings readings readings"
      ". actions actions feedback";
    margin-bottom: max(6px, env(safe-area-inset-bottom));
  }
  [data-lab="true"] .scan-phase { grid-area: phase; }
  [data-lab="true"] .result-score { grid-area: score; margin-left: 6px; }
  [data-lab="true"] .instruction { grid-area: instruction; }
  [data-lab="true"] .readings { grid-area: readings; padding-top: 0; }
  [data-lab="true"] .console-actions { grid-area: actions; }
  [data-lab="true"] .feedback {
    grid-area: feedback;
    min-width: 0;
    margin-left: 6px;
    text-align: left;
    font-size: 11px;
    overflow-wrap: anywhere;
  }
}
@media (max-height: 360px) and (orientation: landscape) {
  .console { gap: 3px; }
  .eq-plot { height: 43px; }
  .eq-frequencies { padding-top: 1px; margin-bottom: 1px; }
  .eq-audition { margin-top: 2px; }
  [data-lab="true"] .eq-plot { height: 36px; }
}
@media (pointer: coarse) {
  .icon-button, .primary, .secondary { min-height: 44px; }
  .icon-button { width: 44px; }
  .slider-row { --ruler-center: 20px; }
  .eq-types button, .eq-audition button, .practice-depth select { min-height: 36px; }
  .lab-fields :is(select, input) { min-height: 44px; font-size: 16px; }
  .lab-results .secondary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .dive-screen .seascape, .dive-screen .currents, .dive-screen .marine-snow, .submersible, .submersible::before,
  [data-scene="scanning"] .sonar-pulse, .creature-view { animation: none; }
  .seascape, .sonar { transition: none; }
  [data-scene="descending"] .waters::before { animation: none; opacity: .18; }
  [data-scene="descending"] .sonar, [data-scene="descending"] .submersible,
  [data-scene="descending"] .marine-snow, .depth-arrival { animation: none; }
  .threat { visibility: hidden; animation: none; }
  [data-scene="attack"] .blackout { animation-duration: .01ms; }
  .judgement, .verdicts li, .fracture { animation: none; }
  .fracture { opacity: .45; }
}

