:root {
  --ink: #140f1f;
  --night: rgba(18, 14, 38, 0.9);
  --cream: #fff7dc;
  --dim: #a9a3cf;
  --gold: #ffd166;
  --coral: #ff6f61;
  --teal: #52d6d8;
  --label: "Silkscreen", "Courier New", monospace;
  --text: "VT323", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #07050f; }
body { color: var(--cream); font: 20px/1.1 var(--text); }
ul, ol { list-style: none; }

#sea { position: fixed; inset: 0 auto auto 0; image-rendering: pixelated; }

/* stepped corners, the way an 8-bit window would have them */
.panel, button {
  --n: 6px;
  clip-path: polygon(0 var(--n), var(--n) var(--n), var(--n) 0, calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n), 100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%, var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n)));
}
.panel { background: var(--night); box-shadow: inset 0 0 0 3px #4a3f7a; }

.label { display: block; font: 11px var(--label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.sub { display: block; font-size: 17px; color: var(--dim); text-transform: uppercase; }
.teal { color: var(--teal); }
.gold { color: var(--gold); }

.hud { position: fixed; top: 14px; left: 16px; right: 16px; display: grid; grid-template-columns: 150px 1fr 150px; align-items: start; gap: 12px; }
.stat { padding: 10px 16px; }
.stat strong { display: block; font-weight: 400; font-size: 48px; line-height: 0.95; }
.right { text-align: right; }

.title { text-align: center; }
.wordmark { font: 700 clamp(24px, 4.2vw, 60px) / 1 var(--label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); text-shadow: 4px 4px 0 var(--coral), 8px 8px 0 var(--ink); }
.dives { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.dives li { width: 40px; height: 32px; display: grid; place-items: center; background: var(--night); box-shadow: 0 0 0 3px #4a3f7a; color: var(--dim); font-size: 22px; }
.dives .done { background: var(--gold); box-shadow: 0 0 0 3px var(--ink); color: var(--ink); }
.dives .now { box-shadow: 0 0 0 3px var(--coral); color: var(--cream); }

.hazards { position: fixed; left: 16px; top: calc(50% - var(--dock, 150px) / 2 + 45px); transform: translateY(-50%); width: 132px; padding: 10px 8px; display: grid; gap: 6px; }
.hazards li { display: grid; grid-template-columns: 38px 1fr; align-items: center; column-gap: 10px; padding: 4px 6px; }
.hazards i { grid-row: span 2; display: block; }
.hazards canvas { width: 36px; height: auto; image-rendering: pixelated; display: block; }
.hazards b { font-weight: 400; font-size: 26px; line-height: 0.9; }
.hazards span { font: 10px var(--label); text-transform: uppercase; color: var(--dim); }
.hazards .seen { background: rgba(255, 111, 97, 0.22); box-shadow: inset 0 0 0 3px var(--coral); }
.hazards .seen span { color: var(--coral); }


.gain { position: fixed; left: var(--x, 55%); top: var(--y, 40%); transform: translate(-40%, -100%); z-index: 2; text-align: center; white-space: nowrap; text-shadow: 3px 3px 0 var(--ink); }
.gain strong { display: block; font: 700 clamp(20px, 2.6vw, 34px) var(--label); text-transform: uppercase; color: var(--gold); }
.gain span { font-size: 20px; text-transform: uppercase; }

#dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 16px calc(14px + env(safe-area-inset-bottom)); }
.corner { max-width: 980px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; }
.note { flex: 1; text-align: center; font: 10px var(--label); text-transform: uppercase; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); }
.bar { max-width: 980px; margin: 0 auto; padding: 16px 20px; display: flex; align-items: center; gap: 24px; }
.risk { display: flex; align-items: center; gap: 20px; flex: 1; }
.stake strong { display: block; font-weight: 400; font-size: 58px; line-height: 0.9; color: var(--gold); }
.odds { flex: 1; max-width: 220px; }
.odds b { font: 20px var(--text); color: var(--teal); }
.meter { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 6px 0 4px; }
.meter i { height: 14px; background: #2d2656; }
.meter i:first-child { background: var(--teal); }

.actions { display: flex; gap: 12px; align-items: stretch; }
button { font: 700 15px var(--label); text-transform: uppercase; border: 0; padding: 14px 18px; min-height: 62px; cursor: default; }
button small { display: block; margin-top: 4px; font: 17px var(--text); }
.go { background: var(--gold); color: var(--ink); font-size: 18px; box-shadow: inset 0 -6px 0 #d99a3a; }
.up { background: var(--teal); color: var(--ink); box-shadow: inset 0 -6px 0 #2b8f9e; }
.dbl { background: #3a1f45; color: #ffb3aa; box-shadow: inset 0 0 0 3px var(--coral); }

.scanlines { position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.14) 2px 3px), radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.45)); }

@media (max-width: 960px) {
  .bar { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 14px; }
  .odds { max-width: none; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .go { grid-column: 1 / -1; min-height: 50px; }
  .stake strong { font-size: 44px; }
  button { font-size: 12px; padding: 8px; min-height: 52px; }
}

@media (max-width: 760px) {
  .hud { grid-template-columns: 1fr 1fr; top: 8px; left: 10px; right: 10px; gap: 8px; }
  .title { grid-row: 2; grid-column: 1 / -1; }
  .stat { padding: 6px 12px; }
  .stat strong { font-size: 32px; }
  .stat .sub { display: none; }
  .wordmark { display: none; }
  .dives { margin-top: 2px; }
  .dives li { width: 34px; height: 26px; font-size: 19px; }
  #dock { padding-left: 10px; padding-right: 10px; }
  .hazards { top: auto; bottom: calc(var(--dock) + 4px); left: 10px; right: 10px; width: auto; transform: none; grid-template-columns: repeat(4, 1fr); padding: 6px; gap: 4px; }
  .hazards li { grid-template-columns: 26px 1fr; column-gap: 6px; padding: 3px 4px; }
  .hazards canvas { width: 26px; }
  .hazards span { font-size: 8px; }
  .note { font-size: 8px; }
  .gain { left: auto; right: 46px; transform: translateY(-110%); padding: 4px 8px; background: rgba(18, 14, 38, 0.72); }
}

/* big monitors: grow the panels along with the world */
@media (min-width: 1600px) and (min-height: 900px) {
  .hud { grid-template-columns: 220px 1fr 220px; top: 22px; left: 26px; right: 26px; }
  .label { font-size: 15px; }
  .sub { font-size: 24px; }
  .stat { padding: 14px 22px; }
  .stat strong { font-size: 68px; }
  .wordmark { font-size: 72px; }
  .dives li { width: 56px; height: 44px; font-size: 30px; }
  .hazards { left: 26px; width: 188px; gap: 10px; padding: 14px 12px; }
  .hazards li { grid-template-columns: 52px 1fr; }
  .hazards canvas { width: 50px; }
  .hazards b { font-size: 36px; }
  .hazards span { font-size: 13px; }
  #dock { padding-bottom: 22px; }
  .corner { max-width: 1320px; }
  .note { font-size: 13px; }
  .bar { max-width: 1320px; padding: 22px 30px; gap: 34px; }
  .stake strong { font-size: 82px; }
  .odds { max-width: 300px; }
  .odds b { font-size: 28px; }
  .meter i { height: 20px; }
  button { font-size: 20px; min-height: 90px; padding: 18px 26px; }
  .go { font-size: 25px; }
  button small { font-size: 24px; }
  .gain span { font-size: 28px; }
}

/* ---------- moving parts (step 2) ---------- */
[hidden] { display: none !important; }
#sea { touch-action: manipulation; }

.ruler { position: fixed; right: 0; top: 108px; bottom: var(--dock); width: 64px; overflow: hidden; pointer-events: none; }
#track, .you { position: absolute; top: 0; right: 0; }
#track { width: 100%; }
.mark { position: absolute; right: 16px; width: 44px; display: grid; place-items: center; font-size: 22px; border-right: 6px solid; text-shadow: 2px 2px 0 var(--ink); }
.mark.shallows { color: #9ff2dd; }
.mark.twilight { color: var(--gold); background: rgba(255, 209, 102, 0.1); }
.mark.abyss { color: #b79cff; }
.you { right: 0; color: var(--cream); font-size: 20px; }

.window { position: fixed; left: 0; right: 0; top: 108px; bottom: var(--dock); overflow: hidden; pointer-events: none; }
.drift { position: absolute; left: 0; right: 0; top: 0; }
.drift > div { position: absolute; white-space: nowrap; font: 11px var(--label); letter-spacing: 0.1em; text-transform: uppercase; text-shadow: 2px 2px 0 var(--ink); }
.boundary { left: 0; right: 0; padding: 4px 0 0 180px; border-top: 3px dashed rgba(190, 220, 255, 0.3); }
.boundary.twilight { color: var(--gold); }
.boundary.abyss { color: #b79cff; }
.flavour { left: 17%; color: rgba(255, 247, 220, 0.6); }
.flavour::before { content: "── "; }
.flavour.far { left: auto; right: 90px; }
.flavour.far::before { content: none; }
.flavour.far::after { content: " ──"; }

.hud, .hazards, .ruler, #dock { z-index: 1; }
.dives .bust { background: #5a2338; box-shadow: 0 0 0 3px var(--coral); color: var(--coral); }
.stake strong.lost { color: var(--coral); }
.meter i.low { background: var(--teal); }
.meter i.mid { background: var(--gold); }
.meter i.high { background: var(--coral); }
.meter i:first-child { background: #2d2656; }
.meter i:first-child.low { background: var(--teal); }
.meter i:first-child.mid { background: var(--gold); }
.meter i:first-child.high { background: var(--coral); }

.stake { min-width: 96px; }
.actions button { width: 168px; }
.actions .go { width: 252px; }
button { cursor: pointer; }
button:hover:not(:disabled) { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translateY(2px); }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible { outline: 3px solid var(--cream); outline-offset: -8px; }
.dbl.armed { background: var(--coral); color: var(--ink); }

.gain.good strong { color: var(--gold); }
.gain.warn strong { color: #ffb36b; }
.gain.bad strong { color: var(--coral); }

@media (max-width: 960px) {
  .actions button, .actions .go { width: auto; }
}
@media (max-width: 760px) {
  .ruler, .window { top: 128px; bottom: calc(var(--dock) + 60px); }
  .ruler { width: 46px; }
  .mark { right: 6px; width: 34px; font-size: 18px; }
  .boundary { padding-left: 10px; font-size: 9px; }
  .drift > .flavour { display: none; }
}
@media (min-width: 1600px) and (min-height: 900px) {
  .ruler, .window { top: 170px; }
  .ruler { width: 90px; }
  .mark { right: 24px; width: 60px; font-size: 32px; }
  .drift > div { font-size: 15px; }
  .boundary { padding-left: 250px; }
  .actions button { width: 240px; }
  .actions .go { width: 360px; }
  .stake { min-width: 140px; }
}

/* ---------- animation gallery ---------- */
.gallery { position: fixed; z-index: 4; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(980px, calc(100vw - 20px)); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px; }
.gallery button { min-height: 40px; padding: 8px 12px; font-size: 12px; background: #3d3470; color: var(--cream); }
.gallery-open #dock { visibility: hidden; }

/* ---------- screens over the water ---------- */
h2 { font: 700 22px var(--label); text-transform: uppercase; color: var(--gold); }
.center { text-align: center; }
button.tiny { min-height: 32px; padding: 6px 12px; font-size: 10px; background: var(--night); color: var(--cream); box-shadow: inset 0 0 0 3px #4a3f7a; }
button.plain { min-height: 48px; padding: 10px 14px; font-size: 12px; background: #3d3470; color: var(--cream); box-shadow: inset 0 -5px 0 #2a2350; }
.menurow { display: flex; flex-wrap: wrap; gap: 8px; }
.menurow button { flex: 1 1 auto; white-space: nowrap; }

.on-title .hud, .on-title .hazards, .on-title .ruler, .on-title .window, .on-title #dock, .on-title .gain,
.on-log .hud, .on-log .hazards, .on-log .ruler, .on-log .window, .on-log #dock, .on-log .gain { visibility: hidden; }

.titlescreen { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 5vh 16px calc(3vh + env(safe-area-inset-bottom)); pointer-events: none; }
.titlescreen > * { pointer-events: auto; }
.marquee { text-align: center; }
.marquee h1 { font: inherit; }
.logo { display: block; font: 700 clamp(36px, 8.4vw, 112px) / 1 var(--label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); text-shadow: 0.06em 0.06em 0 var(--coral), 0.12em 0.12em 0 var(--ink); }
.kind { display: block; margin-top: 16px; font: 700 clamp(10px, 1.2vw, 17px) / 1.4 var(--label); letter-spacing: 0.08em; text-transform: uppercase; text-wrap: balance; color: var(--cream); }
.tagline { text-wrap: balance; margin-top: 18px; font-size: clamp(19px, 2.2vw, 30px); text-transform: uppercase; }
/* inked all round, so they stay readable where they cross the sun */
.kind, .tagline { text-shadow: -2px -2px 0 var(--ink), 0 -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink), -2px 2px 0 var(--ink), 0 2px 0 var(--ink), 2px 2px 0 var(--ink), 4px 4px 0 var(--ink); }
.menu { container-type: inline-size; width: min(560px, 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 18px 20px; text-align: center; }
.menu .status { font-size: 30px; text-transform: uppercase; }
/* one line always: the label shrinks with the panel before it can wrap */
.menu .go { --go: 20px; font-size: min(var(--go), calc((100cqi - 16px) / 17)); white-space: nowrap; }
.menu .sub { font-size: 19px; }

.sheet { position: fixed; inset: 0; z-index: 3; display: grid; overflow-y: auto; padding: 18px 14px; outline: none; }
.logcard { --night: rgba(18, 14, 38, 0.97); width: min(660px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 22px 24px; }
.logcard header { text-align: center; }
.logcard h2 { margin: 6px 0 2px; font: 400 62px / 1 var(--text); }
.logrows { display: grid; gap: 6px; }
.logrows li { display: grid; grid-template-columns: 22px minmax(0, 1fr) 74px; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(74, 63, 122, 0.35); }
.logrows li.bust { background: rgba(255, 111, 97, 0.2); }
.num { color: var(--dim); font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { min-width: 28px; height: 28px; display: grid; place-items: center; padding: 0 3px; font-style: normal; font-size: 20px; color: var(--ink); background: #9ff2dd; }
.chip.twilight { background: var(--gold); }
.chip.abyss { background: #b79cff; }
.chip:not(.pearl) { background: var(--night); box-shadow: inset 0 0 0 2px #4a3f7a; }
.chip canvas { width: 24px; height: auto; image-rendering: pixelated; }
.chip.twice:not(.pearl) { background: var(--coral); box-shadow: none; }
.logrows li.bust .chip.hazard:nth-last-child(1), .logrows li.bust .chip.hazard:nth-last-child(2):has(+ .twice) { box-shadow: inset 0 0 0 3px var(--coral); }
.end { text-align: right; }
.end b { display: block; font-weight: 400; font-size: 26px; line-height: 0.95; color: var(--gold); }
.logrows li.bust .end b { color: var(--coral); }
.end small { display: block; font-size: 16px; text-transform: uppercase; color: var(--dim); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.compare div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 2px dotted #4a3f7a; padding-bottom: 3px; }
.compare dt { font-size: 18px; color: var(--dim); }
.compare dd { font-size: 22px; white-space: nowrap; }
.share { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.share pre { padding: 8px 12px; font: 18px / 1.25 var(--text); white-space: pre-wrap; overflow-wrap: anywhere; background: #0b0818; user-select: all; }

.modal { position: fixed; inset: 0; margin: auto; width: min(580px, calc(100vw - 24px)); height: fit-content; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; border: 0; padding: 22px 24px; color: var(--cream); background: #141029; }
.modal[open] { display: grid; gap: 12px; }
.modal { scroll-padding-bottom: 90px; }
.modal::backdrop { background: rgba(7, 5, 15, 0.72); }
.modal b { font-weight: 400; color: var(--gold); }
.modal i { color: var(--coral); font-style: normal; }
.modal a { color: var(--cream); text-underline-offset: 3px; }
.modal form { display: grid; }
.lead { font-size: 22px; }
.lessons { display: grid; gap: 10px; }
.lessons li { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 14px; }
.art { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.art canvas { image-rendering: pixelated; width: 78px; height: auto; }
.art[data-art="hazards"] canvas { width: 36px; }
.art[data-art="tank"] canvas { width: 44px; }
.zones i { width: 24px; height: 28px; display: grid; place-items: center; color: var(--ink); font-size: 18px; background: #9ff2dd; }
.zones .z2 { background: var(--gold); }
.zones .z3 { background: #b79cff; }
.statgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.statgrid div { display: flex; flex-direction: column-reverse; padding: 8px 2px; background: rgba(74, 63, 122, 0.35); }
.statgrid dt { font: 9px var(--label); text-transform: uppercase; color: var(--dim); }
.statgrid dd { font-size: 36px; color: var(--gold); }
.recent { display: grid; gap: 4px; }
.recent li { display: flex; justify-content: space-between; border-bottom: 2px dotted #4a3f7a; }
.recent b { color: var(--gold); }

.scanlines { z-index: 5; }
.no-scanlines .scanlines { background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.45)); }

.switches { display: grid; gap: 10px; }
.switches li { display: grid; grid-template-columns: minmax(0, 1fr) 84px; align-items: center; gap: 14px; padding: 10px 12px; background: rgba(74, 63, 122, 0.35); }
.switches b { display: block; font-size: 24px; text-transform: uppercase; }
.switches span { color: var(--dim); }
.switches em { font-style: normal; color: var(--teal); }
.switches button[aria-checked="true"] { background: var(--teal); color: var(--ink); box-shadow: inset 0 -5px 0 #2b8f9e; }

@media (max-width: 760px) {
  .logcard { padding: 16px 14px; gap: 11px; }
  .logcard h2 { font-size: 50px; }
  .logrows li { grid-template-columns: 12px minmax(0, 1fr) 54px; gap: 8px; padding: 5px 8px; }
  .chips { gap: 3px; }
  .chip { min-width: 23px; height: 25px; padding: 0 2px; font-size: 18px; }
  .chip canvas { width: 20px; }
  .end b { font-size: 24px; }
  .end small { font-size: 14px; }
  .compare { grid-template-columns: 1fr; }
  .share { grid-template-columns: minmax(0, 1fr); }
  .share .go { min-height: 52px; }
  .menu { padding: 14px; gap: 9px; }
  .menu .status { font-size: 25px; }
  .menurow button { font-size: 10px; padding: 8px 6px; }
  .menu .menurow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .menu .menurow button { min-height: 44px; }
  .tagline { margin-top: 12px; }
  .modal { padding: 16px 14px; font-size: 18px; }
  .lessons li { grid-template-columns: 58px 1fr; gap: 10px; }
  .art canvas { width: 56px; }
  .art.zones { gap: 2px; }
  .zones i { width: 18px; height: 24px; font-size: 16px; }
  .art[data-art="hazards"] canvas { width: 26px; }
  .art[data-art="tank"] canvas { width: 32px; }
  .statgrid { grid-template-columns: repeat(3, 1fr); }
  .keys { display: none; }
}

@media (max-height: 640px) {
  .titlescreen { padding-top: 2vh; padding-bottom: 2vh; }
  .logo { font-size: clamp(32px, min(11vh, 11vw), 72px); }
  .tagline { margin-top: 10px; font-size: 18px; }
  .kind { margin-top: 8px; font-size: 10px; }
  .menu { gap: 6px; padding: 10px 14px; }
  .menu .status { font-size: 22px; }
  .menu .go { min-height: 44px; padding: 8px; }
  .menu .plain { min-height: 38px; padding: 6px; }
  .menu .sub { display: none; }
}

@media (min-width: 1600px) and (min-height: 900px) {
  button.tiny { min-height: 44px; font-size: 13px; }
  .logcard { width: 860px; gap: 18px; padding: 30px 36px; }
}

@media (min-width: 1600px) and (min-height: 1000px) {
  .menu { width: 760px; gap: 18px; padding: 28px 32px; }
  .menu .status { font-size: 42px; }
  .menu .go { --go: 28px; }
  .menu .plain { font-size: 17px; min-height: 64px; }
  .menu .sub { font-size: 26px; }
}

@media (min-width: 761px) and (min-height: 641px) and (max-height: 800px) {
  .titlescreen { padding-top: 3.5vh; padding-bottom: 1.5vh; }
  .menu { gap: 8px; padding: 12px 18px; }
  .menu .status { font-size: 25px; }
  .menu .go { min-height: 50px; padding: 8px; }
  .menu .plain { min-height: 40px; padding: 8px 10px; }
}

/* a middling window that is short: the controls stack, so the hazard list slims down */
@media (min-width: 761px) and (max-width: 960px) and (min-height: 501px) and (max-height: 700px) {
  .hazards { gap: 2px; padding: 6px; }
  .hazards li { padding: 1px 4px; }
  .hazards canvas { width: 28px; }
  .hazards li { grid-template-columns: 30px 1fr; }
  .hazards b { font-size: 22px; }
}

@media (max-width: 360px) {
  .menu .go { --go: 15px; padding-left: 6px; padding-right: 6px; }
}

/* wide: the dives and leaderboard on the left, the totals beside them */
@media (min-width: 1000px), (min-width: 640px) and (max-height: 500px) and (orientation: landscape) {
  .logcard { width: min(1040px, 100%); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 22px; row-gap: 9px; align-content: start; padding: 16px 24px; }
  .logcard header { grid-column: 1 / -1; }
  .logcard h2 { font-size: 46px; }
  .logcard .compare { grid-template-columns: 1fr; }
  .logcard .share { grid-template-columns: minmax(0, 1fr); }
  .logcard .share .go { min-height: 44px; padding: 8px; }
  .logcard .menurow button { min-height: 40px; padding: 8px; }
}

/* ---------- leaderboard and account ---------- */
.logleft, .logright { display: grid; grid-template-columns: minmax(0, 1fr); gap: inherit; align-content: start; }
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding-top: 4px; }
.board h3 { font-weight: 400; color: var(--gold); }
.ranks { display: grid; gap: 3px; }
.ranks li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 2px 10px; background: rgba(74, 63, 122, 0.35); }
.ranks li.mine { background: rgba(255, 209, 102, 0.2); box-shadow: inset 0 0 0 2px var(--gold); }
.ranks .place { color: var(--dim); }
.ranks .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 21px; }
.ranks b { font-weight: 400; font-size: 24px; color: var(--gold); }
.board .menurow:not(:has(button:not([hidden]))) { display: none; }
.board .menurow button { min-height: 40px; padding: 8px; }

.menu .me { justify-self: center; max-width: 100%; display: flex; flex-wrap: wrap; justify-content: center; column-gap: 1ch; line-height: 1.5; }
.me span { white-space: nowrap; }

.modal[open] { grid-template-columns: minmax(0, 1fr); }
#accountText { overflow-wrap: anywhere; }
.who b { display: block; font-size: 34px; overflow-wrap: anywhere; }
.linkform { display: grid; gap: 8px; }
.modal input { width: 100%; min-height: 48px; padding: 8px 12px; font: 24px var(--text); color: var(--cream); background: #0b0818; border: 0; box-shadow: inset 0 0 0 3px #4a3f7a; border-radius: 0; }
.modal input:focus-visible { outline: 3px solid var(--cream); outline-offset: -3px; }
.note-line { color: var(--teal); overflow-wrap: anywhere; }
.note-line:empty { display: none; }

/* ---------- phones and touch ---------- */
button { touch-action: manipulation; }
.hud, .hazards, #dock, .titlescreen, button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* "Got it" and "Done" stay in reach however long the panel is */
.modal .foot { position: sticky; bottom: -22px; margin-bottom: -22px; padding: 8px 0 22px; background: #141029; }
.taps { display: none; }
@media (pointer: coarse) {
  .keys { display: none; }
  .taps { display: block; }
}
@media (max-width: 760px) {
  .modal .foot { bottom: -16px; margin-bottom: -16px; padding-bottom: 16px; }
  .corner { gap: 6px; }
  .corner button.tiny { min-height: 40px; padding: 6px 10px; }
  .long { display: none; }
  #helpBtn { min-width: 40px; }
}

/* short upright phones: slimmer controls, more water */
@media (max-width: 760px) and (max-height: 700px) {
  .bar { gap: 8px; padding: 8px 12px; }
  .stake strong { font-size: 36px; }
  .meter { margin: 3px 0 2px; }
  .meter i { height: 10px; }
  .odds .sub { font-size: 15px; }
  .actions { gap: 6px; }
  .actions button { min-height: 44px; padding: 5px 6px; font-size: 11px; }
  .actions .go { min-height: 46px; font-size: 16px; }
  .actions button small { margin-top: 1px; font-size: 16px; }
  .corner { margin-bottom: 6px; }
  .corner button.tiny { min-height: 36px; }
}

/* phones on their side: everything gets out of the way vertically */
@media (max-height: 500px) and (orientation: landscape) {
  .hud { top: 6px; left: 8px; right: 8px; grid-template-columns: 112px 1fr 112px; gap: 8px; }
  .title { grid-row: auto; grid-column: auto; }
  .wordmark { display: none; }
  .dives { margin-top: 4px; }
  .dives li { width: 32px; height: 24px; font-size: 18px; }
  .stat { padding: 4px 10px; }
  .stat strong { font-size: 28px; }
  .stat .sub { display: none; }

  .hazards { top: 60px; bottom: auto; left: 8px; right: auto; width: 74px; transform: none; grid-template-columns: 1fr; gap: 3px; padding: 5px; }
  .hazards li { grid-template-columns: 28px 1fr; column-gap: 6px; padding: 2px 3px; }
  .hazards i { grid-row: auto; }
  .hazards canvas { width: 26px; }
  .hazards b { font-size: 22px; }
  .hazards span { display: none; }

  .ruler, .window { top: 54px; bottom: var(--dock); }
  .ruler { width: 46px; }
  .mark { right: 6px; width: 34px; font-size: 18px; }
  .boundary { padding-left: 100px; font-size: 9px; }
  .drift > .flavour { display: none; }

  #dock { padding: 0 8px calc(6px + env(safe-area-inset-bottom)); }
  .corner { margin-bottom: 4px; }
  .corner button.tiny { min-height: 32px; padding: 4px 10px; }
  .bar { flex-direction: row; align-items: center; gap: 12px; padding: 7px 10px; }
  .risk { gap: 10px; min-width: 0; }
  .stake { min-width: 56px; }
  .stake strong { font-size: 34px; }
  .label { font-size: 9px; letter-spacing: 0.06em; }
  .odds b { font-size: 17px; }
  .meter { gap: 2px; margin: 3px 0 2px; }
  .meter i { height: 9px; }
  .odds .sub { font-size: 14px; }
  .actions { display: flex; gap: 6px; }
  .actions button { width: 112px; min-height: 52px; padding: 4px 6px; font-size: 10px; }
  .actions .go { width: 164px; min-height: 52px; font-size: 12px; }
  .actions button small { margin-top: 2px; font-size: 15px; }

  .titlescreen { align-items: flex-end; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .marquee { align-self: center; }
  .logo { font-size: clamp(30px, 11vh, 56px); }
  .menu { width: min(340px, 46%); }
  .menu .menurow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .menu .menurow button { min-height: 38px; padding: 6px 4px; font-size: 10px; }
  .menu .label { font-size: 9px; letter-spacing: 0.04em; }
  .menu .go { --go: 15px; }

  .logcard { row-gap: 6px; padding: 10px 14px; }
  .logcard h2 { font-size: 34px; margin: 2px 0 0; }
  .logrows { gap: 4px; }
  .logrows li { padding: 2px 8px; }
  .chip { height: 22px; min-width: 22px; font-size: 17px; }
  .chip canvas { width: 18px; }
  .end b { font-size: 21px; }
  .end small { font-size: 13px; line-height: 0.9; }
  .compare dt { font-size: 16px; }
  .compare dd { font-size: 19px; }

  .sheet { padding: 10px; }
  .modal { padding: 14px 16px; font-size: 18px; gap: 8px; }
  .modal .foot { bottom: -14px; margin-bottom: -14px; padding: 6px 0 14px; }
  .modal .go { min-height: 44px; padding: 8px; }
}

/* the smallest phones on their side still need room for the diver's name */
@media (max-height: 340px) and (orientation: landscape) {
  .menu { gap: 4px; padding: 6px 12px; }
  .menu .go { min-height: 40px; padding: 6px; }
  .menu .menurow { gap: 4px; }
  .menu .menurow button { min-height: 34px; }
  .menu .me { min-height: 28px; padding: 2px 8px; font-size: 9px; line-height: 1.3; }
}

/* keep clear of notches and rounded corners */
.hud { margin: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
.ruler, .window { margin-top: env(safe-area-inset-top, 0px); }
.ruler { margin-right: env(safe-area-inset-right, 0px); }
.hazards, #dock { margin-left: env(safe-area-inset-left, 0px); }
#dock, .hazards { margin-right: env(safe-area-inset-right, 0px); }
.titlescreen, .sheet { margin: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
