/* UC-L1 (11-09, a cartoon castle-builder): chunky wooden panels in a stone frame, gold numerals, no thin bright edges. The wood,
   stone and gold are render/look.js UI's values (the HUD canvas draws the same panels); --panel is the planks' colour that
   tools/colour_check.py holds the player labels to */
:root { --ink: #f4f1e8; --dim: #e2d6c2; --panel: rgba(58, 36, 18, 0.94); --bad: #ffb4a8; --gold: #ffd24a;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --wood: linear-gradient(180deg, #8a5a30 0%, #6b4423 45%, #4e2f16 100%); --stone: #b5ac98; --stone-dark: #6f6757; --inkline: #1c1410;
  --frame: 3px solid var(--stone); --lift: 0 3px 0 var(--stone-dark), 0 5px 8px rgba(0, 0, 0, 0.35); }
html, body { margin: 0; height: 100%; background: #0b1622; color: var(--ink); font-family: var(--font); overflow: hidden; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* LOAD_UC.md UC-L7: while the page boots, the renderer warms up its pipelines by drawing one of every model, and draws the first
   island once, into these canvases; they stay hidden until the game's first real frame is on the GPU (main.js reveal), then fade in.
   (11-11, RJ: "When the game loads there is a few frames of random black and white models") */
body.booting #view, body.booting .render-hud { visibility: hidden; }
/* CHECK_UC.md: the ?check=1 page's text */
#ui .checkinfo { position: absolute; left: 12px; top: 12px; right: 12px; background: var(--panel); border: var(--frame); border-radius: 12px;
  padding: 8px 12px; font: 600 12px/1.45 var(--font); color: var(--ink); word-break: break-word; }
#ui .checkinfo div:first-child { font-weight: 900; color: var(--gold); }
#ui .checklabel { position: absolute; transform: translate(-50%, 0); font: 800 13px/1 var(--font); color: #fff; text-shadow: 0 1px 2px #000; white-space: nowrap; }
#view, .render-hud { transition: opacity 0.35s ease-out; }
body.revealing #view, body.revealing .render-hud { opacity: 0; }
#boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b1622; color: var(--dim);
  flex-direction: column; gap: 10px; text-align: center; padding: 0 16px;
  font: 800 16px/1.3 var(--font); letter-spacing: 0.12em; z-index: 100; transition: opacity 0.35s ease-out; }   /* over the page's own buttons too */
#boot small { font: 600 12px/1.4 var(--font); letter-spacing: 0.04em; color: var(--dim); max-width: 60ch; }
#boot .bad { color: var(--bad); }
body:not(.booting) #boot { opacity: 0; pointer-events: none; }
#ui { position: fixed; inset: 0; pointer-events: none; user-select: none; z-index: 2; }
#ui .foot { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(1100px, calc(100% - 32px)); box-sizing: border-box;
  background: var(--panel); border: var(--frame); box-shadow: var(--lift); border-radius: 14px; padding: 8px 14px; text-align: center; font-size: 13px; line-height: 1.5; }
#ui .devs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; font-weight: bold; }
#ui .sub { color: var(--dim); }
#ui .note { color: var(--bad); }
#ui .keys { color: var(--dim); }
#ui .corner { position: absolute; left: 12px; top: 64px; color: var(--gold); font-size: 13px; background: var(--panel); border: var(--frame); padding: 4px 10px; border-radius: 10px; }
#nogpu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }
#nogpu div { max-width: 70ch; font-size: 18px; line-height: 1.5; white-space: pre-wrap; }
#nogpu h1 { color: var(--gold); }
#ui .credits { margin-top: 6px; font-size: 11px; color: var(--dim); pointer-events: auto; }
#ui .credits a { color: var(--ink); }
/* the page never scrolls, pans or zooms under a finger: every touch is the game's */
html, body, #view { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* the CONTROLS choice on the join screen */
#ui .ctl { pointer-events: auto; display: inline-flex; gap: 6px; align-items: center; margin-bottom: 6px; font-weight: bold; }
#ui .ctl button { font: 800 13px/1 var(--font); color: var(--ink); background: var(--wood); border: var(--frame); box-shadow: 0 2px 0 var(--stone-dark);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; min-height: 32px; }
#ui .ctl button.on { background: #1957ff; border-color: var(--gold); color: #fff; }
/* player 1's touch controls: a stick on the left, A B Y on the right, sized for thumbs, above the player cards */
.tpad { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.tpad[hidden] { display: none; }
.tstick, .tb, .tpause, .tframe { pointer-events: auto; touch-action: none; }
.tstick { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 12vh);
  width: min(36vmin, 170px); height: min(36vmin, 170px); border-radius: 50%; background: rgba(58,36,18,0.45);
  border: 4px solid rgba(181,172,152,0.8); box-sizing: border-box; }
.tknob { position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; border-radius: 50%; background: var(--wood);
  border: 3px solid var(--stone); box-shadow: 0 3px 0 var(--stone-dark); pointer-events: none; }
.tbtns { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 12vh);
  width: min(44vmin, 210px); height: min(44vmin, 210px); }
.tb { position: absolute; width: 42%; height: 42%; border-radius: 50%; font: 900 min(7vmin, 30px)/1 var(--font); color: #fff;
  border: 3px solid var(--stone); box-shadow: 0 3px 0 var(--stone-dark); background: rgba(58,36,18,0.7); padding: 0; text-shadow: 0 2px 0 var(--inkline); }
.tb.down { filter: brightness(1.6); transform: scale(0.94); }
.tb-a { right: 0; bottom: 0; background: rgba(47,159,95,0.82); }
.tb-b { right: 0; top: 0; background: rgba(196,67,63,0.82); }
.tb-y { left: 0; bottom: 0; background: rgba(214,160,30,0.85); }
.tpause { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: max(12px, env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 50%; font: 900 15px/1 var(--font); color: var(--gold); background: var(--wood);
  border: 3px solid var(--stone); box-shadow: 0 2px 0 var(--stone-dark); }
.tframe { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: calc(max(12px, env(safe-area-inset-right)) + 52px);
  width: 44px; height: 44px; border-radius: 50%; font: 900 20px/1 var(--font); color: var(--gold); background: var(--wood);
  border: 3px solid var(--stone); box-shadow: 0 2px 0 var(--stone-dark); padding: 0; }
/* a short screen (a phone held sideways): a compact foot, so the join screen's rows end above it (render/hud.js FOOT) */
@media (max-height: 559px) {
  #ui .foot { bottom: 6px; padding: 4px 10px; font-size: 11px; line-height: 1.35; }
  #ui .ctl { margin-bottom: 2px; }
  #ui .ctl button { padding: 5px 12px; min-height: 32px; font-size: 12px; }   /* a thumb's tap target, still inside the 84 px foot */
}
/* the how-to card on the join screen (overlay.js howto): left of the menu rows on a wide or a short screen, above the foot on a
   narrow one (a phone held upright); --foot-h is the foot's measured height */
#ui .howto { position: absolute; left: 16px; top: 46%; width: 250px; background: var(--panel); border: var(--frame); box-shadow: var(--lift);
  border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.35; text-align: left; }
#ui .hhead { font-weight: 900; color: var(--gold); letter-spacing: 0.08em; font-size: 12px; }
#ui .hgoal { color: var(--dim); margin: 3px 0 2px; }
#ui .hrow { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
#ui .ico { flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-height: 559px) {
  /* left of the menu rows, which start 230 px left of the middle (render/hud.js drawSetup half): 50vw - 230 - the 8 px gutter and 8 px gap */
  #ui .howto { top: 34%; left: 8px; box-sizing: border-box; width: min(205px, calc((50vw - 246px) / var(--ts, 1))); padding: 6px 9px; font-size: 11px; line-height: 1.3; }
  #ui .hhead { font-size: 11px; }
  #ui .hrow { margin-top: 4px; }
  #ui .ico { flex-basis: 18px; width: 18px; height: 18px; }
}
/* a phone held sideways narrower than 800 px has under 154 px beside the rows: no room for the card, so it is not shown there */
@media (max-height: 559px) and (max-width: 799px) { #ui .howto { display: none; } }
@media (max-width: 639px) and (min-height: 560px) {
  #ui .howto { top: auto; left: 16px; right: 16px; width: auto; bottom: calc(var(--foot-h, 140px) + 24px); }
}
/* the first match's hint strip (overlay.js HintStrip): under the top bar; it fades after the first round */
.hint { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); top: 50px; max-width: calc(100% - 24px); box-sizing: border-box;
  background: var(--panel); border: var(--frame); box-shadow: var(--lift); border-radius: 18px; padding: 6px 16px; font: 700 15px/1.3 var(--font);
  color: var(--ink); display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; text-align: center; pointer-events: none;
  transition: opacity 1.2s ease; opacity: 1; width: max-content; }
.hint[hidden] { display: none; }
.hint b { color: var(--gold); font-weight: 900; }
.hint.gone { opacity: 0; }
.hint .goals { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }   /* UC-T2: the phase's goals */
.hint .goal { color: rgba(255, 240, 215, 0.75); font-weight: 800; }
.hint .goal i { font-style: normal; color: var(--gold); }
.hint .goal.done { color: #9be07a; }
@media (max-width: 639px), (max-height: 559px) { .hint { font-size: 13px; padding: 5px 12px; } }

/* the action bar (app/actions.js): the mouse and keyboard player's labelled buttons, centred above the player cards */
/* width: max-content (11-10): a fixed box at left 50% is laid out in the half of the window right of its left edge, so at 1440 px the
   seven-button row (728 px) wrapped Ready onto a line of its own; the max-width still lets a phone's narrow row wrap */
.abar { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: 100px; display: flex; gap: 8px; width: max-content; max-width: calc((100vw - 24px) / var(--ts, 1));
  pointer-events: auto; touch-action: none; }
.abar[hidden] { display: none; }
/* CONTROLS_SMOOTH_UC.md UC-C2 step 1: while a started match is held (main.js prepareLevel) the Playing screen's overlays are painted as
   they will be, all but transparent and untouchable, so their first paint is paid there and not in the match's first frames; .warmed
   is the frame after, so the hint strip's fade does not run as they come in */
body.warming .abar, body.warming .hint, body.warming .tpad { opacity: 0.004 !important; pointer-events: none !important; transition: none !important; }
body.warmed .abar, body.warmed .hint, body.warmed .tpad { transition: none !important; }
.ab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 96px; min-height: 52px; padding: 5px 12px;
  font: 800 15px/1.1 var(--font); color: #fff; text-shadow: 0 2px 0 var(--inkline); background: var(--wood); border: var(--frame);
  box-shadow: var(--lift); border-radius: 14px; cursor: pointer; }
.ab .at { font: 900 11px/1 var(--font); color: var(--gold); letter-spacing: 0.06em; min-height: 11px; }
.ab .ak { font: 600 11px/1 var(--font); color: rgba(255,240,215,0.8); }
.ab:hover:not(.off) { filter: brightness(1.18); border-color: var(--gold); }
.ab.down { filter: brightness(1.4); transform: translateY(2px) scale(0.97); box-shadow: 0 1px 0 var(--stone-dark); }
.ab.on { background: linear-gradient(180deg, #d0453c, #8e1f19); border-color: var(--gold); }
.ab.off { opacity: 0.45; cursor: default; filter: saturate(0.4); }

/* the action bar has two rows: the verbs (row 0) and, in the bomb rule set, the shop with the score (row 1) */
.abar { flex-direction: column; align-items: center; gap: 6px; }
.abr { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.abr[hidden], .ab[hidden], .abscore[hidden] { display: none; }
.abscore { align-self: center; padding: 6px 12px; font: 900 15px/1 var(--font); color: var(--gold); text-shadow: 0 2px 0 var(--inkline); background: var(--wood);
  border: 3px solid var(--gold); box-shadow: var(--lift); border-radius: 14px; min-height: 44px; display: flex; align-items: center; box-sizing: border-box; }
.abr1 .ab { min-width: 84px; min-height: 48px; }
.ab.poor { opacity: 0.6; border-color: #c97a6c; filter: saturate(0.5); }
.ab[data-action="defuse"].down { background: #b3261e; }
/* touch: the shop row alone, small, above the stick and the A / B / Y buttons */
.abar.compact .abr0 { display: none; }
.abar.compact .abr1 .ab { min-width: 56px; min-height: 44px; padding: 3px 5px; font-size: 12px; }
.abar.compact .abr1 .ab .ak { display: none; }
.abar.compact .abr1 .ab .at { font-size: 9px; }
.abar.compact .abscore { padding: 3px 7px; font-size: 12px; min-height: 36px; }
.abar.compact .abr1 { gap: 4px; }
/* the touch buttons say what they do in the bomb rule set */
.tb[data-cap]::after { content: attr(data-cap); position: absolute; left: 0; right: 0; bottom: 8%; font: 800 9px/1 var(--font); letter-spacing: 0.08em; text-align: center; }
@media (max-height: 559px) { .abr1 .ab { min-width: 70px; min-height: 42px; padding: 3px 7px; font-size: 13px; } }
.abar.compact .abr1 { flex-wrap: wrap; }

.tshop { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: calc(max(12px, env(safe-area-inset-right)) + 104px); pointer-events: auto; touch-action: none;
  width: 44px; height: 44px; border-radius: 50%; font: 900 10px/1 var(--font); letter-spacing: 0.04em; color: var(--gold); background: var(--wood); border: 3px solid var(--gold); box-shadow: 0 2px 0 var(--stone-dark); padding: 0; }
.tshop[hidden] { display: none; }
.tshop.on { background: #b3261e; }

/* the page's host (app/host.js): its lines on the title footer, and the CONTROLS buttons it does not allow */
#ui .hostline { margin-top: 6px; font-size: 12px; font-weight: bold; color: var(--dim); }
#ui .hostline.bad { color: var(--bad); }
#ui .ctl button[disabled] { opacity: 0.45; cursor: not-allowed; text-decoration: line-through; }

/* SETTINGS (SETTINGS_UC.md UC-ST1): the button on the title and the join screen, and the panel. The panel is the HUD's wooden board
   (render/hud.js woodPanel, UC-L1): a stone rim lit at the top in an ink line, planks inside with seams, the chosen row in gold.
   The rows take no pointer events (#ui takes none): main.js hit-tests them (overlay.js settingsHitAt) and feeds the menu. */
#ui .setopen { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 104px; min-height: 48px; padding: 6px 12px; box-sizing: border-box;
  font: 900 15px/1 var(--font); letter-spacing: 0.06em; color: #fff; text-shadow: 0 2px 0 var(--inkline); background: var(--wood);
  border: var(--frame); box-shadow: var(--lift); border-radius: 14px; cursor: pointer; }
#ui .setopen .sk { font: 700 11px/1 var(--font); letter-spacing: 0.04em; color: var(--gold); }
#ui .setopen:hover { filter: brightness(1.15); border-color: var(--gold); }
#ui .setdim { position: absolute; inset: 0; background: rgba(6, 20, 36, 0.68); }   /* over the menu's own dim: the panel stands alone */
#ui .settings { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(540px, calc(100% - 32px)); box-sizing: border-box;
  padding: 6px; border-radius: 22px; background: linear-gradient(180deg, #cfc6b2, #8c8372);
  box-shadow: 0 0 0 1.5px var(--inkline), 1px 4px 0 rgba(0, 0, 0, 0.32), 0 10px 24px rgba(0, 0, 0, 0.45); }
#ui .sbody { border-radius: 16px; padding: 12px 14px 10px; box-shadow: inset 0 0 0 1.5px rgba(20, 10, 4, 0.55);
  background: linear-gradient(180deg, rgba(255, 240, 210, 0.16) 0 26px, rgba(0, 0, 0, 0) 26px),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 62px, rgba(30, 16, 6, 0.35) 62px 64px), linear-gradient(180deg, #8a5a30, #4e2f16); }
#ui .shead { text-align: center; font: 900 30px/1.1 var(--font); letter-spacing: 0.08em; color: var(--gold); text-shadow: 0 3px 0 var(--inkline); margin: 2px 0 8px; }
#ui .srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 50px; margin: 4px 0; padding: 0 10px 0 14px;
  border: 3px solid transparent; border-radius: 16px; font: 900 20px/1 var(--font); color: rgba(255, 255, 255, 0.78); text-shadow: 0 2px 0 var(--inkline); }
#ui .srow.sel { color: #fff; border-color: var(--gold); background: linear-gradient(180deg, #9c6a3a, #6b4423); box-shadow: 0 0 0 1.5px var(--inkline), 0 3px 0 var(--stone-dark); }
#ui .sval { display: flex; align-items: center; gap: 6px; color: rgba(255, 210, 74, 0.8); }
#ui .srow.sel .sval { color: var(--gold); }
#ui .sarr { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; border-radius: 12px; font-size: 18px; opacity: 0.5; }
#ui .srow.sel .sarr { opacity: 1; background: rgba(20, 10, 4, 0.28); }
#ui .snum { min-width: 4.3ch; text-align: center; }
#ui .skey { min-width: 3ch; padding: 6px 12px; border-radius: 10px; text-align: center; background: rgba(20, 10, 4, 0.35); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35); }
#ui .meter { display: inline-flex; gap: 3px; }
#ui .meter i { width: 8px; height: 20px; border-radius: 3px; background: rgba(20, 10, 4, 0.45); box-shadow: inset 0 0 0 1px rgba(255, 210, 74, 0.35); }
#ui .meter i.on { background: var(--gold); box-shadow: inset 0 -3px 0 rgba(150, 90, 10, 0.55); }
#ui .shelp { text-align: center; color: var(--dim); font: 600 12px/1.4 var(--font); margin-top: 8px; text-shadow: 0 1px 0 var(--inkline); }
/* more rows than the screen has room for scroll (the KEYS page, UC-ST3; nine settings rows on a short phone); the rows take the
   finger and the wheel for that, and a click on one still reaches the page (main.js reads the window's pointer) */
#ui .srows { max-height: calc((100vh - 170px) / var(--ts, 1)); overflow-y: auto; overscroll-behavior: contain; pointer-events: auto; scrollbar-width: thin; }
#ui .srows.more { mask-image: linear-gradient(180deg, #000 82%, transparent); }
#ui .snote { text-align: center; color: var(--gold); font: 800 14px/1.35 var(--font); margin-top: 6px; text-shadow: 0 1px 0 var(--inkline); }
/* TEXT SIZE (SETTINGS_UC.md UC-ST4): the page's own panels grow with the HUD by --ts (main.js sets it to the size the HUD gave,
   render/hud.js textScaleFor); a size taken from the viewport is divided by it, so the grown panel still fits */
#ui .foot, #ui .howto, #ui .settings, #ui .setopen, #ui .corner, .hint, .abar { zoom: var(--ts, 1); }
@media (max-width: 479px) {
  #ui .srow { font-size: 16px; padding: 0 4px 0 10px; gap: 4px; }
  #ui .meter { gap: 2px; }
  #ui .meter i { width: 5px; height: 16px; }
  #ui .sarr { min-width: 36px; }
  #ui .sval { gap: 3px; }
}
@media (max-height: 559px) {
  #ui .settings { width: min(500px, calc(100% - 32px)); }
  #ui .sbody { padding: 6px 12px 6px; }
  #ui .shead { font-size: 22px; margin: 0 0 4px; }
  #ui .srow { min-height: 38px; margin: 2px 0; font-size: 17px; }   /* 38 + the 6 px border: a 44 px tap target */
  #ui .shelp { margin-top: 4px; }
}

/* CONTROLS & CREDITS (TITLE_UC.md UC-T1): the button under SETTINGS, the one-line title foot, and the two-page panel. The panel is
   the settings board, wider; unlike the settings rows it takes the pointer itself (its credits are links, a click on the dim closes). */
#ui .infoopen { top: calc(max(12px, env(safe-area-inset-top)) + 58px); font-size: 13px; }
#ui .foot .brief { font-weight: bold; }
#ui .idim { pointer-events: auto; }
#ui .settings.info { width: min(760px, calc(100% - 32px)); pointer-events: auto; }
#ui .itabs { display: flex; justify-content: center; gap: 10px; margin: 2px 0 8px; }
#ui .itab { min-width: 140px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; cursor: pointer;
  border: 3px solid transparent; border-radius: 14px; font: 900 18px/1 var(--font); letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.7); text-shadow: 0 2px 0 var(--inkline); }
#ui .itab.sel { color: var(--gold); border-color: var(--gold); background: linear-gradient(180deg, #9c6a3a, #6b4423); box-shadow: 0 0 0 1.5px var(--inkline), 0 3px 0 var(--stone-dark); }
#ui .ipage { max-height: min(56vh / var(--ts, 1), 460px); overflow-y: auto; padding: 4px 8px; font: 600 14px/1.45 var(--font); color: var(--ink); text-shadow: 0 1px 0 var(--inkline); }
#ui .iline { margin: 0 0 7px; }
#ui .ihead { margin: 8px 0 4px; font: 900 15px/1 var(--font); letter-spacing: 0.08em; color: var(--gold); }
#ui .ipage a { color: #ffe08a; }
#ui .iclose { display: inline-flex; align-items: center; min-height: 36px; margin-left: 10px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--gold); color: #fff; font: 900 13px/1 var(--font); letter-spacing: 0.06em; background: rgba(20, 10, 4, 0.3); }
@media (max-height: 559px) {
  #ui .infoopen { top: calc(max(8px, env(safe-area-inset-top)) + 54px); }
  #ui .ipage { max-height: calc(52vh / var(--ts, 1)); font-size: 12px; }
  #ui .itab { min-height: 40px; font-size: 15px; min-width: 110px; }
}
