/* WORM MAY CRY — minimal neon pixel UI. Tokens + shared components (btn / panel / wslot / hpbar) + screens.
   All chrome is code-drawn: flat dark plate, 2px neon outline, hard offset shadow (the "3D" step), outer glow. */
@font-face { font-family: "WormPixel"; src: url("assets/lib/fonts/kenney-fonts/Kenney%20Pixel.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
/* Chinese pixel face: Cubic 11 (11px bitmap design on a 12px em, OFL-1.1 — licence next to the file). The file is WOFF2 data; only its extension is odd. Crisp at 12 / 24 / 36px. */
@font-face { font-family: "WormCJK"; src: url("assets/lib/online/cubic-11-woff2-f8304900ad2f.glb") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
:root {
  --c-bg: #07060f; --c-bg2: #120f24; --c-plate: #0c0b1c; --c-plate2: #17143a; --c-line: #34306e;
  --c-main: #b6ff3c; --c-foe: #ff3df0; --c-accent: #3df5ff; --c-warn: #ffb02e; --c-witch: #c77dff; --c-text: #eafff0; --c-dim: #9d98c8;
  /* pixel italic everywhere: the pixel face first, CJK face only as a fallback for stray glyphs */
  --yoroll-font-title: "WormPixel", "WormCJK", "Yoroll_source-han-sans-sc-medium", monospace;
  --yoroll-font-body: "WormPixel", "WormCJK", "Yoroll_source-han-sans-sc-medium", monospace;
  --yoroll-font-hud: "WormPixel", "WormCJK", "Yoroll_source-han-sans-sc-medium", monospace;
  --f-xs: 20px; --f-s: 24px; --f-m: 28px; --f-l: 34px; --f-xl: 52px;
  --tall: 1.34;           /* display text is stretched vertically: taller pixels */
  --tall-s: 1.22;         /* same idea, lighter, for labels and button captions */
  --tick: 120ms;
  --play-h: 100dvh;       /* play area height; portrait sets 48dvh from script */
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
html, body { background: var(--c-bg); color: var(--c-text); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game { position: fixed; left: 0; top: 0; width: 100vw; height: var(--play-h); min-height: 16px; min-width: 16px; }   /* never 0: the engine cannot build a 0-sized picture */
#game canvas { image-rendering: pixelated; touch-action: none; }
/* round 22: the blackout over the arena picture while a firework shell climbs (weapon_hanabi.js paints the gradient every frame). Above the canvas, under the interface (#ui is z-index 5). */
:root { --fw-veil: rgba(4, 3, 12, .97); }
/* round 24: the blackout is a fixed picture of a hole (#fw-hole) and four bars around it; weapon_hanabi.js only changes their transform and the layer's opacity
   (.old = the dev switch ?fwold=1: one gradient written per frame, as in round 23) */
#fw-veil { position: absolute; inset: 0; z-index: 1; pointer-events: none; display: none; overflow: hidden; contain: strict; }
#fw-veil.on { display: block; }
#fw-hole { position: absolute; left: 0; top: 0; width: 512px; height: 512px; margin: -256px 0 0 -256px; will-change: transform;
  background: radial-gradient(circle closest-side, rgba(4, 3, 12, 0) 55%, var(--fw-veil) 100%); }
.fw-bar { position: absolute; left: 0; top: 0; width: 1px; height: 1px; background: var(--fw-veil); transform-origin: 0 0; will-change: transform; }
#fw-veil.old > * { display: none; }
#fw-flash { position: absolute; inset: 0; z-index: 1; background: #fff8e6; opacity: 0; pointer-events: none; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--yoroll-font-body); font-style: italic; font-size: var(--f-s); line-height: 1; letter-spacing: 1px;
  -webkit-font-smoothing: none; font-smooth: never; text-rendering: optimizeSpeed; }
#ui button { font-style: italic; letter-spacing: 1px; }
#ui [hidden] { display: none !important; }
.center { text-align: center; }
/* taller pixels on single-line labels (transform only: layout is unchanged) */
.btn .tx { display: inline-block; line-height: .7; transform: scaleY(var(--tall-s)); }
.kicker, .save-line, .sec, .up-head, .res-spore, .up-info .nm, .help-w .nm, #hud-arena, #hud-style .combo, .res-rank .lbl { transform: scaleY(var(--tall-s)); transform-origin: 50% 50%; }

/* ---------- shared: button ---------- */
.btn {
  --bc: var(--c-accent); --bd: #0b5560; --bg: rgba(61, 245, 255, .4);
  position: relative; pointer-events: auto; cursor: pointer; box-sizing: border-box;
  min-width: 180px; height: 48px; padding: 0 16px 2px; background: var(--c-plate); border: 2px solid var(--bc); border-radius: 0;
  color: var(--bc); font-family: var(--yoroll-font-title); font-size: var(--f-l); line-height: 1; text-shadow: 0 0 10px var(--bg);
  box-shadow: 4px 4px 0 var(--bd), 0 0 16px var(--bg), inset 0 2px 0 rgba(255, 255, 255, .2);
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  transition: transform var(--tick) steps(2), box-shadow var(--tick) steps(2), filter var(--tick) steps(2);
}
.btn.primary { --bc: var(--c-main); --bd: #3f6b00; --bg: rgba(182, 255, 60, .55); background: var(--c-main); color: #0b1400; text-shadow: none; box-shadow: 4px 4px 0 var(--bd), 0 0 20px var(--bg), inset 0 3px 0 rgba(255, 255, 255, .55); }
.btn.foe { --bc: var(--c-foe); --bd: #6a0066; --bg: rgba(255, 61, 240, .45); }
.btn.on { --bc: var(--c-warn); --bd: #6a4300; --bg: rgba(255, 176, 46, .4); }
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--bd), 0 0 10px var(--bg), inset 0 2px 0 rgba(255, 255, 255, .2); }
.btn:disabled { --bc: var(--c-line); --bd: #000; --bg: transparent; background: var(--c-plate); color: var(--c-dim); text-shadow: none; cursor: default; filter: none; transform: none; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
/* small square keys (pause / sound) */
.sq { pointer-events: auto; cursor: pointer; width: 44px; height: 44px; box-sizing: border-box; border: 2px solid var(--c-line); border-radius: 0; padding: 0 0 2px; background: var(--c-plate); color: var(--c-text);
  font-family: var(--yoroll-font-title); font-size: var(--f-xs); line-height: 1; flex: none; display: inline-flex; align-items: center; justify-content: center; box-shadow: 3px 3px 0 #000; }
.sq:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.sq.off { color: var(--c-dim); text-decoration: line-through; }

/* ---------- shared: panel / dialog ---------- */
.mask { position: fixed; inset: 0; pointer-events: auto; background: rgba(4, 3, 10, .8); display: flex; align-items: center; justify-content: center;
  padding: calc(14px + var(--safe-t)) calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(14px + var(--safe-l)); z-index: 20; }
.panel { --pc: var(--c-accent); --pd: #073c46; --pg: rgba(61, 245, 255, .35);
  position: relative; width: min(660px, 100%); max-height: 100%; display: flex; flex-direction: column; box-sizing: border-box; padding: 10px 16px 16px;
  background: #0a0918; border: 2px solid var(--pc); box-shadow: 6px 6px 0 var(--pd), 0 0 28px var(--pg), inset 0 2px 0 rgba(255, 255, 255, .14); }
.panel.narrow { width: min(460px, 100%); }
.panel:has(.res.win) { --pc: var(--c-main); --pd: #2c4d00; --pg: rgba(182, 255, 60, .35); }
.panel:has(.res.lose) { --pc: var(--c-foe); --pd: #57005a; --pg: rgba(255, 61, 240, .35); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 0 0 8px; border-bottom: 2px solid var(--c-line); flex: none; }
.panel-head h2 { flex: 1; margin: 0; padding-left: 52px; text-align: center; font-family: var(--yoroll-font-title); font-weight: 400; font-size: var(--f-xl); line-height: 1; letter-spacing: 3px; color: var(--pc);
  text-shadow: 2px 2px 0 var(--pd), 4px 4px 0 #000, 0 0 18px var(--pg); transform: scaleY(var(--tall)); }
.panel-x { pointer-events: auto; cursor: pointer; width: 44px; height: 44px; box-sizing: border-box; border: 2px solid var(--c-line); padding: 0 0 2px; background: var(--c-plate); color: var(--c-text); font-family: var(--yoroll-font-title); font-size: var(--f-m); flex: none; box-shadow: 3px 3px 0 #000; }
.panel-x:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.panel-body { padding: 12px 2px 12px; overflow-y: auto; min-height: 0; font-size: var(--f-s); line-height: 1.15; color: var(--c-text); -webkit-overflow-scrolling: touch; }
.panel-body p { margin: 0 0 8px; }
.panel-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; padding: 14px 4px 0 0; border-top: 2px solid var(--c-line); flex: none; }
.panel-actions .btn { min-width: 0; width: 100%; padding: 0 6px 2px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; margin: 8px 0 14px; }
.help-grid .k, .help-w .k { font-family: var(--yoroll-font-title); color: #0b1400; background: var(--c-main); padding: 2px 10px 4px; text-align: center; min-width: 40px; white-space: nowrap; box-shadow: 3px 3px 0 #000; }
.help-w { display: grid; grid-template-columns: 46px 1fr; gap: 10px 12px; align-items: center; margin-top: 8px; }
.help-w .nm { font-family: var(--yoroll-font-title); font-size: var(--f-m); }
.help-w small { color: var(--c-dim); display: block; font-size: var(--f-xs); line-height: 1.1; }
.sec { color: var(--c-accent); font-family: var(--yoroll-font-title); font-size: var(--f-m); letter-spacing: 2px; margin: 12px 0 4px; text-shadow: 0 0 10px rgba(61, 245, 255, .5); }

/* ---------- title: full-bleed key art fading into a dark left column ---------- */
#title { position: fixed; inset: 0; pointer-events: auto; overflow: hidden; display: flex; align-items: center; box-sizing: border-box; background: var(--c-bg);
  padding: calc(18px + var(--safe-t)) calc(20px + var(--safe-r)) calc(18px + var(--safe-b)) calc(max(6vw, 24px) + var(--safe-l)); }
.title-art { position: absolute; inset: 0 0 0 30%; background: 62% center / cover no-repeat; image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 46%); mask-image: linear-gradient(90deg, transparent 0, #000 46%); }
#title::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .2) 0 2px, transparent 2px 4px); }
.title-copy { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; min-width: 0; }
.kicker { margin: 0; font-size: var(--f-s); letter-spacing: 4px; color: var(--c-accent); text-shadow: 0 0 10px rgba(61, 245, 255, .7); }
#title h1 { margin: 18px 0 30px; font-family: var(--yoroll-font-title); font-weight: 400; line-height: .6; font-size: clamp(84px, 13vw, 180px); letter-spacing: .02em; transform: scaleY(var(--tall)); transform-origin: 0 50%; }
#title h1 span { display: block; }
/* title effects layer (game.js UI.titleFx): low-res canvas shown with hard pixels and added as light over the key art */
#title-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; image-rendering: pixelated; mix-blend-mode: screen; }
#title h1 .a { color: var(--c-main); text-shadow: 3px 3px 0 #5a9a00, 6px 6px 0 #2c4d00, 9px 9px 0 #000, 0 0 34px rgba(182, 255, 60, .7); }
#title h1 .b { color: var(--c-foe); text-shadow: 3px 3px 0 #a000a0, 6px 6px 0 #57005a, 9px 9px 0 #000, 0 0 34px rgba(255, 61, 240, .7); margin-left: .12em; }
.save-line { margin: 0; font-size: var(--f-s); color: var(--c-warn); letter-spacing: 1px; text-shadow: 0 0 8px rgba(255, 176, 46, .5); }
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; width: min(440px, 86vw); margin-top: 4px; }
.menu .btn { width: 100%; min-width: 0; }
.menu .btn.primary { grid-column: 1 / -1; height: 60px; font-size: var(--f-xl); }
#btn-mute-t { position: absolute; z-index: 2; right: calc(14px + var(--safe-r)); top: calc(14px + var(--safe-t)); }

/* ---------- duel HUD: slanted health bars + timer on top, weapon bar at the bottom ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#witch-fx { position: absolute; left: 0; right: 0; top: 0; height: var(--play-h); pointer-events: none; opacity: 0; background: rgba(96, 40, 170, .16);
  box-shadow: inset 0 0 0 4px var(--c-witch), inset 0 0 110px rgba(170, 90, 255, .6); transition: opacity 80ms steps(2); }
#witch-fx.on { opacity: 1; }
#witch-fx.on.f { box-shadow: inset 0 0 0 4px var(--c-foe), inset 0 0 110px rgba(255, 61, 240, .45); background: rgba(120, 20, 110, .14); }
.topbar { position: absolute; left: calc(16px + var(--safe-l)); right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t));
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.hpbar { --hc: var(--c-main); --hd: #2c4d00; --hg: rgba(182, 255, 60, .5); position: relative; height: 28px; box-sizing: border-box; max-width: 460px; width: 100%; margin-top: 4px; overflow: hidden;
  background: #05040c; border: 2px solid var(--hc); transform: skewX(-14deg); box-shadow: 4px 4px 0 var(--hd), 0 0 14px var(--hg); }
.hpbar.foe { --hc: var(--c-foe); --hd: #57005a; --hg: rgba(255, 61, 240, .5); justify-self: end; }
.hpbar .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; background: linear-gradient(180deg, #ecffb8 0 30%, var(--c-main) 30% 100%); transition: width var(--tick) steps(3); }
.hpbar.foe .fill { left: auto; right: 0; background: linear-gradient(180deg, #ffc0fa 0 30%, var(--c-foe) 30% 100%); }
.hpbar .nm { position: absolute; top: 0; bottom: 2px; left: 10px; display: flex; align-items: center; font-family: var(--yoroll-font-hud); font-size: var(--f-s); line-height: 1; color: #fff; white-space: nowrap;
  text-shadow: 2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000, 2px 2px 0 #000; transform: skewX(14deg) scaleY(var(--tall-s)); }
.hpbar.foe .nm { left: auto; right: 10px; }
.hpbar.hitfx { animation: hp-hit 180ms steps(3); }
.hpbar.low .fill { animation: hp-low 500ms steps(2) infinite; }
@keyframes hp-hit { 0% { filter: brightness(2.6); } 100% { filter: none; } }
@keyframes hp-low { 0% { filter: brightness(1.7); } 100% { filter: none; } }
.topbar .mid { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 70px; }
#hud-timer { font-family: var(--yoroll-font-title); font-size: var(--f-xl); line-height: .8; color: var(--c-warn); text-shadow: 2px 2px 0 #6a4300, 4px 4px 0 #000, 0 0 14px rgba(255, 176, 46, .6); font-variant-numeric: tabular-nums; transform: scaleY(var(--tall)); }
#hud-timer.hurry { color: var(--c-foe); animation: hp-low 500ms steps(2) infinite; }
#hud-arena { font-size: var(--f-xs); color: var(--c-dim); letter-spacing: 2px; white-space: nowrap; text-shadow: 2px 2px 0 #000; }
.sysbtns { display: flex; gap: 8px; }
#hud-style { position: absolute; right: calc(14px + var(--safe-r)); top: calc(76px + var(--safe-t)); text-align: right; font-family: var(--yoroll-font-title); }
#hud-style .rank.pop { animation: rank-pop 240ms steps(4); }
@keyframes rank-pop { 0% { transform: scale(1.7, 2); filter: brightness(2); } 100% { transform: scaleY(var(--tall)); filter: none; } }
#hud-style .rank { font-size: 72px; line-height: .8; color: var(--c-accent); text-shadow: 3px 3px 0 #0b5560, 6px 6px 0 #000, 0 0 20px rgba(61, 245, 255, .7); transform: scaleY(var(--tall)); transform-origin: 100% 0; }
#hud-style .combo { margin-top: 16px; font-size: var(--f-s); color: var(--c-text); font-family: var(--yoroll-font-hud); text-shadow: 2px 2px 0 #000; }
#hud-mode { display: none; position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--safe-b)); padding: 4px 16px 6px; font-family: var(--yoroll-font-title); font-size: var(--f-l); letter-spacing: 3px; white-space: nowrap;
  color: var(--c-foe); background: rgba(7, 6, 15, .7); border: 2px solid var(--c-foe); box-shadow: 4px 4px 0 #57005a, 0 0 16px rgba(255, 61, 240, .45); }
/* controls container. PC: the weapon bar with its caption, centred at the bottom (stick and round buttons are not shown). Touch: see "touch controls" below. */
#pad { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#pad-l, .pad-acts { display: none; }
#pad-r { display: flex; flex-direction: column; align-items: center; }
#wname { font-family: var(--yoroll-font-hud); font-size: var(--f-xs); color: var(--c-text); text-shadow: 2px 2px 0 #000; white-space: nowrap; background: rgba(7, 6, 15, .5); padding: 2px 10px 4px; }
#wbar { display: flex; gap: 8px; }
/* watching mode: no player controls */
body.auto #hud-mode { display: block; }
body.auto #pad, body.auto #hud-style { display: none !important; }

/* shared: weapon slot / list icon frame */
.wslot, .up-ico { --wc: var(--c-main); --ws: 50px; position: relative; width: var(--ws); height: var(--ws); box-sizing: border-box; padding: 0; flex: none; border-radius: 0;
  background: var(--c-plate); border: 2px solid var(--c-line); box-shadow: 3px 3px 0 #000; }
.up-ico { border-color: var(--wc); }
.wslot { pointer-events: auto; cursor: pointer; transition: transform var(--tick) steps(2); }
.wslot .ico, .up-ico .ico { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--yoroll-font-title); font-size: var(--f-l); line-height: 1; color: var(--wc); text-shadow: 0 0 10px var(--wc); background-repeat: no-repeat; }
.wslot .key { position: absolute; right: 2px; bottom: 2px; font-family: var(--yoroll-font-hud); font-size: var(--f-xs); line-height: .8; color: var(--c-text); text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.wslot .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, .74); }
.wslot.sel { transform: translateY(-4px); border-color: var(--wc); box-shadow: 2px 2px 0 #000, 0 0 12px var(--wc), inset 0 2px 0 rgba(255, 255, 255, .25); }
.wslot.ready { animation: slot-ready 260ms steps(3); }
/* hold ring: while USE stays down on a weapon that charges, a line runs round the frame (--hold 0 → 1, set from script); white when full */
.wslot .ring { position: absolute; inset: -2px; box-sizing: border-box; padding: 3px; pointer-events: none; opacity: 0; --rc: var(--wc);
  background: conic-gradient(from 0deg, var(--rc) calc(var(--hold, 0) * 360deg), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.wslot.holding .ring { opacity: 1; }
.wslot.full .ring { --rc: #fff; }
@keyframes slot-ready { 0% { filter: brightness(2.6); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) { .hpbar.hitfx, .hpbar.low .fill, #hud-timer.hurry, #hud-style .rank.pop, .wslot.ready { animation: none; } }

/* ---------- touch controls (touch / portrait) ---------- */
/* The pad (body.pad = touch device or portrait). One grid container: round pixel stick on the left, on the right one column —
   the six weapon squares (the weapon bar itself, 3 × 2, U I O over J K L like the keyboard) and under them a row with round DASH (left) + JUMP (right corner).
   Minimal look: see-through plates, a thin line, no drop shadows and no resting glow; colour appears only while something is pressed or in hand.
   Sizes follow the short side of the screen (numbers come from data.js WORM.PAD, written to these variables by UI.layout); the fallbacks below match them. */
:root { --pk: clamp(44px, 14vmin, 60px); --pgap: calc(var(--pk) * .13); --prow: calc(var(--pk) * .2); --pj: calc(var(--pk) * 1.45); --pdash: calc(var(--pk) * 1.15);
  --pstick: clamp(112px, 34vmin, 140px); --pknob: 40%; --pside: 16px; --pbot: 12px; --dock-h: clamp(292px, 46dvh, 400px);
  --k-plate: rgba(12, 11, 28, .26); --k-line: rgba(234, 255, 240, .3); --k-ico: .82; }
body.pad #pad { left: 0; right: 0; bottom: 0; transform: none; box-sizing: border-box; display: grid; grid-template-columns: auto minmax(12px, 1fr) auto; align-items: end; gap: 0;
  padding: 0 calc(var(--pside) + var(--safe-r)) calc(var(--pbot) + var(--safe-b)) calc(var(--pside) + var(--safe-l)); }
body.pad #pad-l { display: flex; align-items: center; justify-content: center; grid-column: 1; grid-row: 1; }
body.pad #pad-r { grid-column: 3; grid-row: 1; align-items: stretch; gap: var(--prow); }
body.pad #wname { display: none; }
body.pad #wbar { display: grid; grid-template-columns: repeat(3, var(--pk)); gap: var(--pgap); touch-action: none; }
body.pad .pad-acts { display: flex; align-items: center; justify-content: space-between; }
#stick { position: relative; flex: none; width: var(--pstick); height: var(--pstick); box-sizing: border-box; pointer-events: auto; border-radius: 50%; touch-action: none;
  background: center / 100% 100% no-repeat; image-rendering: pixelated; }
#stick .knob, #stick .gh { position: absolute; left: 50%; top: 50%; width: var(--pknob); height: var(--pknob); margin: calc(var(--pknob) / -2) 0 0 calc(var(--pknob) / -2); background: center / 100% 100% no-repeat; image-rendering: pixelated; pointer-events: none; }
#stick .knob { opacity: .8; }
#stick.live .knob { opacity: 1; filter: drop-shadow(0 0 6px rgba(182, 255, 60, .7)); }
#stick .gh { opacity: 0; filter: drop-shadow(0 0 5px rgba(182, 255, 60, .55)); }
.tbtn { --kc: 61, 245, 255; position: relative; flex: none; pointer-events: auto; cursor: pointer; box-sizing: border-box; border: 0; border-radius: 50%; padding: 0; background: center / 100% 100% no-repeat; image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center; touch-action: none; font-family: var(--yoroll-font-title); line-height: 1; color: rgba(234, 255, 240, .82); text-shadow: 1px 1px 0 rgba(0, 0, 0, .6);
  transition: background-color 90ms steps(2); }
.tbtn .tx { display: block; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; pointer-events: none; }
#btn-jump { width: var(--pj); height: var(--pj); font-size: var(--f-s); }
#btn-dash { --kc: 199, 125, 255; width: var(--pdash); height: var(--pdash); font-size: var(--f-xs); }
.tbtn.on { background-color: rgba(var(--kc), .3); color: #fff; box-shadow: inset 0 0 0 2px rgba(var(--kc), .95); }
#pad-bg { position: absolute; left: 0; right: 0; top: var(--play-h); bottom: 0; display: none;
  background: repeating-linear-gradient(0deg, #0d0a1d 0 6px, #0a0817 6px 12px); border-top: 2px solid var(--c-line); }
/* weapon squares on the pad: quiet at rest, lit by the weapon's own colour while pressed; the one in hand keeps a coloured line */
body.pad .wslot { --ws: var(--pk); touch-action: none; background: var(--k-plate); border: 1.5px solid var(--k-line); box-shadow: none; transition: background-color 90ms steps(2), border-color 90ms steps(2); }
body.pad .wslot .ico { opacity: var(--k-ico); text-shadow: none; }
body.pad .wslot .cd { background: rgba(0, 0, 0, .45); }
body.pad .wslot:nth-child(n + 4) { order: -1; }                 /* U I O on the top row, J K L under it */
body.pad .wslot.sel { transform: none; border-color: var(--wc); border-color: color-mix(in srgb, var(--wc) 90%, transparent); box-shadow: inset 0 0 10px rgba(255, 255, 255, .08); }
body.pad .wslot.on { background: rgba(255, 255, 255, .16); background: color-mix(in srgb, var(--wc) 30%, transparent); border-color: var(--wc); }
body.pad .wslot.on .ico { opacity: 1; }
body.pad .wslot.empty { opacity: .35; }
body.pad .wslot .key { font-size: 16px; opacity: .55; }
body.lang-zh.pad .wslot .key { font-size: 12px; }
@media (prefers-reduced-motion: reduce) { #stick.live .knob, #stick .gh { filter: none; } .tbtn, body.pad .wslot { transition: none; } }

/* ---------- portrait: arena on top, control dock below (dock height = --dock-h, the arena takes the rest) ---------- */
body.portrait { --pside: 12px; --pbot: 12px; }
body.portrait #pad-l { padding-bottom: 54px; }                  /* the sound / pause buttons sit under the stick, so the right-hand keys use the full height of the dock */
body.portrait #pad-bg { display: block; }
body.portrait #pad { top: var(--play-h); grid-template-rows: auto minmax(0, 1fr); align-items: center; padding-top: 8px; row-gap: 4px; }
body.portrait #wname { display: block; grid-column: 1 / -1; grid-row: 1; justify-self: center; min-width: 0; max-width: 100%; box-sizing: border-box; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; text-align: center; }   /* long move captions wrap inside the dock instead of being cut */
body.portrait #pad-l, body.portrait #pad-r { grid-row: 2; }
body.portrait #hud-mode { bottom: auto; top: calc(var(--play-h) + 40px); }
/* short landscape phones with the pad: rank letter and combo share one line, so they end above the weapon squares */
@media (max-height: 480px) and (orientation: landscape) {
  body.pad #hud-style { display: flex; flex-direction: row-reverse; align-items: center; gap: 10px; }
  body.pad #hud-style .rank { transform-origin: 100% 50%; }
  body.pad #hud-style .combo { margin-top: 0; }
}
body.portrait #hud-style .rank { font-size: 56px; }
body.portrait #hud-style { top: calc(64px + var(--safe-t)); }
body.portrait .hpbar { height: 26px; }
body.portrait .topbar { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; }
body.portrait #hud-arena { display: none; }
body.portrait .sysbtns { position: fixed; left: calc(var(--pside) + var(--safe-l) + var(--pstick) / 2); transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); }
body.portrait #title { flex-direction: column; justify-content: flex-end; align-items: stretch; padding: calc(16px + var(--safe-t)) calc(20px + var(--safe-r)) calc(28px + var(--safe-b)) calc(20px + var(--safe-l)); }
body.portrait .title-art { inset: 0 0 42% 0; background-position: 84% center;   /* keeps both worms (and their tap zones) on screen */
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 55%, transparent 100%); mask-image: linear-gradient(180deg, #000 0, #000 55%, transparent 100%); }
body.portrait .title-copy { align-items: center; text-align: center; gap: 14px; }
body.portrait #title h1 { font-size: clamp(76px, 25vw, 132px); transform-origin: 50% 50%; }
body.portrait #title h1 .b { margin-left: 0; }
body.portrait .menu { width: min(440px, 100%); gap: 10px 14px; }
body.portrait .menu .btn:not(.primary) { height: 44px; }
/* mid-height landscape: seven menu buttons (FIGHT + three rows) still fit under the logo */
@media (min-height: 481px) and (max-height: 740px) and (orientation: landscape) {
  #title h1 { font-size: clamp(80px, 20vh, 150px); margin: 12px 0 22px; }
  .title-copy { gap: 12px; }
  .menu { gap: 10px 14px; }
  .menu .btn:not(.primary) { height: 44px; }
  .menu .btn.primary { height: 54px; }
}

/* short landscape: compress the title so every button stays visible */
@media (max-height: 480px) and (orientation: landscape) {
  #title h1 { font-size: clamp(56px, 22vh, 100px); margin: 8px 0 14px; }
  #title h1 span { display: inline; }
  #title h1 .b { margin-left: .1em; }
  .title-copy { gap: 10px; }
  .menu { grid-template-columns: repeat(3, 1fr); width: min(560px, 60vw); gap: 10px 12px; }
  .menu .btn { height: 42px; font-size: var(--f-m); padding: 0 4px 2px; }
  .menu .btn.primary { grid-column: auto; height: 42px; font-size: var(--f-m); }
  #hud-style { top: calc(60px + var(--safe-t)); }
  #hud-style .rank { font-size: 48px; }
}

/* ---------- result / upgrade / rivals (reuse panel + btn) ---------- */
.btn.sm { height: 40px; min-width: 112px; padding: 0 6px 2px; font-size: var(--f-m); flex: none; }
.res { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.res-rank { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.res-rank b { font-family: var(--yoroll-font-title); font-weight: 400; font-size: 110px; line-height: .8; margin: 8px 0 14px; color: var(--c-main); text-shadow: 3px 3px 0 #5a9a00, 6px 6px 0 #2c4d00, 9px 9px 0 #000, 0 0 30px rgba(182, 255, 60, .7); transform: scaleY(var(--tall)); }
.res.lose .res-rank b { color: var(--c-foe); text-shadow: 3px 3px 0 #a000a0, 6px 6px 0 #57005a, 9px 9px 0 #000, 0 0 30px rgba(255, 61, 240, .6); }
.res-rank .lbl { font-size: var(--f-s); color: var(--c-dim); letter-spacing: 2px; white-space: nowrap; }
.res-grid { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px 14px; width: 100%; max-width: 520px; box-sizing: border-box; padding: 8px 12px 10px; background: var(--c-plate); border: 2px solid var(--c-line); text-align: left; font-size: var(--f-s); }
.res-grid span { color: var(--c-dim); }
.res-grid b { font-family: var(--yoroll-font-hud); font-weight: 400; color: var(--c-text); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-grid b:nth-of-type(odd) { padding-right: 14px; border-right: 2px solid var(--c-line); }
.res-spore { font-family: var(--yoroll-font-title); font-size: var(--f-l); color: var(--c-warn); letter-spacing: 1px; text-shadow: 0 0 10px rgba(255, 176, 46, .5); }
.res-spore small { font-size: var(--f-s); color: var(--c-dim); letter-spacing: 0; text-shadow: none; }
/* round 29: rewarded-ad double (only in the markup when an ad can be shown); one row under the spore line, the shared button shell */
.res-x2 { display: flex; justify-content: center; width: 100%; min-width: 0; }
.res-x2 .btn { height: 44px; min-width: 0; max-width: 100%; padding: 0 14px 2px; }
.res-x2 .btn .tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.res-spore .x2 { display: inline-block; margin-left: 6px; padding: 0 6px; background: var(--c-warn); color: #1a0f00; text-shadow: none; letter-spacing: 0; }
.res-spore.x2-pop { animation: x2-pop 480ms steps(4) 1; }
@keyframes x2-pop { 0% { filter: brightness(2.2); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) { .res-spore.x2-pop { animation: none; } }
.res-note { margin: 0; font-size: var(--f-s); line-height: 1.1; color: var(--c-accent); }
.up-head { margin: 4px 0 8px; color: var(--c-warn); font-family: var(--yoroll-font-title); font-size: var(--f-m); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.up-head b { font-weight: 400; font-size: var(--f-l); }
.up-head small { color: var(--c-dim); font-size: var(--f-xs); }
.up-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.up-list:last-child { margin-bottom: 0; }
.up-row { --wc: var(--c-main); display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px 8px 8px; background: var(--c-plate); border-left: 4px solid var(--wc); }
.up-row.cur { background: var(--c-plate2); box-shadow: inset 0 0 0 2px var(--wc); }
.up-ico { --ws: 46px; }
.up-info { min-width: 0; }
.up-info .nm { font-family: var(--yoroll-font-title); font-size: var(--f-m); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--wc); }
.up-info small { color: var(--c-dim); font-size: var(--f-xs); line-height: 1.05; display: block; margin-top: 4px; }
.up-sec { margin-top: 6px; padding-bottom: 2px; font-size: var(--f-xs); letter-spacing: 1px; color: var(--c-accent); border-bottom: 2px solid var(--c-line); }
.up-sec:first-child { margin-top: 0; }
.pv-tag.try { color: var(--c-warn); }
.set-on { color: var(--c-main); }
.set-off { color: var(--c-warn); opacity: .8; }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 10px; height: 10px; background: #05040c; outline: 2px solid var(--c-line); }
.pips i.on { background: var(--wc); }
/* ---------- shop: preview + loadout (left) / tabs + catalog (right). Reuses panel, btn, up-row, up-ico ---------- */
/* D.I.Y.: the panel itself never scrolls. Left column (preview + key slots) stays put, the right column keeps its billboard, header and tabs
   fixed and only the catalog list scrolls. The generic panel header is hidden: the D.I.Y. header sits over the right column only. */
.panel.shop-panel { width: min(1020px, 100%); height: 100%; max-height: 760px; }
.panel.shop-panel > .panel-head { display: none; }
.panel.shop-panel > .panel-body { flex: 1 1 auto; overflow: hidden; padding: 4px 2px 10px; display: flex; }
.shop { flex: 1 1 auto; min-width: 0; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; }
.shop-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; overflow-y: auto; box-sizing: border-box; padding: 10px; margin: 0 4px 4px 0; background: var(--c-plate); border: 2px solid var(--c-line); box-shadow: 4px 4px 0 #000; }
.shop-right { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding-right: 4px; }
.shop-right > * { flex: none; }
.shop-right > .up-list { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 0; padding: 2px 6px 4px 2px; -webkit-overflow-scrolling: touch; }
.shop-right > .up-head { margin: 0 0 8px; }
.diy-head { display: flex; align-items: center; gap: 8px; padding: 0 0 8px; margin-bottom: 10px; border-bottom: 2px solid var(--c-line); }
.diy-head h2 { flex: 1; margin: 0; padding-left: 52px; text-align: center; font-family: var(--yoroll-font-title); font-weight: 400; font-size: var(--f-xl); line-height: 1; letter-spacing: 3px; color: var(--c-accent);
  text-shadow: 2px 2px 0 #073c46, 4px 4px 0 #000, 0 0 18px rgba(61, 245, 255, .35); transform: scaleY(var(--tall)); }
/* key slots: tap one, tap another, they swap */
.keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding: 4px 2px 6px; }
.up-ico.kslot { --ws: auto; width: 100%; height: auto; aspect-ratio: 1 / 1; min-width: 0; }
.kslot .key { position: absolute; right: 2px; bottom: 2px; font-family: var(--yoroll-font-hud); font-size: var(--f-xs); line-height: .8; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.kslot.empty { border-style: dashed; }
.kslot.fixed { opacity: .7; }
.kslot.pick { transform: translateY(-4px); border-color: #fff; box-shadow: 3px 3px 0 #000, 0 0 14px var(--c-warn), inset 0 0 0 2px var(--c-warn); animation: key-pick 520ms steps(2) infinite; }
@keyframes key-pick { 0% { filter: brightness(1.5); } 100% { filter: none; } }
/* after a swap: a streak of light runs around both slots */
@property --ka { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.kslot.swapfx { animation: key-pop 700ms steps(7) 1; z-index: 1; }
.kslot.swapfx::after { content: ''; position: absolute; inset: -7px; padding: 3px; pointer-events: none;
  background: conic-gradient(from var(--ka), transparent 0 50%, var(--c-warn) 72%, #fff 92%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  filter: drop-shadow(0 0 4px var(--c-warn)); animation: key-run 850ms linear 1 forwards; }
@keyframes key-run { 0% { --ka: 0deg; opacity: 1; } 75% { opacity: 1; } 100% { --ka: 720deg; opacity: 0; } }
@keyframes key-pop { 0% { filter: brightness(2.6); transform: scale(1.16); } 100% { filter: none; transform: none; } }
/* swap show (meta.js swapFx): the icons fly across on an arc, a beam links the two slots, ghost dots trail the flight and both slots burst */
.keys { position: relative; }
.kslot { overflow: visible; }
.kslot.swapfx { z-index: 4; }
.sw-beam, .sw-dot, .sw-spark, .sw-ring { position: absolute; pointer-events: none; z-index: 2; }
.sw-beam { height: 4px; margin-top: -2px; transform-origin: 0 50%; background: linear-gradient(90deg, var(--c1), #fff 50%, var(--c0)); box-shadow: 0 0 10px #fff, 0 0 18px var(--c-warn); animation: sw-beam 520ms steps(8) 1 forwards; }
@keyframes sw-beam { 0% { opacity: 0; clip-path: inset(0 50% 0 50%); height: 8px; margin-top: -4px; } 25% { opacity: 1; clip-path: inset(0 0 0 0); } 70% { opacity: 1; height: 4px; margin-top: -2px; } 100% { opacity: 0; clip-path: inset(0 0 0 0); height: 2px; margin-top: -1px; } }
.sw-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; opacity: 0; box-shadow: 0 0 8px #fff; animation: sw-dot 420ms steps(5) 1 forwards; }
@keyframes sw-dot { 0% { opacity: 0; transform: scale(2); } 20% { opacity: .95; } 100% { opacity: 0; transform: scale(.3); } }
.sw-spark { width: 4px; height: 4px; margin: -2px 0 0 -2px; opacity: 0; animation: sw-spark 520ms steps(7) 380ms 1 forwards; }
@keyframes sw-spark { 0% { opacity: 1; transform: translate(0, 0) scale(1.6); } 100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(.5); } }
.sw-ring { width: 12px; height: 12px; margin: -8px 0 0 -8px; border: 2px solid #fff; opacity: 0; box-shadow: 0 0 10px #fff; animation: sw-ring 460ms steps(6) 380ms 1 forwards; }
@keyframes sw-ring { 0% { opacity: 1; transform: scale(.6); } 100% { opacity: 0; transform: scale(5); } }
/* rivals list: the six weapons a rival carries */
.kit { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kit .up-ico.mini { --ws: 30px; }

/* ---------- scrollbars: square neon pixel bars instead of the browser default ---------- */
.panel-body::-webkit-scrollbar, .up-list::-webkit-scrollbar, .shop-left::-webkit-scrollbar { width: 14px; height: 14px; }
.panel-body::-webkit-scrollbar-track, .up-list::-webkit-scrollbar-track, .shop-left::-webkit-scrollbar-track {
  background: repeating-linear-gradient(0deg, #05040c 0 4px, #0c0b1c 4px 8px); border-left: 2px solid var(--c-line); box-shadow: inset 2px 0 0 #000; }
.panel-body::-webkit-scrollbar-thumb, .up-list::-webkit-scrollbar-thumb, .shop-left::-webkit-scrollbar-thumb {
  min-height: 36px; border: 2px solid #05040c; border-left-width: 4px; border-radius: 0;
  background: linear-gradient(90deg, #fff 0 2px, var(--c-accent) 2px 6px, #0b8a94 6px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .7), inset 0 -2px 0 #073c46; }
.panel-body::-webkit-scrollbar-thumb:hover, .up-list::-webkit-scrollbar-thumb:hover, .shop-left::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, #fff 0 2px, var(--c-main) 2px 6px, #5a9a00 6px); }
.panel-body::-webkit-scrollbar-thumb:active, .up-list::-webkit-scrollbar-thumb:active, .shop-left::-webkit-scrollbar-thumb:active { background: linear-gradient(90deg, #fff 0 2px, var(--c-warn) 2px 6px, #6a4300 6px); }
.panel-body::-webkit-scrollbar-button, .up-list::-webkit-scrollbar-button, .shop-left::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.panel-body::-webkit-scrollbar-corner, .up-list::-webkit-scrollbar-corner, .shop-left::-webkit-scrollbar-corner { background: #05040c; }
/* browsers without the ::-webkit-scrollbar parts (Firefox): coloured thin bar */
@supports not selector(::-webkit-scrollbar) { .panel-body, .up-list, .shop-left { scrollbar-width: thin; scrollbar-color: var(--c-accent) #05040c; } }
@media (prefers-reduced-motion: reduce) { .sw-beam, .sw-dot, .sw-spark, .sw-ring { display: none; } }

/* half-price billboard: bulbs chase along the edges, the offer scrolls right to left and halts now and then for a slogan */
.ad { position: relative; display: block; width: 100%; height: 44px; box-sizing: border-box; padding: 0; margin: 0 0 10px; overflow: hidden; pointer-events: auto; cursor: pointer; border-radius: 0;
  background: #1a0f00; border: 2px solid var(--c-warn); color: var(--c-warn); font-family: var(--yoroll-font-title); font-size: var(--f-m); line-height: 1; text-align: left;
  box-shadow: 4px 4px 0 #6a4300, 0 0 18px rgba(255, 176, 46, .45); }
.ad::before, .ad::after { content: ''; position: absolute; left: 0; right: 0; height: 4px; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(90deg, #fff 0 4px, transparent 4px 8px, var(--c-foe) 8px 12px, transparent 12px 16px); animation: ad-bulbs 480ms steps(2) infinite; }
.ad::before { top: 0; } .ad::after { bottom: 0; animation-direction: reverse; }
@keyframes ad-bulbs { 0% { background-position: 0 0; } 100% { background-position: 16px 0; } }
.ad-run { position: absolute; inset: 0; display: flex; align-items: center; overflow: hidden; }
.ad-track { display: inline-flex; flex: none; white-space: nowrap; will-change: transform; animation: ad-scroll 9s linear infinite; }
.ad-track > span { flex: none; padding-right: 8px; }
.ad-track b { font-weight: 400; color: #fff; text-shadow: 0 0 10px var(--c-warn); }
.ad-track s { color: var(--c-dim); }
.ad-track i { color: var(--c-foe); }
@keyframes ad-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.ad.halt .ad-track { animation-play-state: paused; opacity: .25; }
.ad-stamp { position: absolute; inset: 4px 0; z-index: 1; display: none; align-items: center; justify-content: center; white-space: nowrap; color: #1a0f00; background: var(--c-warn); letter-spacing: 2px; }
.ad.halt .ad-stamp { display: flex; animation: ad-stamp 1700ms steps(1) 1; }
@keyframes ad-stamp { 0% { filter: brightness(2.2); transform: scale(1.2, 1.5); } 8% { filter: none; transform: none; } 50% { filter: brightness(1.5); } 60% { filter: none; } }
.ad:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #6a4300; }
.ad:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.tagk.sale { color: #1a0f00; background: var(--c-warn); padding: 0 6px 2px; box-shadow: 2px 2px 0 #000; }
.up-row.deal { box-shadow: inset 0 0 0 2px var(--c-warn), 0 0 14px rgba(255, 176, 46, .35); }
.tabs .btn.sale::after, .sale-tag { position: absolute; right: 2px; top: 2px; padding: 0 5px 2px; font-family: var(--yoroll-font-hud); font-size: var(--f-xs); line-height: 1; color: #1a0f00; background: var(--c-warn); box-shadow: 2px 2px 0 #000; text-shadow: none; }
.tabs .btn.sale::after { content: '%'; }
.sale-tag { display: none; }
.btn.sale .sale-tag { display: block; animation: key-pick 700ms steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .ad-track, .ad::before, .ad::after, .kslot.pick, .kslot.swapfx, .kslot.swapfx::after, .btn.sale .sale-tag, .ad.halt .ad-stamp { animation: none; } .kslot.swapfx::after { display: none; } }
/* training ground: small control strip under the health bars */
#train-bar { display: none; position: absolute; left: calc(16px + var(--safe-l)); top: calc(54px + var(--safe-t)); align-items: center; flex-wrap: wrap; gap: 8px 10px; max-width: min(560px, calc(100vw - 150px)); }
body.training #train-bar { display: flex; }
#train-info { flex: 1 1 100%; font-family: var(--yoroll-font-hud); font-size: var(--f-xs); color: var(--c-accent); letter-spacing: 1px; text-shadow: 2px 2px 0 #000; white-space: nowrap; }
#train-bar .btn.sm { min-width: 0; height: 38px; padding: 0 10px 2px; font-size: var(--f-s); }
body.training #hud-timer { color: var(--c-accent); }
.pv-box { position: relative; background: repeating-linear-gradient(0deg, #0d0a1d 0 6px, #0a0817 6px 12px); border: 2px solid var(--c-accent); box-shadow: inset 0 0 26px rgba(61, 245, 255, .25), 3px 3px 0 #073c46; }
.pv-box canvas { display: block; width: 100%; aspect-ratio: 88 / 48; image-rendering: pixelated; }
.pv-tag { position: absolute; left: 6px; top: 4px; font-size: var(--f-xs); color: var(--c-accent); text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
.lo-spores { font-family: var(--yoroll-font-title); font-size: var(--f-l); color: var(--c-warn); text-shadow: 0 0 10px rgba(255, 176, 46, .5); }
.lo-spores b { font-weight: 400; }
.lo { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: var(--f-xs); padding: 6px 0; border-top: 2px solid var(--c-line); border-bottom: 2px solid var(--c-line); }
.lo span { color: var(--c-dim); }
.lo b { font-weight: 400; text-align: right; color: var(--c-text); }
.lo-sec { font-size: var(--f-xs); color: var(--c-accent); letter-spacing: 1px; }
.lo-ics { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; align-items: center; font-size: var(--f-xs); color: var(--c-dim); }
.lo-ics.lo-w { gap: 4px; }
.up-ico.mini { --ws: 34px; box-shadow: 2px 2px 0 #000; }
.up-ico.mini .lv { position: absolute; right: 1px; bottom: 1px; font-size: 16px; line-height: .8; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; margin-bottom: 12px; padding-right: 6px; }
/* weapon rows: upgrade + carry buttons side by side; achievements: status tag instead of a button */
.row-btns { display: flex; gap: 8px; align-items: center; }
.ach-st { min-width: 96px; text-align: center; font-family: var(--yoroll-font-title); font-size: var(--f-s); color: var(--wc); letter-spacing: 1px; text-shadow: 0 0 10px var(--wc); }
.up-row.ach.off .nm, .up-row.ach.off .ach-st { color: var(--c-dim); text-shadow: none; }
.res-note.ach-note { color: var(--c-warn); text-shadow: 0 0 10px rgba(255, 176, 46, .6); }
/* round 26: stars of a ladder rival (rivals list + result) and the rule tag of a world-tour duel. Code-drawn: a clipped square per star. */
.stars { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: middle; }
.stars i { display: block; width: 12px; height: 12px; background: var(--c-line); clip-path: polygon(50% 0, 63% 34%, 100% 38%, 72% 61%, 81% 100%, 50% 78%, 19% 100%, 28% 61%, 0 38%, 37% 34%); }
.stars i.on { background: var(--c-warn); filter: drop-shadow(0 0 4px rgba(255, 176, 46, .8)); }
.res-stars { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 6px; }
.res-stars .stars { margin-left: 0; gap: 6px; }
.res-stars .stars i { width: 24px; height: 24px; }
.res-stars .lbl { font-size: var(--f-xs); color: var(--c-warn); letter-spacing: 1px; }
.up-info small.mut { color: var(--c-warn); }
.wslot.empty { opacity: .45; cursor: default; border-style: dashed; }
/* secret tap zones over the two worms of the title art (placed from script) */
.egg { position: absolute; cursor: default; -webkit-tap-highlight-color: transparent; }
.tabs .btn { min-width: 0; width: 100%; height: 40px; padding: 0 4px 2px; font-size: var(--f-s); }
.tabs .btn.on { background: var(--c-warn); color: #1a0f00; text-shadow: none; box-shadow: 4px 4px 0 var(--bd), 0 0 16px var(--bg), inset 0 3px 0 rgba(255, 255, 255, .5); }
button.up-ico { pointer-events: auto; cursor: pointer; font: inherit; color: inherit; transition: transform var(--tick) steps(2); }
button.up-ico:hover { filter: brightness(1.35); }
button.up-ico:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
button.up-ico:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.up-row.pvw { box-shadow: inset 0 0 0 2px var(--c-accent); }
.tagk { font-size: var(--f-xs); color: var(--c-dim); letter-spacing: 1px; white-space: nowrap; }
/* narrow: preview strip on top (preview | spores + look, key slots across the full width), catalog below; still only the list scrolls */
@media (max-width: 899px) {
  .panel.shop-panel { max-height: none; }
  .shop { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 10px; }
  .shop-left { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 4px 12px; align-items: start; overflow: visible; padding: 8px; margin: 0 4px 0 0; }
  .shop-left > * { grid-column: 2; }
  .shop-left > .pv-box { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .shop-left > .lo-t { display: none; }
  .shop-left > .lo-k, .shop-left > .keys { grid-column: 1 / -1; }
  .keys { gap: 8px; padding: 2px 2px 4px; max-width: 420px; }
  .shop-right { padding-right: 0; }
  .diy-head { margin-bottom: 8px; padding-bottom: 6px; }
}
@media (max-width: 619px) {
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; margin-bottom: 8px; }
  .row-btns { flex-direction: column; gap: 6px; }
  .ach-st { min-width: 0; font-size: var(--f-xs); }
  .lo-spores { font-size: var(--f-m); }
  .lo { padding: 4px 0 0; border-bottom: 0; gap: 2px 10px; }
  .lo > :nth-child(n + 5) { display: none; }      /* phones: skin + head only, the rest is read from the tabs */
  .shop-right > .up-head { display: none; }
  .diy-head h2 { font-size: 40px; padding-left: 48px; }
  .ad { height: 40px; font-size: var(--f-s); margin-bottom: 8px; }
  #train-bar { top: calc(46px + var(--safe-t)); gap: 6px; max-width: calc(100vw - 110px); }
  #train-bar .btn.sm { height: 36px; padding: 0 7px 2px; font-size: var(--f-xs); }
}
/* short landscape: left column beside the catalog again, compact */
@media (max-height: 480px) and (orientation: landscape) {
  .shop { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 12px; }
  .shop-left { display: flex; overflow-y: auto; gap: 4px; padding: 6px; }
  .shop-left > .lo, .shop-left > .lo-t { display: none; }
  .keys { gap: 4px; }
  .diy-head { padding-bottom: 2px; margin-bottom: 6px; }
  .diy-head h2 { font-size: 34px; }
  .tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 6px; }
  .tabs .btn { height: 36px; font-size: var(--f-xs); }
  .shop-right > .up-head { display: none; }
  .ad { height: 34px; font-size: var(--f-s); margin-bottom: 6px; }
  .panel.shop-panel > .panel-actions { display: none; }      /* the X in the D.I.Y. header closes it */
}

@media (max-width: 520px) {
  .panel { padding: 8px 10px 12px; }
  .panel-head h2 { font-size: 40px; padding-left: 48px; letter-spacing: 1px; }
  .panel-actions { gap: 10px; padding-top: 12px; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
  .panel-actions .btn { height: 46px; font-size: var(--f-m); }
  .up-row { gap: 8px; padding: 6px; }
  .btn.sm { min-width: 92px; }
  .res-rank b { font-size: 88px; }
  .res-grid { gap: 6px 8px; padding: 8px; }
  .res-grid b:nth-of-type(odd) { padding-right: 8px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .panel { width: min(720px, 100%); padding: 6px 12px 10px; }
  .panel-head { padding-bottom: 4px; }
  .panel-head h2 { font-size: 36px; }
  .panel-x { width: 40px; height: 40px; }
  .panel-body { padding: 8px 2px; }
  .panel-actions { padding-top: 8px; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .panel-actions .btn { height: 42px; font-size: var(--f-m); }
  .res { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
  .res-rank b { font-size: 64px; margin: 4px 0 8px; }
  .res-grid { flex: 1 1 300px; }
  .res-spore, .res-note, .res-x2 { flex: 1 1 100%; }
}

/* ---------- how to play / settings dialog: sticky tabs (how to play / sound / controls / language) ---------- */
.panel.help-panel { width: min(760px, 100%); }
.help-tabs { position: sticky; top: -12px; z-index: 3; margin: -12px 0 10px; padding: 12px 6px 10px 0; background: #0a0918; border-bottom: 2px solid var(--c-line); }
.set-row { display: flex; align-items: center; gap: 10px; margin: 12px 6px 12px 0; }
.set-l { flex: 0 0 132px; font-family: var(--yoroll-font-title); font-size: var(--f-m); color: var(--c-text); white-space: nowrap; }
.set-v { flex: 0 0 62px; text-align: right; font-weight: 400; color: var(--c-warn); font-size: var(--f-m); font-variant-numeric: tabular-nums; }
.vbar { flex: 1 1 120px; min-width: 0; max-width: 320px; height: 28px; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; padding: 3px; box-sizing: border-box; background: #05040c; border: 2px solid var(--c-line); box-shadow: 3px 3px 0 #000; }
.vbar i { background: #1a1736; }
.vbar i.on { background: var(--c-accent); box-shadow: 0 0 8px rgba(61, 245, 255, .6), inset 0 2px 0 rgba(255, 255, 255, .5); }
.set-row[data-vol="music"] .vbar i.on { background: var(--c-foe); box-shadow: 0 0 8px rgba(255, 61, 240, .6), inset 0 2px 0 rgba(255, 255, 255, .5); }
.set-row[data-vol="sfx"] .vbar i.on { background: var(--c-main); box-shadow: 0 0 8px rgba(182, 255, 60, .6), inset 0 2px 0 rgba(255, 255, 255, .5); }
.set-row .sq { font-size: var(--f-l); }
.set-row .sq:disabled { color: var(--c-line); cursor: default; transform: none; }
.set-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; margin: 8px 6px 10px 0; }
.set-opts .btn { min-width: 0; width: 100%; }
.set-opts .btn.on { background: var(--c-warn); color: #1a0f00; text-shadow: none; box-shadow: 4px 4px 0 var(--bd), 0 0 16px var(--bg), inset 0 3px 0 rgba(255, 255, 255, .5); }
.set-opts .btn.only { grid-column: 1; cursor: default; }
.set-note { color: var(--c-dim); font-size: var(--f-xs); line-height: 1.15; margin: 6px 0 10px; }
@media (max-width: 519px) {
  .set-row { flex-wrap: wrap; gap: 8px; }
  .set-l { flex: 1 1 100%; }
  .set-v { flex: 0 0 54px; }
}
/* ---------- Chinese: drawn with the Chinese pixel face (WormCJK). Sizes sit on its 12px grid (12 / 18 / 24 / 36) so the pixels stay square; no tall-pixel stretch, normal line height.
   Glyphs the pixel face lacks fall through to the smooth CJK face. ---------- */
body.lang-zh { --f-xs: 12px; --f-s: 18px; --f-m: 18px; --f-l: 24px; --f-xl: 36px; --tall: 1; --tall-s: 1;
  /* one face for Chinese, digits and key letters, so mixed lines keep one size; the logo, timer and rank letters stay in the Latin pixel face */
  --yoroll-font-title: "WormCJK", "Yoroll_source-han-sans-sc-medium", "WormPixel", sans-serif; --yoroll-font-body: "WormCJK", "Yoroll_source-han-sans-sc-medium", "WormPixel", sans-serif; --yoroll-font-hud: "WormCJK", "Yoroll_source-han-sans-sc-medium", "WormPixel", sans-serif; }
body.lang-zh #ui, body.lang-zh #ui button { letter-spacing: 0; font-style: italic; }      /* Chinese is slanted too: the same italic pixel look as the English UI */
body.lang-zh #title h1, body.lang-zh #hud-timer, body.lang-zh #hud-style .rank, body.lang-zh .res-rank b { font-family: "WormPixel", monospace; }
body.lang-zh #hud-timer { font-size: 52px; transform: scaleY(1.34); }
body.lang-zh #hud-style .rank, body.lang-zh .res-rank b { transform: scaleY(1.34); }
body.lang-zh .btn .tx { line-height: 1.5; }
body.lang-zh .ad { line-height: 1.5; }
body.lang-zh .panel-head h2, body.lang-zh .diy-head h2 { letter-spacing: 2px; line-height: 1.2; }
body.lang-zh .panel-body { line-height: 1.35; }
body.lang-zh .up-info small, body.lang-zh .help-w small, body.lang-zh .set-note { line-height: 1.3; }
body.lang-zh .kicker { letter-spacing: 2px; }
body.lang-zh #title h1, body.lang-zh #hud-timer, body.lang-zh #hud-style .rank, body.lang-zh .res-rank b { font-style: italic; }
body.lang-zh #title h1 { transform: scaleY(1.34); }
body.lang-zh .sq { font-size: 12px; }
body.lang-zh .set-row .sq { font-size: 24px; }
/* Chinese logo: the Chinese pixel face, slanted, two lines (one line on short landscape screens) */
body.lang-zh #title h1 { font-family: "WormCJK", "WormPixel", sans-serif; font-style: italic; transform: none; line-height: 1.3; letter-spacing: 0; font-size: clamp(48px, 6.4vw, 96px); margin: 0 0 10px; }
body.lang-zh #title h1 span { padding: 0 .22em 0 .04em; }      /* room for the slant, so the glyphs stay inside their own box */
body.lang-zh #title h1 .b { margin-left: .3em; }
body.lang-zh.portrait #title h1 { font-size: clamp(48px, 16vw, 88px); }
body.lang-zh.portrait #title h1 .b { margin-left: 0; }
@media (min-height: 481px) and (max-height: 740px) and (orientation: landscape) { body.lang-zh #title h1 { font-size: clamp(44px, 10.5vh, 80px); } }
@media (max-height: 480px) and (orientation: landscape) { body.lang-zh #title h1 { font-size: clamp(32px, 12vh, 52px); margin: 0 0 6px; } body.lang-zh #title h1 .b { margin-left: 0; } body.lang-zh #title h1 span { padding: 0 .1em 0 0; } }
/* language picker: the Chinese option is always drawn small and slanted in the Chinese pixel face */
.set-opts .btn .tx.zhl { font-family: "WormCJK", "Yoroll_source-han-sans-sc-medium", sans-serif; font-size: 18px; font-style: italic; line-height: 1.5; letter-spacing: 0; transform: none; }

/* ---------- CONTROLS tab pictures: PC keys, phone pad in landscape and portrait ---------- */
.dev-tag { display: inline-block; margin-left: 10px; padding: 1px 8px 3px; font-size: var(--f-xs); line-height: 1; letter-spacing: 1px; color: #1a0f00; background: var(--c-warn); text-shadow: none; vertical-align: middle; box-shadow: 2px 2px 0 #000; }
.dg-kb, .dg-row { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: center; margin: 10px 6px 14px 0; padding: 14px 10px 10px; background: var(--c-plate); border: 2px solid var(--c-line); }
.kb-g { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kb-r { display: flex; gap: 4px; }
.kb-g span, .dg figcaption { margin-top: 4px; font-size: var(--f-xs); line-height: 1.1; color: var(--c-dim); white-space: nowrap; }
.dg-kb kbd { --kc: var(--c-line); box-sizing: border-box; min-width: 34px; height: 34px; padding: 0 6px 2px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--yoroll-font-title); font-style: italic; font-size: var(--f-xs); line-height: 1;
  color: var(--kc); background: #05040c; border: 2px solid var(--kc); box-shadow: 3px 3px 0 #000; }
.dg-kb kbd:not(.j):not(.d):not(.u) { color: var(--c-text); }
.dg-kb kbd.j { --kc: var(--c-accent); } .dg-kb kbd.d { --kc: var(--c-witch); } .dg-kb kbd.u { --kc: var(--c-warn); }
.dg-kb kbd.w2 { min-width: 66px; } .dg-kb kbd.w3 { min-width: 112px; }
.dg { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dg-scr { position: relative; box-sizing: border-box; overflow: hidden; background: #05040c; border: 2px solid var(--c-accent); box-shadow: 4px 4px 0 #073c46; }
.dg.land .dg-scr { width: 248px; height: 118px; }
.dg.port .dg-scr { width: 118px; height: 212px; }
.dg-ar { position: absolute; left: 0; right: 0; top: 8px; text-align: center; font-size: var(--f-xs); line-height: 1; color: var(--c-line); letter-spacing: 2px; }
.dg-bot { position: absolute; left: 0; right: 0; bottom: 0; height: 46%; border-top: 2px solid var(--c-line); background: repeating-linear-gradient(0deg, #0d0a1d 0 4px, #0a0817 4px 8px); }
/* the pad in small, same shape as the real one: thin-line stick, 3 × 2 squares, DASH + JUMP on one row under them (sizes passed in from WORM.PAD) */
.dg-stick { position: absolute; left: 8px; bottom: 10px; width: 34px; height: 34px; box-sizing: border-box; border-radius: 50%; border: 1px solid rgba(234, 255, 240, .5); background: rgba(12, 11, 28, .4); }
.dg-stick::after { content: ''; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--c-main); opacity: .85; }
.dg-pad { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: var(--rg, 3px); }
.dg-keys { display: grid; grid-template-columns: repeat(3, var(--u, 13px)); gap: var(--g, 2px); }
.dg-pad i { width: var(--u, 13px); height: var(--u, 13px); box-sizing: border-box; border: 1px solid var(--c-warn); background: rgba(12, 11, 28, .4); }
.dg-acts { display: flex; align-items: center; justify-content: space-between; }
.dg-pad b { box-sizing: border-box; border-radius: 50%; background: rgba(12, 11, 28, .4); }
.dg-pad b.d { width: var(--d, 15px); height: var(--d, 15px); border: 1px solid var(--c-witch); }
.dg-pad b.j { width: var(--j, 19px); height: var(--j, 19px); border: 1px solid var(--c-accent); }
.dg.port .dg-stick { left: 6px; bottom: 28px; }
.dg.port .dg-pad { right: 6px; bottom: 20px; }
/* tucked-away credit line at the very end of HOW TO PLAY (shown by one more pull past the bottom) */
.panel-body .credit { display: none; margin: 22px 0 0; text-align: center; font-size: 16px; line-height: 1.2; letter-spacing: 2px; color: #4b4788; }
.panel-body .credit.show { display: block; }
body.lang-zh .panel-body .credit { font-size: 12px; letter-spacing: 1px; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); padding: 6px 22px 10px; background: var(--c-plate); border: 2px solid var(--c-warn); color: var(--c-warn);
  font-family: var(--yoroll-font-title); font-size: var(--f-xl); line-height: 1; letter-spacing: 2px; text-shadow: 0 0 12px rgba(255, 176, 46, .6); box-shadow: 4px 4px 0 #6a4300, 0 0 18px rgba(255, 176, 46, .4); width: max-content; max-width: 90vw; box-sizing: border-box; text-align: center; opacity: 0; transition: opacity var(--tick) steps(3); z-index: 30; }
#toast.show { opacity: 1; }
