/* Sea Change: the sea is the picture; the HUD is dark glass in the corners. Local fonts only. */
:root {
  --abyss: #03141f;
  --panel: rgba(5, 32, 46, 0.72);
  --panel-strong: rgba(4, 25, 37, 0.91);
  --scrim: rgba(2, 13, 20, 0.65);
  --line: rgba(255, 255, 255, 0.18);
  --line-strong: rgba(255, 255, 255, 0.34);
  --foam: #f2faf8;
  --mist: #b9d0d6;
  --dim: #86a2ab;
  --lure: #7ff0dc;
  --lure-ink: #04222b;
  --sun: #ffd98a;
  --amber: #ffb35c;
  --habitat-shallows: #8fe3f2;
  --habitat-reef: #ff9f85;
  --habitat-deep: #8c9bff;
  --tissue: #e0908a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --inset: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--abyss); color: var(--foam); font: 15px/1.45 var(--sans); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#view:focus-visible { outline: 3px solid var(--sun); outline-offset: -6px; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 1em; height: 1em; flex: none; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); font: 600 12px/1 var(--sans); color: var(--foam); }
.eyebrow { font: 700 11px/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); }
.sun { color: var(--sun); }
.glass { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { :root { --panel: rgba(5, 32, 46, 0.86); } }

button, a.button { font: 600 15px/1.2 var(--sans); color: var(--foam); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px; min-height: 44px; padding: 10px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; text-decoration: none; touch-action: manipulation; }
button:hover, a.button:hover { border-color: var(--foam); }
button.primary { background: var(--lure); color: var(--lure-ink); border-color: transparent; font-weight: 700; }
button.primary:hover { background: #a4f6e8; }
button b, a.button b { color: var(--lure); font-weight: 600; }
button.primary svg, button svg, a.button svg { font-size: 20px; }

/* ---- arcade navigation (top left; never inert) ---- */
#arcadeNav { position: fixed; z-index: 40; top: calc(var(--inset) - 4px + var(--safe-t)); left: calc(var(--inset) + var(--safe-l)); display: flex; gap: 8px; align-items: flex-start; }
#arcadeBack, #helpPanel > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); color: var(--foam); font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer; list-style: none; }
#arcadeBack svg { font-size: 18px; }
#helpPanel > summary::-webkit-details-marker { display: none; }
#arcadeHelp { position: absolute; left: 0; top: 52px; width: min(560px, calc(100vw - 2 * var(--inset))); max-height: min(70vh, 640px); overflow: auto; padding: 18px 20px; border-radius: 16px; background: var(--panel-strong); border: 1px solid var(--line); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); font-size: 14px; color: var(--mist); user-select: text; -webkit-user-select: text; }
#arcadeHelp strong { color: var(--foam); }
#arcadeHelp p { margin: 0 0 10px; }
#arcadeHelp kbd { min-width: 20px; height: 20px; font-size: 11px; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud a { pointer-events: auto; }
#pauseBtn { position: absolute; top: calc(var(--inset) - 4px + var(--safe-t)); right: calc(var(--inset) + var(--safe-r)); width: 44px; height: 44px; padding: 0; }
#pauseBtn svg { font-size: 22px; }

#reticle { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 1.5px solid rgba(242, 250, 248, 0.6); border-radius: 50%; transition: width 160ms, height 160ms, margin 160ms, border-color 160ms; }
#reticle i { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: var(--foam); }
#reticle.on { width: 34px; height: 34px; margin: -17px 0 0 -17px; border-color: var(--lure); border-width: 2px; }
body.inside #reticle { opacity: 0.5; }
#hud > * { transition: opacity 300ms; }
#hud.fading > :not(#ladder) { opacity: 0; }
body.calm #hud > * { transition: none; }

#prompt { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); margin: 0; display: flex; align-items: center; gap: 12px; padding: 8px 20px 8px 10px; border-radius: 999px; white-space: nowrap; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
#prompt b { font: 700 18px/1.2 var(--sans); }
#prompt span { color: var(--mist); font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
#prompt.tip { padding-left: 20px; }
#prompt.tip kbd { display: none; }
#grace { position: absolute; left: 50%; top: calc(62% + 54px); transform: translateX(-50%); margin: 0; display: flex; align-items: center; gap: 12px; padding: 6px 20px 6px 8px; border-radius: 999px; white-space: nowrap; background: var(--panel); border: 1.5px solid var(--lure); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
#grace b { font-size: 16px; }
#grace span { color: var(--mist); font-size: 14px; }
.ring svg { font-size: 34px; color: var(--lure); }
.ring .track, .ride-ring .track { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 3; }
.ring .arc, .ride-ring .arc { fill: none; stroke: var(--lure); stroke-width: 3; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; stroke-dasharray: 100 100; }

#toastSlot { position: absolute; top: calc(86px + var(--safe-t)); left: 0; right: 0; display: flex; justify-content: center; }
.toast { display: flex; align-items: center; gap: 14px; padding: 9px 22px 9px 9px; border-radius: 16px; max-width: calc(100vw - 32px); background: var(--panel-strong); border: 1px solid var(--line); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); animation: toast-in 240ms ease-out; }
.toast-plate { width: 64px; height: 52px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); display: grid; place-items: center; flex: none; }
.toast-plate:empty { display: none; }
.toast-plate .plate { width: 58px; height: 30px; }
.toast-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast .eyebrow { color: var(--sun); font-size: 10px; }
.toast-title b { font: 400 21px/1.2 var(--serif); }
.toast-title i { font: italic 14px/1.2 var(--serif); color: var(--mist); }
.toast-count { font: 600 14px/1 var(--sans); color: var(--mist); font-variant-numeric: tabular-nums; }
.toast-count:empty { display: none; }
.toast.headsup { border: 1.5px solid var(--amber); }
.toast.headsup .eyebrow { color: var(--amber); }
.toast.headsup .toast-plate { border-radius: 50%; width: 44px; height: 44px; color: var(--amber); }
.toast.plain { padding-left: 22px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
body.calm .toast { animation: none; }

#cue { position: absolute; top: 50%; left: 18px; margin-top: -18px; color: var(--amber); font-size: 36px; opacity: 0; transition: opacity 300ms; }
#cue.show { opacity: 1; }
#cue.right { left: auto; right: 18px; transform: scaleX(-1); }
#cue.behind { left: 50%; top: auto; bottom: 120px; transform: rotate(-90deg); margin-left: -18px; }
#cue.above { left: 50%; top: 70px; transform: rotate(90deg); margin-left: -18px; margin-top: 0; }
#cue.below { left: 50%; top: auto; bottom: 120px; transform: rotate(-90deg); margin-left: -18px; }
#cue.ahead { opacity: 0; }
#wash { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity 600ms; }
#wash.left { background: linear-gradient(90deg, rgba(255, 179, 92, 0.28), transparent 26%); }
#wash.right { background: linear-gradient(270deg, rgba(255, 179, 92, 0.28), transparent 26%); }
#wash.behind, #wash.below { background: linear-gradient(0deg, rgba(255, 179, 92, 0.24), transparent 30%); }
#wash.above { background: linear-gradient(180deg, rgba(255, 179, 92, 0.24), transparent 30%); }
#wash.show { opacity: 1; }
#veil { position: fixed; inset: 0; pointer-events: none; z-index: 6; background: #05080a; opacity: 0; }

#tract { position: absolute; top: calc(26px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(512px, calc(100vw - 32px)); padding: 16px 26px 14px; border-radius: 24px; text-align: center; background: var(--panel-strong); border: 1px solid var(--line); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
#tract .eyebrow { margin: 0; color: var(--sun); font-size: 10px; }
#tract h2 { margin: 6px 0 12px; font: 400 26px/1.2 var(--serif); }
#tractSteps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
#tractSteps::before { content: ""; position: absolute; left: 10%; right: 10%; top: 6px; height: 2px; background: rgba(255, 255, 255, 0.22); }
#tractSteps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--mist); }
#tractSteps li i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--mist); background: var(--panel-strong); position: relative; z-index: 1; }
#tractSteps li.done i { background: var(--tissue); border-color: var(--tissue); }
#tractSteps li.done { color: var(--mist); }
#tractSteps li.now i { width: 16px; height: 16px; margin-top: -2px; background: var(--sun); border: 2px solid var(--foam); }
#tractSteps li.now { color: var(--foam); font-weight: 700; }
#rideOut { position: absolute; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); margin: 0; display: flex; align-items: center; gap: 12px; padding: 7px 22px 7px 8px; border-radius: 999px; white-space: nowrap; background: var(--panel-strong); border: 1px solid var(--line); }
body.inside .id-stats { display: none; }
body.inside #toastSlot { top: calc(176px + var(--safe-t)); }
body.touch.inside #toastSlot { top: calc(150px + var(--safe-t)); }
@media (max-width: 980px) { #rideOut { bottom: calc(118px + var(--safe-b)); } }
.ride-ring { position: relative; display: grid; place-items: center; width: 38px; height: 38px; }
.ride-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ride-ring kbd { min-width: 22px; height: 22px; border-radius: 50%; padding: 0; }

/* depth ladder (desktop) */
#ladder { position: absolute; right: calc(var(--inset) + var(--safe-r)); top: 50%; transform: translateY(-50%); width: 204px; padding: 16px 14px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.ladder-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 10px; }
.ladder-head b { font: 400 21px/1 var(--serif); font-variant-numeric: tabular-nums; }
#ladderStops { list-style: none; margin: 0; padding: 0; position: relative; }
#ladderStops::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 26px; width: 1.5px; background: rgba(255, 255, 255, 0.28); }
#ladderStops li { position: relative; padding: 0 0 14px 26px; display: flex; flex-direction: column; }
#ladderStops li::before { content: ""; position: absolute; left: 1px; top: 3px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--dot); background: var(--panel-strong); }
#ladderStops li.here::before { background: var(--dot); border-color: var(--foam); width: 12px; height: 12px; left: 0; top: 2px; }
#ladderStops li b { font-weight: 400; font-size: 15px; }
#ladderStops li.here b { font-weight: 700; }
#ladderStops li span { font-size: 12px; color: var(--mist); }
#ladderStops li:not(.here) em { display: none; }
#ladderStops li em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--dot); }
#habitatBtn { width: 100%; justify-content: flex-start; background: transparent; border: none; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 10px 0 2px; min-height: 40px; font-size: 14px; }
#habitatBtn kbd { height: 24px; }
#habitatBtn.locked kbd { display: none; }
#habitatBtn.locked { color: var(--mist); font-weight: 500; cursor: default; }

#identity { position: absolute; left: calc(var(--inset) + var(--safe-l)); bottom: calc(var(--inset) + var(--safe-b)); display: flex; align-items: center; gap: 16px; padding: 12px 18px 12px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.id-plate { width: 84px; height: 60px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); display: grid; place-items: center; flex: none; }
.id-plate .plate { width: 72px; height: 36px; }
.id-text { display: flex; flex-direction: column; }
.id-text .eyebrow { font-size: 10px; }
.id-text b { font: 400 26px/1.15 var(--serif); }
.id-text i { font: italic 14px/1.3 var(--serif); color: var(--mist); }
.id-stats { display: flex; flex-direction: column; gap: 10px; padding-left: 16px; border-left: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.id-stats > span { display: flex; align-items: center; gap: 8px; }
.id-stats svg { font-size: 16px; color: var(--mist); }
.meter { display: block; width: 92px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--lure); transform-origin: left; }

#chip, #habitatPill { display: none; }

/* ---- touch layout ---- */
body.touch { --inset: 14px; }
body.touch #arcadeBack span { display: none; }
body.touch #arcadeBack, body.touch #helpPanel > summary { width: 44px; padding: 0; justify-content: center; }
body.touch #helpPanel > summary { font-size: 0; }
body.touch #helpPanel > summary::before { content: "?"; font: 700 18px/1 var(--sans); }
body.touch #identity, body.touch #rideOut, body.touch #ladder { display: none; }
body.touch #chip { display: flex; position: absolute; top: calc(var(--inset) - 4px + var(--safe-t)); left: 50%; transform: translateX(-50%); align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); white-space: nowrap; }
body.touch #chip .id-plate { width: 46px; height: 36px; border-radius: 999px; }
body.touch #chip .id-plate .plate { width: 40px; height: 22px; }
#chipName { font: 400 19px/1 var(--serif); }
#chipPlace { font-size: 13px; color: var(--mist); }
#chipDepth { font-size: 13px; font-weight: 700; color: var(--dot, var(--lure)); font-variant-numeric: tabular-nums; }
body.touch #habitatPill { display: inline-flex; position: absolute; top: calc(var(--inset) - 4px + var(--safe-t)); right: calc(var(--inset) + 52px + var(--safe-r)); height: 44px; padding: 0 14px 0 12px; gap: 8px; font-size: 15px; }
.mini-ladder { display: flex; flex-direction: column; gap: 3px; }
.mini-ladder i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }
.mini-ladder i.here { background: var(--dot); width: 8px; height: 8px; margin-left: -1px; }
.pill-icon, .pill-lock { font-size: 18px; }
.pill-lock { display: none; }
#habitatPill.locked { color: var(--mist); }
#habitatPill.locked .pill-icon { display: none; }
#habitatPill.locked .pill-lock { display: inline; }
body.touch #toastSlot { top: calc(66px + var(--safe-t)); }
body.touch #tract { top: calc(64px + var(--safe-t)); padding: 10px 18px; }
body.touch #tract .eyebrow { display: none; }
body.touch #tract h2 { font-size: 20px; margin: 0 0 8px; }
body.touch #prompt { top: 60%; padding-left: 20px; }
body.touch #prompt kbd { display: none; }
body.touch #grace { top: calc(60% + 50px); }
/* At tablet widths a touch screen shows the full depth ladder instead of the Habitat pill. */
@media (min-width: 1024px) {
  body.touch #ladder { display: block; top: calc(50% - 40px); }
  body.touch #habitatPill { display: none; }
}

#touch { position: fixed; inset: 0; z-index: 8; touch-action: none; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 42%; height: 70%; touch-action: none; }
#stickBase { position: absolute; left: var(--stick-x, calc(56px + 60px + var(--safe-l))); top: var(--stick-y, calc(100% - 116px - var(--safe-b))); width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: rgba(5, 32, 46, 0.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#stickZone:not(.active) #stickBase { left: calc(56px + 60px + var(--safe-l)); top: calc(100% - 116px - var(--safe-b)); }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: rgba(242, 250, 248, 0.88); transform: translate(-50%, -50%); }
#lookZone { position: absolute; right: 0; top: 0; width: 58%; height: 100%; touch-action: none; }
#touchButtons { position: absolute; right: calc(20px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); width: 232px; height: 200px; pointer-events: none; }
#touchButtons button { position: absolute; pointer-events: auto; flex-direction: column; gap: 2px; padding: 0; border-radius: 50%; font-size: 14px; font-weight: 700; touch-action: none; }
#touchButtons button svg { font-size: 22px; }
#btnUp, #btnDown { width: 56px; height: 56px; left: 0; }
#btnUp { top: 22px; }
#btnDown { top: 90px; }
#btnDart { width: 62px; height: 62px; right: 22px; top: 0; }
#btnAction { width: 84px; height: 84px; right: 0; bottom: 0; background: var(--lure); color: var(--lure-ink); border-color: transparent; font-size: 15px; }
#btnAction svg#actionIcon { font-size: 26px; }
#touchButtons button.held { filter: brightness(1.25); border-color: var(--foam); }
#btnAction .ride-ring { position: absolute; inset: -6px; width: auto; height: auto; pointer-events: none; }
#btnAction .ride-ring .arc { stroke: var(--foam); stroke-width: 2.5; }
@media (orientation: portrait) and (max-width: 700px) {
  #touchButtons { transform: scale(0.92); transform-origin: right bottom; }
  body.touch #chip #chipPlace { display: none; }
  body.touch #habitatPill b { display: none; }
  #prompt span { display: none; }
}
@media (max-width: 520px) {
  /* Narrow portrait: the identity chip gets its own row under the buttons. */
  body.touch #chip { top: calc(62px + var(--safe-t)); padding-right: 14px; gap: 8px; }
  body.touch #chip #chipPlace { display: none; }
  body.touch #toastSlot { top: calc(116px + var(--safe-t)); }
  body.touch.inside #toastSlot { top: calc(196px + var(--safe-t)); }
  body.touch #tract { top: calc(112px + var(--safe-t)); }
  .toast-title i { display: none; }
  #grace span:not(.ring) { display: none; }
}
/* Short landscape touch screens: keep the prompt and the grace chip clear of the Up/Down buttons. */
@media (max-height: 520px) and (orientation: landscape) {
  body.touch #prompt span, body.touch #grace span:not(.ring) { display: none; }
  body.touch #prompt { top: 54%; }
  body.touch #grace { top: calc(54% + 46px); }
}

/* ---- overlays ---- */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: calc(72px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow: auto; background: var(--scrim); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.overlay.solid { background: var(--abyss); }
.card { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 24px; padding: 28px; backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
.card h1 { font: 400 44px/1.1 var(--serif); margin: 0 0 10px; }
.lead { color: var(--mist); margin: 0 0 18px; }
.small { font-size: 13px; color: var(--mist); }
.stack { display: flex; flex-direction: column; gap: 10px; }
#loading .card { text-align: center; max-width: 440px; }
#loading.failed .card { border-color: var(--amber); }

/* title */
.overlay.title { place-items: start stretch; background: linear-gradient(180deg, rgba(3, 20, 31, 0.15), rgba(3, 20, 31, 0.55) 70%, rgba(3, 20, 31, 0.85)); backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: calc(84px + var(--safe-t)); }
.title-inner { width: min(1250px, 100%); margin: 0 auto; padding: 0 clamp(0px, 4vw, 64px); }
.title h1 { font: 400 clamp(48px, 7.4vw, 104px)/1 var(--serif); margin: 6px 0 14px; letter-spacing: -0.01em; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35); }
.tagline { font: italic 30px/1.2 var(--serif); color: var(--lure); margin: 0 0 22px; }
.title .lead { max-width: 600px; font-size: 17px; line-height: 1.6; color: var(--foam); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5); }
.title .note { max-width: 600px; color: var(--mist); margin: 0 0 26px; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5); }
.title-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 36px; }
.title-actions button { min-height: 58px; padding: 0 28px; font-size: 19px; }
.keys-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 32px; padding: 20px 24px; border-radius: 24px; background: var(--panel-strong); border: 1px solid var(--line); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
.keys-panel h2 { margin: 0 0 10px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; margin: 0; align-items: center; font-size: 14px; }
.keys dt { display: flex; gap: 5px; }
.keys dd { margin: 0; color: var(--mist); }
body.touch .keys-panel > div:nth-child(1), body.touch .keys-panel > div:nth-child(2) { display: none; }
body.touch .keys-panel { grid-template-columns: 1fr; }
@media (max-width: 860px) { .keys-panel { grid-template-columns: 1fr; } }
/* Short landscape screens (phones): the start screen keeps Dive in above the fold. */
@media (max-height: 520px) {
  .overlay.title { padding-top: calc(64px + var(--safe-t)); }
  .title h1 { font-size: 44px; margin: 2px 0 6px; }
  .tagline { font-size: 20px; margin-bottom: 10px; }
  .title .lead { font-size: 14px; line-height: 1.45; margin-bottom: 8px; max-width: 640px; }
  .title .note { font-size: 13px; margin-bottom: 14px; }
  .title-actions { margin-bottom: 18px; }
  .title-actions button { min-height: 48px; font-size: 17px; }
  .eyebrow.sun { display: none; }
}

/* pause + Sea Log */
.pause-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 884px); gap: 24px; align-items: start; width: min(1250px, 100%); }
.pause-card h1 { font-size: 46px; }
.pause-card .stack button, .pause-card .stack a.button { width: 100%; }
.pause-card .small { margin: 18px 0 0; display: flex; gap: 8px; align-items: center; }
.log-card { padding: 26px 28px; }
.log-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.log-head h2 { font: 400 32px/1.1 var(--serif); margin: 0; }
.log-head p { margin: 0; font-weight: 700; }
.log-lead { color: var(--mist); font-size: 14px; margin: 6px 0 14px; }
.log-row h3 { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; font: 700 15px/1.2 var(--sans); }
.log-row h3 i { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); }
.log-row h3 span { font-weight: 400; color: var(--mist); font-size: 13px; }
.log-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.log-grid li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; text-align: center; }
.log-grid .cell { width: 100%; aspect-ratio: 86 / 66; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); display: grid; place-items: center; font: 400 26px/1 var(--serif); color: var(--dim); }
.log-grid .cell .plate { width: 86%; height: auto; }
.log-grid li.met .cell { background: rgba(127, 240, 220, 0.06); border-color: var(--line-strong); }
.log-grid li.met { font-weight: 600; }
.log-grid li.glimpsed .cell .plate { filter: brightness(0) invert(0.75); opacity: 0.55; }
.log-grid li.glimpsed { color: var(--mist); }
.log-grid li.unknown { color: var(--dim); }
@media (max-width: 860px) { .pause-grid { grid-template-columns: 1fr; width: min(640px, 100%); } }
@media (max-width: 1100px) and (min-width: 861px) { .pause-card h1 { font-size: 38px; } .log-card, .pause-card { padding: 20px; } .log-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); } }

/* habitat sheet */
.overlay.sheet { place-items: center; }
.sheet-card { width: min(860px, 100%); padding: 30px 32px 26px; }
.grabber { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h1 { font-size: 40px; margin: 0; }
.text-button { background: none; border: none; color: var(--mist); font-weight: 500; gap: 8px; padding: 0 4px; }
.sheet-lead { color: var(--mist); max-width: 560px; margin: 8px 0 18px; }
.sheet-body { display: grid; grid-template-columns: 26px 1fr; gap: 12px; }
.axis { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--sun); padding: 6px 0; }
.axis svg { font-size: 18px; }
.axis svg:last-child { color: var(--habitat-deep); }
.axis i { flex: 1; width: 2px; background: linear-gradient(var(--habitat-shallows), var(--habitat-reef), var(--habitat-deep)); border-radius: 1px; }
.sheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.habitat-card { width: 100%; border-radius: 16px; padding: 9px; display: grid; grid-template-columns: 168px 1fr auto; gap: 16px; align-items: center; text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); min-height: 112px; font-weight: 400; }
.habitat-card .thumb { height: 92px; border-radius: 10px; display: grid; place-items: center; overflow: hidden; }
.habitat-card .thumb .plate { width: 78%; height: auto; }
.thumb.shallows { background: radial-gradient(120% 90% at 50% -10%, #7fdcea, #1b7aa0 55%, #0a3d5c); }
.thumb.reef { background: radial-gradient(120% 90% at 50% -10%, #5cc0c0, #0f6070 55%, #3d4d3a); }
.thumb.deep { background: radial-gradient(60% 50% at 50% 30%, #12303a, #05080c 70%); }
.habitat-card .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.habitat-card .name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.habitat-card .name b { font: 400 26px/1.15 var(--serif); }
.habitat-card .name b::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); margin-right: 10px; vertical-align: 0.2em; }
.habitat-card .name span { font-size: 13px; color: var(--mist); }
.habitat-card .become { font-size: 15px; }
.habitat-card .blurb { font-size: 13px; color: var(--mist); }
.habitat-card .tags { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); color: var(--foam); white-space: nowrap; }
.tag svg { font-size: 14px; }
.habitat-card[aria-current="true"] .tag { font-weight: 500; color: var(--mist); }
.habitat-card[aria-pressed="true"] { border: 2px solid var(--lure); background: rgba(127, 240, 220, 0.07); padding: 8px; }
.habitat-card[aria-pressed="true"] .tag:not(.here) { background: var(--lure); color: var(--lure-ink); border-color: transparent; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.keys-hint { display: flex; align-items: center; gap: 6px; color: var(--mist); font-size: 14px; margin: 0; }
.keys-hint kbd:nth-of-type(2), .keys-hint kbd:nth-of-type(5) { margin-right: 6px; }
#sheetGo { min-height: 52px; padding: 0 28px; font-size: 18px; }
#sheetStay { display: none; }
body.touch .keys-hint { display: none; }
body.touch #sheetStay { display: inline-flex; }
body.touch .sheet-head .text-button kbd { display: none; }
@media (max-height: 520px) and (orientation: landscape) {
  /* Leave a gutter on the left for the arcade buttons, and fit all three cards and the buttons on one screen. */
  .overlay.sheet { padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(68px + var(--safe-l)); place-items: center; }
  .sheet-card { padding: 12px 16px; border-radius: 18px; }
  .sheet-head h1 { font-size: 24px; }
  .sheet-lead { display: none; }
  .sheet-list { gap: 6px; }
  .habitat-card { grid-template-columns: 96px 1fr auto; min-height: 0; padding: 5px; gap: 12px; }
  .habitat-card[aria-pressed="true"] { padding: 4px; }
  .habitat-card .thumb { height: 52px; }
  .habitat-card .thumb .plate { width: 70%; }
  .habitat-card .name b { font-size: 20px; }
  .habitat-card .become { font-size: 13px; }
  .habitat-card .blurb { display: none; }
  .habitat-card .tags { flex-direction: row; align-items: center; }
  .habitat-card .tags kbd { display: none; }
  .sheet-foot { margin-top: 8px; flex-wrap: nowrap; }
  #sheetGo, #sheetStay { min-height: 46px; font-size: 16px; }
  .axis { display: none; }
  .sheet-body { grid-template-columns: 1fr; }
}
@media (max-height: 760px) and (orientation: landscape) and (min-height: 521px) {
  .overlay.sheet { padding-top: 64px; }
  .sheet-card { padding: 20px 24px 18px; }
  .sheet-head h1 { font-size: 32px; }
  .sheet-lead { margin: 4px 0 12px; }
  .habitat-card { grid-template-columns: 132px 1fr auto; min-height: 0; }
  .habitat-card .thumb { height: 72px; }
  .sheet-foot { margin-top: 12px; }
}
/* Phone portrait: the sheet becomes a bottom sheet. */
@media (orientation: portrait) and (max-width: 700px) {
  .overlay.sheet { place-items: end stretch; padding: 0; }
  .sheet-card { border-radius: 24px 24px 0 0; padding: 14px 16px calc(18px + var(--safe-b)); width: 100%; }
  .grabber { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 12px; }
  .sheet-head h1 { font-size: 32px; }
  .sheet-head .text-button { display: none; }
  .sheet-body { grid-template-columns: 1fr; }
  .axis { display: none; }
  .habitat-card { grid-template-columns: 112px 1fr; }
  .habitat-card .thumb { height: 82px; }
  .habitat-card .blurb { display: none; }
  .habitat-card .tags { grid-column: 2; align-items: flex-start; flex-direction: row; }
  .habitat-card .tags kbd { display: none; }
  .sheet-foot { flex-direction: column; align-items: stretch; }
  .sheet-foot button { width: 100%; }
}
@media (max-width: 560px) {
  .title-actions button { min-height: 52px; }
  .tagline { font-size: 24px; }
  .card { padding: 22px 18px; }
  .habitat-card { grid-template-columns: 96px 1fr; }
  .habitat-card .tags { grid-column: 2; align-items: flex-start; flex-direction: row; }
}

#noscript { position: fixed; inset: auto 16px 16px; padding: 16px; border-radius: 16px; background: var(--panel-strong); z-index: 50; }
#noscript a { color: var(--lure); }

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  #reticle, #wash, #cue { transition: none; }
}
