@font-face { font-family: Barlow; src: url(fonts/BarlowCondensed-Bold.ttf); font-weight: 700; }
@font-face { font-family: Barlow; src: url(fonts/BarlowCondensed-Medium.ttf); font-weight: 500; }
:root { --cell: 56px; --ivory: #F8F5ED; --black: #0C0B0A; }
/* Themes. Everything below uses these semantic variables; [data-theme] is set on <html> by the inline
   script in index.html (System follows prefers-color-scheme). Any element can carry data-theme (roster sheet). */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C0B0A; --ink: #F8F5ED; --ink-rgb: 248, 245, 237; --bg-rgb: 12, 11, 10;
  --cell-bg: #191714; --cell-line: #26231F; --peek-bg: #2C2A26;
  --lit: #2E7268; --ff: #A63D30;
  --tut-ring: #FFB81C; --tut-ring-edge: rgba(12,11,10,.55); --tut-good: #5CC8B8;
  --strip: rgba(160, 238, 224, .5); --strip-bad: rgba(255, 150, 135, .75);
  --beam: 92, 200, 184;   /* accent teal (beam strips, glow) */
  --bad: 229, 103, 90;    /* friendly-fire red */
  --wall: #CFC9BC; --wall-num: #F8F5ED; --wall-ink: #0C0B0A; --wall-ok: #8E897F; --wall-ok-ink: rgba(12,11,10,.9);
  --crate: #A9733F; --crate-frame: #24140A; --crate-seam: #6E4522; --crate-brace: #8A5A2E; --crate-hi: #C48D55;
  --hazard: #FFC23D; --hazard-ink: #0C0B0A; --door-trim-a: #FFB81C; --door-trim-b: #0C0B0A; --door-edge: #0C0B0A; --door-steel: #5E666C; --door-seam: #2E3337; --door-rivet: #B9C1C6; --door-lamp-off: #E8402F; --door-lamp: #3CD070; --door-lamp-rim: #0C0B0A; --door-glow: 60, 208, 112;
  --badge-bg: #0C0B0A; --badge-ink: #F8F5ED;
  --btn: #1E1B18; --btn-line: #3A3631; --btn-active: #2A2622; --rule: #2A2622;
  --card: #16140F; --scrim: rgba(12,11,10,.82);
  --accent: #1D4A44; --accent-ink: #F8F5ED; --accent-line: rgb(92, 200, 184);
  --mech-body: #F8F5ED; --mech-shade: #BDB6A8; --mech-shade-plain: #BDB6A8; --mech-detail: #0C0B0A; --mech-line: #0C0B0A;
  --sticker: #F8F5ED; --sticker-edge: rgba(0,0,0,.55); --sticker-bad: #E8402F; --cross-on-lit: #F8F5ED;
  --visor: #FFB81C; --visor-rim: #0C0B0A; --visor-bad: #FF4D3D; --visor-bad-flash: #F8F5ED;
  --logo-filter: none;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #F8F5ED; --ink: #0C0B0A; --ink-rgb: 12, 11, 10; --bg-rgb: 248, 245, 237;
  --cell-bg: #F1ECE1; --cell-line: #CFC8B9; --peek-bg: #DCD5C6;
  --lit: #287A6E; --ff: #B23F33;
  --tut-ring: #B86A00; --tut-ring-edge: rgba(248,245,237,.7); --tut-good: #0E6B5E;
  --strip: rgba(205, 246, 238, .45); --strip-bad: rgba(255, 210, 200, .55);
  --beam: 18, 122, 108;
  --bad: 200, 58, 44;
  --wall: #2A2622; --wall-num: #0C0B0A; --wall-ink: #F8F5ED; --wall-ok: #5A554D; --wall-ok-ink: rgba(248,245,237,.85);
  --crate: #B17A43; --crate-frame: #24140A; --crate-seam: #6E4522; --crate-brace: #8F5D30; --crate-hi: #CB955C;
  --hazard: #FFC23D; --hazard-ink: #0C0B0A; --door-trim-a: #FFC23D; --door-trim-b: #0C0B0A; --door-edge: #0C0B0A; --door-steel: #8C959B; --door-seam: #3E4549; --door-rivet: #E4E8EA; --door-lamp-off: #E8402F; --door-lamp: #3CD070; --door-lamp-rim: #0C0B0A; --door-glow: 60, 208, 112;
  --badge-bg: #F8F5ED; --badge-ink: #0C0B0A;
  --btn: #EEE9DE; --btn-line: #CFC8B9; --btn-active: #E2DBCC; --rule: #DED7C9;
  --card: #FFFDF8; --scrim: rgba(60,54,46,.4);
  --accent: #1F6B60; --accent-ink: #F8F5ED; --accent-line: #1F6B60;
  --mech-body: #0C0B0A; --mech-shade: #CFC8BA; --mech-shade-plain: #6E685E; --mech-detail: #F8F5ED; --mech-line: #0C0B0A;
  --sticker: #F8F5ED; --sticker-edge: rgba(12,11,10,.5); --sticker-bad: #E8402F; --cross-on-lit: #F8F5ED;
  --visor: #FFC23D; --visor-rim: #0C0B0A; --visor-bad: #FF4D3D; --visor-bad-flash: #F8F5ED;
  --logo-filter: invert(1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: Barlow, -apple-system, system-ui, sans-serif; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
#app { height: 100%; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header { display: flex; align-items: center; gap: 12px; padding: 10px 18px; height: 60px; flex: none; }
/* the dog-T mark is inline SVG in the ink colour: black on ivory (light), ivory on black (dark), no tile */
header .mark { width: 36px; height: 36px; display: block; flex: none; color: var(--ink); }
header h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.rungs { margin-left: auto; display: flex; gap: 14px; align-items: baseline; font-weight: 500; }
#rung { font-size: 22px; font-weight: 700; }
#best { font-size: 16px; opacity: .5; }
.stage { flex: 1; display: flex; min-height: 0; align-items: center; justify-content: center; gap: 24px; padding: 8px 18px 18px; }
@media (orientation: portrait) { .stage { flex-direction: column; gap: 16px; } }
.board-wrap { flex: 1; min-width: 0; min-height: 0; align-self: stretch; display: flex; align-items: center; justify-content: center; }
.side { display: flex; flex-direction: column; gap: 18px; width: 150px; flex: none; }
.tools { display: flex; flex-direction: column; gap: 12px; }
@media (orientation: portrait) { .side { width: 100%; max-width: 520px; gap: 12px; } .tools { flex-direction: row; } .tools button { flex: 1; } }
button { font: inherit; font-weight: 700; font-size: 20px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink);
  background: var(--btn); border: 2px solid var(--btn-line); border-radius: 12px; padding: 14px 10px; cursor: pointer; transition: transform .1s, background .2s, opacity .2s; }
button:active { transform: scale(.96); background: var(--btn-active); }
button:disabled { opacity: .3; }
button.next { visibility: hidden; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.solved button.next { visibility: visible; animation: nextIn .5s .5s both; }
@keyframes nextIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.board { display: grid; gap: 3px; padding: 3px; background: var(--cell-line); border-radius: 10px; position: relative; }
.cell { width: var(--cell); height: var(--cell); position: relative; background: var(--cell-bg); border-radius: 5px; overflow: hidden; cursor: pointer; }
.cell.wall { background: var(--wall); cursor: default; display: flex; align-items: center; justify-content: center; }
.cell.wall.num { background: var(--wall-num); color: var(--wall-ink); font-weight: 700; font-size: calc(var(--cell) * .58); line-height: 1; transition: background .3s, color .3s; }
.cell.wall.num.ok { background: var(--wall-ok); color: var(--wall-ok-ink); }
.cell.wall.num.over { color: rgb(var(--bad)); box-shadow: inset 0 0 0 3px rgb(var(--bad)); }
/* site art (game.js): buildings (numbered), hazards (0), crates (blank). Building art stays out of the numeral's box. */
.bld, .crate, .hazard-sign, .door { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.num-t { position: relative; z-index: 2; display: block; width: .62em; height: 1em; text-align: center; transform-origin: 50% 50%; transition: transform .45s cubic-bezier(.3,1.3,.6,1) .3s, color .3s .3s; }
.num-t::before { content: ''; position: absolute; z-index: -1; inset: 0 -.19em; border-radius: .24em; background: var(--badge-bg); box-shadow: 0 0 0 .07em var(--wall-ok); opacity: 0; transition: opacity .3s .35s; }
/* on solve the numeral shrinks into a top-left corner badge so the doors and roof are the hero (hazards have no numeral) */
.solved .cell.wall.num .num-t { transform: translate(calc(var(--cell) * -.325), calc(var(--cell) * -.325)) scale(.4); color: var(--badge-ink); }
.solved .cell.wall.num .num-t::before { opacity: 1; }
.bld-roof { fill: none; stroke: currentColor; stroke-width: 1.2px; opacity: 0; transition: opacity .4s .6s; }
.solved .bld-roof { opacity: .35; }
.bld-frame { fill: none; stroke: currentColor; stroke-width: 1.3px; opacity: .22; }
.bld-vent { fill: currentColor; opacity: .16; }
/* hazard (0 clue): amber warning triangle with a black rim, on the building block */
.hazard-sign { inset: 6%; width: 88%; height: 88%; }
.hz-tri { fill: var(--hazard); stroke: var(--hazard-ink); stroke-width: 2.4px; stroke-linejoin: round; }
.hz-ink { fill: var(--hazard-ink); }
.cell.wall.num.hazard.over .hz-tri { stroke: rgb(var(--bad)); }
/* crate: fills the block edge to edge */
.cell.wall.crate-block { background: var(--crate-frame); }
.crate { overflow: hidden; }
.cr-frame { fill: var(--crate-frame); }
.cr-board { fill: var(--crate); }
.cr-seam { stroke: var(--crate-seam); stroke-width: 1.3px; fill: none; }
.cr-brace { stroke: var(--crate-frame); stroke-width: 5.2px; stroke-linecap: square; fill: none; }
.cr-brace-hi { stroke: var(--crate-brace); stroke-width: 2.8px; stroke-linecap: square; fill: none; }
.cr-nail { fill: var(--crate-hi); }
.f-wall { fill: var(--crate); }
/* doors: only on solve, one per side with a mech in front; they swing open out of the building edge */
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.hzs-a { fill: var(--door-trim-a); } .hzs-b { fill: var(--door-trim-b); }
.door-frame { fill: url(#hz-stripes); stroke: var(--door-edge); stroke-width: .9px; stroke-linejoin: round; }
.door-slab { fill: var(--door-steel); stroke: var(--door-edge); stroke-width: .7px; stroke-linejoin: round; }
.door-seam { stroke: var(--door-seam); stroke-width: .7px; fill: none; }
.door-rivet { fill: var(--door-rivet); stroke: var(--door-seam); stroke-width: .3px; }
.door-lamp { fill: var(--door-lamp); stroke: var(--door-lamp-rim); stroke-width: .7px; animation: lampOn .7s steps(1, end) both; animation-delay: calc(var(--dd, 450ms) + 300ms); }
/* status lamp: red while the blast door drops into place, then flips green (secured) */
@keyframes lampOn { 0% { fill: var(--door-lamp-off); } 100% { fill: var(--door-lamp); } }
.door-g { transform-box: fill-box; transform-origin: 50% 0; animation: doorIn .38s cubic-bezier(.3,1.5,.6,1) both; animation-delay: var(--dd, 450ms); }
/* blast door drops out of the wall edge into place with a heavy settle */
@keyframes doorIn { 0% { transform: scaleY(0); opacity: 0; } 60% { transform: scaleY(1.06); opacity: 1; } 80% { transform: scaleY(.97); } 100% { transform: none; opacity: 1; } }
/* doors light up as they lock: the green lamp glow flares and settles to a soft steady one */
.door { filter: drop-shadow(0 0 2px rgba(var(--door-glow), .55)); animation: doorGlow 1.1s ease-out both; animation-delay: var(--dd, 450ms); }
@keyframes doorGlow { 0% { filter: drop-shadow(0 0 0 rgba(var(--door-glow), 0)); } 35% { filter: drop-shadow(0 0 7px rgba(var(--door-glow), 1)); } 100% { filter: drop-shadow(0 0 2px rgba(var(--door-glow), .55)); } }

/* beams: lit cells get an obvious teal fill, unlit stay plain dark. Beam strips show direction.
   No transitions or animations on any of this: the DOM is rebuilt from state on every render. */
.cell.lit { background: var(--lit); }
.cell.ff { background: var(--ff); }
.fx { position: absolute; inset: 0; pointer-events: none; }
.b { position: absolute; background: var(--strip); }
.bh { left: 0; right: 0; top: 42%; bottom: 42%; }
.bv { top: 0; bottom: 0; left: 42%; right: 42%; }
.b.red { background: var(--strip-bad); }
/* landing flash: resting style is invisible, fill-mode none, element is removed by timer */
.flash { position: absolute; inset: 0; background: rgb(var(--beam)); opacity: 0; animation: flash .45s ease-out; animation-fill-mode: none; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
/* flat chassis sticker (mechs.js svg): die-cut ivory border + dark outline + coloured parts, no plate.
   Sized so the sticker edge stays >=4% inside the cell (clear of the beam-strip probes at the edge). */
.mech { position: absolute; left: 8.5%; top: 8.5%; width: 83%; height: 83%; pointer-events: none; overflow: visible; opacity: 0; transform: scale(.4); transition: transform .18s cubic-bezier(.3,1.6,.6,1), opacity .12s; }
.has-mech .mech { opacity: 1; transform: scale(1); }
[data-mech=scout] { --mb: #C9D3D8; --ms: #7E929D; }
[data-mech=vanguard] { --mb: #B7CDE0; --ms: #6F8CA6; }
[data-mech=bulwark] { --mb: #D98A2E; --ms: #7C766C; }
.m-body { fill: var(--mb, var(--mech-body)); }
.m-shade { fill: var(--ms, var(--mech-shade-plain)); }
.m-dark { fill: var(--mech-line); }
.m-visor { fill: var(--visor); stroke: var(--mech-line); stroke-width: 1.2px; paint-order: stroke; stroke-linejoin: round; transition: fill .2s; }
/* bold silhouette: the same shapes again, underneath, as a thick dark stroke (1.6 units outside the parts) */
.m-line > * { fill: var(--mech-line); stroke: var(--mech-line); stroke-width: 3.2px; stroke-linejoin: round; }
/* sticker cut: the shapes once more, underneath that, as a thicker ivory stroke (3.1 units outside the parts) */
.m-cut > * { fill: var(--sticker); stroke: var(--sticker); stroke-width: 6.2px; stroke-linejoin: round; }
/* drop edge: the cut shape again, 0.9 units lower, in a translucent dark, so the ivory border also reads on pale
   ground (light unlit cells, the tray). Plain vector, no CSS/SVG filter (cheaper in WebKit). */
.m-drop > * { fill: var(--sticker-edge); stroke: var(--sticker-edge); stroke-width: 6.2px; stroke-linejoin: round; }
/* a misplaced mech: red sticker border, and a red visor that pulses to ivory */
.bad .mech .m-cut > * { fill: var(--sticker-bad); stroke: var(--sticker-bad); }
.bad .mech .m-visor { fill: var(--visor-bad); animation: badEyes 1.1s ease-in-out infinite; }
@keyframes badEyes { 50% { fill: var(--visor-bad-flash); } }
@media (prefers-reduced-motion: reduce) { .bad .mech .m-visor { animation: none; } }
.bad .mech { animation: wobble .4s; }
@keyframes wobble { 30% { transform: rotate(-6deg); } 60% { transform: rotate(5deg); } }
.cross { position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; transform: translate(-50%,-50%) scale(.4); opacity: 0; pointer-events: none; }
.cross path { stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; fill: none; }
/* the cross fades in after a beat so a quick double tap (cross -> mech) never visibly flashes it */
.has-cross .cross { opacity: .6; transform: translate(-50%,-50%) scale(1); transition: opacity .12s ease-out .11s, transform .14s ease-out .11s; }
.lit.has-cross .cross { opacity: .85; }   /* ivory cross needs more body on teal */
.lit.has-cross .cross path { stroke: var(--cross-on-lit); }
/* hint */
.hinted::after { content: ''; position: absolute; inset: 2px; border-radius: 5px; box-shadow: inset 0 0 0 3px var(--ink); animation: hint 1.2s ease-in-out 3; pointer-events: none; }
.hinted.hint-wrong::after { box-shadow: inset 0 0 0 3px rgb(var(--bad)); }
@keyframes hint { 50% { opacity: .2; } }
/* solve */
.solved .cell:not(.wall) { animation: clear .7s ease-out; animation-delay: var(--sd, 0ms); animation-fill-mode: none; }
@keyframes clear { 35% { background: rgb(var(--beam)); transform: scale(.88); } }
.solved .board { animation: glow 1.2s .4s ease-out both; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(var(--beam), .0); } 40% { box-shadow: 0 0 40px 6px rgba(var(--beam), .45); } 100% { box-shadow: 0 0 18px 2px rgba(var(--beam), .2); } }
#debug { position: fixed; left: 8px; bottom: 6px; font: 12px ui-monospace, monospace; opacity: .45; pointer-events: none; }

/* numbered-wall neighbour peek */
.cell.peek { animation: peek 1.2s ease-out; animation-fill-mode: none; }
@keyframes peek { 0%, 70% { box-shadow: inset 0 0 0 3px rgba(var(--ink-rgb),.85); background-color: var(--peek-bg); } 100% { box-shadow: inset 0 0 0 3px rgba(var(--ink-rgb),0); } }
.cell.wall.num { cursor: pointer; }
/* help button + how to play */
button.help { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 22px; margin-left: 4px; flex: none; }
.howto { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; animation: fadeIn .2s ease-out; }
.howto[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.howto-card { background: var(--card); border: 2px solid var(--btn-line); border-radius: 18px; padding: 22px 26px 24px; width: min(560px, 100%); max-height: 100%; overflow: auto; }
.howto-card h2 { margin: 0 0 12px; font-size: 28px; text-transform: uppercase; letter-spacing: .04em; }
button.gotit { margin-top: 16px; width: 100%; background: var(--ink); color: var(--bg); border-color: var(--ink); font-size: 22px; padding: 16px; }
.howto-card { width: min(600px, 100%); }
.howto-lede { margin: 0 0 14px; font-size: 18px; font-weight: 500; line-height: 1.3; }
.rules, .controls { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rules li, .controls li { display: flex; align-items: center; gap: 14px; }
.rules p, .controls p { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.25; }
.controls p b { font-weight: 700; }
.mini-fig { flex: none; width: 124px; display: flex; justify-content: center; --cell: 28px; }
.board.mini { gap: 2px; padding: 2px; border-radius: 6px; animation: none !important; }
.board.mini .cell { border-radius: 3px; cursor: default; animation: none !important; }
.board.mini .cell.wall.num { cursor: default; }
.board.mini .doors .num-t { transform: translate(calc(var(--cell) * -.325), calc(var(--cell) * -.325)) scale(.4); color: var(--badge-ink); transition: none; }
.board.mini .doors .num-t::before { opacity: 1; transition: none; }
.board.mini .doors .bld-roof { opacity: .35; transition: none; }
.howto-sub { margin: 16px 0 8px; font-size: 17px; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.ctl-chip { font-weight: 700; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; border: 2px solid var(--btn-line); border-radius: 10px; padding: 4px 10px; background: var(--btn, transparent); }
.ctl-chip.num { text-transform: none; font-variant-numeric: tabular-nums; font-size: 15px; }
.howto-hide { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 17px; font-weight: 500; cursor: pointer; }
.howto-hide input { width: 22px; height: 22px; margin: 0; accent-color: var(--ink); flex: none; }
button.howto-tut { display: block; margin: 8px auto 0; }
.howto-card:focus { outline: none; }
@media (max-width: 520px) { .howto-card { padding: 16px; } .howto-card h2 { font-size: 24px; margin-bottom: 6px; } .howto-lede { font-size: 16px; margin-bottom: 10px; } .mini-fig { width: 92px; --cell: 20px; } .rules p, .controls p { font-size: 15.5px; } .rules li, .controls li { gap: 10px; } .ctl-chip { font-size: 12px; padding: 3px 8px; } .howto-hide { font-size: 16px; margin-top: 12px; } button.gotit { padding: 13px; font-size: 20px; margin-top: 12px; } }
/* Ladder tutorial: a banner above the board, glowing target squares, locked pre-deployed mechs */
.tut { flex: none; align-self: center; box-sizing: border-box; width: calc(100% - 36px); max-width: 760px; margin: 0 18px; padding: 10px 14px 10px; border: 2px solid var(--btn-line); border-radius: 14px; background: var(--card); display: flex; flex-direction: column; gap: 4px; }
.tut[hidden] { display: none; }
.tut.done { border-color: rgb(var(--beam)); }
.tut-top { display: flex; align-items: center; gap: 10px; }
.tut-step { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .7; flex: none; }
.tut-title { flex: 1; font-size: 18px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
button.tut-skip { background: none; border: none; padding: 4px 6px; font-size: 15px; text-transform: none; letter-spacing: 0; text-decoration: underline; text-underline-offset: 3px; opacity: .85; flex: none; }
.tut-text { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.3; }
.tut-bottom { display: flex; align-items: center; gap: 12px; }
.tut-msg { margin: 0; flex: 1; min-height: 1.3em; font-size: 16px; font-weight: 700; line-height: 1.3; }
.tut-msg.bad { color: rgb(var(--bad)); }
.tut-msg.good { color: var(--tut-good); }
button.tut-next { flex: none; background: var(--ink); color: var(--bg); border-color: var(--ink); padding: 10px 22px; font-size: 18px; }
body.tutorial #code, body.tutorial #share-top, body.tutorial #next, body.tutorial .squad, body.tutorial #win-reopen { display: none !important; }
.cell.tut-target::after { content: ''; position: absolute; inset: 1px; border-radius: 5px; box-shadow: inset 0 0 0 3px var(--tut-ring), inset 0 0 0 5px var(--tut-ring-edge), inset 0 0 calc(var(--cell) * .35) var(--tut-ring); animation: tutPulse 1.1s ease-in-out infinite; pointer-events: none; z-index: 3; }
@keyframes tutPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.cell.given { cursor: default; }
@media (max-width: 520px) { .tut { width: calc(100% - 20px); margin: 0 10px; padding: 8px 10px; } .tut-title { font-size: 15px; } .tut-step { font-size: 11px; } .tut-text { font-size: 15px; } .tut-msg { font-size: 14px; } button.tut-next { padding: 8px 16px; font-size: 16px; } button.tut-skip { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .cell.tut-target::after { animation: none; } }

/* mech tray: one slot per mech in the solution; rebuilt from state on every render */
.tray { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.slots { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot-row { display: flex; justify-content: center; gap: 4px; }
.slot { width: 26px; height: 26px; flex: none; }
.slot svg { width: 84%; height: 84%; margin: 8%; display: block; overflow: visible; }
.slot:not(.on):not(.extra) svg * { fill: rgba(var(--ink-rgb), .17); stroke: none; }
.slot:not(.on):not(.extra) svg .m-line, .slot:not(.on):not(.extra) svg .m-cut, .slot:not(.on):not(.extra) svg .m-drop { display: none; }
.slot.extra .m-body, .slot.extra .m-shade { fill: rgb(var(--bad)); }
.slot.extra { border-radius: 4px; box-shadow: inset 0 0 0 2px rgb(var(--bad)); }
.slot.pop { animation: pop .3s cubic-bezier(.3,1.6,.6,1); animation-fill-mode: none; }
@keyframes pop { from { transform: scale(.5); } }
.count { font-size: 16px; font-weight: 500; opacity: .5; letter-spacing: .05em; }
.count.full { opacity: .8; }
.count.over { color: rgb(var(--bad)); opacity: .9; }
@media (orientation: portrait) { .slot { width: 24px; height: 24px; } .tray { flex-direction: row; justify-content: center; gap: 10px; } }
/* all mechs deployed but not solved: unlit cells breathe gently */
.cell.missed::before { content: ''; position: absolute; inset: 0; border-radius: 5px; box-shadow: inset 0 0 0 2px rgba(var(--ink-rgb),.5); opacity: 0;
  animation: missed 1.8s ease-in-out infinite; animation-fill-mode: none; pointer-events: none; }
@keyframes missed { 50% { opacity: 1; } }

/* no iOS callout/selection or double-tap zoom on cells */
.cell { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
/* hint rings: primary pulses, referenced wall/square gets a softer dashed ring */
.hint-ref::after { content: ''; position: absolute; inset: 3px; border-radius: 5px; border: 2px dashed rgba(var(--ink-rgb),.7); pointer-events: none; }
.cell.wall.hint-ref::after { border-color: var(--wall-ink); opacity: .6; }
/* toast line near the counter */
.toast { min-height: 2.6em; font-size: 17px; font-weight: 500; line-height: 1.25; text-align: center; opacity: 0; transition: opacity .4s; color: var(--ink); }
.toast.show { opacity: 1; transition: opacity .15s; }
@media (orientation: portrait) { .toast { min-height: 1.3em; } }

/* views */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view[hidden] { display: none; }
/* in-game Home button */
button.back { display: flex; align-items: center; gap: 2px; padding: 8px 12px 8px 6px; font-size: 17px; border-radius: 10px; flex: none; }
button.back svg { width: 20px; height: 20px; }
@media (max-width: 520px) { button.back span { display: none; } button.back { padding: 8px; } header { gap: 8px; padding: 10px 10px; } header h1 { font-size: 22px; } }
/* home */
.home { align-items: center; justify-content: center; gap: 36px; padding: 20px; position: relative; }
.home-top { position: absolute; top: 12px; right: 14px; display: flex; gap: 10px; }
button.icon { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 22px; display: flex; align-items: center; justify-content: center; }
button.icon svg { width: 24px; height: 24px; }
.home-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.wordmark { width: min(300px, 64vw); height: auto; }
.home-title { margin: 0; font-size: clamp(40px, 8vw, 64px); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.home-buttons { display: flex; gap: 20px; width: min(640px, 100%); }
@media (orientation: portrait) { .home-buttons { flex-direction: column; } .home { gap: 28px; } }
button.big { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border-radius: 18px; text-transform: none; letter-spacing: 0; }
button.big .big-label { font-size: 34px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
button.big .big-sub { font-size: 22px; font-weight: 500; }
button.big .big-meta { font-size: 17px; font-weight: 500; opacity: .6; min-height: 1.2em; }
button.big.daily { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.big.daily.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-line); }
button.big.daily.done .big-meta { opacity: .9; }
/* settings */
.settings-card { width: min(440px, 100%); }
.setting { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: 20px; font-weight: 500; }
.setting-label { flex: 1; }
/* theme: three-way segmented choice */
.seg { display: flex; border: 2px solid var(--btn-line); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; font-size: 15px; padding: 9px 12px; background: var(--btn); }
.seg button + button { border-left: 2px solid var(--btn-line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
button.small { font-size: 17px; padding: 10px 16px; border-radius: 10px; }
button.danger { color: rgb(var(--bad)); border-color: rgba(var(--bad), .6); }
button.danger.solid { background: rgb(var(--bad)); color: var(--bg); }
.confirm { padding: 12px 0 4px; }
.confirm p { margin: 0 0 12px; font-size: 18px; line-height: 1.3; }
.confirm[hidden] { display: none; }
.confirm-row { display: flex; gap: 12px; justify-content: flex-end; }

/* free play + sharing */
.home-buttons { width: min(900px, 100%); }
button.big.free .big-sub { opacity: .8; }
@media (orientation: portrait) { button.big { padding: 18px 16px; gap: 4px; } button.big .big-label { font-size: 30px; } }
.picker-card { width: min(460px, 100%); display: flex; flex-direction: column; gap: 12px; }
.picker-card h2 { margin-bottom: 4px; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
button.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px; border-radius: 14px; text-transform: none; letter-spacing: 0; }
button.pick[hidden] { display: none; }
.pick-label { font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pick-sub { font-size: 16px; font-weight: 500; opacity: .6; }
button.pick.cont { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.pick.cont .pick-sub { opacity: .7; }
.pick-cancel { align-self: center; }
.code-chip { font-size: 13px; font-weight: 500; letter-spacing: .06em; padding: 4px 8px; border-radius: 8px; opacity: .55; text-transform: none; min-height: 0; }
.code-chip:active { opacity: 1; }
.share-top svg { width: 20px; height: 20px; }
@media (max-width: 520px) { header h1, header .mark { display: none; } .code-chip { font-size: 12px; padding: 3px 6px; } .rungs { gap: 8px; font-size: 15px; } }
.solved .tray { display: none; }
/* side panel when solved: a small Results button reopens the Zone Secured modal */
button.win-reopen { display: none; align-items: center; justify-content: center; gap: 8px; width: 100%; font-size: 18px; }
button.win-reopen svg { width: 20px; height: 20px; color: var(--visor); }
.solved button.win-reopen { display: flex; animation: nextIn .5s .5s both; }
@media (orientation: portrait) { button.win-reopen { width: auto; align-self: center; padding-left: 26px; padding-right: 26px; } }

/* Zone Secured modal */
.win { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--scrim); animation: fadeIn .25s ease-out; overflow: hidden; }
.win[hidden] { display: none; }
.win-card { position: relative; z-index: 1; width: min(440px, 100%); max-height: 100%; overflow: auto; background: var(--card); border: 2px solid var(--btn-line); border-radius: 22px;
  padding: 18px 24px 22px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; box-shadow: 0 0 0 4px rgba(var(--beam), .25), 0 24px 60px rgba(0,0,0,.35); }
.win.celebrate .win-card { animation: winIn .55s cubic-bezier(.3,1.4,.6,1) both; }
@keyframes winIn { from { opacity: 0; transform: translateY(24px) scale(.88); } to { opacity: 1; transform: none; } }
.win-hero { position: relative; width: 150px; height: 132px; display: flex; align-items: flex-end; justify-content: center; }
.win-halo { position: absolute; left: 50%; top: 54%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,184,28,.55), rgba(255,184,28,.18) 55%, rgba(255,184,28,0)); }
.win.celebrate .win-halo { animation: haloIn 1.2s ease-out both; }
@keyframes haloIn { 0% { transform: scale(.3); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: none; opacity: 1; } }
.win .solved-mech { position: relative; }
.solved-render { display: block; width: 132px; height: 132px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.3)); }
.win.celebrate .solved-render { animation: heroIn .8s .1s cubic-bezier(.3,1.6,.5,1) both; transform-origin: 50% 100%; }
@keyframes heroIn { 0% { transform: translateY(30px) scale(.6); opacity: 0; } 55% { transform: translateY(-10px) scale(1.06) rotate(-4deg); opacity: 1; } 75% { transform: rotate(3deg); } 100% { transform: none; } }
.win-title { margin: 2px 0 0; font-size: 46px; line-height: 1; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.win-sub { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .04em; opacity: .7; }
.solved-stats { margin: 2px 0 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.win-streak { margin: 0; font-size: 16px; font-weight: 600; color: var(--accent-line); }
[data-theme=light] .win-streak { color: var(--accent); }
button.win-cta { margin-top: 12px; width: 100%; padding: 18px 16px; font-size: 26px; background: var(--ink); color: var(--bg); border-color: var(--ink); border-radius: 14px; }
button.win-link { background: none; border: none; padding: 6px 10px; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; opacity: .8; }
.win-row { display: flex; gap: 8px; width: 100%; margin-top: 8px; }
.win-row button { flex: 1; padding: 12px 6px; font-size: 16px; }
button.share-btn { background: var(--accent); border-color: var(--accent-line); color: var(--accent-ink); }
@media (max-height: 700px) { .win-hero { width: 110px; height: 96px; } .solved-render { width: 96px; height: 96px; } .win-halo { width: 110px; height: 110px; margin: -55px 0 0 -55px; } .win-title { font-size: 36px; } button.win-cta { padding: 14px; font-size: 22px; } }
@media (max-width: 380px) { .win-card { padding: 14px 16px 18px; } .win-title { font-size: 36px; } .win-row button { font-size: 14px; letter-spacing: .02em; } }
.share-top { display: flex; align-items: center; justify-content: center; }
/* logos are ivory artwork: invert them in light mode */
.wordmark { filter: var(--logo-filter); }
/* squad line: subtle, under the tray / solved panel */
.squad { font-size: 15px; font-weight: 500; opacity: .55; text-align: center; letter-spacing: .03em; }
.squad b { font-weight: 700; }
@media (orientation: portrait) { .squad { font-size: 14px; } }
/* how-to figures */
.f-cell { fill: var(--cell-bg); } .f-ink { fill: var(--ink); } .f-bg { fill: var(--bg); } .f-wall { fill: var(--wall); }
.f-num { fill: var(--wall-num); } .f-num-ink { fill: var(--wall-ink); }
.f-teal { fill: rgb(var(--beam)); } .f-teal-soft { fill: rgba(var(--beam), .45); } .f-red-soft { fill: rgba(var(--bad), .55); }
.s-teal { stroke: rgb(var(--beam)); } .s-red { stroke: rgb(var(--bad)); }
/* reduced motion for the solve moment (kept last so it beats the animation rules above) */
@media (prefers-reduced-motion: reduce) {
  .door-g, .door, .door-lamp { animation: none; }
  .num-t, .num-t::before, .bld-roof { transition: none; }
  .win, .win.celebrate .win-card, .win.celebrate .win-halo, .win.celebrate .solved-render, .solved button.win-reopen { animation: none; }
  .win-burst { display: none; }
  .solved .cell:not(.wall), .solved .board { animation: none; }
}
/* confetti/spark burst behind the modal card (amber, ivory, teal); none under reduced motion */
.win-burst { position: absolute; left: 50%; top: 42%; width: 0; height: 0; pointer-events: none; }
.spark { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 2px; opacity: 0; animation: spark 1.3s cubic-bezier(.15,.7,.3,1) both; animation-delay: var(--t, 0ms); }
.spark.long { width: 4px; height: 14px; }
.s-amber { background: #FFB81C; } .s-ivory { background: #F8F5ED; box-shadow: 0 0 0 1px rgba(12,11,10,.25); } .s-teal { background: rgb(92, 200, 184); }
@keyframes spark { 0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.4); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 60px)) rotate(var(--r)) scale(1); } }
/* home footer: small links under the menu (home screen only, never over the board) */
.home { overflow-y: auto; justify-content: flex-start; }
.home > .home-brand { margin-top: auto; }
.home-foot { margin-top: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; padding: 4px 0 0; }
.foot-link { background: none; border: none; padding: 8px 8px; font: inherit; font-size: 15px; font-weight: 500; letter-spacing: .02em; text-transform: none; color: var(--ink); opacity: .7; text-decoration: none; border-radius: 6px; cursor: pointer; }
.foot-link:hover, .foot-link:focus-visible { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.foot-link[hidden] { display: none; }
/* About */
.about-card { width: min(460px, 100%); text-align: center; }
.about-mark { width: 64px; height: 64px; display: block; margin: 2px auto 8px; color: var(--ink); }
.about-card h2 { margin-bottom: 10px; }
.about-blurb { margin: 0 0 12px; font-size: 18px; font-weight: 500; line-height: 1.35; }
.about-more { margin: 0 0 10px; font-size: 17px; font-weight: 500; }
.about-more a, .consent a { color: inherit; font-weight: 700; text-underline-offset: 3px; }
.about-credits { margin: 0 0 6px; font-size: 15px; opacity: .75; }
.about-version { margin: 0; font-size: 14px; opacity: .6; font-variant-numeric: tabular-nums; }
/* consent bar: one slim line at the bottom, ivory on dark / black on light */
.consent { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; box-sizing: border-box; width: min(820px, calc(100% - 20px));
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--ivory); color: var(--black); box-shadow: 0 6px 24px rgba(0,0,0,.35); }
[data-theme="light"] .consent { background: var(--black); color: var(--ivory); }
.consent[hidden] { display: none; }
.consent-text { margin: 0; flex: 1; font-size: 15px; font-weight: 500; line-height: 1.3; }
.consent-btns { display: flex; gap: 8px; flex: none; }
.consent button { font-size: 15px; padding: 9px 14px; border-radius: 9px; letter-spacing: .03em; }
.consent-yes { background: var(--black); color: var(--ivory); border-color: var(--black); }
.consent-no { background: transparent; color: var(--black); border-color: rgba(12,11,10,.4); }
[data-theme="light"] .consent-yes { background: var(--ivory); color: var(--black); border-color: var(--ivory); }
[data-theme="light"] .consent-no { color: var(--ivory); border-color: rgba(248,245,237,.45); }
@media (max-width: 560px) { .consent { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; } .consent-text { font-size: 14px; } .consent-btns button { flex: 1; } }
