/* PLUNDER — the game's one stylesheet.
   Merged from what used to be four layered files, in their original cascade
   order: game.css (base) → v2.css (redesign) → webgl-stage.css (3D stage) →
   v3.css ("moonlit glass"). Later layers still override earlier ones exactly
   as before, so comments below that mention "game.css" / "v2.css" etc. mean
   that layer of this file. Rules for elements the game no longer renders
   (the old lobby, jackpot, fog, music button...) were dropped in the merge.
   verify.html has its own small sheet: css/verify.css. */

/* ═════════════ LAYER: game.css ═════════════ */
/* ============================================================
   PLUNDER — night-raid aesthetic
   ink sea · lantern gold · crimson vs teal
   ============================================================ */

:root {
  --ink: #070b18;
  --sea-1: #0a1124;
  --sea-2: #13224a;
  --panel: rgba(13, 20, 44, 0.78);
  --panel-solid: #0e1531;
  --line: rgba(245, 197, 66, 0.16);
  /* antique brass, not the bright #f5c542 "AI yellow" */
  --gold: #d3a24b;
  --gold-dim: #8d6a2d;
  --text: #ece3cd;
  --muted: #8b93ad;
  --port: #e2493b;
  --port-soft: rgba(226, 73, 59, 0.16);
  --star: #6ea8e0;
  --star-soft: rgba(110, 168, 224, 0.16);
  --danger: #ff6b5e;
  --radius: 14px;
  /* readable geometric sans (free stand-in for Nexa Heavy — see note in the PR) */
  --display: 'Outfit', 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  --sans: 'IBM Plex Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 70% -10%, #1b2a55 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, #101c3d 0%, transparent 55%),
    var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  overflow-x: hidden;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--gold); }
button { font-family: inherit; cursor: pointer; }

/* film grain */
#grain {
  position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
}

/* ---------------- topbar ---------------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px 6px;
  width: 100%; max-width: 1560px; margin: 0 auto;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-right { gap: 8px; flex-shrink: 0; }   /* aboard + balance kept tight together */
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand h1 {
  font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1;
  letter-spacing: 2px; color: var(--gold);
  text-shadow: 0 0 18px rgba(211, 162, 75, 0.35);
}
.online-pill {
  color: var(--muted); font-size: 12px; padding: 5px 9px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
}
.you-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 6px 11px; border-radius: 999px; font-size: 13px;
}
.you-chip .mono { color: var(--gold); font-weight: 600; }
.you-chip .mono::after { content: ""; }

/* ---------------- layout ---------------- */
#layout {
  max-width: 1560px; margin: 0 auto; padding: 6px 10px 0;
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
/* PC: two columns — big scene on the left, chat+betting panel on the right */
@media (min-width: 980px) {
  #layout { grid-template-columns: minmax(0, 2.05fr) minmax(320px, 0.95fr); align-items: start; }
}
@media (min-width: 1500px) {
  #layout { grid-template-columns: minmax(0, 2.4fr) minmax(340px, 0.85fr); }
}

/* ---------------- ship cards ---------------- */
/* DESKTOP: the two ship info cards sit in a row above the stage (the classic
   layout). On phones this becomes an on-ship overlay — see the @media block. */
#cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch;
  margin-bottom: 6px;
}
.ship-card {
  border-radius: var(--radius); padding: 9px 12px 7px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  color: var(--text); position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .2s;
}
.ship-card:active { transform: scale(.98); }
.ship-card.port { border-color: rgba(226,73,59,.4); box-shadow: inset 0 0 30px rgba(226,73,59,.08); }
.ship-card.star { border-color: rgba(110,168,224,.4); box-shadow: inset 0 0 30px rgba(110,168,224,.08); }
.ship-card .card-name {
  font-family: var(--display); font-size: 17px; letter-spacing: 2px; line-height: 1;
  display: flex; align-items: center; gap: 6px;
}
.card-name .cn-txt { line-height: 1.02; text-transform: uppercase; font-weight: 800; letter-spacing: .8px; }
/* ship cards are DISPLAY-ONLY now (betting happens on the board buttons) */
.ship-card { cursor: default; }
.ship-card:hover, .ship-card:active { transform: none; }
.ship-card.port .card-name { color: var(--port); }
.ship-card.star .card-name { color: var(--star); }
.ship-card.bump { animation: bump .35s ease; }

/* ---- the live multiplier on each ship card ----
   Both ships ride one clock, so these read alike until a ship sinks; then
   that one FREEZES at its crash point and goes .sunk, which is what makes
   "the Pearl died at x1.20 while the Interceptor made x9" legible at a
   glance. Tabular figures so the number doesn't jitter as it climbs. */
.card-mult {
  display: block; margin-top: 2px;
  font-size: 20px; font-weight: 800; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  color: #e9f3ff; text-shadow: 0 2px 10px rgba(0,0,0,.55);
  transition: color .18s ease, opacity .18s ease;
}
.ship-card.port .card-mult { color: #ffd8d2; }
.ship-card.star .card-mult { color: #d6e9ff; }
.card-mult.sunk { color: var(--muted); opacity: .7; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ship-card.sunk { filter: grayscale(.7) brightness(.72); }
.ship-card.sunk .card-name { opacity: .5; }
@keyframes bump { 30% { box-shadow: 0 0 24px rgba(245,197,66,.25); } }

/* ---- jackpot DROP full-screen flash ---- */
#jackpot-flash {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  pointer-events: none;
  /* no backdrop at all — just the solid box floats over the live scene (no black wash) */
  background: transparent;
}
#jackpot-flash[hidden] { display: none; }
#jackpot-flash.go { animation: jfFade 3.8s ease forwards; }
@keyframes jfFade { 0%, 78% { opacity: 1; } 100% { opacity: 0; } }

/* phase indicator: a slim centered line above the stage. Fixed height + nowrap so
   it never reflows when the label/eta text changes between phases (no height jump). */
#phase-ribbon {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px;
  height: 30px; flex-wrap: nowrap; white-space: nowrap; overflow: hidden;
}
#phase-label {
  font-family: var(--display); font-size: 17px; letter-spacing: 2px; color: var(--gold);
  text-transform: uppercase; line-height: 1;
}
#phase-clock { font-size: 18px; color: var(--text); }

#timerbar { height: 3px; background: rgba(255,255,255,.06); border-radius: 3px; overflow: hidden; }
#timerbar-fill { height: 100%; width: 100%; background: var(--gold); transition: none; border-radius: 3px; }
#timerbar-fill.fog { background: #9db3d8; }
#timerbar-fill.race { background: var(--danger); }

/* ---------------- stage ---------------- */
#stage {
  position: relative; margin-top: 8px;
  height: clamp(320px, 44vh, 460px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
  background: linear-gradient(#0a1c40 0%, #0d2c52 16%, #14507e 22%, #10456f 55%, #0a2b4c 100%);
}
#sea, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
#fx { z-index: 5; pointer-events: none; }
.lane { position: absolute; left: 0; width: 100%; z-index: 3; }
#lane-port { top: calc(8% + 10px); height: 44%; }
#lane-star { top: calc(50% + 10px); height: 44%; }

.ship {
  position: absolute; left: 0; top: 0;
  width: clamp(190px, 30vw, 300px);
  will-change: transform;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.45));
}
.ship svg { width: 100%; height: auto; display: block; overflow: visible; }
/* premium ship motion: sails breathe, flags flutter */
.ship .sails { animation: sailBillow 3.4s ease-in-out infinite; }
#lane-star .ship .sails { animation-delay: -1.2s; }
@keyframes sailBillow {
  0%, 100% { transform: scaleX(1) skewX(0deg); }
  50% { transform: scaleX(1.035) skewX(-1.4deg); }
}
.ship .flag { animation: flagWave 1.1s ease-in-out infinite; }
@keyframes flagWave {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  50% { transform: skewY(4deg) scaleX(.9); }
}
.ship .skull { transition: opacity .4s ease; }
.deck-crew {
  position: absolute; left: 14%; right: 20%; top: 34%;
  display: flex; flex-wrap: nowrap; gap: 2px; justify-content: center; align-items: flex-end;
  pointer-events: none;
}
.av {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--c, #ccc);
  border: 1.5px solid rgba(0,0,0,.55);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.28);
  flex: 0 0 auto;
}
.av.bot { opacity: .8; border-style: dashed; }
.av.you { outline: 2px solid #fff; outline-offset: 1px; animation: youpulse 1.6s infinite; }
@keyframes youpulse { 50% { outline-color: rgba(255,255,255,.25); } }

/* fog — the tensest beat of the round: a heavy, moody bank that swallows the ships,
   darker at the edges (vignette) with a slow breathing pulse */
/* DEAD — The Fog phase went away with the hidden-headcount game, and
   nothing renders #fog any more. These rules are unreachable and can be
   deleted wholesale along with .fog-blob / #fog-note / @keyframes fogDrift
   and the body.fog-on rules below. */
#fog {
  position: absolute; inset: 0; z-index: 4;
  /* dense, near-opaque steel-blue fog bank — the scene is almost fully hidden.
     No blur: it's the fog itself (thick opacity) doing the work. */
  background:
    radial-gradient(150% 130% at 50% 45%,
      rgba(196,210,232,.88) 0%, rgba(176,193,220,.92) 55%,
      rgba(150,170,202,.95) 100%);
  animation: fogIn 1s ease, fogBreathe 4.5s ease-in-out infinite;
  transition: opacity 1s ease, background 1s ease;
}
@keyframes fogIn { from { opacity: 0; } }
@keyframes fogBreathe { 0%, 100% { filter: brightness(1) contrast(1); } 50% { filter: brightness(1.09) contrast(1.04); } }
#lane-port, #lane-star { transition: opacity .6s ease; }

/* race / winner banner — a proper overlay card over the stage */
#banner {
  position: absolute; z-index: 7; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  padding: 16px 30px; border-radius: 16px;
  background: rgba(6, 10, 22, 0.6); border: 1px solid var(--line);
  backdrop-filter: blur(3px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 40px rgba(245,197,66,.12);
  animation: bannerin .5s cubic-bezier(.2, 1.6, .4, 1);
}
#banner[hidden] { display: none; }
#banner.port { border-color: rgba(226,73,59,.6); box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 46px rgba(226,73,59,.3); }
#banner.star { border-color: rgba(110,168,224,.6); box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 46px rgba(110,168,224,.28); }
@keyframes bannerin { from { opacity: 0; transform: translate(-50%, -30%) scale(.7); } }
#banner .b-big {
  font-family: var(--display); font-size: clamp(26px, 5vw, 44px); letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold); text-shadow: 0 2px 24px rgba(245,197,66,.5), 0 2px 4px #000;
}
#banner .b-sub {
  color: var(--text); font-size: 14px; text-shadow: 0 1px 3px #000; margin-top: 2px;
  text-transform: uppercase; letter-spacing: .5px;
}
#banner.void .b-big { color: #9db3d8; text-shadow: 0 2px 18px rgba(157,179,216,.4); }
/* quick fade-out for "The Race" right before the gold reveal */
#banner.bfade { animation: bannerFadeOut .3s ease forwards; }
@keyframes bannerFadeOut { to { opacity: 0; transform: translate(-50%, -60%) scale(.94); } }

/* ---------------- panel: controls ---------------- */
#panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
  min-height: 320px;
}
/* chat on top, betting controls at the bottom */
#panel > #tabs { order: 1; }
#panel > .tabpane { order: 2; }
#panel > #controls { order: 3; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
#chips { display: flex; gap: 6px; }
.chip {
  flex: 1; padding: 8px 0; border-radius: 9px; font-family: var(--mono); font-weight: 600;
  background: rgba(255,255,255,.05); color: var(--muted);
  border: 1px solid rgba(255,255,255,.1); font-size: 13px;
}
.chip.sel { background: rgba(245,197,66,.16); color: var(--gold); border-color: var(--gold-dim); }
.custom-field {
  flex: 1; display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px; padding: 0 12px;
}
.custom-field:focus-within { border-color: var(--gold-dim); }
.custom-field span { color: var(--gold); font-family: var(--mono); font-weight: 600; }
.board {
  border-radius: 12px; padding: 12px 8px 10px; border: 1px solid;
  display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center;
  min-height: 82px;
  color: #fff; position: relative; overflow: hidden;
  transition: transform .12s, filter .2s;
}
.board:active { transform: scale(.97); }
.board:disabled { filter: grayscale(.7) brightness(.6); cursor: not-allowed; }
.board.port { background: linear-gradient(160deg, #a33227, #6c1f17); border-color: #e2493b; box-shadow: 0 4px 18px rgba(226,73,59,.25); }
.board.star { background: linear-gradient(160deg, #3a6ba3, #22436e); border-color: #6ea8e0; box-shadow: 0 4px 18px rgba(110,168,224,.22); }
/* BET is the hero of the button; the ship name is the subtitle */
.b-verb { font-size: 21px; font-weight: 800; letter-spacing: 1.2px; line-height: 1.05; opacity: 1; }
/* reserve two lines so the FULL "bet $X → win $Y" always shows, and the button
   height stays constant whether the text is one line or two */
.b-mult {
  font-size: 12px; opacity: .95; text-align: center; padding: 0 4px;
  font-family: var(--mono); line-height: 1.2; white-space: normal;
  min-height: 29px; display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;   /* BET $0.50 -> WIN $1.04 / MOVE YOUR GOLD */
}

/* ---- the four lives of a ship button ----
   .mine     bet placed, waiting for the ships to sail
   .cashout  LIVE — money on the table, worth more every frame
   .cashed   got out in time, at the multiplier shown
   .lost     went down with the gold still aboard
   The two buttons are independent, so any combination of these can be on
   screen at once — including .cashed on one ship and .cashout on the other,
   which is exactly what a hedged round looks like mid-flight. */
.board.mine { outline: 2px solid var(--gold); outline-offset: -2px; box-shadow: 0 0 0 1px var(--gold), 0 6px 24px rgba(245,197,66,.32); }
.board.mine .b-verb { color: var(--gold); opacity: 1; }
.board.mine .b-mult { color: #ffe9a8; opacity: 1; font-weight: 600; }
#btn-salvage {
  background: rgba(110,168,224,.12); color: var(--star); border: 1px dashed var(--star);
  padding: 9px; border-radius: 9px; font-size: 13px;
}

/* ---------------- tabs + feed ---------------- */
#tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; color: var(--muted); padding: 7px 10px 8px;
  font-size: 13px; border-bottom: 2px solid transparent; letter-spacing: .3px;
}
.tab.sel { color: var(--gold); border-bottom-color: var(--gold); }

.tabpane { display: flex; flex-direction: column; gap: 8px; min-height: 180px; }
.tabpane[hidden] { display: none; }   /* the reset broke [hidden]; restore it so only one tab shows */
#tab-log, #tab-book { overflow: hidden; }   /* only the inner list scrolls, never the pane */
#tab-book .pane-note { order: 2; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
#tab-book #rounds-list { order: 1; }
#feed, #feed-bets {
  height: 240px; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 5px;
  padding-right: 6px; overscroll-behavior: contain;
  scroll-behavior: smooth;
}
@media (min-width: 980px) { #feed, #feed-bets { height: 300px; } }
/* one clean scrollbar style across the panel */
#feed, #feed-bets, #leaderboard, #rounds-list {
  scrollbar-width: thin; scrollbar-color: rgba(245,197,66,.35) transparent;
}
#feed::-webkit-scrollbar, #leaderboard::-webkit-scrollbar, #rounds-list::-webkit-scrollbar { width: 7px; }
#feed::-webkit-scrollbar-track, #leaderboard::-webkit-scrollbar-track, #rounds-list::-webkit-scrollbar-track { background: transparent; }
#feed::-webkit-scrollbar-thumb, #leaderboard::-webkit-scrollbar-thumb, #rounds-list::-webkit-scrollbar-thumb {
  background: rgba(245,197,66,.28); border-radius: 6px;
}
#feed::-webkit-scrollbar-thumb:hover, #leaderboard::-webkit-scrollbar-thumb:hover, #rounds-list::-webkit-scrollbar-thumb:hover {
  background: rgba(245,197,66,.5);
}
/* "new messages" nudge when scrolled up */
#tab-chat { position: relative; }
#scroll-bottom {
  position: absolute; right: 12px; bottom: 58px; z-index: 6;
  display: none; align-items: center; gap: 4px;
  background: var(--gold); color: #201a06; font-size: 11px; font-weight: 600;
  border: none; border-radius: 999px; padding: 5px 11px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
#scroll-bottom.show { display: inline-flex; }
.msg { font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.msg .who { font-weight: 600; }
.msg.sys { color: var(--muted); font-style: italic; }
.msg.evt { color: var(--gold); }
.msg.evt.treasure { color: #7bdff2; }
#chat-form { display: flex; gap: 6px; }
#chat-input {
  flex: 1; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); padding: 9px 12px; border-radius: 9px; font-size: 14px; font-family: var(--sans);
}
#chat-input:focus { outline: 1px solid var(--gold-dim); }
#chat-form button {
  background: var(--gold); color: #201a06; border: none; border-radius: 9px;
  padding: 0 14px; font-size: 13px; font-weight: 700; font-family: var(--sans);
}

.pane-note { font-size: 11.5px; color: var(--muted); }
#leaderboard, #rounds-list { list-style: none; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; flex: 1 1 auto; min-height: 0; max-height: 46vh; }
#leaderboard li, #rounds-list li {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: rgba(255,255,255,.04); padding: 7px 9px; border-radius: 8px;
}
#leaderboard .pos { font-family: var(--mono); color: var(--muted); width: 16px; }
#leaderboard .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaderboard .lb-pct { font-family: var(--mono); color: var(--gold); font-weight: 600; }
#leaderboard .lb-n { font-size: 10.5px; color: var(--muted); }
#rounds-list .r-round { font-family: var(--mono); color: var(--muted); }
#rounds-list .r-mult { margin-left: auto; font-family: var(--mono); color: var(--gold); }

/* ---------------- footer ---------------- */
#foot {
  max-width: 1560px; margin: 4px auto 14px; padding: 0 14px;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  color: var(--muted); font-size: 10.5px;
}

/* ---------------- toasts / result ---------------- */
/* Toasts sit ABOVE the bet bar, never over it. In a crash round the two
   ship buttons are live controls with a deadline — a sink/cash-out toast
   landing on top of them can cover the exact button the player is reaching
   for, and cost them the round. --betbar-h is kept in sync with the real
   bar height by app.js's syncBars(). */
#toasts {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--betbar-h, 120px) + 14px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: var(--panel-solid); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 14px; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: toastin .3s ease, toastout .4s ease 3.4s forwards;
}
.toast.win { border-color: var(--gold); color: var(--gold); font-weight: 600; font-size: 16px; text-transform: uppercase; letter-spacing: .5px; }
.toast.loss { border-color: rgba(226,73,59,.5); text-transform: uppercase; letter-spacing: .5px; }
.toast.err { border-color: var(--danger); color: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(14px); } }
@keyframes toastout { to { opacity: 0; transform: translateY(8px); } }

/* ---------------- dialog ---------------- */
/* ---- custom modal (own z-index + backdrop; no native <dialog> quirks) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 16px;
  background: rgba(4, 6, 14, 0.82); backdrop-filter: blur(4px);
  animation: overlayIn .2s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes overlayIn { from { opacity: 0; } }
/* Same glass-panel language as the settings dropdown (.settings-pop) and the
   side panel (#panel, var(--panel)) — translucent + blurred so the scene
   shows through, instead of a flat opaque card that reads as a generic web
   dialog dropped on top of the game. */
.modal-box {
  position: relative; width: min(640px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--text);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(245,197,66,.28); border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  animation: helpIn .28s cubic-bezier(.2,1.2,.4,1);
}
/* a thin gold wash across the top edge — the one "this belongs to Plunder"
   flourish every settings page shares, echoing the horizon line in the scene */
.modal-box::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .85;
}
.help-body { overflow-y: auto; padding: 26px 26px 10px; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
/* pretty gold scrollbar, not the default */
.help-body { scrollbar-width: thin; scrollbar-color: rgba(245,197,66,.4) transparent; }
.help-body::-webkit-scrollbar { width: 8px; }
.help-body::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.help-body::-webkit-scrollbar-thumb { background: rgba(245,197,66,.32); border-radius: 8px; }
.help-body::-webkit-scrollbar-thumb:hover { background: rgba(245,197,66,.55); }
.help-foot { flex: 0 0 auto; padding: 14px 26px 20px; border-top: 1px solid rgba(245,197,66,.16); }
#help-x, #info-x, #limits-x, #credits-x {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,.16);
  background: rgba(10,21,38,.6); color: var(--text); font-size: 16px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
#help-x:hover, #info-x:hover, #limits-x:hover, #credits-x:hover {
  background: rgba(226,73,59,.35); border-color: rgba(226,73,59,.6); color: #fff; transform: scale(1.06);
}
/* lock ONLY the background from scrolling while the modal is open */
html.modal-open, body.modal-open { overflow: hidden !important; touch-action: none; }
@keyframes helpIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
#help h2, #info h2, #limits h2, #credits h2 {
  font-family: var(--display); color: var(--gold); font-weight: 400; letter-spacing: 1px;
  font-size: 26px; margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid rgba(245,197,66,.2);
}
#help h3, #info h3, #limits h3, #credits h3 {
  font-family: var(--display); color: var(--gold); font-weight: 400; letter-spacing: .4px;
  font-size: 16px; margin: 20px 0 8px;
}
#help h3:first-child, #info h3:first-child, #limits h3:first-child, #credits h3:first-child { margin-top: 0; }
#help p, #info p, #limits p, #credits p { font-size: 13.5px; line-height: 1.55; color: var(--text); margin-bottom: 10px; }
/* the gold "Got it" close button — a gentle sheen + lift on hover, matching
   the bet buttons' tactile feel instead of a flat solid rectangle */
#help .close, #info .close, #limits .close, #credits .close {
  width: 100%; padding: 13px; border-radius: 10px;
  border: 1px solid rgba(245,197,66,.5);
  background: linear-gradient(180deg, #e8c26c, var(--gold) 55%, #b9893a);
  color: #201a06; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
#help .close:hover, #info .close:hover, #limits .close:hover, #credits .close:hover {
  transform: translateY(-1px); box-shadow: 0 7px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.45);
}
#help .close:active, #info .close:active, #limits .close:active, #credits .close:active { transform: translateY(0); }

/* animated demo: lighter ship overtakes and plunders the heavy one, on a loop */
.demo {
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(#0b1630, #0a1226); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 10px; margin-bottom: 14px; overflow: hidden;
}

.steps { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.steps li {
  display: flex; gap: 11px; align-items: flex-start; font-size: 13.5px; line-height: 1.4;
  opacity: 0; transform: translateX(-8px);
  animation: stepIn .45s ease forwards;
}
.steps li:nth-child(1) { animation-delay: .1s; }
.steps li:nth-child(2) { animation-delay: .22s; }
.steps li:nth-child(3) { animation-delay: .34s; }
.steps li:nth-child(4) { animation-delay: .46s; }
.steps li:nth-child(5) { animation-delay: .58s; }
@keyframes stepIn { to { opacity: 1; transform: translateX(0); } }
@keyframes tilt { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
#help .fine { font-size: 11px; color: var(--muted); margin-top: 12px; }
#help .close, #info .close, #limits .close, #credits .close {
  width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: var(--gold); color: #201a06; font-weight: 700; font-size: 15px;
}
/* custom numbering — a gold coin-badge per step instead of the browser's
   flat "1." — so this reads as a designed sequence, not a default <ol>. */
.rules { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 14px; margin-bottom: 4px; }
.rules li {
  position: relative; padding-left: 38px; font-size: 13.5px; line-height: 1.55; color: var(--text);
}
.rules li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--display); font-size: 13px; font-weight: 700;
  color: #201a06; background: linear-gradient(180deg, #e8c26c, var(--gold) 65%, #b9893a);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.rules b { color: var(--gold); font-weight: 600; }

/* ---------------- Terms: numbered clauses ---------------- */
.terms-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.terms-list li { font-size: 13px; line-height: 1.55; color: var(--text); }
.terms-list b { color: var(--gold); font-weight: 600; }
.terms-note {
  font-size: 12px; color: var(--muted); background: rgba(255,193,7,.08);
  border: 1px solid rgba(255,193,7,.3); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.terms-updated { font-size: 11px; color: var(--muted); margin-top: 16px; font-style: italic; }

/* ---------------- Limits: min/max/max-multiplier readout ---------------- */
.limits-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 16px; }
.limit-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 10px; border-left: 3px solid var(--gold-dim);
  background: linear-gradient(135deg, rgba(245,197,66,.09), rgba(255,255,255,.02));
  border-top: 1px solid rgba(245,197,66,.18); border-right: 1px solid rgba(245,197,66,.18); border-bottom: 1px solid rgba(245,197,66,.18);
}
.limit-row dt { font-size: 13px; color: var(--muted); }
.limit-row dd { margin: 0; font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--gold); }

/* ---------------- Credits: asset attribution ---------------- */
.credits-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; padding: 0; }
.credits-list li {
  font-size: 13px; line-height: 1.55; color: var(--text);
  padding: 10px 14px; border-radius: 10px; border-left: 3px solid var(--gold-dim);
  background: linear-gradient(135deg, rgba(245,197,66,.06), rgba(255,255,255,.02));
  border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.credits-list b { color: var(--gold); font-weight: 600; }
.credits-list a { color: #6ea8e0; margin-left: 4px; white-space: nowrap; }

/* non-blocking: a small pill, never a modal — the game stays fully visible */
/* ============ v6: spacing, full-height desktop, premium polish ============ */

#controls { display: flex; flex-direction: column; gap: 16px; padding: 6px 2px 2px; }
#chips { gap: 8px; }
.chip { padding: 10px 0; }
.board { padding: 15px 10px 13px; border-radius: 14px; }
#panel { padding: 16px; gap: 12px; }

.ship-card { backdrop-filter: blur(6px); transition: box-shadow .25s ease, transform .15s ease; }
.ship-card:hover { transform: translateY(-1px); }
.ship-card.port:hover { box-shadow: inset 0 0 30px rgba(226,73,59,.14), 0 6px 24px rgba(226,73,59,.18); }
.ship-card.star:hover { box-shadow: inset 0 0 30px rgba(110,168,224,.14), 0 6px 24px rgba(110,168,224,.16); }
#phase-label { text-shadow: 0 0 20px rgba(245,197,66,.45); }

.board { overflow: hidden; }
.board::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.16) 50%, transparent 60%);
  transform: translateX(-130%); transition: transform .55s ease;
}
.board:hover::after { transform: translateX(130%); }

#stage { box-shadow: inset 0 0 90px rgba(2,5,14,.85), 0 18px 50px rgba(0,0,0,.35); }
.msg { animation: msgin .25s ease; }
@keyframes msgin { from { opacity: 0; transform: translateY(5px); } }
.toast.win { box-shadow: 0 0 34px rgba(245,197,66,.28); }
#banner .b-big { font-size: clamp(19px, 3vw, 30px); }

/* PC: fit to the viewport (no scroll). Big scene fills the left column;
   the right panel has chat on top and the betting buttons at the bottom. */
@media (min-width: 980px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  #topbar, #foot { flex: 0 0 auto; }
  #layout { flex: 1 1 auto; min-height: 0; width: 100%; padding-bottom: 4px; }
  #stage-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #stage { flex: 1 1 auto; height: auto; max-height: none; min-height: 300px; }
  #panel { height: 100%; min-height: 0; overflow: hidden; }
  #tab-chat, #tab-bets { flex: 1 1 auto; min-height: 0; }
  #feed, #feed-bets { flex: 1 1 auto; height: auto; min-height: 0; }
  #tab-log, #tab-book { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  #leaderboard, #rounds-list { max-height: none; }
  .ship { width: clamp(220px, 24vw, 360px); }
}

/* "back to the game" pill — only on scrolling (mobile/tablet) layouts.
   The chat is its own scroll box, so page-scrolling up is fiddly; this jumps
   straight back to the scene. Hidden on PC (that layout never scrolls). */
#to-top {
  position: fixed; z-index: 86; right: 10px; bottom: calc(7px + env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 5px;
  background: rgba(20, 26, 54, 0.92); color: var(--gold); font-weight: 700; font-size: 12.5px;
  border: 1px solid var(--gold-dim); border-radius: 999px; padding: 8px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
#to-top.show { display: inline-flex; }
@media (min-width: 980px) { #to-top { display: none !important; } }

#reconnect {
  position: fixed; left: 12px; bottom: 12px; z-index: 100;
  pointer-events: none;
  background: rgba(14, 21, 49, 0.92); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px;
  font-size: 12.5px; color: var(--gold);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* ============ v7: responsive — tablet & phone ============ */

/* Single column (≤979px): SCENE is the star (big) at the top, chat scrolls,
   BETTING BUTTONS at the very bottom. Natural vertical page-scroll is fine;
   only horizontal scroll is forbidden (body has overflow-x: hidden). */
@media (max-width: 979px) {
  #online { display: none; }                       /* hide "aboard" on tablet + mobile */
  /* pad the scroll container (a footer margin-bottom is ignored at the scroll end) */
  body { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  #foot { margin-bottom: 0; }
  #layout { display: block; padding: 6px 10px 14px; }
  #stage-wrap { display: block; }
  #stage { height: 52vh; min-height: 300px; }     /* big scene */
  #cards { margin-bottom: 4px; }
  #panel { min-height: 0; }
  #tab-chat, #tab-bets { min-height: 0; }
  #feed, #feed-bets { height: 50vh; }                          /* generous, scrollable chat */
  /* EVERY device below PC (tablet, fold, phone): betting on TOP, chat at BOTTOM */
  #panel > #controls { order: 0; border-top: none; margin-top: 0; padding-top: 0; }
  #panel > #tabs { order: 1; }
  #panel > .tabpane { order: 2; }
}

/* Phones */
@media (max-width: 620px) {
  body { font-size: 14px; }
  /* MOBILE: betting on TOP, chat at the BOTTOM */
  #panel > #controls { order: 0; border-top: none; margin-top: 0; padding-top: 0; }
  #panel > #tabs { order: 1; }
  #panel > .tabpane { order: 2; }
  /* topbar: everything icon-sized so nothing overlaps */
  #topbar { padding: 8px 8px 4px; gap: 6px; flex-wrap: nowrap; }
  .brand { gap: 5px; min-width: 0; flex-shrink: 0; align-items: center; }
  .brand h1 { font-size: 21px; letter-spacing: 1px; }
  .online-pill { padding: 4px 7px; font-size: 11px; }
  #you-name { display: none; }
  .you-chip { padding: 5px 9px; font-size: 12.5px; gap: 4px; flex-shrink: 0; }

  /* ON-SHIP READOUTS (phones only): the info cards overlay the stage, positioned
     relative to #stage-wrap, instead of sitting in a desktop top row. */
  #stage-wrap { position: relative; }
  #cards { display: contents; }
  .ship-card {
    position: absolute; left: 12px; z-index: 6;
    width: 152px; box-sizing: border-box; min-height: 48px; justify-content: center;
    padding: 7px 13px; border-radius: 11px; gap: 2px;
    background: rgba(8,15,25,.7); border: 1px solid var(--line);
  }
  /* #card-port/#card-star positioning + tint now live entirely in v2.css
     (loaded after this file, so it already wins) — this block used to also
     set `top`/`bottom` here. Nothing else set `bottom:auto` for #card-star
     at any narrower breakpoint, so that stray `bottom: 12px` combined with
     v2.css's `top: 44%` and stretched the card into a full-height box (an
     absolutely-positioned element with BOTH top and bottom pinned fills the
     gap between them). Removed — v2.css's .ship-card now also explicitly
     pins bottom:auto itself so this class of bug can't come back. */
  #lane-port { top: calc(23% + 10px); }
  #lane-star { top: calc(53% + 10px); }

  #online { display: none; }               /* drop the aboard pill on phones */
  /* tighter everything so the betting + Jump-ship button all fit above the fold */
  #topbar { padding: 6px 8px 2px; }
  #cards { margin-bottom: 2px; }
  /* scene as tall as possible while the betting block + Jump ship still clear the
     fold. We reserve room for topbar+cards+controls+Jump; chat lives below (scroll). */
  /* svh (small viewport height) is FIXED — it does not change when the mobile
     address bar collapses on scroll, so the scene never resizes/reflows mid-scroll */
  /* scene as tall as possible: reserve only topbar + phase + controls + Auto Rebet;
     the chat feed lives entirely below the fold (scroll to reach it) */
  #stage { border-radius: 12px; height: calc(100svh - 403px); max-height: 66svh; min-height: 150px; margin-top: 4px; }
  .ship { width: clamp(160px, 46vw, 220px); }     /* fits two ships + readouts */
  #layout { padding: 3px 8px 10px; gap: 6px; }
  #panel { padding: 9px; gap: 7px; border-radius: 12px; }
  #feed, #feed-bets { height: 46vh; }                   /* scrollable chat, below the betting */
  #controls { gap: 8px; }
  #chips { gap: 5px; } .chip { padding: 8px 0; }
  .board { min-height: 76px; padding: 9px 8px; }
  /* instructions stay fully readable */
  .modal-overlay { padding: 8px; }
  .modal-box { max-height: 92vh; }
  .help-body { padding: 20px 16px 6px; }
  .help-foot { padding: 10px 16px 16px; }
  .steps li { font-size: 13px; }
  #help h2, #info h2, #limits h2, #credits h2 { font-size: 21px; }

  #chips { flex-wrap: wrap; gap: 6px; }
  .chip { flex: 1 1 27%; padding: 8px 0; font-size: 13px; }
  .board { padding: 10px 8px; min-height: 76px; }

  #foot { font-size: 9.5px; gap: 3px 10px; margin-bottom: 0; }
  #toasts { width: calc(100vw - 24px); }
  .toast { font-size: 13px; }
}

/* Short phones: the stage is cramped, so shrink the ships (they must never
   overlap each other) and the on-ship readouts. */
@media (max-width: 620px) and (max-height: 740px) {
  .ship { width: clamp(92px, 29vw, 130px); }
  #lane-port { top: calc(24% + 8px); }
  #lane-star { top: calc(51% + 8px); }
  .ship-card { max-width: 108px; padding: 4px 8px; gap: 1px; }
  .ship-card .card-name { font-size: 12px; }
}

/* Very small phones */
@media (max-width: 380px) {
  /* Folds (~344px): the wordmark collapses to a P monogram so RULES / I / music
     and the balance all keep their real hit targets on one line. */
  .brand h1 { font-size: 19px; letter-spacing: 0; }
  .you-chip .mono::after { content: ""; }     /* drop the coin glyph to save space */
  .chip { flex: 1 1 30%; }
  #phase-ribbon { min-width: 58px; }
}

/* Landscape phones: keep the stage from eating the whole viewport */
@media (max-height: 520px) and (orientation: landscape) {
  #stage { height: 46vh; }
}

/* ═════════════ LAYER: v2.css ═════════════ */

/* ============================================================
   PLUNDER v2 — full-bleed redesign.
   Loaded AFTER game.css and overrides layout only, so the original
   design is one <link> away (see index.html).
   ============================================================ */
html, body { height: 100%; overflow: hidden; }
body { background: #06121f; padding-bottom: 0; }
/* Replay embed (?replay=1): show ONLY the game scene with its real numbers —
   no chat panel, no bet bar (there is nothing to bet on in a past round). */
body.replay #panel, body.replay #betbar, body.replay #to-top { display: none !important; }
/* Spectator embed (?spectator=1): betting controls disabled, chat stays live.
   The buttons are visibly inert (dimmed + not clickable); the "SPECTATOR" overlay
   label was removed — it sat on top of the BET buttons and read as broken UI. */
body.spectator #bet-controls { pointer-events: none; opacity: .45; filter: grayscale(.4); }
/* ================= animated night-sea background ================= */
#bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; background: #060b1e; }
/* Painterly night background (David "Movable Sea" scene, ported 1:1). A fixed
   1672×941 scene — the design's native coordinate space — scaled to COVER the
   stage so the baked moon, stars, clouds and waterline stay perfectly aligned at
   any viewport. Two stacked canvases: sky (2D: base + moon glow + stars + clouds)
   over water (WebGL living-wave shader). All motion is driven by nightbg.js. */
.plbg {
  position: absolute; left: 50%; top: 50%;
  width: 1672px; height: 941px;
  /* centred cover — keeps the baked top-right moon at its full position (uncropped) */
  transform: translate(-50%, -50%) scale(var(--plbg-s, 1));
  transform-origin: center;
}
.plbg-scene {
  position: absolute; left: 0; top: 0;
  width: 1672px; height: 941px; display: block; pointer-events: none;
}
/* mobile-only crescent moon (the baked moon is cropped off in portrait) */
.mobile-moon { display: none; }
/* a handful of extra glowing stars, on PC and mobile (in the upper-centre sky so
   they stay visible in portrait too) */
.glow-star {
  position: absolute; z-index: 2; width: 3px; height: 3px; border-radius: 50%;
  background: #fff; animation: starGlow 3s ease-in-out infinite;
}
.gs1 { top: 11%; left: 34%; animation-delay: 0s; }
.gs2 { top: 19%; left: 56%; animation-delay: 1.1s; }
.gs3 { top: 8%;  left: 47%; animation-delay: 2.2s; }
.gs4 { top: 23%; left: 40%; animation-delay: .6s; }
@keyframes starGlow {
  0%, 100% { opacity: .45; box-shadow: 0 0 4px 1px rgba(255,255,255,.5); }
  50% { opacity: 1; box-shadow: 0 0 11px 3px rgba(255,255,255,.95); }
}
@keyframes mMoonGlow { 0%, 100% { opacity: .5; transform: scale(1); } 50% { opacity: 1; transform: scale(1.28); } }
/* ---------------- full-bleed scene ---------------- */
#layout { display: block; padding: 0; margin: 0; height: 100%; gap: 0; }
#stage-wrap { position: fixed; inset: 0; z-index: 0; display: block; }
#stage {
  position: absolute; inset: 0;
  height: auto; max-height: none; min-height: 0; margin: 0;
  border: 0; border-radius: 0;
  box-shadow: inset 0 -120px 160px -60px rgba(2,6,14,.75);
  background: linear-gradient(#07182f 0%, #0a2547 34%, #10406c 58%, #092444 100%);
}
#sea, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
/* ---------------- loading screen ----------------
   Pure CSS/SVG — no three.js, no GLBs, nothing that waits on the module
   graph. Logo, then a minimalist night-sea scene (two wave layers scrolling
   in opposite directions, two bobbing ship silhouettes), then the real
   progress bar (driven by the inline script right after #loader in
   index.html) and the "Loading…" line. */
#loader {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 50% 40%, #0a1234 0%, #05070f 100%);
  transition: opacity .5s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
/* Round-end screen wipe (see index.html + app.js showRoundTransition/
   hideRoundTransition). Fades in AFTER the loser has finished sinking, holds
   solid black through the reset, fades back out as Boarding opens — hiding
   the instant "ship snaps back upright" behind the black frame so it reads
   as a deliberate "new round starting" cue instead of a jump cut. Below the
   modal layer (z-index 1000) so settings/help still open on top if needed;
   above everything else in the scene/panel. */
#round-transition {
  position: fixed; inset: 0; z-index: 500;
  background: #000;
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
#round-transition.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  #round-transition { transition: none; }
}
/* ships ride the baked waterline (~54% of the David scene), stacked & separated so
   they never overlap: Black Pearl upper/back, Interceptor lower/near. */
#lane-port { top: 37%; height: 28%; }
#lane-star { top: 58%; height: 28%; }
.ship { width: clamp(180px, 19vw, 300px); }
.ship-img { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 20px rgba(0,0,0,.5)); }
/* ---------------- top bar ---------------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: none; border: 0; backdrop-filter: none;
}
.nav-left { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand { display: flex; align-items: center; margin-right: 6px; }
.brand h1 {
  font-family: var(--display); font-size: 22px; font-weight: 900; letter-spacing: 1.5px;
  color: #d9a441; margin: 0; line-height: 1; white-space: nowrap;
  /* navy badge like the favicon (navy square, gold letters) */
  background: #0b1020; padding: 8px 14px; border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(217,164,65,.55);
}
.nav-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.icon-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: #0a1526; border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-weight: 800; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: #12233c; }
.icon-btn .micon { width: 18px; height: 18px; }
.icon-btn .gear-icon { width: 18px; height: 18px; }
/* ---------------- settings dropdown (gear icon) ---------------- */
.settings-wrap { position: relative; }
.settings-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: 208px; padding: 8px; border-radius: 14px;
  /* glass effect: translucent + blurred, so the scene behind shows through */
  background: rgba(10,21,38,.55);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 16px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 2px;
  animation: settingsPopIn .16s ease-out;
}
.settings-pop[hidden] { display: none; }
@keyframes settingsPopIn {
  from { opacity: 0; transform: scale(.92) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.settings-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px; border-radius: 10px; border: 0; background: none;
  color: var(--text); font-size: 13.5px; font-family: inherit; text-align: left; cursor: pointer;
}
.settings-row:hover { background: rgba(255,255,255,.08); }
.sr-ic { width: 19px; height: 19px; flex: 0 0 auto; display: flex; color: #9db3c2; }
.sr-ic svg { width: 100%; height: 100%; }
.settings-row[aria-pressed="true"] .sr-ic { color: #01F4A0; }
.sr-label { flex: 1 1 auto; }
/* wide iOS-style switch */
.sr-switch {
  width: 42px; height: 22px; border-radius: 999px; flex: 0 0 auto; position: relative;
  background: rgba(255,255,255,.18); transition: background .18s ease;
}
.sr-switch i {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); transition: transform .18s ease;
}
.settings-row[aria-pressed="true"] .sr-switch { background: #01F4A0; }
.settings-row[aria-pressed="true"] .sr-switch i { transform: translateX(20px); }
/* CRASH STRIP — floating above the phase pill (#phase-ribbon, shifted down
   below to make room — see its own rule). One capsule per recent round.
   A past round is TWO crash points, not one — each ship draws its own,
   independently (server/crash.js) — so a normal crash game's single-number
   history pill doesn't fit. Each capsule stacks the Black Pearl's number
   over the Interceptor's: a coloured left edge says WHICH ship (matches the
   red/blue used on the bet buttons and ship cards everywhere else), and the
   number's own colour is heat — how far that ship got before she went down
   (same h-cold/h-low/h-mid/h-high/h-huge scale The Book uses). Scanning the
   strip answers "has this table been sinking early?" for both ships at once. */
#crash-strip {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 8;
  display: flex; gap: 6px; align-items: center;
  max-width: min(640px, 86vw); overflow-x: auto; overflow-y: hidden;
  padding: 2px 3px; scrollbar-width: none;
  /* fade the far edge instead of a hard clip, so a scrollable overflow reads
     as "more here" rather than looking like the strip just ends mid-pill */
  mask-image: linear-gradient(90deg, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, black calc(100% - 28px), transparent);
}
#crash-strip::-webkit-scrollbar { display: none; }
#crash-strip:empty::after {
  content: 'no rounds yet this session'; font-size: 11px; color: #8aa0a8; font-style: italic;
  white-space: nowrap; padding: 4px 2px;
}
.crash-pill {
  display: flex; flex-direction: column; gap: 1px; flex: 0 0 auto;
  padding: 3px 7px; border-radius: 7px; background: rgba(7,24,31,.72);
  border: 1px solid rgba(255,255,255,.12);
  font-family: var(--mono); font-size: 11px; line-height: 1.25; letter-spacing: -.01em;
}
/* newest pill: highlighted background + a pop-in on arrival */
#crash-strip .crash-pill:first-child {
  background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22);
  animation: crashPillIn .35s ease;
}
@keyframes crashPillIn { from { transform: scale(0); opacity: 0; } }
.cp-half { padding-left: 5px; border-left: 2px solid; }
.cp-port { border-left-color: #D92E15; }
.cp-star { border-left-color: #2E8FD9; }
/* heat: how far that ship got before she went down (mirrors The Book's scale) */
.cp-half.h-cold { color: #6b7f88; }
.cp-half.h-low  { color: #9fb4bd; }
.cp-half.h-mid  { color: #6fd39b; }
.cp-half.h-high { color: #ffce3a; }
.cp-half.h-huge { color: #ff8a3a; text-shadow: 0 0 6px rgba(255,138,58,.5); }
.cp-half.void   { color: #56666e; }
/* ---------------- floating scene chrome ---------------- */
/* phase pill — David's green-bordered status: pulse dot · label · clock, with a
   thin green progress bar directly beneath. */
#phase-ribbon {
  /* Sits just below the crash strip (#crash-strip, top:8px) — still pinned
     high in the scene, the pill is the one piece of chrome a player checks
     constantly, it just gave up the very top slot to the round history. */
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 8;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 7px 20px; border-radius: 12px; height: auto;
  background: rgba(7,24,31,.82); border: 1px solid #f5c542;   /* yellow, matches the timer bar */
}
#phase-ribbon::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: #f5c542; box-shadow: 0 0 8px #f5c542;
  animation: phaseDotPulse 1.4s ease-in-out infinite;
}
@keyframes phaseDotPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
#phase-label { font-size: 18px; font-weight: 700; letter-spacing: .14em; color: #f4efe4; }
#phase-clock { font-size: 18px; font-weight: 700; color: #01F4A0; }
#timerbar {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 4px; border-radius: 2px;
  background: rgba(7,24,31,.7); overflow: hidden; z-index: 8;
}
/* The phase pill and its bar only matter for Boarding — the one phase with
   an actual deadline the player needs to plan around ("bet now, this long
   left"). Flight has no fixed length (it ends when the second ship sinks,
   which nobody knows in advance) and its clock only ever counted UP as
   elapsed time — not useful information, just a number climbing next to
   the ships. Between rounds there is nothing to time either. So the pill
   and bar show ONLY during Boarding. Driven by body.phase-* from ui.js
   setPhase(). */
#phase-ribbon, #timerbar { transition: opacity .25s ease; }
body:not(.phase-boarding) #phase-ribbon,
body:not(.phase-boarding) #timerbar {
  opacity: 0; pointer-events: none;
}
#timerbar-fill { background: #01F4A0; }
/* green by default; fog/race keep their tints */
/* on-ship readouts stay: the pool per ship is the core read of the game */
#cards {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  display: block; margin: 0; grid-template-columns: none;
}
/* Small pill that hugs its text — NEVER a stretched box. Explicitly pins
   every box-model axis (width/height auto to content, bottom/right auto)
   so no OTHER stylesheet/breakpoint can reintroduce the old bug: a leftover
   mobile rule (game.css) set `bottom` on #card-star without `top` ever being
   unset, so with both top AND bottom pinned the browser stretched it to
   fill the whole gap between them — a huge translucent box. Declaring
   height/bottom/right here, on the single shared class both cards use,
   means that can't happen again regardless of what any other rule does. */
.ship-card {
  position: absolute; left: 22px; top: auto; right: auto; bottom: auto;
  width: auto; height: auto; max-width: 150px; box-sizing: border-box;
  min-height: 0; justify-content: center; align-items: center; gap: 2px;
  padding: 8px 14px; border-radius: 12px;
  background: rgba(6,14,26,.72); border: 1px solid rgba(255,255,255,.12);
  pointer-events: auto;
}
/* Card position — sits right above each ship's mast. Now shows ONLY the
   ship name — GAME-ECONOMY-DESIGN.md §1 forbids showing per-ship pool size
   or coefficient, so those readouts are gone (see index.html) and the name
   label — previously hidden by this same redesign layer to make room for
   them — is back, since a card with nothing in it at all reads as a bug.
   Both ships use the IDENTICAL .ship-card/.card-name style — only position
   and accent color (the inset box-shadow tint) differ. `left` marks each
   ship's horizontal CENTER (translateX(-50%)), not its left edge — same
   fix as mobile portrait's ≤620 override below, measured live the same way
   (window.__plunderShipBounds() projects the real 3D hull to screen %) at
   1440×900: Black Pearl centers ~38.5% across / masthead top ~38.5%,
   Interceptor centers ~18.4% / masthead top ~35.7%. The old left:55%/40%
   values (pre-transform, i.e. left EDGE not center) put both cards well to
   the right of and below their actual ships. */
#card-port { left: 38.5%; top: 31%; transform: translateX(-50%); box-shadow: inset 0 0 0 1px rgba(226,73,59,.4); }
#card-star { left: 18.4%; top: 28%; transform: translateX(-50%); box-shadow: inset 0 0 0 1px rgba(110,168,224,.4); }
/* The name is authored with an explicit <br> ("Black<br>Pearl",
   "The<br>Interceptor") — nowrap defeated that and made a single long line
   that clipped to "THE INTERCEPTOI" at narrower card widths. Let it break
   on its own line breaks instead; the card now carries a multiplier under
   the name, so vertical room is cheaper than horizontal. */
.ship-card .card-name {
  display: flex; max-width: 100%;
  white-space: normal; text-align: center;
}
/* A sunk ship's card goes down WITH her. It holds on its frozen crash value
   long enough to read (the 1.1s delay), then fades out over the back half of
   the hull's descent, so the label never outlives the ship it points at.
   The number is not lost: the bet button reports what happened to that bet,
   and the round's two crash points land in the history strip when it seals.
   Delay + duration together stay inside webgl-scene.js's SINK_DURATION. */
.ship-card { transition: opacity .5s ease; }
.ship-card.sunk {
  opacity: 0; pointer-events: none;
  transition: opacity 1s ease 1.1s;
}
/* The banner is centred at 50%/50% in game.css, which lands it straight on top of
   #card-star (left 40%, top 44%) — so the sunk ship's stake was unreadable exactly
   when you most want to check it against the result. Drop it into the clear water
   below both readouts and above the bet bar. */
#banner { top: 70%; }
/* ---------------- live panel ---------------- */
/* full height, from under the top bar to the floor.
   height:auto is REQUIRED — game.css sets height:100%, and top+height+bottom
   over-constrains the box so `bottom` gets ignored and the panel overflows. */
/* bottom edge lines up with the BET buttons (both 12px off the floor), so sea
   shows underneath the panel exactly like it does under the buttons */
#panel {
  /* starts just under the moon (top-right); ~45px taller than before */
  position: fixed; right: 12px; top: 165px; bottom: 12px; height: auto; width: 320px; z-index: 20;
  display: flex; flex-direction: column; gap: 0; min-height: 0;
  background: rgba(4,10,20,.92);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; overflow: hidden; padding: 0 0 10px;
  backdrop-filter: blur(4px);
}
/* all three tabs share one blue bar; active tab is a dark chip */
#tabs { display: flex; gap: 4px; padding: 5px; background: #2E8FD9; border: 0; margin: 0; }
#tabs .tab {
  flex: 1; padding: 7px 6px; border: 0; border-radius: 8px;
  background: none; color: #06263f; font-weight: 700; font-size: 12.5px; letter-spacing: .2px;
}
#tabs .tab.sel { background: #08131f; color: #fff; }
/* race / sinking / intermission: betting closed → the whole bottom control cluster
   (stake stepper, chips, auto-rebet) is blocked, matching the disabled bet buttons. */
#betbar.locked #bet-controls {
  opacity: .4; pointer-events: none; filter: grayscale(.35);
  transition: opacity .2s ease;
}
/* the `hidden` attribute must win over game.css display rules */
#topbar [hidden], #betbar [hidden] { display: none !important; }
/* tabs on top, then the two headline stats, then the list */
#tabs { order: 0; }
.tabpane { order: 2; }
.tabpane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tabpane[hidden] { display: none; }
/* live bets table — masked name | stake | outcome. One row per bet, styled
   like The Book's rows (ship-coloured, WON green / LOST gray) — see
   ui.js addBetRow/resolveBetWin/resolveBetLoss, which update a row IN PLACE
   as its outcome resolves rather than appending a second line. */
.bet-row {
  display: grid; grid-template-columns: minmax(0,1fr) 68px 88px; gap: 16px; align-items: baseline;
  padding: 7px 8px 7px 2px; border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 12.5px;
}
.br-name { color: #cfd8e6; letter-spacing: .5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet-row.port .br-name { border-left: 2px solid var(--port); padding-left: 7px; }
.bet-row.star .br-name { border-left: 2px solid var(--star); padding-left: 7px; }
/* stake and outcome are fixed-width columns, both right-aligned, so the
   numbers form two clean vertical columns down the whole list instead of
   drifting left/right with each name's length. */
.br-stake { color: #fff; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.br-win { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.br-win.pending { color: #8a97a8; font-style: italic; font-weight: 500; }
.br-win.won { color: #01F4A0; font-weight: 700; }
.br-win.lost { color: #8a97a8; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
#feed-bets, #feed {
  flex: 1 1 auto; min-height: 0; height: auto; max-height: none;
  overflow-y: auto; padding: 2px 14px 12px;
}
/* chat composer: 5px clear of both panel edges */
#chat-form { box-sizing: border-box; padding-left: 5px; padding-right: 5px; }
/* Send button uses the same blue as the tab bar */
#chat-form button { background: #2E8FD9; color: #06263f; }
/* back-to-game button: ↑ arrow, matched to the Send button — same blue, size, shape */
#to-top {
  gap: 0; padding: 10px 22px; font-size: 16px; line-height: 1; border-radius: 10px;
  background: #2E8FD9; color: #06263f; border: 0; font-weight: 800;
  backdrop-filter: none; box-shadow: 0 4px 14px rgba(0,0,0,.4);
  right: 14px;   /* line up with the Send button's right edge */
}
/* usernames (chat + bets) are gold, like the bet buttons; chat messages stay light,
   bet stakes/wins stay green. */
#feed .msg { color: #eef3f5; }
#feed .msg .who { color: var(--gold); font-weight: 700; font-family: var(--mono); }
#feed .msg .who-you { color: #fff; }
/* "(You)" marks your own messages */
#tab-bets .br-name { color: var(--gold); }
#tab-bets .br-stake { color: #01F4A0; }
#tab-bets .br-win.pending { color: #8a97a8; }
#tab-bets .br-win.won { color: #01F4A0; }
#tab-bets .br-win.lost { color: #8a97a8; }
/* The book — each round shows BOTH ships (winner + loser) with (WON)/(LOST) and pot.
   Ship names keep their colour, WON is green, LOST is gray, pots are gold. No slash. */
#rounds-list li { align-items: center; gap: 10px; }
#rounds-list .r-round { font-family: var(--mono); color: #8a97a8; flex: 0 0 auto; }
#rounds-list .r-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#rounds-list .r-line { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; }
#rounds-list .r-line.port .r-ship { color: var(--port); }
#rounds-list .r-line.star .r-ship { color: var(--star); }
#rounds-list .r-ship { font-weight: 600; white-space: nowrap; }
/* loser pot gray, like (LOST) */
/* line the note up with where the round numbers start */
#tab-book .pane-note { margin-left: 9px; }
/* ---------------- bet bar ---------------- */
/* The bar STOPS before the panel (right:348px) rather than just padding itself —
   otherwise its background sheet covers the panel's bottom and hides the chat input. */
#betbar {
  position: fixed; left: 0; right: 344px; bottom: 0; z-index: 30;
  display: flex; align-items: stretch; gap: 12px; padding: 10px 0 12px 14px;
  background: none;          /* the sea shows through behind the controls */
}
#balance-box {
  flex: 0 0 auto; min-width: 136px; text-align: center;
  background: #08131f; border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px; padding: 13px 18px;
  display: flex; flex-direction: column; justify-content: center;
}
#you-balance { font-size: 21px; font-weight: 800; color: #24d98a; margin-top: 5px; }
/* fixed column width: the chips row fills it, and the stepper + Auto Rebet span
   exactly the same width above it. Everything left over goes to the BET buttons. */
#bet-controls { flex: 0 0 414px; width: 414px; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
/* the bet field and Auto Rebet share the row equally (same width) */
#stepper {
  flex: 1 1 0; display: flex; align-items: center; gap: 4px;
  background: #08131f; border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px; padding: 6px;
}
/* min-width:0 lets the field shrink below the <input>'s intrinsic size, so the
   chips row — not the input — decides how wide this column is */
.custom-field { flex: 1 1 auto; min-width: 0; border: 0; background: none; padding: 0 6px; }
.custom-field:focus-within { border-color: transparent; }
#chips { display: flex; flex-wrap: nowrap; gap: 5px; margin: 0; }
#chips .chip {
  flex: 1 1 0; padding: 8px 7px; min-width: 40px; text-align: center;
  border-radius: 9px; font-size: 13.5px; font-weight: 600;
  background: #08131f; border: 1px solid rgba(255,255,255,.14); color: #cfd8e6;
}
#chips .chip.sel { background: rgba(211,162,75,.18); color: var(--gold); border-color: var(--gold-dim); }
/* "cap hit" flash (Task 3) — briefly rings the bet field when a control
   (chip/2X/5X/stepper/typed value) tried to go past this table's range and
   got clamped back into it. */
.custom-field.capped { animation: chipCapped .32s ease; }
@keyframes chipCapped { 30% { box-shadow: 0 0 0 2px rgba(226,73,59,.6); } }
.board {
  min-height: 96px; border-radius: 14px; padding: 10px;
  background: #0a1526; border: 2px solid #1d3b5e;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.board.port { border-color: rgba(226,73,59,.65); background: linear-gradient(#12202f, #0d1826); }
.board.star { border-color: rgba(110,168,224,.65); background: linear-gradient(#101f31, #0c1927); }
.b-verb { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: 1px; white-space: nowrap; }
.b-mult { font-size: 15px; font-weight: 800; color: var(--gold); min-height: 0; white-space: nowrap; }
/* fixed button footprint — every state is now 3 single lines, so the size never changes */
.board { overflow: hidden; }
.board:disabled { opacity: .5; }
#foot { display: none; }
/* disclaimer lives in the Info dialog, not as a black band */
/* ---------------- laptops & tablets (…1240px) ----------------
   The side panel still fits here, but balance + controls + panel no longer do.
   Move the balance to the top-right corner and tighten everything so the BET
   buttons keep real width. Must come BEFORE the phone block so phones win. */
@media (max-width: 1240px) {
  #topbar { padding-right: 132px; }        /* reserve the corner for the balance */
  #balance-box {
    position: fixed; top: 6px; right: 10px; z-index: 40;
    flex: 0 0 auto; min-width: 0; width: auto;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 6px 11px; border-radius: 10px;
  }
  #you-balance { font-size: 15px; margin: 0; }

  #panel { width: 284px; }
  #betbar { right: 308px; }
  #bet-controls { flex: 0 0 356px; width: 356px; }
  #chips .chip { font-size: 12px; padding: 7px 4px; }
  .board { min-height: 86px; }
  /* only the last line ("YOUR SPLIT ×n" / "bet $x → win $y") is long — shrink JUST
     that one so it never clips; the BET / ship-name lines keep their size. */
  .b-mult { font-size: 12px; }
}
/* the tight laptop band just ABOVE the 1240 tier: the side panel is still full
   width so the BET buttons get squeezed. Same idea — only the last line shrinks. */
@media (min-width: 1241px) and (max-width: 1560px) {
  .b-mult { font-size: 12.5px; }
}
/* the very tightest desktop band (just above the 1240 layout tier): full-width side
   panel + balance gutter squeeze the BET buttons hardest, so "bet $x → win $y"
   nearly breaks the box — shrink JUST that last line further here. */
@media (min-width: 1241px) and (max-width: 1360px) {
  .b-mult { font-size: 10.5px; letter-spacing: 0; }
}
/* ---------------- phones: normal page flow ----------------
   The first screen is ALL scene + controls; the chat sits below the fold and you
   scroll to reach it. Nothing is fixed, so nothing can cover the controls.
   #layout uses display:contents so stage / bet bar / chat become siblings we can
   order directly on the body flex column. */
@media (max-width: 1000px) {
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  body { display: flex; flex-direction: column; position: relative; }
  /* drop the laptop tier's balance gutter: here the balance is fixed top-right and
     the history is its own full-width row, so the reserve would just crop it */
  #topbar { flex-wrap: wrap; padding-right: 14px; }
  #layout { display: contents; }

  /* crash strip: a touch smaller, still centred above the phase pill */
  #crash-strip { max-width: 92vw; top: 6px; }
  .crash-pill { padding: 2px 6px; font-size: 10px; }

  /* Balance belongs to the header's top-right and must scroll away with it, not
     follow the viewport. It lives inside #betbar (which is absolute at the bottom
     of the first screen), so we offset back up by exactly that distance to land
     at page y=6. --betbar-h is measured in app.js, so this stays exact. */
  #balance-box {
    position: absolute; right: 10px;
    top: calc(10px - (100svh - var(--betbar-h, 200px)));
    height: 34px; box-sizing: border-box;
  }

  /* the scene owns the WHOLE first screen; the bars float on top of it */
  #stage-wrap { position: relative; order: 1; height: 100svh; }
  #stage { position: absolute; inset: 0; height: auto; border-radius: 0; }

  /* bars are absolute against <body>, so they scroll away with the page and the
     chat still begins at exactly 100svh (below the fold) */
  /* above #betbar (z-index 30) so the music volume popover overlays the balance
     (which lives inside #betbar and would otherwise render on top). */
  #topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 50; }
  #betbar {
    position: absolute; left: 0; right: 0; z-index: 30; bottom: auto;
    top: calc(100svh - var(--betbar-h, 200px));
    padding: 8px 10px 12px;
  }
  #bet-controls { flex: 1 1 auto; width: auto; }
  /* only the last line ("YOUR SPLIT ×n" / "bet $x → win $y") overflows on tablets —
     shrink just it, leave the BET / ship-name lines alone. */
  .b-mult { font-size: 12.5px; }

  /* SHIPS ON THE WATER (tablets + phones): the bars float at the bottom here, so
     over-scale the sea to fill the frame and lift it — otherwise on tall/narrow
     tablets the painted horizon sits mid-screen and the ships float in the sky.
     Black Pearl rides the water; the Interceptor anchors just above the buttons. */
  .plbg {
    top: 50%;
    transform: translate(-50%, calc(-50% - 60px)) scale(calc(var(--plbg-s, 1) * 1.2));
  }
  #lane-port { top: 46%; height: 16%; }
  #lane-star { top: calc(var(--controls-top, 700px) - 150px); height: 16%; }
  .ship { width: clamp(150px, 30vw, 230px); }

  #panel {
    position: static; order: 3; left: auto; right: auto; top: auto; bottom: auto;
    width: auto; height: 78vh; max-height: none; margin: 6px 8px 10px;
  }
}
/* narrow tablets / large phones (621–900px): the two BET buttons are cramped, so
   even "JUMP HERE" / "THE INTERCEPTOR" clip — shrink all three lines so nothing
   breaks the box. */
@media (min-width: 621px) and (max-width: 900px) {
  .b-verb { font-size: 15px; letter-spacing: .4px; }
  .b-mult { font-size: 11px; letter-spacing: 0; }
}
/* Mobile-landscape — REAL devices, not devtools' responsive-mode preview:
   a real phone's browser chrome (address bar, tab strip, etc.) eats real
   vertical space devtools doesn't show, so actual landscape viewports run
   shorter than a clean "844×390" figure suggests. Scoped by short height,
   not a width range, since landscape widths vary a lot across phones/
   tablets — max-height 460 (not 420) leaves room for that visible chrome. */
@media (min-width: 621px) and (max-height: 460px) {
  /* 1. Shorter bet bar/board buttons — trades some touch-target size for a
     visibly bigger strip of ships + sea above the controls. */
  #betbar { padding: 6px 10px 8px; gap: 8px; }
  #bet-controls { gap: 5px; }
  .board { min-height: 56px; padding: 6px 8px; }
  .b-verb { font-size: 15px; }
  .b-mult { font-size: 10px; }
  #stepper { padding: 4px; }
  #chips .chip { padding: 6px 5px; font-size: 11.5px; min-width: 32px; }

  /* 2. crash strip: centred the same way it already is on desktop, sized
     for the tighter landscape topbar. */
  #crash-strip { top: 12px; max-width: 70vw; }
  .crash-pill { padding: 2px 5px; font-size: 9.5px; }

  /* 3. Ship-name labels: dropped entirely on landscape. Almost everyone
     reaches landscape by rotating out of portrait, where they already know
     which ship is which — the pills just cost space here for no new info,
     and the BET buttons are labelled with the ship name anyway. */
  .ship-card { display: none; }

  /* 4. Smaller live phase pill, now that the topbar is one row. Already
     centered via its own base rule's left:50%/translateX(-50%) — untouched
     here, so it lines up under the crash strip above. */
  #phase-ribbon { top: 54px; padding: 5px 10px; gap: 6px; }
  #phase-label, #phase-clock { font-size: 13px; }
  #phase-ribbon::before { width: 6px; height: 6px; }
  #timerbar { top: 88px; width: 150px; }

  /* 5. Same fix as portrait: the result banner's length varies round to
     round, so centering it on a fixed point risks it growing low enough to
     sit on the bet controls. Anchor to the bet bar's live-measured height
     and grow upward instead — can never reach the controls either way. */
  #banner {
    top: auto; bottom: calc(var(--betbar-h, 140px) + 10px);
    left: 50%; transform: translateX(-50%);
    max-width: min(calc(100% - 32px), 480px);
    animation-name: bannerinBottom;
  }
}
@media (max-width: 620px) {
  #betbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px 12px; }
  #balance-box { min-width: 0; flex: 1 1 40%; padding: 8px 12px; }
  #you-balance { font-size: 16px; }
  /* balance rides in the top-right of the page (as it did before), freeing its
     whole row in the bet bar for the scene and controls */
  /* see the ≤1000 rule: offset up out of #betbar so it sits in the header corner.
     34px + top 10px matches the icon buttons exactly, so the row reads as one. */
  #balance-box {
    position: absolute; right: 10px; z-index: 40;
    top: calc(10px - (100svh - var(--betbar-h, 200px)));
    height: 34px; box-sizing: border-box;
    flex: 0 0 auto; min-width: 0; width: 116px;   /* match the jackpot pill width */
    flex-direction: row; align-items: center; justify-content: center; gap: 6px;
    padding: 0 10px; border-radius: 9px;
  }
  #you-balance { font-size: 15px; margin: 0; }
  #bet-controls { flex: 1 1 100%; }
  #chips { flex-wrap: nowrap; }
  #chips .chip {
    flex: 1 1 0; min-width: 0; padding: 8px 4px; font-size: 12.5px;
  }
  .board { min-height: 74px; padding-left: 6px; padding-right: 6px; }
  .b-verb { font-size: 18px; }
  /* the "bet $x → win $y" line is the longest — shrink it so it never clips/overflows */
  .b-mult { font-size: 11px; letter-spacing: 0; }
  #panel { height: 78vh; }                /* chat below the fold — scroll to reach it */
  /* Portrait's camera framing is tighter/closer than the desktop one these
     left/top %s were tuned for (see webgl-scene.js's PORTRAIT_HALF_W/MARGIN),
     so each ship sits at a different spot on screen here. Measured live via
     window.__plunderShipBounds() (projects the real 3D hull to screen %):
     Black Pearl centers ~51% across / masthead top ~43%, Interceptor centers
     ~19% across / masthead top ~41%. `left` now marks the ship's horizontal
     CENTER (translateX(-50%)), not its left edge, so the label always centers
     over the mast regardless of how wide the two-line name text renders. */
  /* Centred over each hull, measured against the real ships at this width
     (window.__plunderShipBounds(): Pearl centres ~77%, Interceptor ~27%).
     Re-measure with that helper if the ships or the portrait framing move. */
  #card-port { left: 77%; top: 34%; transform: translateX(-50%); }
  #card-star { left: 27%; top: 32%; transform: translateX(-50%); }
  /* readouts sit right above each ship's mast, not on top of them */
  .ship-card { max-width: 128px; padding: 6px 11px; }
  .ship-card .card-name { font-size: 14px; }
  /* over-scale (×1.2) so the sea fills the whole frame (no black gap at the bottom)
     and lift it so the Black Pearl rides the water; ships well separated. */
  .plbg {
    top: 50%;
    transform: translate(-50%, calc(-50% - 60px)) scale(calc(var(--plbg-s, 1) * 1.2));
  }
  /* sit the pair low on the water (not floating in the sky). The Interceptor rides
     below the Black Pearl, separated so they don't overlap, and still clear of the
     floating bet controls below. */
  /* Push the two ships as far apart as the water allows: the Black Pearl high (hull
     still on the water, not the sky), the Interceptor anchored low — just above the
     bet bar (its height is measured live into --betbar-h) so it's as low as it can
     go without being covered, on every device height. */
  #lane-port { top: 40%; height: 16%; }
  /* anchor to the TOP of the visible controls (not the bet-bar element, which
     reserves safe-area space below) so the Interceptor rides just above the
     buttons — as low as possible — on every device. */
  #lane-star { top: calc(var(--controls-top, 700px) - 150px); height: 16%; }
  .ship { width: clamp(140px, 44vw, 200px); }
  .brand h1 { font-size: 19px; letter-spacing: 0; background: none; padding: 0; box-shadow: none; }   /* no side panel here — hug the corner */

  /* crescent moon top-right in the sky, with a pulsing glow (the exceptional bit) */
  .mobile-moon {
    display: block; position: absolute; z-index: 2;
    top: 120px; right: 24px; width: 46px; height: 46px; border-radius: 50%;
    background: transparent;
    box-shadow: inset -13px -6px 0 0 #f5edcf;
  }
  /* glow halo swells + brightens on a 3.6s loop, like the PC moon-glow pulse */
  .mobile-moon::after {
    content: ""; position: absolute; inset: -22px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,246,214,.6) 0%, rgba(255,246,214,0) 68%);
    animation: mMoonGlow 3.6s ease-in-out infinite; z-index: -1;
  }
  /* ---- balance <-> "last round" swap ----
     Balance moves into the roomy row "last round" used to occupy (easier to
     read at a glance); "last round" becomes a compact strip inline in the
     icon row, right after "?" — the topbar no longer needs a dedicated
     second row for it, so it shrinks and the live phase pill below (which
     already tracks --topbar-h live, see app.js syncBars()) rides up with it. */
  .nav-left { order: 0; }
  /* Recent-rounds strip is back at the very top row on portrait — kept small
     enough to leave the icon/balance row below it untouched. */
  #crash-strip { display: flex; top: 8px; max-width: 92vw; }
  .crash-pill { padding: 2px 6px; font-size: 10px; }
  .nav-right { order: 2; }

  /* Icon row + balance now form ROW 2, pushed down below the crash strip
     (row 1) instead of sharing the very top of the screen with it. The extra
     "+ 2.5vh" nudges the whole row a bit further down the screen. */
  #topbar { padding-top: calc(46px + 2.5vh); }

  /* Balance stays top-RIGHT, just moved down onto row 2 with the icons —
     see #topbar padding-top above. The calc() resolves to a FIXED page-Y
     (46px + 2.5vh here) regardless of viewport height — betbar's own
     `top: 100svh - betbar-h` cancels out the `100svh` here — which is what
     lets the pill (positioned inside #stage, whose `inset:0` starts at
     page-Y 0) line up with the icon row. */
  #balance-box {
    left: auto; right: 10px; width: auto; min-width: 0;
    top: calc(46px + 2.5vh - (100svh - var(--betbar-h, 200px)));
    height: 34px; padding: 0 12px; flex-direction: row; justify-content: center; gap: 6px;
    border-radius: 10px; background: rgba(7,24,31,.65); border: 1px solid rgba(255,255,255,.14);
  }
  #you-balance { font-size: 15px; }

  /* Phase pill (Boarding/countdown) is ROW 3, below the crash strip AND the
     icon/balance row above it. */
  #phase-ribbon {
    top: 90px; left: 50%; right: auto; transform: translateX(-50%);
    padding: 6px 10px; gap: 6px;
  }
  #phase-label { font-size: 12px; letter-spacing: .08em; }
  #phase-clock { font-size: 12px; }
  #phase-ribbon::before { width: 6px; height: 6px; }
  #timerbar { top: 128px; left: 50%; right: auto; transform: translateX(-50%); width: 130px; }
  /* lift the back-to-game pill clear of the chat's Send button */
  #to-top { bottom: calc(74px + env(safe-area-inset-bottom)); }   /* 10px higher, clear of Send */
  #foot { display: none; }

  /* Result/status banner ("BLACK PEARL WINS!", "Dead Calm", etc.) is centred
     via top:70% + translate(-50%,-50%) on desktop — fine there, but its
     content length varies round to round (a 2-line void message vs. a
     4-line win breakdown with the crew count and multiplier), and on a short
     phone screen a tall banner centred on a fixed point can grow low enough
     to sit on top of the bet controls. Anchor it to the BET BAR instead —
     grows upward from a fixed gap above it, so it can never reach the
     controls no matter how much text a given round's result has. */
  #banner {
    top: auto; bottom: calc(var(--betbar-h, 200px) + 14px);
    left: 50%; transform: translateX(-50%);
    max-width: calc(100% - 32px);
    animation-name: bannerinBottom;
  }
  @keyframes bannerinBottom { from { opacity: 0; transform: translate(-50%, 14px) scale(.85); } }
}
/* ═══ crash states on the two ship buttons ═══════════════════════════════
   .mine     bet placed, waiting for the ships to sail
   .cashout  LIVE — money on the table, worth more every frame
   .cashed   got out in time, at the multiplier shown
   .lost     went down with the gold still aboard
   The two buttons are independent, so any combination can be on screen at
   once — including .cashed on one ship and .cashout on the other, which is
   exactly what a hedged round looks like mid-flight. */
.board.mine { outline: 2px solid var(--gold); outline-offset: -2px; }
.board.mine .b-verb { color: var(--gold); }
.board.mine .b-mult { color: #ffe9a8; }
/* THE CASH-OUT STATE — deliberately the loudest thing on screen. It is the
   only control in the game with a deadline nobody knows in advance. */
.board.cashout {
  background: linear-gradient(160deg, #17c46a, #0b7f45);
  border-color: #2effa0;
  box-shadow: 0 0 0 1px #2effa0, 0 6px 26px rgba(46,255,160,.4);
  outline: none;
  animation: cashPulse 1.05s ease-in-out infinite;
}
.board.cashout .b-verb { color: #eafff4; font-weight: 800; letter-spacing: .6px; }
.board.cashout .b-mult { color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; }
@keyframes cashPulse {
  50% { box-shadow: 0 0 0 1px #2effa0, 0 8px 34px rgba(46,255,160,.66); }
}
@media (prefers-reduced-motion: reduce) { .board.cashout { animation: none; } }
.board.cashed {
  background: linear-gradient(160deg, #12603d, #0a3d28);
  border-color: rgba(46,255,160,.5);
}
.board.cashed .b-verb { color: #7ff0bb; }
.board.cashed .b-mult { color: #d8fff0; font-weight: 700; font-variant-numeric: tabular-nums; }
.board.lost {
  background: linear-gradient(160deg, #2a2f38, #171b21);
  border-color: rgba(255,255,255,.12);
}
.board.lost .b-verb { color: #8794a1; }
.board.lost .b-mult { color: #6d7883; text-decoration: line-through; }
/* A disabled ship button must stay READABLE — in flight it is the only
   on-screen record of what happened to that bet, so it cannot fade out the
   way an inert control normally would. This deliberately overrides the
   generic `.board:disabled { opacity: .5 }` above. */
.board:disabled { opacity: .85; cursor: default; }
.board.mine:disabled, .board.cashed:disabled, .board.lost:disabled { opacity: 1; }
/* the per-ship multiplier on the stage cards, at the v2 scale */
.card-mult { font-size: 22px; }
@media (max-width: 700px) { .card-mult { font-size: 17px; } }
/* ═══ The Book: one line per round ═══════════════════════════════════════
   Both ships named, each with the multiplier it sank at. Colour is heat —
   how far that ship got — not who "won", because a crash round has no
   winner: each ship simply went down where it went down. */
#rounds-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#rounds-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 9px; border-radius: 8px;
  background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.07);
}
#rounds-list li.cur { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.2); }
#rounds-list li.empty { justify-content: center; color: #8aa0a8; font-style: italic; }
#rounds-list .r-round {
  font-family: var(--mono); font-size: 10.5px; color: #8aa0a8;
  flex: 0 0 auto; min-width: 46px;
}
#rounds-list .r-body { display: flex; flex: 1 1 auto; gap: 8px; min-width: 0; }
#rounds-list .r-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
  flex: 1 1 0; min-width: 0; padding-left: 6px; border-left: 2px solid;
}
#rounds-list .r-line.port { border-left-color: #D92E15; }
#rounds-list .r-line.star { border-left-color: #2E8FD9; }
#rounds-list .r-ship {
  font-size: 11px; font-weight: 600; color: #b8c6d0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#rounds-list .r-line.port .r-ship { color: #e58a7c; }
#rounds-list .r-line.star .r-ship { color: #8dbde8; }
#rounds-list .r-mult {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
/* heat: how far that ship got before she went down */
#rounds-list .h-cold { color: #6b7f88; }
#rounds-list .h-low  { color: #9fb4bd; }
#rounds-list .h-mid  { color: #6fd39b; }
#rounds-list .h-high { color: #ffce3a; }
#rounds-list .h-huge { color: #ff8a3a; text-shadow: 0 0 6px rgba(255,138,58,.5); }
#rounds-list .void   { color: #56666e; }
/* ═══ music opt-in prompt ════════════════════════════════════════════════
   Nothing plays until this is answered. A corner card rather than a modal:
   a round may already be running behind it and it must not block the bet
   buttons or the scene. */
#music-ask {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--betbar-h, 120px) + 58px);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px; border-radius: 12px;
  background: rgba(7,24,31,.92); border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  animation: maIn .22s ease;
}
#music-ask.closing { opacity: 0; transition: opacity .2s ease; }
@keyframes maIn { from { opacity: 0; transform: translate(-50%, 6px); } }
#music-ask .ma-txt { font-size: 13px; font-weight: 600; color: #e6eef5; white-space: nowrap; }
#music-ask .ma-btn {
  padding: 5px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: #cdd7eb;
}
#music-ask .ma-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
#music-ask .ma-yes { border-color: var(--gold); color: var(--gold); }
@media (prefers-reduced-motion: reduce) { #music-ask { animation: none; } }

/* ═════════════ LAYER: webgl-stage.css ═════════════ */

/* ═══════════════════════════════════════════════════════════════
   WebGL visual-layer mount — added by the 3D integration.
   See PLUNDER-INTEGRATION-PLAN.md for the full plan.

   What this does:
   - Hides Plunder's OLD 2D scene layer: nightbg.js's sky/moon/stars/sea
     canvas (#bg), scene.js's ship <img> cutouts (.lane), and the fx
     particle canvas (#fx). Nothing about their JS was deleted — app.js's
     calls into Scene's methods are all still wired and harmless, they
     just no longer paint anything visible. This keeps the diff to
     scene.js/app.js at ZERO.
   - Positions the new three.js canvas (#webgl-stage, mounted by
     webgl-scene.js) to fill the same #stage box #sea/#bg used to fill.

   To revert to the old 2D visuals: delete this file, remove its <link>
   and the #webgl-stage <canvas> + its <script type="module"> from
   index.html, and re-add nightbg.js's <script> tag. Nothing else needs
   to change back — this file is the entire seam.
   ═══════════════════════════════════════════════════════════════ */
/* Hide the old 2D scene ONLY when the 3D one can actually replace it. Without
   the :not(), a browser with no WebGL context hides the sea, ships and stars
   and then paints nothing in their place — the bet panel works, the scene is an
   empty box. The .no-webgl marker is set by the probe in index.html <head>. */
html:not(.no-webgl) #bg,
html:not(.no-webgl) #sea,
html:not(.no-webgl) #fx,
html:not(.no-webgl) .lane {
    display: none !important;
}
#webgl-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
}
/* Lite's stand-in for the film pass's vignette (lite draws without post-
   processing). Static, so it costs nothing per frame. */
#stage-vignette {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 75% 85% at 50% 50%, rgba(0,0,0,0) 40%, rgba(0,0,0,.4) 100%);
}
html.lite:not(.no-webgl) #stage-vignette { display: block; }
/* An empty canvas stacked over the 2D sea would just cover it. */
html.no-webgl #webgl-stage {
    display: none;
}
/* ───────────────────────────────────────────────────────────────
   2D fallback layout.

   The old 2D lanes were laid out for the pre-v2 design, where the betting
   controls sat BELOW the stage. v2 floats them over it, so the lanes' original
   8%→94% span puts the lower ship underneath the bet bar. Pull both lanes up
   into the clear water above it.

   Scoped to .no-webgl so the 3D path is untouched — it does not use .lane at
   all, and this must stay a fallback-only adjustment.
   Keep BOTH hulls below the waterline too. The sea the player actually sees is
   painted by nightbg.js, whose horizon is H * 0.545 — NOT scene.js's drawSea()
   at h * 0.20, which is a second canvas stacked under it. An earlier `top: 6%`
   on the port lane measured against the wrong one and left the Black Pearl
   hanging in the sky. Port sits higher than star so it reads as the further
   ship; the horizontal stagger in updateShips() keeps them from overlapping.
   ─────────────────────────────────────────────────────────────── */
html.no-webgl #lane-port { top: 40%; height: 28%; }
html.no-webgl #lane-star { top: 52%; height: 28%; }
html.no-webgl .ship { width: clamp(150px, 22vw, 240px); }

/* ═════════════ LAYER: v3.css ═════════════ */

/* ============================================================
   PLUNDER v3 — "moonlight & lantern"
   The HUD borrows everything from the scene it sits on: ink-dark night
   plates lit by a thin moonlit rim, one warm lantern-amber accent used ONLY
   for actions and money, ship colours taken from each ship's own pennants
   (muted, never neon), engraved serif captions, condensed instrument-style
   numerals. No gloss, no rainbow tiers, no glowing borders: the moon and the
   ships are the bright things on screen, the HUD is not.
   Loaded LAST (after game.css, v2.css, webgl-stage.css). Remove its <link>
   in index.html to fall back to v2. Many rules are scoped under an id on
   purpose — they must out-rank v2's id-level selectors.
   ============================================================ */
:root {
  --ink: rgba(8, 14, 26, .84);
  --ink-soft: rgba(8, 14, 26, .62);
  --well: rgba(2, 6, 13, .55);
  --line: rgba(176, 196, 224, .14);
  --rim: rgba(214, 226, 244, .30);          /* the moonlit top edge */
  --moon: #dbe4f0;
  --mist: #8a97ad;
  --lantern: #e2a954;
  --lantern-hi: #f2cb84;
  --lantern-lo: #b0782d;
  --foam: #8fcfbd;
  --blood: #cf4a52;
  --pearl: #c4474f;                         /* the Black Pearl's red pennants */
  --inter: #5d93c9;                         /* the Interceptor's blue pennants */
  --skull: #e2545c;                         /* the Black Pearl's symbol: red skull */
  --anchor: #62a6ea;                        /* the Interceptor's symbol: blue anchor */
  --head: 'Cinzel', Georgia, serif;
  --num: 'Barlow Condensed', 'Outfit', sans-serif;
  --r: 9px;
}
/* ═════════════════════ top bar ═════════════════════ */
#topbar { padding-right: 14px; }
#topbar .icon-btn {
  width: 36px; height: 36px; border-radius: var(--r);
  background: var(--ink); border: 1px solid var(--line); border-top-color: rgba(214,226,244,.2);
  color: var(--moon); transition: color .2s, border-color .2s;
}
#topbar .icon-btn:hover { color: var(--lantern-hi); border-color: rgba(226,169,84,.45); }
/* balance: top-right, like every crash game. No caption — a gold coin and a
   bold amber figure on a lantern-rimmed plate say what it is. Tabular digits
   keep the width still while it counts up after a cash-out. */
#topbar #balance-box {
  position: static; top: auto; right: auto; left: auto; z-index: auto;
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  width: auto; min-width: 0; height: 38px; padding: 0 14px 0 9px; box-sizing: border-box;
  background: linear-gradient(180deg, rgba(20,26,38,.92), rgba(6,10,19,.92));
  border: 1px solid rgba(226,169,84,.38); border-top-color: rgba(242,203,132,.55);
  border-radius: var(--r); line-height: 1; transition: box-shadow .3s;
  box-shadow: inset 0 1px 0 rgba(255,236,200,.06), 0 4px 14px rgba(0,0,0,.35);
}
#topbar .bb-coin { width: 20px; height: 20px; flex: 0 0 auto; filter: drop-shadow(0 0 4px rgba(226,169,84,.35)); }
#topbar #you-balance {
  margin: 0; font-family: var(--num); font-weight: 700; font-size: 23px; letter-spacing: .03em;
  font-variant-numeric: tabular-nums; color: var(--lantern-hi);
  text-shadow: 0 1px 0 rgba(0,0,0,.6), 0 0 12px rgba(226,169,84,.22);
}
#topbar #balance-box.counting { box-shadow: 0 0 0 1px rgba(226,169,84,.6), 0 0 16px rgba(226,169,84,.25); }
#topbar #balance-box.kaching { animation: kaching .3s ease; }
@keyframes kaching { 45% { transform: scale(1.05); } }
/* ═════════════════════ ship symbols ═════════════════════
   Each ship's mark (sprite in index.html): red skull = Black Pearl,
   blue anchor = Interceptor. Sized by font-size, like a glyph. */
.ship-sym { display: inline-block; width: 1.05em; height: 1.05em; flex: 0 0 auto; vertical-align: -.17em; }
.ship-sym.port { color: var(--skull); }
.ship-sym.star { color: var(--anchor); }
/* ═════════════════════ history strip ═════════════════════ */
#stage .crash-pill {
  padding: 3px 8px 3px 6px; gap: 1px; border-radius: 7px;
  background: var(--ink-soft); border: 1px solid var(--line);
  font-family: var(--num); font-weight: 600; font-size: 13px; letter-spacing: .02em;
}
#stage #crash-strip .crash-pill:first-child { background: var(--ink); border-color: rgba(214,226,244,.26); }
#stage .cp-half { border-left: 0; padding-left: 0; display: flex; align-items: center; gap: 4px; }
#stage .cp-half .ship-sym { font-size: 11px; }
#stage .cp-half.h-cold { color: #b97b80; }
#stage .cp-half.h-low  { color: var(--moon); }
#stage .cp-half.h-mid  { color: var(--lantern); }
#stage .cp-half.h-high { color: var(--lantern-hi); }
#stage .cp-half.h-huge { color: #fff2d6; text-shadow: 0 0 8px rgba(242,203,132,.55); }
/* the round clock replaces the old phase pill + timer bar */
#phase-ribbon, #timerbar { display: none !important; }
/* ═════════════════════ storm sky ═════════════════════ */
#storm { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.storm-clouds {
  position: absolute; inset: -10% -20% 35% -20%;
  opacity: calc(var(--storm, 0) * .9);
  background:
    radial-gradient(40% 55% at 18% 18%, rgba(14,18,28,.95), transparent 70%),
    radial-gradient(38% 50% at 52% 8%,  rgba(10,14,22,.95), transparent 72%),
    radial-gradient(45% 60% at 85% 22%, rgba(16,20,30,.9), transparent 70%),
    radial-gradient(30% 40% at 35% 40%, rgba(20,26,38,.7), transparent 70%),
    linear-gradient(rgba(5,8,14,.75), transparent 85%);
  background-size: 160% 100%;
  animation: stormDrift 26s linear infinite;
  filter: blur(6px);
  /* Off entirely until there's a storm (fx.js sets #stage.stormy). Animating
     background-position can't run on the compositor, so this drift used to
     repaint — and re-blur — a full-stage layer on every display refresh
     (90/s on a 90Hz tablet) even at opacity 0 with a clear sky. */
  visibility: hidden;
  animation-play-state: paused;
}
#stage.stormy .storm-clouds { visibility: visible; animation-play-state: running; }
/* Lite: the clouds still darken the sky in a storm, but hold still and skip
   the blur — the radial gradients are soft enough on their own. */
html.lite .storm-clouds { animation: none; filter: none; }
@keyframes stormDrift { to { background-position: -160% 0, -120% 0, -200% 0, -90% 0, 0 0; } }
/* display:none between flashes (fx.js adds .on for each one): a full-stage
   mix-blend-mode layer otherwise sits in the compositor every frame. */
#storm-flash { display: none; position: absolute; inset: 0; opacity: 0; background: radial-gradient(80% 70% at 50% 20%, #e7f0ff, rgba(170,200,255,.4) 60%, transparent); mix-blend-mode: screen; }
#storm-flash.on { display: block; }
/* ═════════════════════ round clock ═════════════════════ */
#hero {
  position: absolute; z-index: 9; pointer-events: none;
  top: 70px; left: calc((100% - 344px) / 2); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  transition: opacity .4s;
}
#hero.is-flight, #hero.is-end { opacity: 0; }
.hero-sub {
  font-family: var(--head); font-weight: 700; font-size: 11.5px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--moon); white-space: nowrap;
  padding: 6px 16px; border-radius: 999px; background: var(--ink-soft); border: 1px solid var(--line);
}
/* ═════════════════════ ship flags (stage labels) ═════════════════════ */
/* With WebGL the scene pins each flag to its real masthead (left/top in px);
   the transform hangs the flag just above that point. */
html.tracked-cards #stage #card-port,
html.tracked-cards #stage #card-star { transform: translate(-50%, calc(-100% - 10px)); }
#stage .ship-card {
  --acc: var(--inter);
  background: none; border: 0; box-shadow: none; border-radius: 0;
  padding: 5px 20px 6px 12px; max-width: none; gap: 0; isolation: isolate; overflow: visible;
  align-items: flex-start;
}
#stage #card-port { --acc: var(--pearl); box-shadow: none; }
#stage #card-star { box-shadow: none; }
#stage .ship-card::before {             /* the swallowtail pennant */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, var(--acc) 0 3px, rgba(8,14,26,.86) 3px);
  clip-path: polygon(0 0, 100% 0, 90% 50%, 100% 100%, 0 100%);
}
#stage .ship-card::after {              /* the halyard down to the masthead */
  content: ""; position: absolute; left: 0; top: 100%; width: 1px; height: 10px; background: var(--acc); opacity: .8;
}
#stage .ship-card .card-name {
  font-family: var(--head); font-weight: 700; font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--mist); line-height: 1.2; text-align: left; justify-content: flex-start; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
#stage .ship-card .card-name .ship-sym { font-size: 13px; }
#stage .card-mult {
  font-family: var(--num); font-weight: 600; font-size: 26px; line-height: 1.05; letter-spacing: .01em;
  color: var(--moon); text-align: left; font-variant-numeric: tabular-nums; transition: color .4s;
}
#stage .card-mult:empty { display: none; }
#stage .card-mult { transition: color .25s, text-shadow .25s; }
/* your payout on her, under the number: live (gold, counting) or banked (green ✓) */
#stage .card-pay { font-family: var(--num); font-weight: 600; font-size: 15px; line-height: 1.1; color: var(--lantern-hi); letter-spacing: .02em; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
#stage .card-pay:empty { display: none; }
#stage .card-pay.banked { color: #9fe6bf; }
#stage .ship-card.sunk .card-pay:not(.banked) { display: none; }
/* milestone flash: a ring sweeps out from the number in its heat colour */
#stage .card-ring { position: absolute; left: 30px; top: 60%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 2px solid var(--ring, #f2cb84); opacity: 0; pointer-events: none; }
#stage .ship-card.ms .card-ring { animation: msRing .75s cubic-bezier(.2,.8,.3,1); }
#stage .ship-card.ms .card-mult { animation: msPop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes msRing { 0% { opacity: .95; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.6); border-width: 1px; } }
@keyframes msPop { 40% { transform: scale(1.22); } }
@media (prefers-reduced-motion: reduce) { #stage .ship-card.ms .card-ring, #stage .ship-card.ms .card-mult { animation: none; } }
#stage .card-mult.sunk { color: #d9878d; text-decoration: line-through; text-decoration-thickness: 1px; }
/* ═════════════════════ SUNK stamps, payout floats, red flash ═════════════════════ */
#hud-fx { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.sink-stamp {
  position: absolute; transform: translate(-50%, -150%) rotate(-5deg);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 16px 6px; border: 2px solid var(--blood); border-radius: 6px;
  background: rgba(20,6,10,.78); color: var(--moon);
  animation: stampSlam .38s cubic-bezier(.2,1.4,.4,1) both;
}
.sink-stamp b { font-family: var(--head); font-weight: 900; font-size: 22px; letter-spacing: .3em; color: var(--blood); }
.sink-stamp b .ship-sym { font-size: .85em; margin-right: .3em; vertical-align: -.1em; }
.sink-stamp span { font-family: var(--num); font-weight: 600; font-size: 20px; color: var(--moon); }
.sink-stamp small { font-family: var(--head); font-weight: 700; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--mist); white-space: nowrap; }
.sink-stamp.out { opacity: 0; transition: opacity .6s; }
@keyframes stampSlam { from { opacity: 0; transform: translate(-50%, -150%) rotate(-12deg) scale(1.9); } }
.cash-float {
  position: absolute; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--num); font-weight: 700; font-size: 34px; color: var(--lantern-hi); white-space: nowrap;
  text-shadow: 0 2px 10px rgba(0,0,0,.7);
  animation: floatUp 2s cubic-bezier(.2,.8,.3,1) forwards;
}
.cash-float small { font-size: 16px; font-weight: 600; color: var(--moon); }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -60%); }
  15% { opacity: 1; transform: translate(-50%, -100%); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -240%); }
}
#sink-flash {
  position: absolute; inset: 0; z-index: 7; pointer-events: none; opacity: 0;
  background: radial-gradient(80% 75% at 50% 45%, transparent 45%, rgba(150,12,24,.5) 100%);
}
#sink-flash.hit { animation: redFlash .8s ease-out; }
#sink-flash.hit-hard { animation: redFlash 1.3s ease-out; }
@keyframes redFlash { 0% { opacity: .9; } 100% { opacity: 0; } }
/* ═════════════════════ bet bar: two ship panels ═════════════════════ */
/* Colour carries meaning, the same way on every panel:
     amber  — an action you can take with money (BET)
     green  — your money is aboard and alive (PLACED, CASH OUT, CASHED):
              green reads as "go / safe / winning" before it is read at all
     red    — money lost or a cancel (SUNK, CANCEL); used sparingly so it
              keeps its sting
   Everything else stays in the night palette. */
#betbar {
  left: 12px; bottom: 12px; padding: 0; gap: 0; display: block;
  background: none; border: 0; box-shadow: none;
}
#betbar #bet-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: auto; flex: none; opacity: 1; filter: none; pointer-events: auto;
}
/* One bet plate per ship: solid night ink with a thin ship-coloured top
   edge. The big button (fixed 86px, see .board below) owns the right side;
   the left column — symbol + name, stake stepper, quick amounts — is sized
   to fill exactly that height so both sides line up, and the two auto
   switches run along one slim footer row underneath. */
.bet-panel {
  --acc: var(--inter);
  display: grid; min-width: 0; gap: 4px 12px; padding: 8px 10px 6px;
  grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
  grid-template-rows: auto auto auto;
  grid-template-areas: "head btn" "stake btn" "autos autos";
  align-items: center;
  background: linear-gradient(180deg, rgba(214,226,244,.045), transparent 55%), var(--ink);
  border: 1px solid var(--line);
  border-top: 2px solid color-mix(in srgb, var(--acc) 75%, transparent);
  border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.4);
  backdrop-filter: blur(6px);
}
.bet-panel.port { --acc: var(--pearl); }
.bp-main { display: contents; }
.bp-head { grid-area: head; }
.bp-stake { grid-area: stake; }
.bet-panel .board { grid-area: btn; }
.bp-autos { grid-area: autos; }
/* header: just the ship's symbol and name (16px tall) */
.bp-head { display: flex; align-items: center; gap: 7px; min-width: 0; height: 16px; }
.bp-sym { font-size: 14px; }
.bp-name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--moon);
}
/* stepper 34 + gap 4 + quick amounts 26 = 64; with the 16px name and the
   4px row gap the left column is 84px, level with the 86px button */
.bp-stake { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* stake: typeable, with − / + */
#betbar .bp-stepper {
  display: flex; align-items: center; gap: 3px; flex: none;
  height: 34px; padding: 3px; border-radius: 8px;
  background: var(--well); border: 1px solid var(--line);
}
#betbar .bp-stepper:focus-within { border-color: rgba(226,169,84,.55); }
.bp-step {
  width: 30px; height: 100%; flex: 0 0 auto; border: 0; border-radius: 5px;
  background: rgba(214,226,244,.07); color: var(--moon); font-size: 18px; line-height: 1;
  transition: color .15s, background .15s;
}
.bp-step:hover { color: #fff; background: rgba(214,226,244,.14); }
.bp-step:active { background: rgba(214,226,244,.2); }
.bp-amount {
  flex: 1 1 auto; min-width: 0; width: 100%; padding: 0; border: 0; outline: none; background: none;
  text-align: center; color: var(--moon); font-family: var(--num); font-weight: 600; font-size: 19px; letter-spacing: .02em;
  -moz-appearance: textfield;
}
.bp-amount::-webkit-outer-spin-button, .bp-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* quick amounts: one segmented strip rather than four loose boxes */
.bp-chips {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; height: 26px;
  border-radius: 7px; overflow: hidden; background: var(--well); border: 1px solid var(--line);
}
.bp-chips .chip {
  height: 100%; padding: 0; min-width: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  background: none; color: var(--mist);
  font-family: var(--num); font-weight: 600; font-size: 13px; letter-spacing: .01em;
  transition: color .15s, background .15s;
}
.bp-chips .chip:first-child { border-left: 0; }
.bp-chips .chip:hover { color: var(--moon); background: rgba(214,226,244,.06); }
.bp-chips .chip.sel { color: var(--lantern-hi); background: rgba(226,169,84,.13); }
/* ── the big button: "rising tide" ──
   One line: verb · big multiplier · amount. In flight the button is a gauge —
   sea-green water rises inside it with the multiplier (--tide, 0..1, set by
   betpanels.js on a log scale, full at ×10), so the tension sits in the very
   control you press to get out.
   Height: a fixed 86px (two 30% cuts from the original full-panel 176px);
   the phone and short-screen breakpoints below set their own. */
#betbar .board {
  --tide: 0;
  position: relative; isolation: isolate;
  min-height: 0; height: 86px; align-self: center; padding: 0 14px; gap: 10px; overflow: hidden;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  border-radius: 8px; border: 1.5px solid #e2a954;
  background: rgba(14,20,36,.55); box-shadow: none;
  color: #f5d27a; opacity: 1; cursor: pointer; outline: none;
  transition: filter .15s, border-color .2s, transform .08s, background .25s;
}
#betbar .board:not(:disabled):hover { filter: brightness(1.12); background: rgba(226,169,84,.1); }
#betbar .board:not(:disabled):active { transform: translateY(1px); }
#betbar .board:focus-visible { box-shadow: 0 0 0 2px var(--moon); }
#betbar .b-tide {
  position: absolute; inset: auto 0 0 0; z-index: -1; height: calc(var(--tide) * 100%);
  background: #2f8f62; opacity: 0; transition: height .25s linear, opacity .2s;
}
/* a lighter crest on the waterline, so it reads as water rather than a bar */
#betbar .b-tide::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: #5fd39a;
}
#betbar .b-verb {
  font-family: var(--head); font-weight: 900; font-size: 20px; letter-spacing: .2em; text-transform: uppercase;
  color: inherit; white-space: nowrap; text-shadow: none; line-height: 1;
}
#betbar .b-x {
  font-family: var(--num); font-weight: 700; font-size: 26px; letter-spacing: .01em; line-height: 1;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
#betbar .b-x:empty { display: none; }
#betbar .b-mult {
  font-family: var(--num); font-weight: 600; font-size: 16px; letter-spacing: .02em; color: inherit; opacity: .8;
  white-space: nowrap; min-height: 0; margin: 0; line-height: 1;
}
/* PLACED — your bet is aboard: calm green outline, nothing to press */
#betbar .board.mine { border-color: rgba(143,224,182,.7); background: rgba(18,48,31,.6); color: #bdf2d6; }
#betbar .board.mine .b-verb::before { content: "✓ "; }
/* When a button is too narrow for its words (the 1001–1360px band, phones),
   the second part wraps onto its own line instead of spilling out of it. */
#betbar .board { flex-wrap: wrap; align-content: center; row-gap: 4px; text-align: center; }
#betbar .board.cashout { justify-content: center; }
#betbar .board.mine .b-verb { font-size: 14px; letter-spacing: .14em; }
#betbar .board.mine .b-mult { font-size: 14px; }
/* CASH OUT — the tide is rising: the brightest green on screen */
#betbar .board.cashout { border-color: #8fe0b6; background: rgba(9,30,22,.75); color: #eafff3; justify-content: space-between; }
/* it breathes — faster as the multiplier climbs (--pulse, set by betpanels.js) */
#betbar .board.cashout { animation: cashBreath var(--pulse, 1.2s) ease-in-out infinite; }
@keyframes cashBreath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(143,224,182,0); }
  50% { box-shadow: 0 0 0 1px rgba(143,224,182,.85), 0 0 24px rgba(143,224,182,.42); filter: brightness(1.12); }
}
#betbar .board.cashout .b-tide { opacity: 1; }
#betbar .board.cashout .b-verb { font-size: 13px; letter-spacing: .16em; }
#betbar .board.cashout .b-mult { font-size: 17px; opacity: 1; font-weight: 700; }
/* CASHED — banked: green, at rest */
#betbar .board.cashed { background: rgba(14,48,34,.85); border-color: rgba(120,214,166,.6); color: #9fe6bf; }
#betbar .board.cashed .b-verb { font-size: 14px; }
#betbar .board.cashed .b-x { font-size: 18px; color: #eafff3; }
#betbar .board.cashed .b-mult { color: #eafff3; opacity: 1; }
#betbar .board.just-cashed { animation: cashedPop .45s ease; }
@keyframes cashedPop { 0% { filter: brightness(1.8); } 100% { filter: none; } }
/* SUNK — the gold went down with her */
#betbar .board.lost { background: rgba(44,10,15,.82); border-color: rgba(207,74,82,.5); color: #e39aa0; }
#betbar .board.lost .b-verb { font-size: 16px; }
#betbar .board.lost .b-mult { color: var(--mist); opacity: 1; }
/* betting closed, no bet on this ship: queue one for the next round */
#betbar .board.next { border-color: rgba(226,169,84,.45); color: var(--lantern-hi); }
#betbar .board.next .b-verb { font-size: 16px; }
#betbar .board.next .b-mult { font-size: 13px; color: var(--mist); opacity: 1; }
#betbar .board.queued { background: rgba(70,14,20,.6); border-color: rgba(207,74,82,.6); color: #f0c2c5; }
#betbar .board.queued .b-verb { font-size: 16px; }
#betbar .board.queued .b-mult { font-size: 12px; color: var(--mist); opacity: 1; }
#betbar .board:disabled { cursor: default; opacity: 1; }
/* auto bet / auto cash-out: one footer row, a switch each */
.bp-autos {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 0; padding-top: 4px; border-top: 1px solid var(--line);
}
.bp-tog { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 22px; }
.bp-tog > button {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 2px 0;
  background: none; border: 0; color: var(--mist); cursor: pointer;
  font-family: var(--head); font-weight: 700; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  transition: color .2s;
}
.bp-tog > button span { overflow: hidden; text-overflow: ellipsis; }
.bp-tog > button:hover { color: var(--moon); }
.bp-tog .tog {
  position: relative; flex: 0 0 auto; width: 30px; height: 17px; border-radius: 99px;
  background: rgba(214,226,244,.14); transition: background .2s;
}
.bp-tog .tog::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--moon); transition: transform .2s;
}
.bp-tog.on > button { color: #9fe6bf; }
.bp-tog.on .tog { background: #2f7a59; }
.bp-tog.on .tog::after { transform: translateX(13px); background: #eafff3; }
.bp-ac {
  display: flex; align-items: center; gap: 1px; height: 22px; padding: 0 7px; border-radius: 6px;
  background: var(--well); border: 1px solid var(--line);
  font-family: var(--num); font-weight: 600; font-size: 14px; color: var(--mist);
  opacity: .55; transition: opacity .2s, border-color .2s;
}
.bp-tog.on .bp-ac { opacity: 1; border-color: rgba(120,214,166,.45); }
.bp-ac:focus-within { opacity: 1; border-color: rgba(226,169,84,.6); }
.bp-ac input {
  width: 44px; padding: 0; background: none; border: 0; outline: none; text-align: right;
  font-family: var(--num); font-weight: 600; font-size: 15px; color: var(--moon); -moz-appearance: textfield;
}
.bp-ac input::-webkit-outer-spin-button, .bp-ac input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
body.spectator .bet-panel { opacity: .5; pointer-events: none; }
/* ═════════════════════ side panel: chat / bets / book ═════════════════════ */
#panel {
  background: var(--ink); border: 1px solid var(--line); border-top-color: rgba(214,226,244,.2);
  border-radius: var(--r); backdrop-filter: none; box-shadow: 0 14px 34px rgba(0,0,0,.4);
  padding-bottom: 0;
}
#panel #tabs { background: none; padding: 4px 8px 0; gap: 0; border-bottom: 1px solid var(--line); }
#panel #tabs .tab {
  font-family: var(--head); font-weight: 700; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--mist); background: none; border-radius: 0; padding: 11px 4px 10px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s, border-color .2s;
}
#panel #tabs .tab:hover { color: var(--moon); }
#panel #tabs .tab.sel { background: none; color: var(--moon); border-bottom-color: var(--lantern); }
/* chat: plain lines, the name a quiet label above-left of the words */
#panel #feed { padding: 6px 0; }
#panel #feed .msg {
  display: block; padding: 6px 14px; margin: 0; border: 0; background: none;
  font-family: var(--sans); font-size: 13px; line-height: 1.45; color: #c7d1df;
}
#panel #feed .msg + .msg { border-top: 1px solid rgba(176,196,224,.06); }
#panel #feed .msg .who {
  display: block; margin-bottom: 1px;
  font-family: var(--num); font-weight: 600; font-size: 12px; letter-spacing: .1em; color: var(--mist);
}
#panel #feed .msg .who.who-you { color: var(--lantern-hi); }
#panel #chat-form { padding: 10px; gap: 8px; border-top: 1px solid var(--line); background: none; margin: 0; }
#panel #chat-form input {
  background: var(--well); border: 1px solid var(--line); border-radius: 7px; color: var(--moon);
  font-family: var(--sans); font-size: 13px;
}
#panel #chat-form input::placeholder { color: var(--mist); }
#panel #chat-form input:focus { border-color: rgba(226,169,84,.5); outline: none; }
#panel #chat-form button {
  border: 1px solid rgba(214,226,244,.22); border-radius: 7px; background: var(--well); color: var(--moon);
  font-family: var(--head); font-weight: 700; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
}
#panel #chat-form button:hover { border-color: rgba(226,169,84,.5); color: var(--lantern-hi); }
#scroll-bottom { background: var(--ink); color: var(--moon); border: 1px solid var(--line); font-family: var(--num); }
/* bets: a clean three-column ledger, ship shown as a thin pennant-coloured rule */
#panel #feed-bets .bet-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; gap: 10px; align-items: center;
  padding: 7px 14px; margin: 0; border: 0; border-radius: 0; background: none;
  font-family: var(--num); font-weight: 500; font-size: 14px; letter-spacing: .03em;
}
#panel #feed-bets .bet-row + .bet-row { border-top: 1px solid rgba(176,196,224,.06); }
#panel #feed-bets .br-name { color: #c7d1df; border-left: 0; padding-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#panel #feed-bets .br-name .ship-sym { font-size: 12px; margin-right: 6px; }
#panel #feed-bets .br-stake { color: var(--mist); }
#panel #feed-bets .br-win { text-align: right; color: var(--mist); }
#panel #feed-bets .br-win.won { color: #9fe6bf; }
#panel #feed-bets .br-win.lost { color: #c97f86; }
/* water on the lens (lens.js): over the 3D scene, under every HUD layer */
#stage .lens-water { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
/* ═════════════════════ close call + big hauls ═════════════════════ */
.close-call {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 14px 6px; border-radius: 8px; background: rgba(8,14,26,.88); border: 1px solid rgba(143,224,182,.6);
  box-shadow: 0 0 18px rgba(143,224,182,.25); white-space: nowrap; animation: ccIn .45s cubic-bezier(.2,1.6,.4,1);
}
.close-call b { font-family: var(--head); font-size: 15px; letter-spacing: .2em; text-transform: uppercase; color: #bff5d8; }
.close-call span { font-family: var(--num); font-size: 13px; color: var(--mist); }
.close-call.out { opacity: 0; transform: translate(-50%, -80%); transition: opacity .5s, transform .5s; }
@keyframes ccIn { from { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }
.big-haul {
  position: absolute; z-index: 9; transform: translate(-50%, 0); pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 12px; border-radius: 999px; white-space: nowrap;
  background: linear-gradient(90deg, rgba(8,14,26,.92), rgba(40,28,8,.92)); border: 1px solid rgba(226,169,84,.55);
  box-shadow: 0 6px 20px rgba(0,0,0,.4), 0 0 16px rgba(226,169,84,.18);
  font-family: var(--head); font-size: 12px; letter-spacing: .06em; color: var(--moon);
  animation: haulIn .45s cubic-bezier(.2,1.3,.4,1);
}
.big-haul .ship-sym { font-size: 14px; }
.big-haul b { color: #fff; font-weight: 700; }
.big-haul em { font-style: normal; font-family: var(--num); font-weight: 700; font-size: 14px; color: var(--lantern-hi); }
.big-haul.out { opacity: 0; transform: translate(-50%, -12px); transition: opacity .4s, transform .4s; }
@keyframes haulIn { from { opacity: 0; transform: translate(-50%, -16px); } }
@media (max-width: 620px) { .big-haul { font-size: 10px; padding: 5px 12px 5px 10px; } .big-haul em { font-size: 12px; } }
/* ═════════════════════ flying coins + big win ═════════════════════ */
#fx-layer { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.coin {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f8e3b4, var(--lantern) 50%, var(--lantern-lo) 100%);
  box-shadow: inset 0 0 0 1.5px rgba(110,62,14,.55);
}
/* ═════════════════════ treasure screen (vault.js) ═════════════════════
   --c1 / --c2 are the tier's colours, set by vault.js. */
#vault {
  position: fixed; inset: 0; z-index: 97; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: radial-gradient(55% 50% at 50% 52%, color-mix(in srgb, var(--c2) 38%, rgba(4,8,16,.6)), rgba(2,4,9,.9));
  opacity: 0; transition: opacity .3s ease;
}
#vault[hidden] { display: none; }
#vault.in { opacity: 1; }
/* depth of field: the scene and HUD fall out of focus behind the chest */
#vault { -webkit-backdrop-filter: blur(0) saturate(1); backdrop-filter: blur(0) saturate(1); transition: opacity .3s ease, backdrop-filter .45s ease, -webkit-backdrop-filter .45s ease; }
#vault.in { -webkit-backdrop-filter: blur(7px) saturate(.85); backdrop-filter: blur(7px) saturate(.85); }
#vault.out { opacity: 0; transition-duration: .35s; }
.vw-rays {
  position: absolute; left: 50%; top: 52%; width: 170vmax; height: 170vmax; margin: -85vmax 0 0 -85vmax; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--c1) 34%, transparent) 0deg 7deg, transparent 7deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, rgba(0,0,0,.55) 18%, transparent 46%); mask: radial-gradient(circle, #000 0, rgba(0,0,0,.55) 18%, transparent 46%);
  opacity: 0; transform: scale(.6); transition: opacity .5s ease, transform .9s cubic-bezier(.2,1,.3,1);
  animation: vwSpin 22s linear infinite;
}
#vault.rainbow .vw-rays { background: repeating-conic-gradient(from 0deg, rgba(255,84,104,.42) 0 6deg, transparent 6deg 12deg, rgba(255,211,77,.42) 12deg 18deg, transparent 18deg 24deg, rgba(62,224,143,.38) 24deg 30deg, transparent 30deg 36deg, rgba(120,170,255,.4) 36deg 42deg, transparent 42deg 48deg, rgba(183,123,255,.42) 48deg 54deg, transparent 54deg 60deg); }
#vault.open .vw-rays { opacity: 1; transform: scale(1); }
@keyframes vwSpin { to { rotate: 360deg; } }
.vw-coins { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.vw-stack { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 16px; text-align: center; }
.vw-title {
  font-family: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; line-height: 1;
  font-size: clamp(28px, min(6vw, 9vh), 78px); max-width: 94vw; margin-bottom: clamp(4px, 1.6vh, 16px);
  background: linear-gradient(180deg, #fffbe8 0%, #ffe39a 38%, var(--c1) 62%, var(--c2) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(40,20,0,.85)) drop-shadow(0 0 22px color-mix(in srgb, var(--c1) 70%, transparent));
  opacity: 0; transform: scale(2.2);
}
#vault.open .vw-title { animation: vwSlam .55s cubic-bezier(.2,1.5,.4,1) .08s forwards; }
@keyframes vwSlam { to { opacity: 1; transform: scale(1); } }
.vw-chest { position: relative; width: clamp(170px, min(42vw, 36vh), 320px); aspect-ratio: 320 / 290; animation: vwDrop .6s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes vwDrop { from { transform: translateY(-55vh) scale(.6); } }
#vault.in:not(.open) .vw-chest { animation: vwDrop .6s cubic-bezier(.3,1.5,.5,1) both, vwRattle .12s .45s 2 linear; }
@keyframes vwRattle { 25% { rotate: -2.5deg; } 75% { rotate: 2.5deg; } }
#vault.open .vw-chest { animation: vwPop .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes vwPop { 40% { transform: scale(1.06, .95); } }
.vw-chest > div svg { display: block; width: 100%; height: 100%; }
/* layers, positioned in the 320 × 290 box (see chest-art.js) */
.vw-chest > div { position: absolute; left: 0; width: 100%; }
.vw-base     { bottom: 0; height: calc(180 / 290 * 100%); z-index: 3; }
.vw-lid      { top: 0; height: calc(128 / 290 * 100%); z-index: 4; transform-origin: 50% 90%; transition: transform .14s cubic-bezier(.6,0,.9,.4); }
.vw-pile     { top: calc(20 / 290 * 100%); height: calc(96 / 290 * 100%); z-index: 2; }
.vw-lid-open { top: calc(-8 / 290 * 100%); height: calc(120 / 290 * 100%); z-index: 1; transform-origin: 50% 100%; transform: scaleY(0); transition: transform .32s cubic-bezier(.2,1.7,.45,1) .12s; }
.vw-shadow   { bottom: -6%; height: 12%; left: 6% !important; width: 88% !important; z-index: 0; border-radius: 50%; background: radial-gradient(closest-side, rgba(0,0,0,.6), transparent); }
#vault.open .vw-lid { transform: scaleY(0); }
#vault.open .vw-lid-open { transform: scaleY(1); }
.vw-glow {
  top: calc(30 / 290 * 100%); left: -25% !important; width: 150% !important; aspect-ratio: 1; translate: 0 -50%; z-index: 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff7d6 0, color-mix(in srgb, var(--c1) 85%, #fff) 14%, color-mix(in srgb, var(--c1) 40%, transparent) 34%, transparent 64%);
  opacity: 0; scale: .3; transition: opacity .35s ease, scale .6s cubic-bezier(.2,1.4,.4,1);
}
#vault.open .vw-glow { opacity: 1; scale: 1; animation: vwPulse 1.6s ease-in-out .6s infinite; }
@keyframes vwPulse { 50% { scale: 1.08; opacity: .85; } }
.vw-amt { font-family: var(--num); font-weight: 700; font-size: clamp(30px, min(6vw, 8vh), 60px); line-height: 1.05; color: var(--lantern-hi); letter-spacing: .02em; margin-top: clamp(8px, 2vh, 18px); text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 26px rgba(226,169,84,.4); font-variant-numeric: tabular-nums; }
.vw-mult { font-family: var(--num); font-weight: 600; font-size: clamp(18px, 2.6vw, 26px); color: var(--c1); letter-spacing: .06em; }
.vw-skip { margin-top: 10px; font-family: var(--head); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--mist); opacity: 0; }
#vault.open .vw-skip { animation: vwFade .4s 1.6s forwards; }
@keyframes vwFade { to { opacity: .8; } }
@media (prefers-reduced-motion: reduce) {
  .vw-rays, .vw-chest, #vault.open .vw-glow { animation: none; }
  .vw-title { opacity: 1; transform: none; }
}
/* ═════════════════════ responsive ═════════════════════ */
@media (max-width: 1240px) {
  #hero { left: calc((100% - 308px) / 2); }
}
/* the tight desktop band: panels are narrow — smaller captions, the
   button keeps its size */
@media (min-width: 1001px) and (max-width: 1360px) {
  .bp-tog > button { font-size: 9px; letter-spacing: .08em; gap: 6px; }
  .bp-ac input { width: 36px; }
  #betbar .b-verb { font-size: 22px; letter-spacing: .14em; }
  .bp-chips .chip { font-size: 13px; }
}
@media (max-width: 1000px) {
  #hero { left: 50%; top: 104px; }
  #betbar { left: 0; right: 0; bottom: auto; padding: 8px 8px 10px; }
  #topbar #balance-box { height: 34px; padding: 0 11px 0 8px; gap: 6px; }
  #topbar .bb-coin { width: 17px; height: 17px; }
  #topbar #you-balance { font-size: 19px; }
}
@media (max-width: 620px) {
  #hero { top: calc(96px + 2.5vh); }
  .hero-sub { font-size: 10px; letter-spacing: .16em; padding: 5px 12px; }
  #stage .card-mult { font-size: 21px; }
  #stage .ship-card .card-name { font-size: 9px; }
  .sink-stamp { transform: translate(-50%, -20%) rotate(-5deg); padding: 5px 12px 4px; }
  @keyframes stampSlam { from { opacity: 0; transform: translate(-50%, -20%) rotate(-12deg) scale(1.8); } }
  .sink-stamp b { font-size: 18px; }
  .sink-stamp span { font-size: 17px; }
  .cash-float { font-size: 26px; }

  /* the two panels stack, each kept compact: the auto switches move to
     one full-width row so the button keeps the panel's whole right side */
  #betbar #bet-controls { grid-template-columns: 1fr; gap: 6px; }
  .bet-panel { gap: 3px 8px; padding: 7px 8px 6px; grid-template-areas: "head btn" "stake btn" "autos autos"; }
  .bp-autos { flex-direction: row; justify-content: space-between; }
  /* name 14 + stepper 30 + amounts 22 + gaps = 72, level with the button */
  #betbar .board { height: 72px; }
  .bp-head { height: 14px; }
  .bp-stake { gap: 3px; }
  .bp-name { font-size: 10px; letter-spacing: .07em; }
  #betbar .bp-stepper { height: 30px; }
  .bp-chips { height: 22px; }
  .bp-autos { padding-top: 4px; }
  .bp-tog > button { font-size: 9px; letter-spacing: .08em; gap: 6px; }
  .bp-ac input { width: 38px; }
  #betbar .board { padding: 0 8px; gap: 6px; }
  #betbar .b-verb { font-size: 16px; letter-spacing: .14em; }
  #betbar .b-x { font-size: 20px; }
  #betbar .b-mult { font-size: 14px; }
  #betbar .board.cashout .b-verb { font-size: 10px; letter-spacing: .1em; }
  #betbar .board.cashout .b-mult { font-size: 14px; }
  #betbar .board.mine .b-verb { font-size: 11px; letter-spacing: .1em; }
  #betbar .board.mine .b-mult { font-size: 12px; }
}
@media (min-width: 621px) and (max-height: 460px) {
  #hero { top: 46px; }
  .hero-sub { display: none; }
  .bp-autos { display: none; }
  .bet-panel { gap: 3px 8px; padding: 6px 8px; grid-template-areas: "head btn" "stake btn"; }
  /* name 12 + stepper 28 + amounts 20 + gaps = 66 */
  .bp-head { height: 12px; }
  .bp-stake { gap: 3px; }
  #betbar .bp-stepper { height: 28px; }
  .bp-chips { height: 20px; }
  #betbar .board { height: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  .storm-clouds, #betbar .board.cashout { animation: none; }
}
/* Book list: the ship symbol before each ship name */
#rounds-list .r-ship .ship-sym { font-size: 12px; margin-right: 5px; }
/* ═════════════════════ boarding countdown chip ═════════════════════
   Centred under the round-history strip (fx.js placeChip sets left/top each
   tick), shown only while betting is open (html.cd-boarding). The amber line
   drains with the time left (--f, 1 -> 0) and turns red for the last 3s. */
.cd-chip {
  position: absolute; z-index: 9; left: 50%; top: 63px; transform: translateX(-50%); pointer-events: none;
  display: none; align-items: center; gap: 14px; padding: 7px 22px 11px; border-radius: 999px; white-space: nowrap;
  background: var(--ink); border: 1px solid var(--line); border-top-color: rgba(214,226,244,.22);
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
  font-family: var(--head); font-weight: 700; font-size: 14px; letter-spacing: .22em; text-transform: uppercase; color: var(--mist);
}
html.cd-boarding .cd-chip { display: flex; }
.cd-chip b { font-family: var(--num); font-weight: 600; font-size: 27px; line-height: 1; letter-spacing: 0; text-transform: none; color: var(--lantern-hi); min-width: 2.4ch; text-align: right; }
.cd-chip i { position: absolute; left: 22px; right: 22px; bottom: 4px; height: 3px; border-radius: 3px; background: rgba(214,226,244,.12); overflow: hidden; }
.cd-chip u { display: block; height: 100%; width: calc(var(--f, 1) * 100%); background: var(--lantern); transition: width .1s linear; }
.cd-chip.urgent { border-color: rgba(207,74,82,.55); }
.cd-chip.urgent b { color: #f2a7ac; }
.cd-chip.urgent u { background: var(--blood); }
/* the chip carries the boarding message, so the caption stays out of the way */
#hero.is-boarding .hero-sub { display: none; }
/* ═════════════════════ loading screen — VINCO ident, then the compass ═════════════════════
   index.html's loader script adds .compass-on after the ident, .ready when
   the dial is full, and .gone to fade it out (.done alone no longer hides
   it — the script waits for the ident and for the needle to settle). */
#loader {
  display: block; container-type: size; overflow: hidden;
  background: radial-gradient(ellipse at 50% 46%, #142242 0, #070b16 62%);
}
#loader.done { opacity: 1; pointer-events: auto; }
#loader.gone { opacity: 0; pointer-events: none; transition: opacity .55s ease; }
#loader .ld-compass { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4cqmin; text-align: center;
  opacity: 0; transform: scale(.94); transition: opacity .8s ease .15s, transform 1s cubic-bezier(.2,1,.3,1) .15s; }
#loader.compass-on .ld-compass { opacity: 1; transform: none; }
#loader .ld-dial { width: min(56cqmin, 340px); height: min(56cqmin, 340px); overflow: visible; }
#loader .tick { stroke: rgba(219,228,240,.18); transition: stroke .25s; }
#loader .tick.lit { stroke: #f2cb84; }
#loader #ld-needle { transform-origin: 100px 100px; }
#loader .ld-bezel { transition: filter .4s; }
#loader.ready .ld-bezel { filter: drop-shadow(0 0 8px rgba(242,203,132,.6)); }
#loader .ld-word { font: 900 clamp(26px, 7cqmin, 64px) 'Cinzel', serif; letter-spacing: .32em; margin-right: -.32em; color: #f2cb84; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,.6), 0 0 20px rgba(226,169,84,.25); }
#loader .ld-cap { font: 600 clamp(11px, 3.1cqmin, 20px) 'Barlow Condensed', sans-serif; letter-spacing: .32em; text-transform: uppercase; color: #8a97ad; white-space: nowrap; }
#loader .ld-cap b { color: #f2cb84; font-weight: 700; letter-spacing: .08em; margin-left: .6em; font-variant-numeric: tabular-nums; }
#loader .ld-tip { font: italic 500 clamp(10px, 2.5cqmin, 16px) 'Barlow Condensed', sans-serif; letter-spacing: .12em; color: rgba(219,228,240,.55); min-height: 1.2em; }
#loader .ld-credit { position: absolute; right: 3cqw; bottom: 4cqh; display: flex; align-items: center; gap: 10px; opacity: 0; transition: opacity .8s .6s; }
#loader.compass-on .ld-credit { opacity: 1; }
#loader .ld-credit img { height: clamp(20px, 5.2cqmin, 34px); width: auto; }
#loader .ld-credit span { font: 500 clamp(9px, 2.1cqmin, 13px) 'Outfit', sans-serif; letter-spacing: .38em; text-transform: uppercase; color: rgba(219,228,240,.6); }
#loader .ld-credit b { font: 800 clamp(11px, 2.6cqmin, 16px) 'Outfit', sans-serif; letter-spacing: .3em; color: #fff; }
#loader .ld-credit b i, #loader .ld-name i { font-style: normal; color: #34e0c0; }
#loader .ld-ident { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqmin;
  background: radial-gradient(ellipse at 50% 46%, #0a1a1c 0, #03070a 65%); transition: opacity .7s ease, transform .9s ease; }
#loader.compass-on .ld-ident { opacity: 0; transform: scale(1.06); pointer-events: none; }
#loader .ld-ident img { height: min(30cqmin, 240px); width: auto; filter: drop-shadow(0 0 22px rgba(52,224,192,.35)); animation: ldIdentIn 1.2s cubic-bezier(.2,1,.3,1) both; }
#loader .ld-name { font: 800 clamp(24px, 6cqmin, 54px) 'Outfit', sans-serif; letter-spacing: .5em; margin-right: -.5em; color: #fff; animation: ldIdentIn 1.2s .2s cubic-bezier(.2,1,.3,1) both; }
#loader .ld-pres { font: 500 clamp(10px, 2.4cqmin, 16px) 'Outfit', sans-serif; letter-spacing: .6em; margin-right: -.6em; text-transform: uppercase; color: rgba(219,228,240,.55); animation: ldIdentIn 1.2s .45s cubic-bezier(.2,1,.3,1) both; }
@keyframes ldIdentIn { from { opacity: 0; transform: translateY(14px) scale(.96); filter: blur(8px); } }
#loader .ld-sheen { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.12) 50%, transparent 60%); background-size: 250% 100%; animation: ldSheen 1.6s .5s ease-in-out both; }
@keyframes ldSheen { from { background-position: 120% 0; } to { background-position: -40% 0; } }
@media (max-width: 620px) { #loader .ld-credit { right: 0; left: 0; justify-content: center; } }
@media (prefers-reduced-motion: reduce) {
  #loader .ld-ident img, #loader .ld-name, #loader .ld-pres, #loader .ld-sheen { animation: none; }
  #loader .ld-compass, #loader .ld-ident { transition: none; }
}
/* Low-end devices (html.lite — set by the probe in index.html's <head>).
   A backdrop blur over the live WebGL canvas has to re-blur that region on
   every frame the sea moves, which is far more GPU than the effect is worth
   on a weak phone. The panels keep their translucent tint; only the blur goes. */
html.lite *,
html.lite *::before,
html.lite *::after {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
/* Without the blur, a translucent panel shows the moving sea sharp behind
   its text, and the text gets hard to read. Lite makes those panels close to
   opaque instead; the colours are the same panels', only the alpha rises. */
html.lite #banner { background: rgba(6, 10, 22, 0.9); }
html.lite .settings-pop { background: rgba(10, 21, 38, 0.95); }
html.lite .modal-box { background: rgba(13, 20, 44, 0.97); }

/* ═════════════ BET in the ship's own colour ═════════════ */
/* The button a player has to find — BET, and BET for the next round — wears
   its ship's emblem colour: the Interceptor's blue anchor, the Black Pearl's
   red skull. The dark gold-rimmed plate it used to be all but vanished over a
   night sea. The other states keep their own colours (PLACED green, CASH OUT
   rising green, SUNK red-grey) so a glance still tells them apart. */
#betbar .board.star.bet, #betbar .board.star.next {
  border-color: #9fcdf7; color: #fff;
  background: linear-gradient(180deg, #4d93d8 0%, #2a62a4 100%);
  box-shadow: 0 6px 18px rgba(98,166,234,.32), inset 0 1px 0 rgba(255,255,255,.3);
}
#betbar .board.port.bet, #betbar .board.port.next {
  border-color: #f49aa0; color: #fff;
  background: linear-gradient(180deg, #d9505a 0%, #9d2a34 100%);
  box-shadow: 0 6px 18px rgba(226,84,92,.32), inset 0 1px 0 rgba(255,255,255,.26);
}
#betbar .board.star.bet:not(:disabled):hover, #betbar .board.star.next:not(:disabled):hover {
  background: linear-gradient(180deg, #5aa0e4 0%, #306cb2 100%); filter: none;
}
#betbar .board.port.bet:not(:disabled):hover, #betbar .board.port.next:not(:disabled):hover {
  background: linear-gradient(180deg, #e35c66 0%, #ab313b 100%); filter: none;
}
#betbar .board.bet .b-verb, #betbar .board.next .b-verb { text-shadow: 0 1px 2px rgba(0,0,0,.35); }
#betbar .board.bet .b-mult, #betbar .board.next .b-mult { color: rgba(255,255,255,.88); opacity: 1; }

/* ═════════════ Popups in the game's own look ═════════════ */
/* Every popup — the 18+ gate, How to Play, Terms, Limits, Credits — wears
   the same clothes as the game around it: night-glass plates like the bet
   panels (var(--ink), a hairline rim, a lantern-gold top edge), Cinzel
   capitals for headings like the ship names, Barlow Condensed for numbers,
   and buttons cut like the bet buttons: the main action lantern-outlined in
   Cinzel capitals, the other one a quiet moonlit outline. */
.modal-box, .ag-box {
  background: linear-gradient(180deg, rgba(214,226,244,.05), transparent 38%), var(--ink);
  border: 1px solid var(--line); border-top: 2px solid var(--lantern);
  border-radius: 14px; color: var(--moon);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.modal-box::before { display: none; }   /* the top edge is the lantern rim now */
html.lite .modal-box, html.lite .ag-box { background: rgba(8, 14, 26, .97); }
#help .modal-box h2, #info .modal-box h2, #limits .modal-box h2, #credits .modal-box h2 {
  font-family: var(--head); font-weight: 700; font-size: 17px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--moon); border-bottom: 1px solid var(--line);
}
#help .modal-box h3, #info .modal-box h3, #limits .modal-box h3, #credits .modal-box h3 {
  font-family: var(--head); font-weight: 700; letter-spacing: .08em; color: var(--lantern-hi);
}
#help .modal-box p, #info .modal-box p, #limits .modal-box p, #credits .modal-box p { color: var(--moon); }
.terms-list li { color: var(--moon); }
.terms-list b, .modal-box a { color: var(--lantern-hi); }
.terms-note { color: var(--mist); background: rgba(226,169,84,.07); border-color: rgba(226,169,84,.28); }
.help-foot { border-top-color: var(--line); }
/* the close ✕: a top-bar icon button */
#help-x, #info-x, #limits-x, #credits-x {
  width: 34px; height: 34px; border-radius: var(--r);
  background: var(--ink); border: 1px solid var(--line); border-top-color: rgba(214,226,244,.2);
  color: var(--moon); font-size: 14px;
}
#help-x:hover, #info-x:hover, #limits-x:hover, #credits-x:hover {
  background: var(--ink); border-color: rgba(226,169,84,.5); color: var(--lantern-hi); transform: none;
}
/* the main action: cut like a bet button — lantern rim, Cinzel capitals */
#help .help-foot .close, #info .help-foot .close, #limits .help-foot .close, #credits .help-foot .close,
.ht-next, .ag-yes {
  border: 1.5px solid var(--lantern); border-radius: 8px;
  background: rgba(226,169,84,.16); color: var(--lantern-hi);
  font-family: var(--head); font-weight: 900; font-size: 14px; letter-spacing: .16em; text-transform: uppercase;
  box-shadow: none; transition: background .15s, color .15s, transform .08s;
}
#help .help-foot .close:hover, #info .help-foot .close:hover, #limits .help-foot .close:hover, #credits .help-foot .close:hover,
.ht-next:hover, .ag-yes:hover { background: rgba(226,169,84,.26); color: #fff3d6; transform: none; box-shadow: none; }
/* the other choice: a quiet moonlit outline */
.ht-back, .ag-no {
  border: 1px solid var(--rim); border-radius: 8px; background: rgba(214,226,244,.04); color: var(--moon);
  font-family: var(--head); font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
}
.ht-back:hover:not(:disabled), .ag-no:hover { background: rgba(214,226,244,.1); }

/* ═════════════ 18+ age gate (#age-gate in index.html) ═════════════ */
/* Above everything, including the loading screen; gone from the first paint
   for anyone who has confirmed before (html.age-ok, set in <head>). */
#age-gate {
  position: fixed; inset: 0; z-index: 3000;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at 50% 42%, #142242 0, #070b16 65%);
  color: var(--moon);
}
html.age-ok #age-gate { display: none; }
/* The loading screen's ident waits behind the gate instead of playing unseen. */
html:not(.age-ok) #loader, html:not(.age-ok) #loader * { animation-play-state: paused !important; }
.ag-box { position: relative; width: min(400px, 100%); text-align: center; padding: 30px 24px 22px; }
.ag-logo { width: 60px; height: 60px; display: block; margin: 0 auto; }
.ag-brand { font-family: var(--head); font-weight: 700; color: var(--lantern); letter-spacing: .34em; font-size: 19px; margin: 8px 0 20px; }
.ag-q { font-family: var(--head); font-weight: 700; font-size: 21px; letter-spacing: .04em; color: #fff; margin: 0 0 6px; }
.ag-sub { margin: 0 0 22px; font-size: 14px; color: var(--mist); }
.ag-btns { display: flex; gap: 10px; }
.ag-btns button { padding: 14px 10px; cursor: pointer; }
.ag-btns button:active { transform: translateY(1px); }
.ag-yes { flex: 2; }
.ag-no { flex: 1; }
.ag-fine { margin: 18px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--mist); opacity: .85; }
.ag-denied .ag-sub { margin-bottom: 4px; }

/* ═════════════ How to Play (#help): four steps with game clips ═════════════ */
.ht-box { width: min(560px, 100%); padding: 20px 22px 18px; overflow-y: auto; }
#help .modal-box h2.ht-title { font-size: 16px; margin: 0 44px 14px 0; padding-bottom: 12px; }
.ht-slide[hidden] { display: none; }
.ht-slide { animation: htIn .25s ease; }
@keyframes htIn { from { opacity: 0; transform: translateX(10px); } }
.ht-media {
  position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden;
  background: #050913; border: 1px solid var(--line);
}
.ht-media video { display: block; width: 100%; height: 100%; object-fit: cover; }
/* the step number: a little ship-flag plate, like the ships' multiplier flags */
.ht-num {
  position: absolute; top: 10px; left: 0; padding: 4px 14px 4px 10px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%);
  background: var(--ink); border-left: 2px solid var(--lantern);
  font-family: var(--num); font-weight: 700; font-size: 15px; letter-spacing: .04em; color: var(--lantern-hi);
}
.ht-num::before { content: "STEP "; font-family: var(--head); font-size: 10px; letter-spacing: .16em; color: var(--mist); }
#help .modal-box .ht-slide h3 {
  margin: 14px 0 4px; font-size: 16px; letter-spacing: .14em; text-transform: uppercase; color: var(--moon);
}
#help .modal-box .ht-slide p { margin: 0; min-height: 2.8em; font-size: 14.5px; line-height: 1.45; color: var(--mist); }
.ht-slide p b { color: var(--lantern-hi); font-family: var(--head); font-size: .9em; letter-spacing: .08em; }
.ht-dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 14px; }
.ht-dots i { width: 7px; height: 7px; border-radius: 4px; background: rgba(214,226,244,.2); transition: width .2s ease, background .2s ease; }
.ht-dots i.on { width: 22px; background: var(--lantern); }
.ht-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ht-hide { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mist); cursor: pointer; user-select: none; }
.ht-hide input { width: 17px; height: 17px; margin: 0; accent-color: var(--lantern); cursor: pointer; }
.ht-btns { display: flex; gap: 8px; margin-left: auto; }
.ht-btns button { padding: 11px 18px; cursor: pointer; }
.ht-btns button:active { transform: translateY(1px); }
.ht-back:disabled { opacity: .35; cursor: default; }
.ht-next { min-width: 120px; }
.ht-next.ht-finish { min-width: 170px; }
@media (max-width: 480px) {
  .ht-box { padding: 18px 14px 14px; }
  .ht-foot { flex-direction: column-reverse; align-items: stretch; }
  .ht-btns { margin-left: 0; }
  .ht-btns button { flex: 1; }
  .ht-hide { justify-content: center; }
}
/* Limits: the figures in the game's number face, like the bet stake and the multipliers */
.limit-row { background: var(--well); border: 1px solid var(--line); border-left: 3px solid var(--lantern); }
.limit-row dt { font-family: var(--head); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--mist); }
.limit-row dd { font-family: var(--num); font-size: 20px; font-weight: 700; letter-spacing: .02em; color: var(--lantern-hi); }
