/* Jersey 15 (SIL OFL) is self-hosted. It's drawn small, so size-adjust brings it in line with the rest of the type scale. */
@font-face { font-family: "Clawcean Body"; src: url("fonts/jersey15-latin.woff2") format("woff2"); font-display: swap; size-adjust: 128%; }
/* Layout: an arcade claw cabinet (left) whose glass tank is the ocean, with a field-guide side panel (right); dialogs for lessons, catches and results.
   Single committed look: a sunset arcade. Plum room, orange cabinet, blue ocean tank. */
:root {
  color-scheme: dark;
  --abyss: #150b1c;
  --deep: #221029;
  --panel: #2e1738;
  --panel-2: #3d2049;
  --line: #93639f;   /* 3:1 against panels, so card edges stay visible */
  --ink: #fbeff3;
  --muted: #c9a7cc;
  --coral: #ff6f59;
  --coral-ink: #2a0d07;
  --sodium: #ffd166;
  --kelp: #3ad6a5;
  --danger: #ff6fb5;   /* candy pink: reads as "uh-oh" without the alarm red, and sits apart from coral */
  --sky: #7fd8ff;
  --sky-ink: #062033;
  /* color jobs: gold = targets, plastic and rewards; sky = guide and info; coral = the cabinet and "press this"; kelp = success; pink = misses */
  --focus: #ffd166;
  --font-display: "Bungee", "Impact", "Arial Black", system-ui, sans-serif;
  --font-body: "Clawcean Body", "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;
  --font-mono: "Silkscreen", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-digits: "VT323", "Silkscreen", ui-monospace, monospace;
  --font-game: "Bungee", "Impact", system-ui, sans-serif;
  /* paragraphs in popups: pixel fonts stay on titles, labels and buttons */
  --font-read: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;
  --step--1: 0.86rem; --step-0: 1rem; --step-1: 1.2rem; --step-2: 1.5rem; --step-3: 2.1rem; --step-4: 3rem;
  --radius: 4px;
  --radius-sm: 2px;
  --hard: 4px 4px 0 #0b0510;
}
:root[data-contrast="high"] {
  --abyss: #000; --deep: #000; --panel: #0a0a0a; --panel-2: #1a1a1a; --line: #fff;
  --ink: #fff; --muted: #e6e6e6; --sodium: #ffe600; --kelp: #4dffb8; --coral: #ff8a73;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* component display rules (.row, .btn, .quiz-box) would otherwise override it */
html, body { min-height: 100%; }
html { font-synthesis: none; }   /* no smeared fake-bold on pixel fonts */
body {
  margin: 0; background: var(--abyss); color: var(--ink);
  font-family: var(--font-body); font-size: 1.04rem; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 32px;
  /* arcade carpet: a tiled pixel pattern instead of soft glow blobs */
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,209,102,.10) 0 2px, transparent 2.5px),
    radial-gradient(circle at 75% 75%, rgba(127,216,255,.08) 0 2px, transparent 2.5px),
    linear-gradient(45deg, rgba(94,53,105,.18) 25%, transparent 25% 75%, rgba(94,53,105,.18) 75%);
  background-size: 48px 48px, 48px 48px, 24px 24px;
}
:root[data-font="large"] { font-size: 118%; }
/* Easy-read: swaps the pixel fonts for Atkinson Hyperlegible, a typeface designed for low-vision readers */
:root[data-easy="on"] { --font-game: "Atkinson Hyperlegible", system-ui, sans-serif; --font-body: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif; --font-mono: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif; --font-digits: "Atkinson Hyperlegible", system-ui, sans-serif; }

/* pixel art: icons take the surrounding text color; sprites stay crisp at any size */
.ic { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.25em; flex: none; }
.spr { image-rendering: pixelated; image-rendering: crisp-edges; width: 48px; height: 48px; display: inline-block; vertical-align: middle; flex: none; }
.spr.xs { width: 24px; height: 24px; } .spr.sm { width: 32px; height: 32px; } .spr.lg { width: 64px; height: 64px; } .spr.xl { width: 96px; height: 96px; }
.spr.inl { width: 1.15em; height: 1.15em; vertical-align: -0.15em; }
.ic.red { color: var(--danger); } .ic.gold { color: var(--sodium); } .ic.kelp { color: var(--kelp); } .ic.dim { color: var(--line); }
.glow { filter: drop-shadow(0 0 6px currentColor); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 0; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 !important; }
a { color: var(--sodium); }

/* ---------- top bar ---------- */
.topbar { position: relative; max-width: 1240px; margin: 0 auto 12px; display: flex; align-items: center; gap: 10px; }
.more-tools { display: contents; }
.topbar .menu-toggle { display: none; }
/* laptop and tablet: the marquee is the sign, so the page title only exists for screen readers */
@media (min-width: 641px) { .brand { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .ai-pill { margin-right: auto; } }
/* phone: the brand replaces the marquee, and Label Lens / Leaderboard / Settings fold behind Menu */
@media (max-width: 640px) {
  .brand span { display: none; }
  .brand { margin-right: auto; } .brand h1 { font-size: var(--step-1); }
  .topbar .ai-pill { width: 24px; height: 24px; padding: 0; font-size: 0; overflow: hidden; }
  .topbar .ai-pill::before { left: 8px; }
  .topbar .menu-toggle { display: inline-flex; }
  .more-tools { display: none; }
  body.menu-open .more-tools { display: grid; gap: 6px; position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px; padding: 8px; background: var(--deep); border: 3px solid var(--line); box-shadow: var(--hard); }
  .marquee { display: none; }
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand h1 { font-family: var(--font-display); font-weight: 400; font-size: var(--step-2); margin: 0; letter-spacing: 0.02em; color: var(--sodium); text-shadow: 3px 3px 0 #7a2b00; }
.brand span { color: var(--muted); font-size: var(--step--1); }
.btn {
  box-shadow: 3px 3px 0 #0b0510;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; font-weight: 700; font-size: var(--step--1); transition: background .15s, transform .1s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #0b0510; }
.btn.primary { background: var(--coral); color: var(--coral-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: var(--sodium); color: #2b1d00; border-color: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
/* online status reads as a cabinet LED, not a badge */
.ai-pill { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px 4px 22px; border-radius: 0; background: #0b0510; color: var(--muted); position: relative; }
.ai-pill::before { content: ""; position: absolute; left: 8px; top: 50%; width: 8px; height: 8px; margin-top: -4px; background: var(--line); box-shadow: inset -2px -2px 0 rgba(0,0,0,.4); }
.ai-pill.on { color: var(--kelp); }
.ai-pill.on::before { background: var(--kelp); box-shadow: 0 0 0 2px rgba(58,214,165,.25), inset -2px -2px 0 rgba(0,0,0,.3); }

/* manual pause: dims and blurs the cabinet with a Resume button on top */
.cabinet { position: relative; }
.manual-pause-overlay { display: none; }
body.manual-paused .cabinet::after { content: ""; position: absolute; inset: 0; z-index: 10; border-radius: inherit; background: repeating-linear-gradient(0deg, rgba(12,5,16,.72) 0 2px, rgba(12,5,16,.55) 2px 4px); pointer-events: none; }
body.manual-paused .machine { position: relative; z-index: 12; }   /* Pause/Restart stay usable above the overlay */
body.manual-paused .manual-pause-overlay { position: absolute; z-index: 11; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.pause-notice { background: var(--sodium); color: #2b1d00; border: 3px solid #2b1d00; border-radius: 0; padding: 6px 18px; font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .04em; box-shadow: var(--hard); animation: blink 1s steps(2) 3; }
body.manual-paused .manual-pause-overlay #overlayResumeBtn { min-height: 48px; font-family: var(--font-display); font-weight: 400; }

/* ---------- main grid ---------- */
.stage { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .stage { grid-template-columns: minmax(0, 1fr); } }
/* laptops: the cabinet column is sized from the window height, so the whole machine (DROP included) fits without scrolling.
   The non-tank chrome (top bar, marquee, HUD, controls, padding) is about 320px, plus a little breathing room; the tank keeps its 16:9 shape. */
@media (min-width: 981px) {
  .stage { --cab-w: max(560px, calc((100vh - 360px) * 16 / 9 + 28px)); grid-template-columns: minmax(0, var(--cab-w)) 360px; justify-content: center; }
  @supports (height: 100svh) { .stage { --cab-w: max(560px, calc((100svh - 360px) * 16 / 9 + 28px)); } }
  .stage .cabinet { padding-top: 20px; }
  .cabinet .marquee { padding: 10px 16px 8px; margin-bottom: 10px; }
  .cabinet .marquee .title { font-size: clamp(1.9rem, 3.2vw, 2.6rem); }
}

/* cabinet */
.cabinet {
  background: linear-gradient(180deg, #ff7d68 0%, #e9533d 100%);
  border-radius: 28px 28px 18px 18px; padding: 14px 14px 16px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), inset 0 2px 0 rgba(255,255,255,.35), inset 0 -6px 0 rgba(0,0,0,.18);
  min-width: 0;
}
:root[data-contrast="high"] .cabinet { background: #222; border: 3px solid #fff; }
.marquee {
  position: relative; border-radius: 18px 18px 8px 8px; padding: 10px 16px; margin-bottom: 12px;
  background: #2a0f12; text-align: center; overflow: hidden;
  border: 6px solid transparent;
  background-image: linear-gradient(#2a0f12, #2a0f12), repeating-linear-gradient(90deg, var(--sodium) 0 8px, #7a4b00 8px 22px);
  background-origin: border-box; background-clip: padding-box, border-box;
}
.marquee .title { font-family: var(--font-display); font-size: clamp(1.4rem, 4.4vw, 2.6rem); color: var(--sodium); line-height: 1; text-shadow: 3px 3px 0 #7a2b00; letter-spacing: .04em; }
.marquee .sub { font-family: var(--font-mono); font-size: 0.72rem; color: #ffb4a6; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.hud div { background: #1b0a0b; border-radius: var(--radius-sm); box-shadow: inset 2px 2px 0 #000; padding: 6px 10px; min-width: 0; }
.hud small { display: block; font-size: 0.68rem; letter-spacing: .05em; text-transform: uppercase; color: #ffb4a6; }
.hud b { font-family: var(--font-digits); font-size: 1.7rem; line-height: 1; color: #ffe9b0; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) { .hud { gap: 6px; } .hud div { padding: 5px 7px; } .hud b { font-size: 1.4rem; } }
/* the timer is the one urgent number: larger, and it turns pink and blinks for the last 5 seconds */
.hud .hud-timer b { font-size: 2rem; }
@media (max-width: 560px) { .hud .hud-timer b { font-size: 1.6rem; } }
.hud .hud-timer.low { background: #3a0f2a; box-shadow: inset 0 0 0 2px var(--danger); }
.hud .hud-timer.low small, .hud .hud-timer.low b { color: var(--danger); }
.hud .hud-timer.low b { animation: blink .5s steps(2) infinite; }
.hud b.lives { display: flex; gap: 2px; align-items: center; min-height: 1.7rem; }
.hud b.lives .ic { width: 22px; height: 22px; }
.tank { position: relative; border-radius: var(--radius); overflow: hidden; background: #08263d; box-shadow: inset 0 0 0 4px #1b0a0b, inset 0 0 40px rgba(0,0,0,.5); }
.tank canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; touch-action: none; }
.tank::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0 1px, transparent 1px 3px), linear-gradient(115deg, rgba(255,255,255,.10) 0%, transparent 28%, transparent 70%, rgba(255,255,255,.05) 100%); }
:root[data-contrast="high"] .tank::after { display: none; }
.banner {
  display: flex; align-items: center; gap: 8px; justify-content: center; z-index: 1;
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  background: rgba(21,11,28,.92); border: 3px solid var(--line); border-radius: 0; padding: 8px 18px; box-shadow: var(--hard);
  font-weight: 700; text-align: center; max-width: 90%; pointer-events: none; transition: opacity .3s;
}
.banner.good { border-color: var(--kelp); color: var(--kelp); }
.banner.bad { border-color: var(--danger); color: #ffd3ea; }
.banner.info { border-color: var(--sky); color: var(--sky); }
.controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.joy { display: flex; gap: 8px; }
.joy button, .drop {
  border: none; cursor: pointer; font-family: var(--font-display); color: #2a0d07; touch-action: manipulation;
  box-shadow: 0 5px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.5);
}
.joy button { width: 64px; height: 56px; border-radius: var(--radius); background: #ffe3dc; display: grid; place-items: center; }
.joy button .ic { width: 30px; height: 30px; }
.joy button:active, .drop:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
/* the one round part on the cabinet: a domed arcade button */
.drop { height: 64px; padding: 0 28px; border-radius: 32px; background: radial-gradient(ellipse at 50% 30%, #fff1c4 0%, var(--sodium) 45%, #e0a92f 100%); font-size: 1.25rem; letter-spacing: .05em; display: inline-flex; align-items: center; gap: 8px; }
.drop[disabled], .joy button[disabled] { opacity: .5; cursor: not-allowed; }
.keys { margin-left: auto; color: #ffe3dc; font-size: var(--step--1); }
.keys kbd { font-family: var(--font-mono); background: #2a0f12; border-radius: 0; box-shadow: 0 2px 0 #000; padding: 1px 6px; font-size: 0.78rem; }
.machine { display: flex; gap: 8px; margin-left: auto; }
/* the keyboard hint needs room; on a narrow cabinet the tank banner already teaches the keys at the start of each round */
.cabinet { container-type: inline-size; }
@container (max-width: 820px) { .keys { display: none; } }
/* Pause and Restart sit flush with the right edge of the control row; the hint, when shown, sits just before them */
.machine { order: 2; }
.btn.icon { width: 44px; padding: 0; justify-content: center; }
/* the chosen guide's pixel portrait inside the Ask button (Coral by default) */
.btn-av { line-height: 0; margin: -4px 0; } .btn-av .spr { width: 28px; height: 28px; }
@media (max-width: 560px) { .keys { display: none; } .drop { flex: 1; min-width: 0; padding: 0 16px; } .controls { gap: 8px; flex-wrap: nowrap; } .joy button { width: 52px; } }

/* side panel */
.panel { background: var(--deep); border: 3px solid var(--line); border-radius: var(--radius); box-shadow: var(--hard); padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--step-1); margin: 0; color: var(--ink); text-wrap: balance; }
.eyebrow { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid var(--line); border-radius: 0; padding: 3px 10px; font-size: 0.82rem; background: var(--panel); }
.chip.plastic { border-color: var(--sodium); color: var(--sodium); }
.chip.plastic::before { content: "◆ "; }
.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 8px; border-radius: 0; background: var(--panel-2); }
.progress span.done { background: var(--kelp); }
.progress span.now { background: var(--sky); }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.log li button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; cursor: pointer; }
.log li button:hover { background: var(--panel-2); }
.log .spr { width: 32px; height: 32px; }
.log small { color: var(--muted); display: block; }
.empty { color: var(--muted); font-size: var(--step--1); margin: 0; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.chat-log { display: grid; gap: 8px; max-height: 260px; overflow: auto; padding-right: 4px; }
.msg { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 0.92rem; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0; padding-left: 18px; }
.msg.user { background: var(--panel-2); justify-self: end; max-width: 90%; }
.msg.bot { background: var(--panel); border: 2px solid var(--line); }
.chat form { display: flex; gap: 6px; }
.chat input { flex: 1; min-width: 0; background: var(--abyss); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { background: transparent; border: 2px dashed var(--line); border-radius: 0; padding: 4px 10px; font-size: 0.8rem; cursor: pointer; color: var(--muted); }
.suggest button:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- dialogs: arcade-cabinet popups ---------- */
dialog {
  border: 6px solid transparent; border-radius: 0; color: var(--ink); padding: 0;
  width: min(700px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(var(--deep), var(--deep)) padding-box, repeating-linear-gradient(90deg, var(--sodium) 0 10px, #7a4b00 10px 24px) border-box;
  box-shadow: 0 0 0 3px #2a0f12, 8px 8px 0 3px #0b0510;
  font-size: 1.06rem;
}
dialog.wide { width: min(880px, calc(100vw - 24px)); }
:root[data-contrast="high"] dialog { background: #000; border: 4px solid #fff; }
dialog::backdrop { background: repeating-linear-gradient(0deg, rgba(12,5,16,.86) 0 2px, rgba(12,5,16,.74) 2px 4px); }
.dlg { padding: 22px clamp(14px, 4vw, 28px) 24px; display: grid; gap: 16px; }
.dlg h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.05; margin: 0; text-wrap: balance; color: #fff1d6; text-shadow: 3px 3px 0 #c2412d; letter-spacing: .02em; }
.dlg h3 { margin: 0; font-size: var(--step-1); }
.dlg p { margin: 0; max-width: 62ch; }
/* anything a player reads as sentences uses the readable face, a little larger with looser lines */
.dlg p, .dlg li, .msg, .ai-box, .feedback, .quiz-q, .quiz button, .lens-result, .coral-last { font-family: var(--font-read); line-height: 1.55; }
.dlg-sub { color: var(--muted); font-size: 1rem !important; margin-top: -4px !important; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.dlg-head { display: grid; gap: 8px; justify-items: center; text-align: center; }
.dlg-head p { max-width: 50ch; font-size: 1.1rem; }
/* the dive/context line is a ticket stub at the popup's top edge, not a pill label over the title */
.dlg-head .eyebrow, .catch-head .eyebrow { background: var(--sky); color: var(--sky-ink); padding: 4px 18px 5px; border-radius: 0; letter-spacing: .08em;
  clip-path: polygon(0 0, 100% 0, 100% 35%, calc(100% - 6px) 50%, 100% 65%, 100% 100%, 0 100%, 0 65%, 6px 50%, 0 35%); }
.dlg-head > .eyebrow:first-child { margin-top: -22px; }
.hero-art { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; justify-content: center; line-height: 1; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.hero-art .spr.lg { width: clamp(44px, 13vw, 64px); height: clamp(44px, 13vw, 64px); }
.dlg > * { min-width: 0; }   /* no single row (like the guide lineup) can stretch a popup wider than a phone */
.hero-art .ic { width: 64px; height: 64px; color: var(--sodium); filter: drop-shadow(3px 3px 0 #7a2b00); }
.hero-art .ic.red { color: var(--danger); filter: drop-shadow(3px 3px 0 #4a0f33); }
.hero-art .ic.kelp { color: var(--kelp); filter: drop-shadow(3px 3px 0 #0b3a2c); }
.dlg .btn { font-size: .95rem; }
.dlg .btn.primary, .dlg .btn.gold { font-family: var(--font-display); font-weight: 400; letter-spacing: .03em; box-shadow: 4px 4px 0 #0b0510, inset 0 2px 0 rgba(255,255,255,.4); }
.dlg .btn.primary:active, .dlg .btn.gold:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #0b0510; }
.btn.mini { min-height: 32px; padding: 3px 12px; font-size: .8rem; white-space: nowrap; flex: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.center-note { text-align: center; color: var(--muted); font-size: .95rem; margin: 0 auto !important; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: var(--step--1); }
.field input, .field textarea, .field select { background: var(--abyss); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; }
.toggles { display: grid; gap: 8px; }
.toggle { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--sodium); flex: none; }
.toggle small { display: block; color: var(--muted); }
.toggles.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* picture tiles: one idea each, icon first */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
#lessonBody .tiles { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
#lessonBody .tile { text-align: left; }
#lessonBody .tile .ico { place-items: center start; }
.tile { --c: var(--sky); background: var(--panel); border: 2px solid var(--line); border-top: 6px solid var(--c); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 6px; align-content: start; text-align: center; }
.tile .ico { height: 64px; display: grid; place-items: center; color: var(--c); }
.tile .ico .ic { width: 48px; height: 48px; filter: drop-shadow(3px 3px 0 rgba(0,0,0,.5)); }
.tile .ico .spr { width: 64px; height: 64px; }
.tile h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.02rem; color: var(--c); line-height: 1.15; }
.tile p { margin: 0; font-size: 1.02rem; text-align: left; }
#welcomeDlg .tile p { text-align: center; margin: 0 auto; }   /* one-liners stay centered under their icon */
.tile .stat { font-family: var(--font-read); font-size: .9rem; text-align: left; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; }
.tile.c-coral { --c: var(--coral); } .tile.c-danger { --c: var(--danger); } .tile.c-kelp { --c: var(--kelp); } .tile.c-sky { --c: var(--sky); }
.tile .dont { color: #ffd3ea; font-size: .95rem; }
/* stacked rows (catch card, Label Lens): icon on the left, heading and text on the right, read top to bottom */
.tiles.stack { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.tiles.stack .tile { grid-template-columns: 48px minmax(0, 1fr); column-gap: 14px; text-align: left; border-top-width: 2px; border-left: 6px solid var(--c); padding: 12px 14px; }
.tiles.stack .tile .ico { grid-row: 1 / span 3; height: auto; align-self: start; }
.tiles.stack .tile .ico .ic { width: 36px; height: 36px; }
.tiles.stack .tile > :not(.ico) { grid-column: 2; }

/* quick check */
.quiz-box { background: #1b0a0b; border: 2px solid #3a1518; border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 12px; }
.quiz-q { font-weight: 700; font-size: 1.15rem; text-align: center; display: grid; gap: 6px; justify-items: center; }
.quiz-rule { text-align: center; color: var(--muted); font-size: .95rem; margin: -6px auto 0 !important; }
.quiz-q .eyebrow { color: var(--sodium); display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); }
.quiz { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.quiz button { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; font-weight: 700; min-height: 52px; box-shadow: 0 4px 0 #0b0510; }
.quiz button:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 #0b0510; }
.quiz button:hover:not([disabled]) { background: var(--panel-2); border-color: var(--sky); }
.quiz button[disabled] { cursor: default; }
.quiz .k { font-family: var(--font-display); font-weight: 400; background: var(--sky); color: var(--sky-ink); width: 30px; height: 30px; border-radius: 0; display: grid; place-items: center; flex: none; }
.quiz button.right { border-color: var(--kelp); background: rgba(58,214,165,.15); } .quiz button.right .k { background: var(--kelp); }
.quiz button.wrong { border-color: var(--danger); background: rgba(255,111,181,.12); } .quiz button.wrong .k { background: var(--danger); }
.quiz button.right::after { content: "✓"; margin-left: auto; color: var(--kelp); font-size: 1.3rem; }
.quiz button.wrong::after { content: "✕"; margin-left: auto; color: var(--danger); font-size: 1.3rem; }
.feedback { border-left: 4px solid var(--kelp); padding: 8px 12px; background: var(--panel); border-radius: 0; }
.feedback.bad { border-left-color: var(--danger); }

/* catch card */
.catch-head { display: grid; gap: 6px; justify-items: center; text-align: center; }
.catch-orb { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, rgba(255,209,102,.5) 0%, rgba(255,209,102,.08) 60%, transparent 70%); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.points { font-family: var(--font-mono); color: var(--kelp); font-weight: 700; background: rgba(58,214,165,.12); border: 2px solid var(--kelp); border-radius: 0; padding: 2px 12px; }
.inside { display: grid; gap: 6px; justify-items: center; text-align: center; }
.inside .chips { justify-content: center; }
.legend { color: var(--muted); font-size: .9rem; font-family: var(--font-read); }
.town-note { text-align: center; color: var(--muted); font-size: .95rem; margin: 0 auto !important; }
.section-label { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
/* inside popups the labels carry real information, so they read as normal text */
.dlg .section-label { font-family: var(--font-read); font-weight: 700; font-size: .95rem; letter-spacing: 0; text-transform: none; color: var(--ink); }
.dispose { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.ai-box { background: var(--panel); border: 2px dashed var(--kelp); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 1rem; }
.ai-box p { margin: 0 0 6px; } .ai-box ul { margin: 4px 0; padding-left: 18px; }
.ai-tag { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--kelp); margin-bottom: 6px; display: block; }

/* scores */
.stars { display: inline-flex; gap: 6px; color: var(--sodium); line-height: 1; }
.stars .ic { width: 40px; height: 40px; filter: drop-shadow(3px 3px 0 #7a2b00); }
.stars .ic.off { color: var(--line); filter: none; }
.stars.sm { justify-content: center; } .stars.sm .ic { width: 18px; height: 18px; }
.bigscore { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
.bigscore div { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--hard); padding: 12px; text-align: center; }
.bigscore .ico { display: block; color: var(--sodium); }
.bigscore .ico .ic { width: 30px; height: 30px; }
.bigscore b { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.5rem, 6vw, 2.1rem); display: block; color: var(--sodium); font-variant-numeric: tabular-nums; line-height: 1.1; }
.bigscore small { color: var(--muted); }
.sprite-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mods { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.mods div { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px; text-align: center; display: grid; gap: 2px; }
.mods .ico { height: 40px; display: grid; place-items: center; color: var(--sky); }
.mods .ico .ic { width: 32px; height: 32px; } .mods .ico .spr { width: 40px; height: 40px; }
.mods small { color: var(--muted); font-size: .8rem; }
table.lb { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.lb th, table.lb td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.lb td.num, table.lb th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.lb tr.me td { color: var(--sodium); font-weight: 700; }
.tag { font-size: 0.7rem; border: 2px solid var(--line); border-radius: 0; padding: 1px 6px; color: var(--muted); margin-left: 6px; }

/* label lens */
.lens-drop { border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 18px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.lens-drop img { max-height: 180px; border-radius: 0; }
.lens-result { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 16px; display: grid; gap: 12px; }
.verdict { font-family: var(--font-display); font-size: var(--step-1); display: flex; align-items: center; gap: 8px; }
.verdict.contains { color: var(--danger); } .verdict.free { color: var(--kelp); } .verdict.unclear { color: var(--sodium); }

/* coral chat (its own popup, so the game pauses underneath) */
.coral-dlg .chat-log { max-height: min(46vh, 420px); min-height: 180px; background: var(--abyss); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.coral-dlg .msg { font-size: 1rem; }
.paused-tag { font-family: var(--font-mono); font-size: .74rem; letter-spacing: .06em; color: var(--sodium); border: 2px solid var(--sodium); border-radius: 0; padding: 2px 10px; }
.coral-card { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.coral-card .who { display: flex; gap: 10px; align-items: center; line-height: 1.3; }
/* sidebar column: the field guide panel, then the guide in its own box */
.side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.panel.guide-panel { gap: 10px; padding: 14px 16px; border-top: 6px solid var(--sky); }
.coral-av { line-height: 0; }
.coral-av .spr { width: 48px; height: 48px; }
.coral-last { margin: 0; font-size: .9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ocean guide picker */
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.guide { position: relative; display: grid; gap: 2px; justify-items: center; align-content: start; text-align: center; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 8px; cursor: pointer; }
.guide:hover { background: var(--panel-2); }
.guide:has(input:checked) { border-color: var(--sky); background: var(--panel-2); box-shadow: var(--hard); transform: translate(-2px, -2px); }
.guide:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.guide .em { line-height: 0; }
.guide .em .spr { width: 56px; height: 56px; }
.guide b { font-family: var(--font-display); font-weight: 400; font-size: .9rem; color: var(--ink); }
.guide small { color: var(--muted); font-size: .76rem; line-height: 1.3; }
.guide .pr { font-family: var(--font-mono); font-size: .68rem; color: var(--kelp); }
.guide .hear { margin-top: 4px; }

/* guide captions: an RPG dialogue box. It's a popover so it can sit above open popups; it never takes clicks. */
.caption { position: fixed; inset: auto; margin: 0; padding: 10px 16px 12px 10px; width: min(640px, calc(100vw - 24px));
  border: 4px solid var(--sky); border-radius: 0; background: rgba(21, 11, 28, .96); color: #fff8ec; pointer-events: none;
  box-shadow: 0 0 0 3px #2a0f12, 6px 6px 0 3px #0b0510; overflow: visible; }
.caption:popover-open { display: flex; gap: 12px; align-items: center; }
.caption.no-popover { display: none; z-index: 50; } .caption.no-popover.show { display: flex; gap: 12px; align-items: center; }
.cap-face { width: 68px; height: 68px; flex: none; border: 3px solid var(--sky); border-radius: 0; background: var(--abyss); display: grid; place-items: center; }
.cap-face .spr { width: 56px; height: 56px; }
.cap-body { min-width: 0; flex: 1; }
.cap-name { display: inline-block; font-family: var(--font-display); font-size: .78rem; letter-spacing: .04em; color: var(--sky-ink); background: var(--sky); padding: 1px 10px; border-radius: 0; margin-bottom: 4px; }
.cap-text { margin: 0; font-family: var(--font-game); font-size: 1.02rem; line-height: 1.35; min-height: 2.7em; text-wrap: pretty; }
.cap-more { position: absolute; right: 12px; bottom: 6px; color: var(--sky); font-size: .8rem; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
:root[data-contrast="high"] .caption { background: #000; border-color: #fff; }
/* small screens: a compact box that sits over the HUD instead of covering the short tank */
.caption.compact { padding: 6px 10px 8px 6px; gap: 8px; border-width: 3px; }
.caption.compact .cap-face { width: 44px; height: 44px; border-width: 2px; } .caption.compact .cap-face .spr { width: 36px; height: 36px; }
.caption.compact .cap-text { font-size: .86rem; min-height: 2.4em; } .caption.compact .cap-name { font-size: .66rem; }

/* before / after comparison of the tank */
.ba { --pos: 50%; position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 3px solid var(--sodium); background: #08263d; }
.ba img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ba .ba-before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.ba::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--pos); width: 4px; margin-left: -2px; background: var(--sodium); box-shadow: 2px 0 0 #7a2b00; pointer-events: none; }
.ba-tag { position: absolute; top: 8px; font-family: var(--font-mono); font-size: .72rem; background: rgba(21,11,28,.85); color: var(--sodium); padding: 2px 8px; border-radius: 0; pointer-events: none; }
.ba-tag.l { left: 8px; } .ba-tag.r { right: 8px; }
.ba input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.ba:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.friend { display: flex; gap: 10px; align-items: center; justify-content: center; background: var(--panel); border: 2px dashed var(--kelp); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--kelp); }

/* demo checklist */
.tour { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tour li { display: flex; gap: 8px; align-items: center; font-size: .92rem; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 40px; }
.tour li.done { border-color: var(--kelp); color: var(--kelp); }
.tour li > :last-child { margin-left: auto; }
.tour li > .ic { color: var(--sky); } .tour li.done > .ic { color: var(--kelp); }
.tour .chk { font-family: var(--font-mono); font-weight: 700; }
.tour.big { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.muted { color: var(--muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.foot { max-width: 1240px; margin: 18px auto 0; color: var(--muted); font-size: 0.8rem; }
@media (prefers-reduced-motion: reduce) { .cap-more { animation: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }
