/* ============ Monkey Poo — UI styles ============ */
/* Bundled OFL rounded display face (Fredoka, SIL Open Font License — see
   css/fonts/OFL.txt), then the platform's own rounded faces, then system-ui.
   This is the "carved wood and banana leaf" HUD type (L1-ART-06). */
@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-500.woff2") format("woff2");
  font-weight: 400 550;
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-700.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: #14222e;
  font-family: "Fredoka", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: #fff;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  border: none; cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }

#hudTop {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(6px + env(safe-area-inset-top)) 56px 0 56px;
  gap: 8px;
}

.teamBar { width: min(190px, 26vw); }
.teamBar .teamName {
  font-size: 12px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.teamBar.right { text-align: right; }
.barOuter {
  height: 14px; border-radius: 8px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.25);
  overflow: hidden; margin-top: 2px;
}
.barInner {
  height: 100%; width: 100%;
  border-radius: 7px;
  transition: width .5s cubic-bezier(.2,.8,.3,1);
}
.teamBar.right .barInner { margin-left: auto; }
.teamBar .resCount {
  display: inline-block; margin-top: 3px;
  font-size: 12px; font-weight: 800;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}

#hudCenter { text-align: center; flex: 0 0 auto; }
#hudCenter { position:relative; }
#hudNext { position:absolute;left:calc(100% + 8px);top:1px;width:clamp(76px,15vw,130px);
  max-height:36px;box-sizing:border-box;padding:3px 5px;overflow:hidden;text-align:left;
  font-size:11px;line-height:13px;font-weight:700;letter-spacing:0;
  background:#122a30f2;color:#e6efcf;border:1px solid #96ae84;border-radius:4px; }
#hudNext.changed { border-color:#ffd166; color:#fff4cf; }
#hudTimer {
  font-size: clamp(22px, 4.5vw, 34px); font-weight: 900;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
  line-height: 1;
}
#hudTimer.low { color: #ff5544; }
/* CPU turn, clock held while it plans: an animated thinking mark, never a
   frozen number (docs/design/CPU_TURN_READABILITY_2026-09-26.md) */
#hudTimer.cpuThinking { color: #ffe98a; letter-spacing: 1px; }
#hudWind { font-size: 14px; letter-spacing: 1px; text-shadow: 0 1px 3px #000; min-height: 18px; }
#hudWind .l { color: #7fd4ff; } #hudWind .r { color: #ffd47f; }
#hudWind .wgCalm { opacity: .6; }
#hudWind .wgNum { font-size: 11px; font-weight: 800; margin-left: 5px; opacity: .95; letter-spacing: 0; }
#hudWind .wgImmune { font-size: 10px; margin-left: 4px; filter: grayscale(1); opacity: .8; }
/* wind-immune weapon selected: the whole gauge dims — wind won't help this shot */
#hudWind.immune { opacity: .4; }
#hudWind.immune .l, #hudWind.immune .r { color: #9aa4ad; }
#hudRound { font-size: 10px; font-weight: 700; opacity: .8; letter-spacing: 2px; }

/* weapon selector */
#btnWeapon {
  position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 22, 32, .82);
  color: #fff; font-size: 15px; font-weight: 700;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
#btnWeapon:active { transform: translateX(-50%) scale(.96); }
/* vector weapon glyph inside the pill (L1-ART-06) */
#btnWeapon { display: flex; align-items: center; gap: 7px; }
#btnWeapon .btnWepIco { width: 24px; height: 24px; display: block; }
#btnWeapon .btnWepTxt { line-height: 1; }

#weaponPanel {
  position: absolute; bottom: calc(64px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  transform-origin: bottom center;
  animation: panelPop .26s cubic-bezier(.34, 1.56, .64, 1);
  width: min(620px, 96vw);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr));
  gap: 6px; padding: 10px;
  background: rgba(8, 18, 26, .92);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 16px;
  pointer-events: auto;
  z-index: 12;
}
#weaponPanel .weaponPanelMeta {
  grid-column: 1 / -1;
  position: sticky; top: -10px; z-index: 1;
  margin: -10px -10px 2px; padding: 6px 10px;
  background: rgba(8, 18, 26, .97); color: #dce8ed;
  font-size: 10px; font-weight: 700; letter-spacing: .35px;
  text-align: center; pointer-events: none;
}
#weaponPanel .weaponGroupHeading {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 24px; margin-top: 3px; padding: 3px 7px;
  border-bottom: 1px solid rgba(255,255,255,.22);
  color: #fff1b8; font-size: 11px; font-weight: 800;
  letter-spacing: .55px; text-transform: uppercase;
}
#weaponPanel .weaponGroupHeading small {
  min-width: 20px; padding: 1px 5px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #dce8ed;
  font-size: 9px; text-align: center;
}
/* MP-04 core-loadout filter: additive, off by default (see js/ui/weaponFilter.js) */
#weaponPanel .weaponFilterBar { grid-column: 1 / -1; display: flex; justify-content: center; margin: 1px 0 3px; }
.weaponFilterChip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.08); color: #fff1b8;
  border: 1px solid rgba(255,255,255,.3); border-radius: 999px;
  padding: 4px 12px; font-size: 11px; font-weight: 800; letter-spacing: .3px;
}
.weaponFilterChip .wfIco { font-size: 11px; opacity: .9; }
.weaponFilterChip small {
  min-width: 16px; padding: 1px 5px; border-radius: 999px;
  background: rgba(255,255,255,.14); font-size: 9px; font-weight: 700;
}
.weaponFilterChip.on { background: rgba(255,216,61,.22); border-color: #ffd83d; color: #ffe9a8; }
.weaponFilterChip:active { transform: scale(.96); }
/* every id stays in the DOM (curation is additive); the filter only hides
 * whatever is not one of the eight core-job ids (data-core, set at build) */
#weaponPanel.core-filter .wepBtn:not([data-core]) { display: none; }
#weaponPanel.core-filter .weaponGroupHeading.wep-empty { display: none; }
.wepBtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,.07);
  border: 2px solid transparent; border-radius: 12px;
  color: #fff; padding: 8px 4px;
}
.wepBtn .ico { font-size: 26px; line-height: 1.1; height: 32px; display: flex; align-items: center; justify-content: center; }
.wepBtn .ico img { width: 32px; height: 32px; display: block; }
.wepBtn .nm { font-size: 10px; font-weight: 700; }
/* one-line role + arc glyph (L1-GP-03) */
.wepBtn .role {
  font-size: 8.5px; line-height: 1.15; font-weight: 600;
  opacity: .72; text-align: center; min-height: 20px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
}
.wepBtn .role .arc { font-size: 11px; opacity: .95; }
.wepBtn.selected .role { opacity: .95; }
/* MP-04 card completeness: control method + one limitation
 * (js/input.js weaponControlMethod/weaponLimitation). Judge r5 m5 / r6 m7:
 * truncating it to one line cut nearly every tile ("Hold to charge,
 * releas…", "Walk in, tap to strike · …"), and the full text lived only in
 * the hover tooltip a phone never shows. So it wraps in full, at word
 * breaks, balanced across its lines; a row of tiles grows to its tallest. */
.wepBtn .ctrl {
  font-size: 7.5px; line-height: 1.2; font-weight: 600; opacity: .58;
  text-align: center; white-space: normal; text-wrap: balance;
  max-width: 100%;
}
.wepBtn .am { font-size: 10px; opacity: .75; }
.wepBtn { transition: transform .12s cubic-bezier(.34, 1.56, .64, 1), background .15s; }
.wepBtn:active { transform: scale(.92); }
.wepBtn.selected { border-color: #ffd83d; background: rgba(255, 216, 61, .15); }
.wepBtn:disabled { opacity:1; background:rgba(16,29,31,.94); }
.wepBtn:disabled .ico { opacity:.35; }
.wepBtn:disabled .nm, .wepBtn:disabled .role, .wepBtn:disabled .ctrl { opacity:.65; }
.wepBtn:disabled .am { color:#ffe09b;opacity:1; }
/* The locked-reason line (js/input.js refreshWeaponPanel) replaces the
 * now-irrelevant control-method text with WHY the tile can't be picked —
 * crate-gated, uber already spent, can't afford it yet, etc. Called out in
 * amber so it reads as the answer, not just dimmed filler text. */
.wepBtn .ctrl.lockedReason { color:#ffb454; font-weight:700; }
/* Judge round 4 m8 ("Find the golden Alfie c…"): the reason is the one line
 * on a locked tile that must read in full, so it may wrap to a second line
 * rather than ellipsise. The short tile wording (js/input.js
 * refreshWeaponPanel) keeps nearly every reason on one line, so the grid
 * barely grows; the full sentence stays in the title and aria-label. */
.wepBtn .ctrl.lockedReason { white-space:normal; text-overflow:clip; overflow:hidden;
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; }
.wepBtn:disabled .ctrl.lockedReason { opacity:.9; }
.wepBtn.spent { border-color:rgba(150,150,150,.35); box-shadow:none; filter:saturate(.35); }
/* Alfie's Delight traded away this special: greyed AND struck through, so a
 * kid reading the panel can tell at a glance what the trade cost them. */
.wepBtn.traded, .quickWeapon.traded { opacity:.55; filter:grayscale(.6); }
.wepBtn.traded .nm, .wepBtn.traded .role { text-decoration: line-through; }
.wepBtn.traded .am { color:#ff9b7a;opacity:1;text-decoration:none; }
/* Alfie's Delight's confirm banner paints on the canvas the open panel
 * covers, so the tile itself pulses gold while a second tap would confirm
 * the trade — the cue a kid actually sees, right where they're looking. */
.wepBtn.pendingConfirm { border-color:#ffd700; animation: alfiesPending 0.7s ease-in-out infinite; }
.wepBtn.pendingConfirm .am { color:#ffd700; opacity:1; font-weight:800; }
/* Judge r7 B1: a weapon crate grants one free use of that one tile (a token,
 * js/rules/crates.js). The tile wears the weapon crate's blue and its badge
 * reads "📦 FREE" instead of the bank price. */
.wepBtn.crateFree { border-color:#3d7be8; box-shadow: inset 0 0 0 1px rgba(61,123,232,.55); }
.wepBtn.crateFree .am { color:#8fb8ff; opacity:1; font-weight:800; }
@keyframes alfiesPending {
  0%, 100% { background: rgba(255,215,0,.10); box-shadow: 0 0 0 rgba(255,215,0,0); }
  50% { background: rgba(255,215,0,.30); box-shadow: 0 0 14px rgba(255,215,0,.55); }
}
@media (prefers-reduced-motion: reduce) { .wepBtn.pendingConfirm { animation: none; background: rgba(255,215,0,.22); } }

@keyframes panelPop {
  from { transform: translateX(-50%) scale(.65); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* touch pad — a bottom control strip that never overlaps the play area */
#touchPad { position: absolute; inset: 0; pointer-events: none; }
/* opaque dock: the camera keeps the active unit above it, and it occludes
   whatever terrain would otherwise sit behind the walk/jump/FIRE buttons */
#touchStrip {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(84px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8,16,24,0) 0%, rgba(8,16,24,.55) 32%, rgba(8,16,24,.9) 100%);
  pointer-events: none;
}
/* the whole control strip slides away while a drag-aim is in progress so the
   thumb never fights the buttons */
#touchStrip, #padMove, #btnJump, #btnFire, #btnWeapon {
  transition: opacity .14s ease, transform .14s ease;
}
body.aiming #touchStrip, body.aiming #padMove,
body.aiming #btnJump, body.aiming #btnFire, body.aiming #btnWeapon {
  opacity: 0; pointer-events: none; transform: translateY(8px);
}
#padMove {
  position: absolute; left: calc(10px + env(safe-area-inset-left));
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 10px;
}
.padBtn {
  width: 60px; height: 60px; border-radius: 50%;
  font-size: 24px; font-weight: 900; color: #fff;
  background: rgba(10, 22, 32, .65);
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.padBtn:active { background: rgba(255,255,255,.3); }
#btnBackJump { display:flex; flex-direction:column; align-items:center; justify-content:center; line-height:1; }
#btnBackJump span { font-size:24px; }
#btnBackJump small { font-size:9px; font-weight:800; margin-top:2px; }
#btnJump {
  position:absolute; right:calc(108px + env(safe-area-inset-right));
  bottom:calc(14px + env(safe-area-inset-bottom));
}
#btnFire {
  position: absolute; right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%;
  font-size: 17px; font-weight: 900; color: #fff; letter-spacing: 1px;
  background: radial-gradient(circle at 35% 30%, #ff7a59, #d92b1f 70%);
  border: 3px solid rgba(255,255,255,.5);
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
#btnFire:active { transform: scale(.94); filter: brightness(1.2); }

#btnHelp, #btnQuit {
  position: absolute; top: calc(8px + env(safe-area-inset-top));
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(10,22,32,.7); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  font-size: 16px; font-weight: 800;
}
#btnHelp { right: calc(10px + env(safe-area-inset-right)); }
#btnQuit { left: calc(10px + env(safe-area-inset-left)); }

/* ---------- Menu / overlays ---------- */
#menu, #helpOverlay, #gameOver {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(120, 200, 120, .25), transparent),
    linear-gradient(180deg, #11304a 0%, #173a46 55%, #1d4a35 100%);
  padding: 16px;
}
#helpOverlay, #gameOver { background: rgba(8, 16, 24, .82); }

.menuCard {
  background: rgba(10, 24, 34, .92);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  padding: clamp(18px, 4vw, 36px);
  width: min(620px, 96vw);
  max-height: 92vh; overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.menuCard h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900; letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(0,0,0,.35);
}
.menuCard h1 .poo { color: #b07a3c; }
/* wordmark: drawn vector marks flank the type instead of literal emoji (L2-ART-03) */
.menuCard h1.wordmark {
  display: flex; align-items: center; justify-content: center; gap: .34em;
  flex-wrap: nowrap;
}
.menuCard h1.wordmark .tMark {
  width: 1.15em; height: 1.15em; flex: 0 0 auto;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.3));
}
.menuCard h1.wordmark .wm { white-space: nowrap; }
.tagline { margin: 0 0 22px; opacity: .85; font-size: clamp(13px, 2.5vw, 16px); }

.menuRow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 12px 0; flex-wrap: wrap;
}
.menuNote { margin: -6px 0 10px; font-size: 12px; opacity: .65; text-align: right; }
.menuLabel { font-weight: 700; font-size: 14px; opacity: .9; }
#landscapeHint { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; text-align: left; opacity: .8; }
#landscapeSeg button:disabled { cursor: default; }
.sideLabel::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; }
.sideOne::before { background: #44a8ff; }
.sideTwo::before { background: #ff5544; }
.segmented { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,.25); }
.segmented button {
  background: rgba(255,255,255,.06); color: #fff;
  min-height: 44px; padding: 10px 18px; font-size: 14px; font-weight: 700;
}
.segmented button.selected { background: #ffd83d; color: #20232a; }
.segmented button:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

#btnStart, #btnAgain, #btnCloseHelp {
  display: block; width: 100%; min-height: 44px;
  margin: 18px 0 8px;
  padding: 16px;
  font-size: 19px; font-weight: 900; letter-spacing: 1px;
  color: #20232a;
  background: linear-gradient(180deg, #ffe066, #ffc933);
  border-radius: 14px;
  box-shadow: 0 5px 0 #b8860b, 0 8px 18px rgba(0,0,0,.4);
}
#btnStart:active, #btnAgain:active, #btnCloseHelp:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8860b; }
button.ghost {
  background: transparent; color: #fff; opacity: .8;
  padding: 10px; width: 100%; font-size: 14px; font-weight: 700;
  text-decoration: underline;
}

.menuCard.help { text-align: left; }
.menuCard.help h2 { margin-top: 0; text-align: center; }
.menuCard.help h3 { margin: 10px 0 4px; font-size: 15px; }
.menuCard.help ul { margin: 4px 0 10px; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.helpCols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px; }
@media (max-width: 560px) { .helpCols { grid-template-columns: 1fr; } }
.performanceReport {
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 12px;
  background: rgba(255,255,255,.05); text-align: center;
}
.performanceReport h3 { margin-top: 0; }
.performanceReport p { margin: 4px 0 8px; font-size: 12px; line-height: 1.4; opacity: .82; }
#btnPerformanceReport, #btnPerformanceFallback {
  min-height: 44px; border: 1px solid rgba(255,255,255,.32); border-radius: 10px;
  text-decoration: none;
}
#btnPerformanceFallback { margin-top: 7px; }
#btnPerformanceReport:focus-visible, #btnPerformanceFallback:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#btnPerformanceReport:disabled, #btnPerformanceFallback:disabled { opacity: .45; cursor: wait; }
.performanceReport .performanceReport__status { min-height: 17px; margin-bottom: 0; font-weight: 700; opacity: 1; }

#gameOver .menuCard h1 { font-size: clamp(24px, 6vw, 42px); }
#winnerSub { opacity: .85; }

/* Landscape-only rotate gate (mobile, L2-GP-07). A full-screen, opaque overlay
 * ABOVE everything (menu 50 / help 55 / game-over) with pointer-events on, so a
 * tap or drag in portrait lands on the gate and never reaches the board or the
 * menu beneath it. Shown / hidden by js/ui/orientation.js (the .hidden class);
 * it only ever adds .hidden's removal on a portrait, phone-width viewport. */
#rotateGate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: radial-gradient(120% 90% at 50% 20%, #22364a 0%, #0e1620 78%);
  color: #f4ead8; pointer-events: auto; text-align: center;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.rotateGate__card { max-width: 320px; }
.rotateGate__icon {
  width: 108px; height: 108px; color: #ffe135;
  animation: rgTip 2.4s ease-in-out infinite;
}
.rotateGate__icon .rgArrow { color: #f4ead8; }
.rotateGate__title {
  margin: 10px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: .3px;
}
.rotateGate__copy { margin: 0; font-size: 14px; line-height: 1.5; opacity: .85; }
/* the phone tips from portrait toward landscape and back — a "do this" nudge */
@keyframes rgTip {
  0%, 40%, 100% { transform: rotate(0deg); }
  70%, 85%      { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .rotateGate__icon { animation: none; }
}

/* one-thumb aim coach mark: a quiet line above the control strip on touch */
#aimHint {
  position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(8,16,24,.72); color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px;
  z-index: 11; pointer-events: none;
  border: 1px solid rgba(255,255,255,.18);
}
body.aiming #aimHint { opacity: 0; }
#aimHint.melee-hint, #aimHint.material-hint {
  max-width: calc(100% - 24px); white-space: normal;
  text-align: center; line-height: 1.3;
}
body.aiming #aimHint.material-hint { opacity: 1; }

/* ---------- short viewports (landscape phones, e.g. 844×390) ----------
   the whole menu — including START — must fit one screen without scrolling */
@media (max-height: 480px) {
  .menuCard { padding: 14px 22px; max-height: 96vh; border-radius: 16px; }
  .menuCard h1 { font-size: clamp(22px, 6vw, 34px); margin-bottom: 2px; }
  .tagline { margin: 0 0 10px; font-size: 12px; }
  .menuRow { margin: 8px 0; }
  .menuNote { margin: -4px 0 6px; }
  .segmented button { padding: 7px 14px; font-size: 13px; }
  #btnStart, #btnAgain, #btnCloseHelp { margin: 10px 0 4px; padding: 11px; font-size: 17px; }
  button.ghost { padding: 6px; font-size: 13px; }
}
/* very short viewports (e.g. 844×390 landscape phones): a two-column layout so
   the FULL menu — Mode, Team size, CPU skill AND START — fits without scrolling
   even in vs-Computer mode, where the CPU row is present (L1-ART-06, F11). */
@media (max-height: 420px) {
  #menu .menuCard {
    display: grid; grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "tagline tagline"
      "mode solo"
      "size cpu"
      "landscape landscape"
      "ledger ledger"
      "version version"
      "start start"
      "actions actions";
    gap: 3px 20px; align-items: center;
    padding: 10px 20px; max-height: 98vh;
  }
  #menu.pvp .menuCard {
    grid-template-areas:
      "title title"
      "tagline tagline"
      "mode size"
      "p1 p2"
      "landscape landscape"
      "ledger ledger"
      "version version"
      "start start"
      "actions actions";
  }
  #menu .menuCard h1 { grid-area: title; }
  #menu .menuCard .tagline { grid-area: tagline; }
  #rowMode { grid-area: mode; }
  #rowSoloSpecies { grid-area: solo; }
  #rowP1Species { grid-area: p1; }
  #rowP2Species { grid-area: p2; }
  #rowSize { grid-area: size; }
  #rowLandscape { grid-area: landscape; }
  #rowCpu { grid-area: cpu; }
  #menuLedger { grid-area: ledger; }
  #releaseVersion { grid-area: version; }
  #btnStart { grid-area: start; }
  #menu .menuActions { grid-area: actions; }
  #menu .menuCard h1, #menu .menuCard .tagline,
  #menu .menuCard .menuLedger,
  #menu .menuCard #btnStart, #menu .menuCard #btnHowTo { grid-column: 1 / -1; }
  #menu .menuCard h1 { font-size: clamp(20px, 5vw, 30px); margin: 0; }
  #menu .menuCard .tagline { margin: 0 0 2px; font-size: 11px; }
  #menu .menuNote { display: none; }
  #menu .menuRow { margin: 2px 0; flex-wrap: nowrap; }
  #menu .segmented button { padding: 6px 12px; font-size: 12px; }
  #menu #btnStart { margin: 6px 0 2px; padding: 9px; font-size: 16px; }
  #menu #btnHowTo { padding: 3px; font-size: 12px; }
}

/* the shortest landscape phones (e.g. iPhone landscape with browser bars,
   ~342 px): drop the flavour tagline and tuck the build tag into the card's
   corner so the whole menu, START and the footer included, fits unscrolled
   in both vs-Computer and 2-Player modes. */
@media (max-height: 360px) and (orientation: landscape) {
  #menu .menuCard { position: relative; }
  #menu .menuCard .tagline { display: none; }
  #menu #releaseVersion { position: absolute; top: 8px; right: 14px; margin: 0; }
}

/* collapse the CPU-skill row in 2-Player mode (no CPU to configure) —
   also reclaims vertical space so the default menu fits a short screen */
#menu.pvp #rowCpu { display: none; }
#menu:not(.pvp) .pvpSpecies { display: none; }
#menu.pvp #rowSoloSpecies, #menu.pvp #soloMatchup { display: none; }

/* one-line persisted ledger under the menu segments (L1-GP-07) */
.menuLedger {
  margin: 4px 0 0; font-size: 13px; font-weight: 700;
  color: #ffe98a; opacity: .92; letter-spacing: .3px;
}
.releaseVersion { margin: 2px 0 0; text-align: right; font-size: 10px; letter-spacing: .12em; opacity: .48; }
.updateNotice {
  position: fixed; z-index: 70; left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  max-width: min(92vw, 440px); padding: 9px 12px; border-radius: 14px;
  color: #fff7dc; background: rgba(24,45,50,.96); border: 2px solid #ffd15a;
  box-shadow: 0 5px 18px rgba(0,0,0,.38); font-size: 13px; font-weight: 700;
}
.updateNotice button { min-height: 38px; padding: 5px 12px; border-radius: 10px; font-weight: 900; }
/* "Change difficulty" lands here: pull the CPU row forward for a beat */
#rowCpu.rowFocus {
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(255, 216, 61, .9), 0 0 18px rgba(255, 216, 61, .5);
  animation: rowFocusPulse 1.6s ease-out;
}
@keyframes rowFocusPulse { 0% { box-shadow: 0 0 0 4px rgba(255,216,61,.95); } 100% { box-shadow: 0 0 0 2px rgba(255,216,61,.0); } }

/* ---------- end-of-match results screen (L1-GP-07) ---------- */
#resultsCard {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 16, 24, .86);
  padding: 16px;
}
.menuCard.resCard { width: min(680px, 96vw); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.resSummary { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.resSummary:focus-visible { outline: 2px solid #ffe066; outline-offset: -2px; }
.resTitle { margin: 0 0 4px; font-size: clamp(22px, 5.5vw, 40px); }
.resSub { margin: 0 0 14px; opacity: .82; font-size: clamp(12px, 2.4vw, 15px); font-weight: 700; letter-spacing: .5px; }
.resTeams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.resTeam {
  border: 2px solid var(--tc, rgba(255,255,255,.25));
  border-radius: 14px; padding: 10px 12px;
  background: rgba(255,255,255,.04);
}
.resTeam.win { background: color-mix(in srgb, var(--tc) 16%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--tc) 45%, transparent); }
.resTeamName { font-weight: 900; font-size: clamp(14px, 3vw, 18px); color: var(--tc); margin-bottom: 6px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.resStat { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; line-height: 1.7; }
.resStat span { opacity: .82; }
.resStat b { font-variant-numeric: tabular-nums; font-weight: 900; }
.resShared {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  margin: 14px 0 4px; font-size: 13px; font-weight: 700;
}
.resShared b { font-weight: 900; }
.resMvp b { color: #ffd83d; }
.resButtons { display: grid; flex-shrink: 0; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.resButtons button {
  padding: 13px; font-size: 15px; font-weight: 800; letter-spacing: .5px;
  color: #fff; border-radius: 12px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.22);
}
.resButtons button:active { transform: translateY(2px); }
.resButtons .resPrimary {
  grid-column: 1 / -1; color: #20232a;
  background: linear-gradient(180deg, #ffe066, #ffc933);
  box-shadow: 0 4px 0 #b8860b, 0 7px 16px rgba(0,0,0,.4); border: none;
}
.resButtons .resPrimary:active { box-shadow: 0 2px 0 #b8860b; }
.resButtons .ghost { grid-column: 1 / -1; background: transparent; text-decoration: underline; opacity: .85; }
@media (max-width: 520px) { .resTeams { grid-template-columns: 1fr; } }
@media (max-height: 480px) {
  #resultsCard { padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
  .menuCard.resCard { padding: 12px; }
  .resTitle { font-size: clamp(18px, 5vw, 28px); }
  .resSub { margin-bottom: 8px; }
  .resStat { line-height: 1.45; }
  .resButtons { margin-top: 8px; gap: 6px; }
  .resButtons button { padding: 9px; min-height: 44px; font-size: 14px; }
  .resButtons .resPrimary, .resButtons .ghost { grid-column: auto; }
}

/* wood-plank results card (L1-ART-06): carved-wood UI, paper drop shadow.
   Horizontal grain + vertical plank seams over a warm wood gradient. */
.menuCard.resCard {
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.10) 0 3px, rgba(255,255,255,.035) 3px 6px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0) 0 92px, rgba(0,0,0,.28) 92px 96px),
    linear-gradient(180deg, #8a5a34 0%, #74492a 55%, #603c22 100%);
  border: 3px solid #43281699;
  box-shadow: 0 22px 60px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.14), inset 0 -3px 0 rgba(0,0,0,.3);
}
.menuCard.resCard .resTitle { text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.menuCard.resCard .resTeam { background: rgba(0,0,0,.18); }

/* ---------- economy strip (per side): ammo · trees · ripe ---------- */
.econ {
  display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 3px;
  font-size: 12px; font-weight: 800; line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.teamBar.right .econ { justify-content: flex-end; }
.econItem { display: inline-flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.econLbl { font-size: 9px; font-weight: 700; letter-spacing: .5px; opacity: .7; text-transform: uppercase; }
.econPending { font-size: 10px; opacity: .85; color: #ffd47f; }
/* weapon crate tokens held (judge r7 B1): free uses of one tile, not bank */
.econCrate { font-size: 10px; font-weight: 800; color: #8fb8ff; white-space: nowrap; }
.econWorld { display: flex; flex-basis: 100%; align-items: baseline; gap: 6px; }
.econSharedLabel { font-size: 9px; font-weight: 700; text-transform: uppercase; opacity: .85; }
.teamBar.right .econWorld { justify-content: flex-end; }
.econAmmo { padding-right: 6px; border-right: 1px solid rgba(255,255,255,.25); align-items: center; gap: 4px; }
@media (max-width: 900px) { .econLbl { display: none; } }

/* ammo as three pips that bounce on gain/spend (L1-ART-06) */
.econPips { display: inline-flex; gap: 3px; align-items: center; }
.econPips .pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(0,0,0,.35);
  transition: background .15s ease;
}
.econPips[data-kind="banana"] .pip.on { background: #FFD23F; box-shadow: 0 0 5px rgba(255,210,63,.6); }
.econPips[data-kind="poo"] .pip.on { background: #7A4A2A; box-shadow: 0 0 5px rgba(122,74,42,.6); }
.econPips .pip.bounce { animation: pipBounce .34s cubic-bezier(.34,1.56,.64,1); }
@keyframes pipBounce { 0% { transform: scale(1); } 40% { transform: scale(1.7); } 100% { transform: scale(1); } }

/* ---------- hint toast: one slot, own BOTTOM lane above #btnWeapon ----------
   turn banners own the top lane (canvas, below #hudTop); hints live down here
   so the two never collide and neither ever covers the timer (L1-ART-06) */
.hintToast {
  position: absolute; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translate(-50%, 0) scale(.9);
  width: max-content; max-width: min(92vw, 640px);
  padding: 8px 16px; border-radius: 14px;
  background: rgba(10, 22, 32, .86);
  border: 1px solid rgba(255, 233, 138, .55);
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  color: #ffe98a; font-size: clamp(13px, 2.1vw, 18px); font-weight: 800;
  line-height: 1.3; text-align: center;
  overflow-wrap: anywhere;
  opacity: 0; transition: opacity .2s ease, transform .26s cubic-bezier(.34, 1.56, .64, 1);
  z-index: 11;
}
.hintToast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
/* Combat results keep the previous actor and complete outcome readable while
   the next player uses controls. Hud measures a lane above every visible input. */
.hintToast[data-key="attack-result"] { pointer-events: none; }
/* Small landscape screens need the terrain visible above the weapon dock.
   The complete text remains in the live region for assistive technology. */
@media (orientation: landscape) and (max-height: 500px) {
  .hintToast {
    max-width: min(72vw, 360px);
    padding: 5px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 600; line-height: 1.3;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    pointer-events: none;
  }
  .hintToast__text {
    display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; overflow: hidden;
  }
}

/* Combat recap: one compact line in the top strip, directly under the top HUD
   (hud.js seats it left/centre/right clear of the active unit and its aim).
   Too long for the strip: js/ui/hud.js's fitPhoneRecap shortens it in whole
   clauses first (see the .recapShort rule below, which now runs at every
   width); the text-overflow:ellipsis a few rules down is only the last-resort
   safety net for whatever that JS pass still could not fit, so a real
   sentence is never silently cropped mid-word by CSS alone (judge-r1
   desk-s7301: desktop previously had no JS pass and relied on this ellipsis
   for everything). The full sentence always stays in the DOM/title. */
.hintToast.recapTop {
  top: 0; bottom: auto; left: 0;
  transform: none; max-width: min(70vw, 620px);
  padding: 3px 12px; border-radius: 999px;
  background: rgba(10, 22, 32, .72); border-color: rgba(255, 233, 138, .35);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  font-size: 14px; font-weight: 700; line-height: 1.35;
  white-space: nowrap; overflow-wrap: normal;
  transition: opacity .2s ease;
}
.hintToast.recapTop.show { transform: none; }
.hintToast[data-key="attack-result"] .hintToast__text,
.hintToast[data-key="cpu-intent"] .hintToast__text {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  -webkit-line-clamp: unset;
}
/* One-line recap fit (js/ui/hud.js fitPhoneRecap, any width): the full
   sentence stays in the DOM for assistive tech; only the whole-clause-
   shortened line in data-short is actually painted, through this swap. The
   ::before font-size must match .recapTop's own at each breakpoint (14px
   here, 12px under the landscape override below) since fitPhoneRecap
   measures the plain text at that size before choosing what to paint. */
.hintToast.recapTop .hintToast__text.recapShort { font-size: 0; }
.hintToast.recapTop .hintToast__text.recapShort::before { content: attr(data-short); font-size: 14px; }
@media (orientation: landscape) and (max-height: 500px) {
  .hintToast.recapTop { max-width: min(58vw, 520px); padding: 2px 10px; font-size: 12px; }
  .hintToast.recapTop .hintToast__text.recapShort::before { font-size: 12px; }
}

/* ---------- world-space prompt over a ripe tree ---------- */
.treePrompt {
  position: absolute; left: 0; top: 0;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(10, 22, 32, .78);
  border: 1px solid rgba(255,255,255,.35);
  color: #ffe135; font-size: 12px; font-weight: 800; white-space: nowrap;
  animation: promptBob 1.1s ease-in-out infinite;
  will-change: transform;
}
.treePrompt::after {
  content: ''; position: absolute; left: var(--tree-anchor, 50%); top: var(--tree-pointer-y,100%);
  border: 6px solid transparent; border-top-color: rgba(10, 22, 32, .78);
  transform: translateX(-50%) rotate(var(--tree-pointer-rotation,0deg)); transform-origin:50% 0;
}
.treePrompt::before { content:''; position:absolute; left:var(--tree-anchor,50%); top:var(--tree-pointer-y,100%);
  width:var(--tree-line-length,0px);height:1px;background:rgba(255,242,201,.5);
  transform:rotate(var(--tree-line-angle,0rad));transform-origin:0 50%;pointer-events:none; }
.treePrompt--human { color: #ffe135; }
.treePrompt--monkey { color: #8be04a; }
@keyframes promptBob { 0%, 100% { margin-top: 0; } 50% { margin-top: -4px; } }

/* ---------- interactive first-run onboarding (L2-GP-06) ----------
 * A guided first shot. The backdrop is CLICK-THROUGH (pointer-events:none) so
 * it never blocks an aim drag, the FIRE button or the weapon pill — only the
 * Skip button (re-enabled below) is interactive. Sits above the HUD but below
 * the menu / help / rotate-gate overlays so those cover it when open. */
#onboarding {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
}
.ob-card {
  /* Compact, and placed by onboarding.js each frame on a spot clear of the
   * thrower, the marked target and every HUD control (top centre preferred). */
  position: absolute; left: 50%; top: calc(58px + env(safe-area-inset-top));
  width: min(360px, 48vw); min-width: 240px; box-sizing: border-box;
  padding: 7px 12px 8px; text-align: left;
  background: rgba(10, 24, 34, .9);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  animation: obPop .28s cubic-bezier(.34, 1.56, .64, 1);
  transition: left .25s ease, top .25s ease;
}
.ob-card.ob-snap { transition: none; }
.ob-card::before { content: ''; float: right; width: 50px; height: 16px; } /* room for Skip */
.ob-step {
  display: inline-block; margin: 0 6px 0 0; vertical-align: 1px;
  font-size: 9px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  color: #0b1a24; background: #ffe135;
  padding: 1px 7px; border-radius: 999px;
}
.ob-title { display: inline; margin: 0; font-size: 14px; font-weight: 800; color: #fff; }
.ob-hint { margin: 3px 0 0; padding-right: 2px; font-size: 12px; line-height: 1.3; opacity: .9; color: #dfe8ee; }
.ob-loop {
  margin: 4px 0 0; padding-top: 4px;
  border-top: 1px dashed rgba(255,255,255,.18);
  font-size: 11px; line-height: 1.3; font-weight: 700; color: #8be04a;
}
.ob-loop .gmark { width: 13px; height: 13px; vertical-align: -2px; }
/* Short landscape phones: title + hint only; the loop line waits for taller screens. */
@media (max-height: 500px) { .ob-loop { display: none; } }
.ob-skip {
  pointer-events: auto;             /* the ONLY interactive part of the overlay */
  position: absolute; top: 5px; right: 6px;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800; cursor: pointer;
}
.ob-skip:active { transform: scale(.96); }
/* edge arrow: the named target is off screen on this side (onboarding.js) */
.ob-arrow {
  position: absolute; top: 50%; margin-top: -13px;
  width: 26px; height: 26px; line-height: 26px; text-align: center;
  font-size: 14px; color: #0b1a24; background: #ffe135; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}
.ob-arrow.ob-left { left: -13px; }
.ob-arrow.ob-right { right: -13px; }
.ob-arrow.hidden { display: none; }
/* pulsing ring parked over the highlighted target (positioned by onboarding.js) */
.ob-ring {
  position: absolute; left: 0; top: 0;
  width: 74px; height: 74px; margin: -37px 0 0 -37px;
  border: 3px solid #ffe135; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 16px rgba(255,225,53,.6);
  animation: obRing 1.1s ease-in-out infinite;
}
/* coach v2 (onboarding.js): one-line, card-free nudges after the guided shot.
 * Own fixed overlay so the card's hidden state never hides them; never
 * interactive; placed once by JS inside the HUD-safe band. No animation. */
#onboardingLines { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.ob-nudge {
  position: absolute; left: 0; top: 0; max-width: min(420px, 90vw);
  padding: 4px 12px 5px; box-sizing: border-box; white-space: normal;
  font-size: 12px; line-height: 1.3; font-weight: 800; color: #fff;
  background: rgba(10, 24, 34, .9);
  border: 1px solid rgba(255,255,255,.22); border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.ob-nudge.ob-hit { color: #0b1a24; background: #8be04a; border-color: rgba(0,0,0,.25); }
.ob-nudge.hidden, .ob-cover.hidden { display: none; }
/* Miss glance (js/ui/hud.js MissGlance): one line + an impact ring for 1.5 s
 * after every human shot. Placed by JS inside the aim preview's safe band. */
#missGlance { position: fixed; inset: 0; z-index: 39; pointer-events: none; }
#missGlance .mg-line {
  position: absolute; left: 0; top: 0; max-width: min(320px, 80vw);
  padding: 3px 10px 4px; box-sizing: border-box; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; line-height: 1.3; font-weight: 800; color: #fff;
  background: rgba(10, 24, 34, .88);
  border: 1px solid rgba(255,255,255,.22); border-radius: 999px;
}
#missGlance .mg-line.mg-hit { color: #0b1a24; background: #8be04a; border-color: rgba(0,0,0,.25); }
#missGlance .mg-line.mg-wind { color: #7fd4ff; }
#missGlance .mg-mark {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -9px 0 0 -9px;
  border: 2px solid #ffe066; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
#missGlance .hidden { display: none; }
/* marker on the nearest rise the cover line points at (its tip sits on the rise) */
.ob-cover {
  position: absolute; left: 0; top: 0; margin: -22px 0 0 -9px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  font-size: 15px; font-weight: 900; color: #ffe135;
  text-shadow: 0 0 2px #0b1a24, 0 0 2px #0b1a24, 0 1px 3px rgba(0,0,0,.7);
}
@keyframes obPop { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
@keyframes obRing {
  0%, 100% { transform: scale(1); opacity: .95; }
  50% { transform: scale(1.18); opacity: .55; }
}
@media (prefers-reduced-motion: reduce) {
  .ob-card, .ob-ring { animation: none; }
}

/* Assists → Full aim arc (critic pass 6). A compact one-line row at every
   size (the 1280x720 card has 54 px of slack, not a whole 58 px row), and on
   short landscape screens it shares the footer line with the menu actions so
   the menu, START included, still fits unscrolled. */
#rowAssists { margin: 0; }
#rowAssists .menuLabel { font-size: 13px; }
#rowAssists .menuLabel small { display: none; }
#menu #rowAssists .segmented button { min-height: 28px; padding: 2px 12px; font-size: 13px; }
@media (min-height: 421px) { #menu .menuCard { max-height: 96vh; } }
@media (max-height: 420px) {
  #menu .menuCard { grid-template-areas:
      "title title" "tagline tagline" "mode solo" "size cpu" "landscape landscape"
      "ledger ledger" "version version" "start start" "assists actions"; }
  #menu.pvp .menuCard { grid-template-areas:
      "title title" "tagline tagline" "mode size" "p1 p2" "landscape landscape"
      "ledger ledger" "version version" "start start" "assists actions"; }
  #rowAssists { grid-area: assists; }
  #rowAssists .menuLabel small { display: none; }
  #menu #rowAssists { margin: 0; }
}
