* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #082f49 0%, #0c4a6e 60%, #082f49 100%);
  color: #e2e8f0; user-select: none; -webkit-user-select: none;
  touch-action: none; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 860px); margin: 0 auto; }

#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: rgba(0,0,0,0.24); border: 2px solid rgba(255,255,255,0.14); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#hdrHome { border: none; background: #38bdf8; color: #082f49; font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #7dd3fc; }

.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 18px; }
#scr-play, #scr-place { padding: 6px 4px 6px; }
.scr.on { display: flex; }

#scr-menu { align-items: center; text-align: center; gap: 12px; justify-content: center; }
#scr-menu h1 { font-size: clamp(30px, 8.5vw, 44px); color: #f8fafc; }
#scr-menu .sub { color: #7dd3fc; font-weight: 600; margin-bottom: 4px; }
#tierRow { display: flex; gap: 8px; width: 100%; }
.tierCard { flex: 1; background: rgba(0,0,0,0.22); border: 3px solid rgba(255,255,255,0.13); border-radius: 16px; padding: 10px 4px; font-weight: 800; font-size: 14px; line-height: 1.35; cursor: pointer; color: #e2e8f0; font-family: inherit; }
.tierCard small { display: block; color: #7dd3fc; font-weight: 700; font-size: 11.5px; }
.tierCard .te { font-size: 26px; display: block; }
.tierCard.sel { border-color: #38bdf8; background: rgba(56,189,248,0.14); }

button.big { width: 100%; border-radius: 16px; min-height: 56px; font-size: 19px; font-weight: 800; background: rgba(0,0,0,0.22); color: #e2e8f0; border: 3px solid rgba(255,255,255,0.13); cursor: pointer; font-family: inherit; }
button.big:active { transform: translateY(2px); }
button.big.primary { background: #38bdf8; border-color: #0ea5e9; color: #082f49; min-height: 44px;}
#statsLine { color: #7dd3fc; font-weight: 700; font-size: 13px; }

/* ⚙️ Settings — the shared disclosure shape (R-C23). */
#custom { width: 100%; background: rgba(0,0,0,0.22); border: 3px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 10px 12px; text-align: left; }
#custom summary { font-weight: 800; font-size: 16px; cursor: pointer; list-style: none; }
#custom summary::-webkit-details-marker { display: none; }
.field { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.field .lbl { flex: 1; font-weight: 700; font-size: 14px; color: #cbd5e1; }
.seg { display: flex; gap: 4px; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 3px; }
.seg button { min-height: 44px; min-width: 58px; border: none; border-radius: 9px; background: transparent; color: #94a3b8; font-weight: 800; font-size: 13px; font-family: inherit; cursor: pointer; }
.seg button.on { background: #38bdf8; color: #082f49; min-height: 44px;}
.blurb { color: #7dd3fc; font-weight: 700; font-size: 12.5px; margin-top: 10px; line-height: 1.45; }

/* arranging */
#placeTop { text-align: center; font-weight: 800; font-size: 14px; color: #7dd3fc; padding: 2px 6px 6px; }
#placeWrap { flex: 1; position: relative; min-height: 0; }
canvas#placeStage { display: block; touch-action: none; }
#fleetRow { flex: none; display: flex; gap: 6px; padding: 8px 4px 0; overflow-x: auto; }
.shipChip { flex: 1 0 auto; min-height: 46px; border-radius: 12px; background: rgba(0,0,0,0.24); border: 3px solid rgba(255,255,255,0.13); color: #e2e8f0; font-size: 18px; font-weight: 800; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 8px; }
.shipChip span { font-size: 10.5px; font-weight: 800; color: #94a3b8; }
.shipChip.sel { border-color: #fbbf24; background: rgba(251,191,36,0.14); }
#placePad { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 4px max(4px, env(safe-area-inset-bottom)); }
.pbGo { background: #38bdf8 !important; border-color: #0ea5e9 !important; color: #082f49 !important; }
.pbGo span { color: #075985 !important; }

/* play */
#playTop { display: flex; align-items: center; justify-content: space-between; font-weight: 800; padding: 2px 6px 6px; font-size: 15px; min-height: 22px; }
#turnOut { color: #f8fafc; }
#tallyOut { color: #7dd3fc; font-variant-numeric: tabular-nums; }

#stageWrap { flex: 1; position: relative; min-height: 0; }
canvas#stage { display: block; touch-action: none; }

#note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #e2e8f0; pointer-events: none; text-align: center; padding: 20px; font-size: 14px; white-space: pre-line; line-height: 1.55; background: rgba(2,6,23,0.86); border-radius: 12px; }
#note:empty { display: none; }

#pad { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 4px max(4px, env(safe-area-inset-bottom)); }
.pb { min-height: 54px; border-radius: 14px; background: rgba(0,0,0,0.24); border: 3px solid rgba(255,255,255,0.13); color: #e2e8f0; font-size: 20px; font-weight: 800; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; touch-action: manipulation; }
.pb span { font-size: 11px; font-weight: 800; color: #94a3b8; }
.pb:active { transform: translateY(2px); }
.pb:disabled { opacity: 0.42; }

/* ---- the hint control (docs/offline-pwa.md R-C16) -------------------------
   ONE bulb, and the count as an OVERLAID badge. Absolutely positioned inside
   `.bulb`, so 3 -> 2 -> 1 can never change the button's width and shove
   whatever sits beside it. The number is always how many are LEFT, it is shown
   at 1 and at 0, and at 0 the button is disabled with the badge still on it,
   because a control that vanishes teaches a child nothing about why.
   The badge is dark with a pale ring at every game, on purpose: the games run
   from near-black to amber to a light theme, and a dark pill with a light halo
   is the one combination that reads on all of them. */
.hintBtn { position: relative; overflow: visible; }
.hintBtn .bulb { position: relative; display: inline-block; line-height: 1; }
.hintBtn .hintN {
  position: absolute; right: -9px; bottom: -6px;
  min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px;
  background: #0f172a; color: #f8fafc; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .6);
  font: 800 10px/16px inherit; letter-spacing: 0; pointer-events: none;
}
.hintBtn:disabled .hintN, .hintBtn[disabled] .hintN { background: #64748b; }
/* `wide` = the bulb is followed by a WORD. The badge hangs 9px past the
   bulb, so without this it sits on the first letter of the label. */
.hintBtn.wide .bulb { margin-right: 11px; }
/* ...AND THE BULB HAS TO BE THE SIZE OF A GLYPH, NOT THE SIZE OF A LABEL.
   `.pb span { font-size: 11px }` above is meant for the little word under each
   pad glyph — and `.bulb` is a span inside a `.pb`, so it inherited 11px and
   rendered the 💡 at 14x11. The 16px badge then completely covered the thing it
   was counting.
   This was invisible to every guard: the shared markup was present, the shared
   `.hintBtn .hintN` rule was present, and check-hint was green. It took looking
   at it. The other metered hints in the catalogue are `.iconBtn`s laid out in a
   ROW and never inherit a label size, which is why the shared rule alone has
   always been enough everywhere else. */
#pad .hintBtn .bulb { font-size: 20px; margin-right: 0; }
#pad .hintBtn .hintN { right: -11px; bottom: -2px; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; background: rgba(2,6,23,0.9); border-radius: 12px; padding: 16px; overflow-y: auto; overscroll-behavior: contain;}
.ovl.on { display: flex; }
.ovlCard { text-align: center; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; margin: auto;}
#ovlTitle { font-size: 26px; font-weight: 800; color: #f8fafc; }
#ovlSub { color: #7dd3fc; font-weight: 700; min-height: 22px; line-height: 1.45; }
/* A result carries its evidence — the rows are why, not decoration. */
.rows { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 6px; }
.rows .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 700; color: #94a3b8; }
.rows .row b { color: #e2e8f0; font-variant-numeric: tabular-nums; }

#scr-how .card { background: rgba(0,0,0,0.22); border: 3px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 14px; margin-bottom: 10px; font-size: 15px; line-height: 1.55; font-weight: 600; }
#scr-how h2 { margin-bottom: 8px; color: #f8fafc; }

.lgSub { font-weight: 800; font-size: 13.5px; color: #7dd3fc; margin: 10px 0 5px; }
.legend { display: flex; flex-direction: column; gap: 6px; }
.lgRow { display: flex; align-items: center; gap: 10px; }
.lgArt { flex: none; width: 42px; display: flex; align-items: center; justify-content: center; }
.lgSea { width: 28px; height: 28px; border-radius: 3px; background: #12496f; display: inline-flex; align-items: center; justify-content: center; }
.lgMiss { width: 12px; height: 12px; border-radius: 999px; border: 2px solid #93c5fd; display: inline-block; }
.lgHit { width: 16px; height: 16px; border-radius: 999px; background: #f97316; display: inline-block; }
.lgDead { width: 16px; height: 16px; border-radius: 999px; background: #fecaca; color: #7f1d1d; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.lgRing { width: 24px; height: 24px; border-radius: 3px; box-shadow: inset 0 0 0 3px #38bdf8; display: inline-block; }
.lgShip { width: 28px; height: 28px; border-radius: 3px; background: #64748b; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }

.lgTxt { display: flex; flex-direction: column; min-width: 0; }
.lgTxt b { font-size: 14px; font-weight: 800; }
.lgTxt small { font-size: 12.5px; color: #94a3b8; line-height: 1.3; font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: #f8fafc; color: #0f172a; font-weight: 800; padding: 10px 16px; border-radius: 14px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 40; max-width: calc(100vw - 28px); text-align: center; line-height: 1.35; }
#toast.on { opacity: 1; }

/* docs/offline-pwa.md R-C15 — the PAGE must never scroll. */
html, body { overflow: hidden; overscroll-behavior: none; }
.scr { overscroll-behavior: contain; }
