/* The UI rules (type steps, button tiers, colours, spacing, fit, HUD tiers) are in DESIGN.md "UI system".
   Every size below is one of these tokens, a multiple of 4, or a display clamp() on a hero element. */
:root {
  --a: #22e5ff;   /* floor colours: set per floor by applyTheme; decoration only, never a button */
  --b: #ff2e88;
  --y: #ffd23f;   /* yellow fill = the main action; yellow outline = selected */
  --ok: #3dff7a;  /* green = ready, locked in */
  --red: #ff2e55; /* red = danger, damage, FIRED */
  --ink: #07050a;
  --paper: #f4efe4;
  --display: 'Anton', Impact, 'Arial Narrow Bold', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --hand: 'Caveat', 'Comic Sans MS', cursive;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --fs-cap: 11px; --fs-body: 14px; --fs-label: 18px; --fs-action: 24px; --fs-head: 36px;
  --h1: 72px; --h2: 64px; --h3: 44px;   /* main, secondary, anything else you can tap */
}
@media (max-height: 520px) { :root { --h1: 56px; --h2: 48px; } }
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #fff;
  font-family: var(--mono); font-size: var(--fs-body); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#touchpad { position: fixed; inset: 0; z-index: 1; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; touch-action: manipulation; }

/* ---------- buttons: time cards ---------- */
.btn {
  --rot: .8deg;
  position: relative; display: inline-flex; flex-flow: row wrap; align-items: center; align-content: center; column-gap: .3em; row-gap: 4px;
  min-height: var(--h2); padding: 8px 24px 8px 36px; text-align: left;
  font: 400 var(--fs-action)/1 var(--display); letter-spacing: .04em; text-transform: uppercase;
  background: var(--paper); color: var(--ink); border: 0; cursor: pointer;
  transform: rotate(var(--rot)); box-shadow: 3px 4px 0 rgba(0,0,0,.6); transition: transform .08s, box-shadow .08s, background .12s;
}
/* the column of punched holes down the left edge */
.btn::before { content: ''; position: absolute; left: 12px; top: 10px; bottom: 10px; width: 8px;
  background: radial-gradient(circle, var(--ink) 2.5px, transparent 3px) center top / 8px 12px repeat-y; opacity: .85; }
/* the hole a click punches (main.js adds .punched) */
.btn::after { content: ''; position: absolute; right: 12px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); transform: scale(0); }
.btn.punched::after { animation: punchHole .6s cubic-bezier(.2, 1.8, .4, 1) forwards; }
@keyframes punchHole { 25% { transform: scale(1.5); } 70% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.btn small { flex-basis: 100%; font: 800 var(--fs-cap)/1.2 var(--mono); letter-spacing: .08em; color: rgba(7,5,10,.6); }
.btn:nth-child(even) { --rot: -.6deg; }
.btn.big { --rot: -1.2deg; min-height: var(--h1); background: var(--y); }
.btn.big small { color: rgba(70,52,0,.8); }
.btn:hover, .btn:focus-visible { outline: none; background: #fff; transform: rotate(var(--rot)) translate(-2px, -4px); box-shadow: 6px 8px 0 rgba(0,0,0,.6); }
.btn.big:hover, .btn.big:focus-visible { background: #ffe27a; }
.btn:focus-visible { box-shadow: 6px 8px 0 rgba(0,0,0,.6), 0 0 0 4px #fff; }
.btn:active { transform: rotate(var(--rot)) translate(2px, 4px); box-shadow: 1px 0 0 rgba(0,0,0,.6); }
.btn.ghost { --rot: 0deg; min-height: var(--h3); padding: 0 8px; justify-content: center; background: none; box-shadow: none; color: #fff;
  font-size: var(--fs-label); letter-spacing: .1em; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.btn.ghost::before, .btn.ghost::after { display: none; }
.btn.ghost:hover, .btn.ghost:focus-visible { background: none; box-shadow: none; transform: none; color: var(--y); }
.btn.ghost:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: .4; pointer-events: none; }
/* chips: small outlined helpers, an icon and a word */
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h3); min-width: var(--h3); padding: 0 12px;
  border: 2px solid currentColor; background: none; color: inherit; cursor: pointer; font: 800 var(--fs-body)/1 var(--mono); letter-spacing: .04em; }
.chip svg { width: 18px; height: 18px; flex: none; }
.chip:hover, .chip:focus-visible { outline: none; background: rgba(0,0,0,.08); }
.chip:active { transform: translate(1px, 2px); }

.menu { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
.menu.col { flex-direction: column; }
/* menu buttons deal themselves in, one after another, each time their screen opens */
.screen .menu > .btn, .r-actions > .btn, .d-actions > .btn { animation: dealIn .38s cubic-bezier(.2,1.5,.4,1) backwards; }
.screen .menu > .btn:nth-child(2), .r-actions > .btn:nth-child(2), .d-actions > .btn:nth-child(2) { animation-delay: .06s; }
.screen .menu > .btn:nth-child(3), .r-actions > .btn:nth-child(3) { animation-delay: .12s; }
.screen .menu > .btn:nth-child(4), .r-actions > .btn:nth-child(4) { animation-delay: .18s; }
.screen .menu > .btn:nth-child(5) { animation-delay: .24s; }
#title .modes > .btn:nth-child(1) { animation-delay: .45s; } #title .modes > .btn:nth-child(2) { animation-delay: .52s; }
#title .modes > .btn:nth-child(3) { animation-delay: .59s; } #title .links > .btn { animation-delay: .66s; }
@keyframes dealIn { from { opacity: 0; transform: rotate(var(--rot)) translateY(16px) scale(.85); } }

.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px; }
/* screen change: the swap happens under a full ink cover, which slides off trailing pink and cyan stripes */
#wipe { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; visibility: hidden; }
#wipe i { position: absolute; top: 0; bottom: 0; left: -35%; width: 170%; background: var(--ink); transform: skewX(-12deg);
  box-shadow: -34px 0 0 var(--b), -50px 0 0 var(--a); }
#wipe.go { visibility: visible; }
#wipe.go i { animation: wipeOff .4s cubic-bezier(.6, 0, .3, 1) forwards; }
@keyframes wipeOff { to { transform: skewX(-12deg) translateX(110%); } }
@media (prefers-reduced-motion: reduce) { #wipe { display: none; } }

/* ---------- title ---------- */
/* the title block centres in the space above the footer; a window too short for both scrolls rather than stacking them */
#title { background: radial-gradient(ellipse at 50% 60%, transparent 0, rgba(7,5,10,.55) 55%, rgba(7,5,10,.92) 100%); flex-direction: column;
  justify-content: flex-start; padding-bottom: calc(12px + var(--safe-b)); overflow-y: auto; }
.title-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; margin-block: auto; }
.card-holes { display: flex; gap: 12px; margin-bottom: 4px; }
.card-holes i { width: 10px; height: 18px; background: var(--b); border-radius: 2px; opacity: .85; box-shadow: 0 0 12px var(--b); }
.card-holes i:nth-child(3n) { background: var(--a); box-shadow: 0 0 12px var(--a); }
.logo { margin: 0; font-family: var(--display); font-weight: 400; line-height: .84; font-size: clamp(76px, min(15vw, 24vh), 210px);
  transform: skewY(-6deg) rotate(-2deg); letter-spacing: -0.01em; display: flex; flex-direction: column; }
.logo span:first-child { color: #fff; text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 var(--b), 12px 12px 0 rgba(255,46,136,.35); }
.logo span:last-child { color: var(--a); -webkit-text-stroke: 0; text-shadow: 6px 6px 0 var(--ink), 10px 10px 0 var(--b); margin-left: .4em; }
.logo span { animation: logoIn .7s cubic-bezier(.2,1.6,.4,1) both; }
.logo span:last-child { animation-delay: .12s; }
@keyframes logoIn { from { transform: translateX(-60px) scale(1.4); opacity: 0; filter: blur(8px); } }
.sub { margin: 16px 0 0; font-family: var(--display); letter-spacing: .2em; font-size: var(--fs-label); color: var(--y); }
.blurb { margin: 0 0 8px; color: #d8d2e6; font-size: var(--fs-body); line-height: 1.6; }
/* one row of equal cards at any width over 560: they narrow to share it rather than wrap */
#title .modes { flex-wrap: nowrap; align-items: stretch; }
#title .modes .btn { flex: 0 1 240px; min-width: 0; }
#title .links { gap: 24px; }
@keyframes blink { 50% { opacity: 0; } }
/* title footer: the disclaimer hides on short screens; the one-line credit under it always shows */
.foot { flex: none; width: 100%; padding-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fine { text-align: center; font-size: var(--fs-cap); color: rgba(255,255,255,.45); line-height: 1.5; margin: 0; }
.made { display: flex; align-items: center; gap: 8px; margin: 0; font: 800 var(--fs-cap)/1 var(--mono); letter-spacing: .08em; color: rgba(255,255,255,.35); }
.made a { display: inline-flex; align-items: center; gap: 4px; color: rgba(255,255,255,.6); text-decoration: none; padding: 4px 0; }
.made a:hover, .made a:focus-visible { color: #fff; }
.made svg { width: 12px; height: 12px; fill: currentColor; }
@media (max-height: 680px) { #title .fine { display: none; } }
@media (max-height: 420px) { #title { padding-top: 12px; } .foot { padding-top: 4px; } #title .logo { font-size: clamp(48px, 17vh, 140px); } }

/* ---------- elevator ---------- */
#elevator { background: linear-gradient(90deg, rgba(7,5,10,.94) 0%, rgba(7,5,10,.78) 48%, rgba(7,5,10,.15) 100%); justify-content: flex-start; }
.elev { display: flex; gap: 32px; align-items: stretch; max-width: 900px; width: 100%; padding-left: clamp(0px, 3vw, 40px); }
.panel { width: 172px; flex: none; align-self: flex-start; background: linear-gradient(160deg, #3a3844, #1c1b22 60%, #2a2931); border-radius: 10px; padding: 16px 16px 12px;
  box-shadow: inset 0 0 0 2px #55535f, inset 0 2px 0 #77757f, 0 20px 50px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 12px; }
.panel-head { background: #050406; border-radius: 6px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); color: #ff5a3d; text-shadow: 0 0 8px #ff5a3d; box-shadow: inset 0 0 0 1px #000; }
.panel-head b { font-size: var(--fs-head); font-weight: 800; line-height: 1; }
.panel-head .arrow { font-size: var(--fs-label); }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; justify-items: center; }
.fbtn { width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; font-family: var(--mono); font-weight: 800; font-size: var(--fs-body);
  background: radial-gradient(circle at 40% 35%, #f3f2f6, #a8a6b2 70%); color: #222; box-shadow: 0 3px 0 #0e0d12, inset 0 0 0 3px #8c8a96; position: relative; transition: transform .06s; }
.fbtn:hover, .fbtn:focus-visible { outline: none; transform: translateY(-1px); }
.fbtn.sel { box-shadow: 0 3px 0 #0e0d12, inset 0 0 0 3px var(--y), 0 0 18px var(--y); color: #000; }
.fbtn.done::after { content: attr(data-grade); position: absolute; right: -6px; top: -6px; background: var(--ink); color: #fff; font-family: var(--display); font-size: var(--fs-cap);
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; }
.fbtn.locked { background: radial-gradient(circle at 40% 35%, #5b5963, #34333a 70%); color: #6d6b75; cursor: not-allowed; }
.fbtn.locked::before { content: '🔒'; position: absolute; font-size: var(--fs-cap); right: -2px; bottom: -4px; }
.panel-foot { font-size: var(--fs-cap); letter-spacing: .08em; line-height: 1.4; text-align: center; color: #8d8b96; }
.dossier { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.d-floor { font-family: var(--display); letter-spacing: .2em; color: var(--a); font-size: var(--fs-label); }
.dossier h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(44px, 6.5vw, 86px); line-height: .9; transform: skewX(-8deg); transform-origin: left;
  text-shadow: 2px 2px 0 var(--ink), 5px 5px 0 var(--b); }
.d-title { font-family: var(--display); font-size: var(--fs-action); color: var(--y); letter-spacing: .08em; }
.d-tag { margin: 4px 0; font-family: var(--hand); font-size: var(--fs-action); color: #fff; opacity: .92; }
.dossier dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: var(--fs-body); max-width: 440px; }
.dossier dt { color: rgba(255,255,255,.55); letter-spacing: .08em; }
.dossier dd { margin: 0; font-weight: 800; }
.d-best { font-size: var(--fs-cap); color: var(--y); min-height: 16px; }
.memo { background: var(--paper); color: #222; padding: 12px 16px; margin: 8px 0 12px; max-width: 480px; transform: rotate(-1deg);
  box-shadow: 4px 6px 0 rgba(0,0,0,.4); font-size: var(--fs-body); line-height: 1.5; position: relative; }
.memo::before { content: ''; position: absolute; top: -8px; left: 40%; width: 72px; height: 16px; background: rgba(255,240,150,.8); transform: rotate(3deg); }
.memo-head { display: flex; justify-content: space-between; border-bottom: 1px solid #999; padding-bottom: 4px; margin-bottom: 8px; font-size: var(--fs-cap); gap: 12px; }
.memo p { margin: 0; }
.memo .memo-stats { display: none; }
.memo dt { color: #666; }
.d-actions { display: flex; gap: 16px; align-items: center; margin-top: 4px; }
/* phones fold the memo into this tag, so the boss has room to stand below the dossier */
.memo-tag { display: none; align-self: flex-start; min-height: var(--h3); margin-top: 12px; border: 0; cursor: pointer; background: var(--paper); color: #222;
  font: 800 var(--fs-cap) var(--mono); letter-spacing: .14em; padding: 0 12px; transform: rotate(-2deg); box-shadow: 3px 3px 0 rgba(0,0,0,.45); }

/* ---------- intro card ---------- */
#intro { background: rgba(7,5,10,.35); overflow: hidden; flex-direction: column; align-items: flex-start; justify-content: center; padding-left: 8vw; }
#intro .slash { position: absolute; left: -10%; width: 130%; height: 38%; transform: rotate(-8deg); }
#intro .slash.a { top: 26%; background: linear-gradient(90deg, var(--b), transparent 85%); opacity: .85; animation: slashIn .35s cubic-bezier(.2,1,.3,1) both; }
#intro .slash.b { top: 58%; height: 5%; background: var(--a); animation: slashIn .35s .08s cubic-bezier(.2,1,.3,1) both; }
@keyframes slashIn { from { transform: rotate(-8deg) translateX(-100%); } }
#intro > div, #intro > dl { position: relative; z-index: 1; }
.intro-floor { font-family: var(--display); letter-spacing: .3em; font-size: var(--fs-label); color: var(--y); animation: rise .4s .15s both; }
.intro-name { font-family: var(--display); font-size: clamp(60px, 12vw, 170px); line-height: .88; transform: skewX(-10deg); text-shadow: 7px 7px 0 var(--ink);
  animation: slam .5s .2s cubic-bezier(.2,1.8,.4,1) both; max-width: 90vw; }
.intro-title { font-family: var(--display); font-size: var(--fs-action); color: var(--ink); background: #fff; padding: 4px 16px; transform: skewX(-10deg);
  animation: rise .4s .35s both; margin-top: 8px; }
.intro-tag { font-family: var(--hand); font-size: var(--fs-action); margin-top: 16px; animation: rise .4s .5s both; text-shadow: 2px 2px 0 #000; }
.intro-stats { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin-top: 16px; font-size: var(--fs-body); animation: rise .4s .65s both;
  background: rgba(7,5,10,.72); padding: 8px 16px; transform: skewX(-10deg); box-shadow: 4px 4px 0 rgba(0,0,0,.4); }
.intro-stats dt { color: rgba(255,255,255,.65); }
.intro-stats dd { margin: 0; font-weight: 800; color: var(--y); }
.intro-skip { position: absolute !important; bottom: calc(20px + var(--safe-b)); right: 24px; font: 800 var(--fs-cap) var(--mono); letter-spacing: .25em; opacity: .6; }
@keyframes slam { from { transform: skewX(-10deg) scale(2.6); opacity: 0; filter: blur(10px); } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

/* ---------- HUD: (1) HP bars, (2) clock, meter, pips, (3) names, titles, score, chat ---------- */
/* the top of the HUD is a grid: each row starts below everything above it, so nothing overlaps */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: grid; align-content: start; align-items: start; gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "you clock opp" "feed clock invoice" "combo . .";
  padding: calc(16px + var(--safe-t)) 20px 0; }
.bar-block { width: min(100%, 440px); }
.bar-block.you { grid-area: you; }
.bar-block.opp { grid-area: opp; justify-self: end; text-align: right; }
.who { display: flex; align-items: baseline; gap: 8px; font-family: var(--display); margin-bottom: 4px; }
.opp .who { flex-direction: row-reverse; }
.who .nm { flex: none; font-size: var(--fs-action); letter-spacing: .02em; text-shadow: 3px 3px 0 #000; white-space: nowrap; }
.who .tt { min-width: 0; font: 800 var(--fs-cap) var(--mono); color: var(--y); letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 #000; }
.hp { height: 20px; background: rgba(0,0,0,.65); transform: skewX(-18deg); position: relative; overflow: hidden; box-shadow: 0 0 0 2px #fff, 4px 4px 0 2px rgba(0,0,0,.6); }
.hp i { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transform-origin: left; }
.opp .hp i { left: auto; right: 0; transform-origin: right; }
.hp .trail { background: #fff; transition: transform .6s .25s ease-out; }
.hp .fill { background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0) 55%), #22e5ff; transition: transform .08s; }
.opp .hp .fill { background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0) 55%), #ff2e88; }
.hp.low .fill { animation: lowHp .5s infinite alternate; }
@keyframes lowHp { to { filter: brightness(1.8) saturate(1.5); } }
.hp.shake { animation: shake .25s; }
@keyframes shake { 25% { transform: skewX(-18deg) translate(-5px, 2px); } 50% { transform: skewX(-18deg) translate(4px, -2px); } 75% { transform: skewX(-18deg) translate(-2px, 1px); } }
.pips { display: flex; gap: 8px; margin-top: 8px; min-height: 14px; }
.opp .pips { justify-content: flex-end; }
.pips i { width: 14px; height: 14px; transform: rotate(45deg); box-shadow: inset 0 0 0 2px #fff; }
.pips i.on { background: var(--y); box-shadow: 0 0 10px var(--y); }
.you .pips i.on { background: var(--red); box-shadow: 0 0 10px var(--red); }
.clock { grid-area: clock; text-align: center; }
.clock .floor { font: 800 var(--fs-cap) var(--mono); letter-spacing: .3em; color: var(--a); }
.clock .digits { font-family: var(--mono); font-weight: 800; font-size: var(--fs-action); background: #000; color: #ff5a3d; padding: 4px 12px; border-radius: 4px;
  text-shadow: 0 0 10px #ff5a3d; box-shadow: inset 0 0 0 2px #333, 0 4px 0 rgba(0,0,0,.6); letter-spacing: .04em; }
.clock .score { font-family: var(--display); font-size: var(--fs-label); margin-top: 4px; color: #fff; text-shadow: 2px 2px 0 #000; letter-spacing: .08em; }
.meter { position: absolute; bottom: calc(24px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(60vw, 420px); }
.meter .lbl { display: flex; justify-content: space-between; font-family: var(--display); font-size: var(--fs-body); letter-spacing: .2em; margin-bottom: 4px; text-shadow: 2px 2px 0 #000; }
.meter .lbl em { font-style: normal; opacity: 0; color: var(--y); }
.meter .track { height: 14px; background: rgba(0,0,0,.6); transform: skewX(-24deg); position: relative; box-shadow: 0 0 0 2px #fff; overflow: hidden; }
.meter .track i { position: absolute; inset: 0; background: linear-gradient(90deg, #ff8a1a, var(--y)); transform-origin: left; transform: scaleX(0); transition: transform .15s; }
.meter .track s { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0,0,0,.7); }
.meter .track s:nth-of-type(1) { left: 25%; } .meter .track s:nth-of-type(2) { left: 50%; } .meter .track s:nth-of-type(3) { left: 75%; }
.meter.full .track { box-shadow: 0 0 0 2px var(--y), 0 0 24px var(--y); animation: pulse .45s infinite alternate; }
.meter.full .lbl em { opacity: 1; animation: blink .5s steps(2) infinite; }
@keyframes pulse { to { filter: brightness(1.5); } }
#combo { grid-area: combo; justify-self: start; font-family: var(--display); font-size: clamp(40px, 5vw, 58px); line-height: .9; transform: skewX(-10deg); color: var(--y);
  text-shadow: 2px 2px 0 var(--ink), 4px 4px 0 var(--b); opacity: 0; transition: opacity .2s; }
#combo small { display: block; font-size: var(--fs-label); letter-spacing: .2em; color: #fff; text-shadow: 2px 2px 0 #000; }
#combo.on { opacity: 1; }
#combo.bump { animation: bump .15s; }
@keyframes bump { 50% { transform: skewX(-10deg) scale(1.25); } }
#invoice { grid-area: invoice; justify-self: end; background: var(--paper); color: #111; font-size: var(--fs-cap); padding: 8px 12px; transform: rotate(2deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
#invoice span { font-size: var(--fs-action); font-weight: 800; color: #0a8a3a; }
#invoice.bump { animation: bump .2s; }
/* touch only: the last line of the clock */
#pauseBtn { display: none; margin: 8px auto 0; pointer-events: auto;
  width: var(--h3); height: var(--h3); padding: 0; border: 0; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; font: 800 var(--fs-body) var(--mono); letter-spacing: -.1em;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
body.touch #pauseBtn { display: block; }

/* ---------- callouts / popups ---------- */
#callouts, #popups { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
.callout { position: absolute; left: 50%; top: 40%; font-family: var(--display); width: max-content; max-width: 92vw; text-align: center; line-height: .95; color: #fff; letter-spacing: .01em;
  transform: translate(-50%, -50%) skewX(-10deg) rotate(-4deg); animation: callout var(--dur, 0.8s) cubic-bezier(.2,1.6,.4,1) forwards; }
.callout.m { font-size: clamp(28px, 4.5vw, 54px); top: 62%; }
.callout.l { font-size: clamp(48px, 8vw, 110px); }
.callout.xl { font-size: clamp(70px, 13vw, 180px); }
.callout.xxl { font-size: clamp(100px, 22vw, 320px); top: 45%; }
@keyframes callout {
  0% { transform: translate(-50%, -50%) skewX(-10deg) rotate(-4deg) scale(2.4); opacity: 0; filter: blur(6px); }
  14% { transform: translate(-50%, -50%) skewX(-10deg) rotate(-4deg) scale(1); opacity: 1; filter: none; }
  80% { transform: translate(-50%, -50%) skewX(-10deg) rotate(-4deg) scale(1.06); opacity: 1; }
  100% { transform: translate(-50%, -62%) skewX(-10deg) rotate(-4deg) scale(1.08); opacity: 0; }
}
.popup { position: absolute; font-family: var(--display); font-size: var(--fs-label); letter-spacing: .06em; color: #fff; text-shadow: 2px 2px 0 #000, 0 0 12px rgba(0,0,0,.6);
  animation: pop 0.9s ease-out forwards; white-space: nowrap; }
@keyframes pop { 0% { transform: translateY(10px) scale(.6); opacity: 0; } 15% { transform: translateY(0) scale(1.1); opacity: 1; } 100% { transform: translateY(-60px); opacity: 0; } }

#bubble { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; transform: translate(-10%, -100%); max-width: min(46vw, 340px); }
#bubble span { display: block; background: #fff; color: #111; font-family: var(--display); font-size: var(--fs-label); letter-spacing: .02em; line-height: 1.15;
  padding: 8px 12px; border: 3px solid #111; border-radius: 16px 16px 16px 4px; box-shadow: 5px 5px 0 var(--b); animation: bubbleIn .25s cubic-bezier(.2,1.8,.4,1); }
#bubble::after { content: ''; position: absolute; left: 14px; bottom: -14px; border: 9px solid transparent; border-top: 12px solid #111; border-left: 4px solid #111; }
@keyframes bubbleIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }

#banner { position: fixed; left: 0; right: 0; top: 24%; z-index: 7; pointer-events: none; background: var(--b); color: #fff; padding: 8px 0 12px; text-align: center; transform: rotate(-3deg);
  box-shadow: 0 0 0 4px #000, 0 12px 0 rgba(0,0,0,.35); animation: bannerIn 1.3s cubic-bezier(.2,1,.3,1) forwards; }
#banner small { display: block; font: 800 var(--fs-cap) var(--mono); letter-spacing: .4em; opacity: .85; }
#banner b { font-family: var(--display); font-weight: 400; font-size: clamp(32px, 6vw, 72px); letter-spacing: .03em; line-height: 1; text-shadow: 4px 4px 0 #000; }
@keyframes bannerIn { 0% { transform: rotate(-3deg) translateX(-110%); } 18%, 78% { transform: rotate(-3deg) translateX(0); } 100% { transform: rotate(-3deg) translateX(110%); } }

#count { position: fixed; z-index: 7; right: 12%; top: 50%; transform: translateY(-50%); font-family: var(--display); font-size: clamp(120px, 22vw, 300px); line-height: 1;
  color: #fff; text-shadow: 4px 4px 0 var(--ink), 8px 8px 0 var(--b); pointer-events: none; }
#count.tick { animation: tick .3s cubic-bezier(.2,1.8,.4,1); }
@keyframes tick { from { transform: translateY(-50%) scale(1.8); opacity: 0; } }
#mash { position: fixed; z-index: 9; left: 50%; bottom: 20%; transform: translateX(-50%); text-align: center; pointer-events: none; width: min(80vw, 460px); }
#mash b { font-family: var(--display); font-weight: 400; font-size: var(--fs-head); letter-spacing: .06em; display: block; animation: jitter .12s infinite; text-shadow: 3px 3px 0 #000; }
@keyframes jitter { 50% { transform: translate(2px, -1px) rotate(1deg); } }
#mash .track { margin-top: 12px; height: 18px; box-shadow: 0 0 0 3px #fff; background: rgba(0,0,0,.6); transform: skewX(-18deg); }
#mash .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--y)); transform-origin: left; transform: scaleX(0); transition: transform .1s; }
#hint { position: fixed; z-index: 7; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translateX(-50%) skewX(-8deg); background: #fff; color: #000; font-family: var(--display);
  font-size: var(--fs-label); letter-spacing: .06em; padding: 8px 16px; box-shadow: 5px 5px 0 var(--a); pointer-events: none; white-space: nowrap; animation: rise .25s both; max-width: 94vw; overflow: hidden; text-overflow: ellipsis; }

body.clean #hint { display: none; }
#splat { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.splat { position: absolute; animation: splatFade 1.8s ease-in forwards; }
@keyframes splatFade { 0% { transform: scale(.4); opacity: 0; } 8% { transform: scale(1.05); opacity: .95; } 60% { opacity: .9; } 100% { opacity: 0; transform: translateY(40px); } }
.stamp-splat { font-family: var(--display); font-size: clamp(40px, 7vw, 90px); color: var(--red); border: 8px solid var(--red); padding: 0 20px; transform: rotate(-14deg); letter-spacing: .05em; mix-blend-mode: screen; }

/* ---------- results ---------- */
#results { background: rgba(7,5,10,.55); backdrop-filter: blur(3px); }
.review { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.paper { width: min(92vw, 560px); background: var(--paper); color: #1d1a22; padding: 24px 24px 20px; position: relative; transform: rotate(-1.2deg);
  box-shadow: 10px 12px 0 rgba(0,0,0,.55); animation: paperIn .5s cubic-bezier(.2,1.3,.4,1) both;
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(40,90,200,.08) 27px 28px); }
@keyframes paperIn { from { transform: rotate(-12deg) translateY(120vh); } }
.r-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 3px solid #1d1a22; padding-bottom: 8px; }
.r-head b { display: block; font-family: var(--display); font-weight: 400; font-size: var(--fs-head); letter-spacing: .02em; line-height: 1; }
.r-head span { font-size: var(--fs-cap); letter-spacing: .2em; color: #666; }
.r-logo { font-family: var(--display); font-size: var(--fs-body); line-height: .9; text-align: right; color: var(--b); }
.r-meta { display: flex; justify-content: space-between; font-size: var(--fs-cap); margin: 8px 0; color: #444; gap: 12px; }
#rRows { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
#rRows td { padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,.2); }
#rRows td:last-child { text-align: right; font-weight: 800; }
#rRows tr { animation: rise .25s both; }
#rRows tr.total td { font-size: var(--fs-label); border-bottom: 0; padding-top: 8px; }
.r-note { margin-top: 12px; font-size: var(--fs-cap); color: #555; min-height: 44px; padding-right: 100px; }
.r-note em { display: block; font-family: var(--hand); font-size: var(--fs-action); font-style: normal; color: #1f3fbf; line-height: 1.1; margin-top: 4px; }
.stamp { position: absolute; right: -32px; bottom: -40px; width: 136px; height: 136px; border-radius: 50%; border: 6px solid var(--c, var(--red)); color: var(--c, var(--red));
  display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(-16deg); mix-blend-mode: multiply;
  animation: stampIn .35s cubic-bezier(.2,1.6,.4,1) both; background: rgba(255,255,255,.1); }
.stamp b { font-family: var(--display); font-weight: 400; font-size: clamp(56px, 8vw, 76px); line-height: .9; }
.stamp span { font-family: var(--display); font-size: var(--fs-cap); letter-spacing: .08em; text-align: center; padding: 0 12px; line-height: 1.1; }
@keyframes stampIn { from { transform: rotate(-16deg) scale(3); opacity: 0; } }
.pb { position: absolute; top: -16px; left: 24px; background: var(--b); color: #fff; font-family: var(--display); font-size: var(--fs-label); padding: 4px 12px; transform: rotate(-4deg); letter-spacing: .1em; box-shadow: 3px 3px 0 #000;
  animation: slam .4s cubic-bezier(.2,1.8,.4,1) both; }
.r-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; align-items: center; }
.r-promo { margin: 12px 96px 0 0; padding: 8px 12px; border: 2px dashed #c9162f; color: #c9162f; transform: rotate(-1.2deg); animation: slam .35s cubic-bezier(.2, 1.6, .4, 1); }
.r-promo span { display: block; font: 700 var(--fs-cap) var(--mono); letter-spacing: .18em; }
.r-promo b { display: block; font-family: var(--display); font-weight: 400; font-size: var(--fs-action); line-height: 1; margin: 4px 0; letter-spacing: .01em; }
.r-promo em { font-family: var(--hand); font-size: var(--fs-action); color: #333; font-style: normal; }

/* ---------- daily shift ---------- */
body.in-run .run-hide { display: none; }
#shift, #shiftEnd { background: rgba(7,5,10,.6); backdrop-filter: blur(3px); overflow: auto; align-items: flex-start; }
.shift-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; margin: auto 0; padding: 12px 0; }
.shift-paper { width: min(92vw, 620px); }
#shift .r-actions { flex-wrap: nowrap; }
.s-mod { margin: 16px 0 8px; background: #1d1a22; color: #fff; padding: 12px 16px; transform: rotate(.6deg); box-shadow: 5px 5px 0 var(--red); }
.s-mod span { display: block; font-size: var(--fs-cap); letter-spacing: .2em; color: var(--y); }
.s-mod b { display: block; font-family: var(--display); font-weight: 400; font-size: var(--fs-head); letter-spacing: .03em; line-height: 1.05; }
.s-mod em { font-style: normal; font-size: var(--fs-body); color: #ddd; }
.s-rules { margin: 12px 0; padding-left: 20px; font-size: var(--fs-body); line-height: 1.5; color: #333; }
.s-label { font-size: var(--fs-cap); letter-spacing: .2em; color: #666; margin: 12px 0 8px; }
.s-perks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.perk { font: inherit; text-align: left; cursor: pointer; background: #fff; color: #1d1a22; border: 2px solid #1d1a22; padding: 8px 12px; min-height: 64px; box-shadow: 3px 3px 0 rgba(0,0,0,.25); transition: transform .08s; }
.perk b { display: block; font-family: var(--display); font-weight: 400; font-size: var(--fs-label); letter-spacing: .04em; }
.perk em { display: block; font-style: normal; font-size: var(--fs-cap); line-height: 1.35; color: #555; margin-top: 4px; }
.perk:hover:not(:disabled), .perk:focus-visible { outline: none; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--b); }
.perk.sel { box-shadow: inset 0 0 0 3px var(--y), 0 0 0 2px #1d1a22, 4px 4px 0 #1d1a22; }
.perk.sel b::after { content: ' ✓'; }
.perk.locked { opacity: .45; cursor: not-allowed; background: repeating-linear-gradient(-45deg, #eee 0 8px, #e2ddd2 8px 16px); }
.s-best { margin-top: 12px; font-size: var(--fs-cap); letter-spacing: .12em; color: #666; }
.e-squares { font-size: clamp(34px, 8vw, 54px); letter-spacing: .08em; text-align: center; margin: 16px 0 4px; }
.e-head { font-family: var(--display); font-size: var(--fs-head); text-align: center; transform: skewX(-8deg); color: #1d1a22; }
.e-rows { width: 100%; border-collapse: collapse; font-size: var(--fs-body); margin-top: 12px; }
.e-rows td { padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,.2); }
.e-rows td:last-child { text-align: right; font-weight: 800; }
.e-line { font-family: var(--mono); font-size: var(--fs-cap); white-space: pre-wrap; background: #1d1a22; color: #fff; padding: 12px; margin: 16px 0 0; }
.e-best { text-align: center; font-size: var(--fs-cap); letter-spacing: .14em; color: #666; margin-top: 4px; }
.e-best.new { color: #fff; background: #1d1a22; display: table; margin: 8px auto 0; padding: 4px 8px; font-weight: 800; }
.fired-sick { font-family: var(--display); letter-spacing: .1em; color: var(--y); font-size: var(--fs-label); }
.fired-sick:empty { display: none; }

/* ---------- fired ---------- */
#fired { background: radial-gradient(circle at 50% 50%, rgba(80,0,10,.7), rgba(7,5,10,.96)); }
.fired-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fired-big { font-family: var(--display); font-size: clamp(90px, 18vw, 240px); line-height: .82; color: var(--red); transform: skewX(-10deg) rotate(-3deg);
  text-shadow: 8px 8px 0 #000, 0 0 50px rgba(255,46,85,.5); animation: slam .5s cubic-bezier(.2,1.8,.4,1) both, glitch 2.5s 1s infinite; }
@keyframes glitch { 0%, 92%, 100% { clip-path: none; transform: skewX(-10deg) rotate(-3deg); } 94% { clip-path: inset(20% 0 50% 0); transform: skewX(-10deg) rotate(-3deg) translateX(-12px); } 96% { clip-path: inset(60% 0 10% 0); transform: skewX(-10deg) rotate(-3deg) translateX(10px); } }
#firedLine { font-family: var(--hand); font-size: var(--fs-action); margin: 8px 0 0; }
.fired-by { font-size: var(--fs-cap); color: rgba(255,255,255,.6); letter-spacing: .15em; margin-bottom: 8px; }
.menu.row { flex-direction: row; }

/* ---------- ending ---------- */
#ending { background: radial-gradient(circle at 50% 40%, rgba(255,194,51,.25), rgba(7,5,10,.95) 70%); }
.end-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 760px; }
.end-small { font-family: var(--display); font-size: var(--fs-label); letter-spacing: .4em; color: var(--y); }
.end-big { font-family: var(--display); font-size: clamp(64px, 11vw, 150px); line-height: .86; transform: skewX(-8deg); text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 var(--b); animation: slam .6s cubic-bezier(.2,1.8,.4,1) both; }
.end-wrap p { color: #ddd; line-height: 1.6; }
.end-total { font-family: var(--mono); font-weight: 800; font-size: var(--fs-action); color: var(--y); }
.end-memo { max-width: 520px; margin: 16px auto 4px; background: var(--paper); color: #111; padding: 16px; text-align: left; font: var(--fs-body)/1.45 var(--mono); transform: rotate(-1deg);
  box-shadow: 6px 6px 0 rgba(0,0,0,.5); animation: slam .4s .9s both cubic-bezier(.2, 1.6, .4, 1); }
.end-memo b { display: block; font-size: var(--fs-cap); letter-spacing: .14em; color: #c9162f; margin-bottom: 8px; }

/* ---------- share / howto / pause ---------- */
.share-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 94vw; }
#shareImg, #shareVid { width: min(90vw, 760px); max-height: 62vh; object-fit: contain; background: #000; box-shadow: 0 0 0 3px #fff, 10px 10px 0 var(--b); }
.share-tabs { display: flex; gap: 0; box-shadow: 0 0 0 2px #fff; }
.share-tabs button { font-family: var(--display); font-size: var(--fs-label); letter-spacing: .08em; min-height: var(--h3); padding: 0 16px; background: transparent; color: #fff; border: 0; cursor: pointer; }
.share-tabs button.on { background: #fff; color: #000; }
.share-note { font-size: var(--fs-cap); color: rgba(255,255,255,.6); margin: 0; }
/* overlays opened from other screens (pause, results) sit above them and hide them: one main button in sight */
#howto, #share { z-index: 22; background: #07050a; }
/* each device sees only its own controls column */
body.touch .keys :is(th, td):is(:nth-child(2), :nth-child(4)) { display: none; }
body:not(.touch) .keys :is(th, td):nth-child(3) { display: none; }
.howto-wrap { max-width: 860px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.howto-wrap h3 { font-family: var(--display); font-weight: 400; letter-spacing: .12em; font-size: var(--fs-action); margin: 0; color: var(--y); text-align: center; }
.rules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.rules div { background: rgba(255,255,255,.06); padding: 12px; border-left: 4px solid var(--a); }
.rules b { font-family: var(--display); font-weight: 400; font-size: var(--fs-action); letter-spacing: .05em; }
.rules p { margin: 8px 0 0; font-size: var(--fs-body); line-height: 1.5; color: #ddd; }
.rules em { color: var(--y); font-style: normal; font-weight: 800; }
.keys { border-collapse: collapse; font-size: var(--fs-body); }
.keys th { font-family: var(--display); font-weight: 400; letter-spacing: .15em; color: var(--a); padding: 4px 16px; text-align: left; }
.keys td { padding: 4px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.keys td:first-child { color: rgba(255,255,255,.6); }
#pause { background: rgba(7,5,10,.78); backdrop-filter: blur(4px); }
#pause .menu { gap: 12px; }
#pause .btn:not(.ghost) { width: 280px; }
.pause-t { font-family: var(--display); font-size: clamp(48px, 8vw, 64px); transform: skewX(-10deg); text-shadow: 2px 2px 0 var(--ink), 5px 5px 0 var(--b); margin-bottom: 8px; }

#rotate { display: none; }

/* ---------- touch + small screens ---------- */
.tap, body.touch .key { display: none; }
body.touch .tap { display: inline; }
/* screens that can outgrow a phone scroll, and auto margins keep short content centred */
#results, #fired, #ending, #share, #howto, #pause, #shift, #shiftEnd, #elevator, #vsMenu, #vsLobby, #vsJoin, #vsEnd { overflow: hidden auto; overscroll-behavior: contain; }
.review, .fired-wrap, .end-wrap, .share-wrap, .howto-wrap, #pause > .menu, .vs-wrap { margin: auto; }
/* on short or narrow screens the action row sticks to the bottom so NEXT is never below the fold */
@media (max-width: 760px), (max-height: 600px) {
  .review > .r-actions, .shift-wrap > .r-actions, .howto-wrap > .r-actions, .end-wrap > .r-actions { position: sticky; bottom: 0; z-index: 2; align-self: stretch; gap: 12px; margin: 0 -20px -20px; padding: 12px 16px calc(12px + var(--safe-b));
    background: linear-gradient(rgba(7,5,10,0), rgba(7,5,10,.92) 40%); }
}
@media (orientation: portrait) and (min-width: 761px) {
  #elevator { align-items: flex-start; padding-top: calc(40px + var(--safe-t)); background: linear-gradient(rgba(7,5,10,.9) 0 50%, rgba(7,5,10,.35) 80%, rgba(7,5,10,.1)); }
}
@media (max-width: 760px) {
  .elev { flex-direction: column; gap: 16px; padding: 0; }
  .panel { width: 100%; padding: 8px; gap: 8px; }
  .panel-head { padding: 4px 12px; }
  .buttons { grid-template-columns: repeat(6, var(--h3)); justify-content: space-between; gap: 4px; }
  .fbtn { width: var(--h3); height: var(--h3); }
  .fbtn.done::after { right: -4px; top: -4px; }
  .panel-foot { display: none; }
  #elevator { align-items: flex-start; background: linear-gradient(rgba(7,5,10,.9) 0 45%, rgba(7,5,10,.35) 80%, rgba(7,5,10,.1)); }
  .d-actions { order: 1; }
  .memo-tag { display: block; order: 1; }
  #dStats { display: none; }
  .memo .memo-stats { display: grid; margin-top: 10px; padding-top: 8px; border-top: 1px solid #999; }
  /* the open memo sits over a dim cover; the next tap anywhere closes it (main.js) */
  #elevator.memo-open::before { content: ''; position: fixed; inset: 0; z-index: 2; background: rgba(7,5,10,.65); }
  #elevator.memo-open .memo { display: block; position: fixed; left: 16px; right: 16px; top: 50%; z-index: 3; margin: 0 auto;
    transform: translateY(-50%) rotate(-1deg); animation: slam .3s cubic-bezier(.2, 1.6, .4, 1); }
  .memo { display: none; }
  .rules { grid-template-columns: 1fr 1fr; }
  #hud { padding: calc(12px + var(--safe-t)) 12px 0; }
  .hp { height: 16px; }
  .clock .floor { display: none; }
  .r-note { padding-right: 112px; }
  .stamp { width: 104px; height: 104px; }
}
/* the HUD drops one type step under 560 px wide */
@media (max-width: 560px) {
  .who, .opp .who { flex-direction: column; gap: 0; margin-bottom: 4px; }
  .opp .who { align-items: flex-end; }
  .who .nm { font-size: var(--fs-label); line-height: 1.05; max-width: 100%; }
  .who .tt { max-width: 100%; }
  .clock .digits { font-size: var(--fs-label); padding: 4px 8px; }
  .clock .score { font-size: var(--fs-body); }
  #invoice { grid-area: auto; position: absolute; bottom: calc(76px + var(--safe-b)); right: 12px; transform: rotate(2deg) scale(.85); transform-origin: right bottom; }
  .pips i { width: 11px; height: 11px; }
  .s-perks { grid-template-columns: 1fr 1fr; }
  .perk { min-height: 0; padding: 8px; }
  .shift-paper { padding: 16px; }
  /* the whole review fits above the sticky action bar on a phone: tighter paper, stamp tucked in
     beside the promotion instead of hanging off the paper's corner (and off the screen) */
  .review { gap: 12px; }
  .paper { padding: 16px 16px 12px; }
  #rRows td { padding: 2px 0; }
  #rRows tr.total td { padding-top: 4px; }
  #results .r-note { margin-top: 8px; min-height: 36px; padding-right: 0; }
  .r-promo { margin: 8px 112px 0 0; padding: 8px 12px; }
  .stamp { right: 8px; bottom: 8px; }
  /* phones: the main button takes its own row, everything else shares the one under it */
  .r-actions > .btn.big, .fired-wrap .menu > .btn.big, .share-wrap .menu > .btn.big { flex-basis: 100%; justify-content: center; }
  .r-actions, .fired-wrap .menu, .share-wrap .menu { gap: 12px; }
  .btn.ghost { padding: 0 4px; }
}
#fallback { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; background: var(--ink); padding: 32px; text-align: center; }
@media (max-height: 520px) {
  .logo { font-size: clamp(56px, 20vh, 140px); }
  .blurb { display: none; }
  .memo { display: none; }
  .paper { padding: 12px 16px; } #rRows td { padding: 2px 0; }
  .fine { display: none; }
}

/* ---------- company chat (livestream) ---------- */
/* anchored at the bottom like stream chat: new lines push old ones up into a fade, no boxes, so the ring stays visible */
#feed { grid-area: feed; position: relative; width: clamp(240px, 21vw, 420px); height: min(34vh, 380px); font-size: var(--fs-body); font-family: var(--mono);
  display: flex; flex-direction: column; }
#feed .head { flex: none; font-size: var(--fs-cap); letter-spacing: .04em; color: #cfd6e6; display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; }
#feed .live { flex: none; background: #ff2244; color: #fff; font: 800 var(--fs-cap)/1 var(--mono); letter-spacing: .12em; padding: 4px 8px 4px 16px; border-radius: 3px; position: relative;
  box-shadow: 0 0 12px rgba(255,34,68,.55); }
#feed .live::before { content: ''; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #fff; animation: blink 1s steps(2) infinite; }
#feed .head b { color: #fff; font-weight: 800; flex: none; text-shadow: 0 1px 2px #000; }
#feed .eye { flex: none; color: #ff8a9c; font-weight: 800; font-variant-numeric: tabular-nums; }
#feed .eye::before { content: '👁 '; font-size: var(--fs-cap); }
#feed .extra { overflow: hidden; text-overflow: ellipsis; color: #8d96a8; }
#feed .msgs { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 4px 0 2px;
  -webkit-mask-image: linear-gradient(transparent, #000 38%); mask-image: linear-gradient(transparent, #000 38%); }
#feed .msg { flex: none; font-size: 1em; line-height: 1.32; padding: 2px 8px 2px 0; color: #eef1f7; overflow-wrap: anywhere;
  text-shadow: 0 1px 2px #000, 0 0 3px rgba(0,0,0,.9); animation: msgIn .18s ease-out; transition: opacity .5s; }
#feed .msg.out { opacity: 0; }
#feed .msg i { display: inline-block; font: 800 var(--fs-cap)/1 var(--mono); letter-spacing: .04em; color: #0b0b12; background: #cfd6e6; padding: 2px 4px; border-radius: 2px;
  margin-right: 4px; vertical-align: 1px; font-style: normal; text-shadow: none; }
#feed .msg i:empty { display: none; }
#feed .msg b { font-weight: 800; }
#feed .msg b::after { content: ':'; color: #cfd6e6; margin-right: 4px; }
#feed .msg p { display: inline; margin: 0; }
#feed .msg.ghost i { background: var(--y); }
#feed .msg.sys { color: #ffe08a; }
#feed .msg.sys i { background: #ff2244; color: #fff; }
#feed .msg.gone p { color: #7d8595; font-style: italic; }
#feed .floats { position: absolute; left: 100%; width: 56px; bottom: 0; height: 100%; pointer-events: none; }
#feed .floats span { position: absolute; bottom: 0; left: var(--x); font-size: 1.7em; opacity: 0; animation: floatUp 1.9s cubic-bezier(.2,.7,.4,1) both;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(0, 10px) scale(.4); } 12% { opacity: 1; transform: translate(0, -8px) scale(1.15); }
  70% { opacity: .9; } 100% { opacity: 0; transform: translate(var(--dx), -190px) scale(.9); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
/* narrow screens: the chat runs under the clock too, so its row starts below the pause button */
@media (max-width: 760px) {
  #hud { grid-template-areas: "you clock opp" "feed feed invoice" "combo . ."; }
  #feed { width: auto; height: 24vh; font-size: var(--fs-cap); }
  #feed .extra { display: none; }
}
/* phones held sideways: a narrow chat column on the left, beside the clock */
@media (max-height: 520px) {
  #hud { grid-template-areas: "you clock opp" "feed clock invoice" "combo . ."; }
  #feed { width: min(272px, 30vw); height: 30vh; font-size: var(--fs-cap); }
  #feed .extra { display: none; }
}

/* ---------- 1v1 versus (VERSUS.md) ---------- */
#vsMenu, #vsLobby, #vsJoin { background: rgba(7,5,10,.55); }
.vs-wrap { width: min(100%, 420px); display: flex; flex-direction: column; gap: 24px; }
.vs-head h2 { margin: 0; font: 400 var(--fs-head)/1 var(--display); letter-spacing: .01em; text-shadow: 3px 3px 0 var(--ink); }
.vs-head p { margin: 8px 0 0; font-size: var(--fs-cap); letter-spacing: .16em; color: rgba(255,255,255,.75); }
.vs-wrap .btn:not(.ghost) { width: 100%; }
.slip { width: 100%; padding: 16px; transform: rotate(-.8deg); }
.slip-cap { display: block; font-size: var(--fs-cap); letter-spacing: .16em; color: #666; }
.cells { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 8px; }
.cells i { height: 56px; display: grid; place-items: center; font: 400 var(--fs-head)/1 var(--display); font-style: normal; color: var(--ink); background: #fff; border: 2px solid var(--ink); }
.cells i.cur { border-color: #c9162f; box-shadow: inset 0 -4px 0 #c9162f; }
/* one real input over the boxes: the phone keyboard, paste and autofill all go through it */
.cells input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; font-size: 16px; caret-color: transparent;
  -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.chips { display: flex; gap: 8px; margin-top: 16px; color: var(--ink); }
.chips .chip { flex: 1; }
.vl-link { margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed rgba(0,0,0,.3); font-size: var(--fs-cap); color: #444; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.vl-status { margin: 0; min-height: 21px; text-align: center; font-size: var(--fs-body); line-height: 1.5; color: #fff; text-shadow: 0 1px 2px #000; }
.vl-status:empty { display: none; }
.vl-status.wait::after { content: '…'; animation: blink 1s steps(2) infinite; }
.vl-status.bad { color: var(--red); font-weight: 800; }
@media (max-height: 520px) { .vs-wrap { gap: 12px; } .cells i { height: 48px; } }

/* select: the ring stays visible. Wide: card top left, tiles and LOCK IN along the bottom.
   Short (phone sideways): tiles and LOCK IN move beside the card. Narrow (phone upright): one column. */
#vsSelect { display: grid; grid-template: "top top" auto "card ." 1fr "bottom bottom" auto / min(46vw, 420px) minmax(0, 1fr); gap: 12px 24px;
  padding: calc(16px + var(--safe-t)) 20px calc(16px + var(--safe-b)); pointer-events: none; }
#vsSelect > * { pointer-events: auto; }
.sel-top { grid-area: top; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; font-family: var(--display); letter-spacing: .08em; }
.sel-top b { font-size: var(--fs-head); font-weight: 400; transform: skewX(-8deg); text-shadow: 3px 3px 0 var(--b); }
.sel-top span { font-size: var(--fs-body); color: var(--y); text-align: right; text-shadow: 2px 2px 0 #000; }
.sel-top span.ready { color: var(--ok); }
.sel-card { grid-area: card; align-self: start; background: rgba(7,5,10,.78); padding: 12px 16px; transform: skewX(-4deg); box-shadow: 6px 6px 0 rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 4px; }
.sel-card > * { transform: skewX(4deg); }
.sel-card .d-floor { font-size: var(--fs-cap); font-family: var(--mono); font-weight: 800; }
.sel-card .d-title { font-size: var(--fs-label); }
.sel-card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(36px, 5vw, 62px); line-height: .9; text-shadow: 2px 2px 0 var(--ink), 5px 5px 0 var(--b); }
.sc-bars { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; font-size: var(--fs-cap); letter-spacing: .1em; margin: 4px 0; }
.sc-bars dt { color: rgba(255,255,255,.6); }
.sc-bars dd { margin: 0; display: flex; gap: 4px; }
.sc-bars dd i { width: 22px; height: 8px; background: rgba(255,255,255,.14); transform: skewX(-18deg); }
.sc-bars dd i.on { background: var(--a); box-shadow: 0 0 8px var(--a); }
.sc-note { font-size: var(--fs-body); line-height: 1.35; }
.sc-note b { display: block; font-size: var(--fs-cap); letter-spacing: .2em; color: var(--ok); }
.sc-note.weak b { color: var(--red); }
.sc-note i { font-style: normal; font-weight: 800; color: #fff; }
.sc-moves { border-collapse: collapse; font-size: var(--fs-cap); margin-top: 4px; }
.sc-moves td { padding: 2px 0; border-top: 1px dashed rgba(255,255,255,.15); }
.sc-moves td:first-child { color: var(--y); padding-right: 12px; white-space: nowrap; letter-spacing: .06em; }
.sel-bottom { grid-area: bottom; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.sel-hint { flex-basis: 100%; margin: 0; font-size: var(--fs-cap); letter-spacing: .08em; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.sel-grid { display: grid; grid-template-columns: repeat(6, 78px); gap: 8px; }
.tile { position: relative; border: 0; padding: 0 0 4px; cursor: pointer; background: rgba(7,5,10,.78); color: #fff; font: 800 var(--fs-cap) var(--mono); letter-spacing: .06em;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); transform: skewX(-6deg); transition: transform .08s; }
.tile canvas { display: block; width: 100%; height: auto; }
.tile:hover, .tile:focus-visible { outline: none; transform: skewX(-6deg) translateY(-2px); }
.tile.me { box-shadow: inset 0 0 0 3px var(--y), 0 0 16px var(--y); }
.tile.me.locked { box-shadow: inset 0 0 0 3px var(--ok), 0 0 18px var(--ok); }
.tile .them { position: absolute; top: -10px; right: -6px; background: var(--b); color: #fff; font-size: var(--fs-cap); padding: 2px 4px; display: none; }
.tile.them .them { display: block; }
.tile.shut { cursor: not-allowed; }
.tile.shut span { color: rgba(255,255,255,.55); }
.sel-actions { display: flex; gap: 16px; align-items: center; }
#selLock.locked { background: var(--ok); }
@media (max-width: 760px), (max-height: 520px) {
  .sc-moves { display: none; }
}
@media (max-height: 520px) {
  #vsSelect { grid-template: "top top" auto "card ." 1fr "card bottom" auto / min(46vw, 400px) minmax(0, 1fr); }
  .sel-top b { font-size: var(--fs-action); }
  .sel-card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  .sc-bars { grid-template-columns: auto 1fr auto 1fr; }
  .sc-bars dd i { width: 16px; }
  .sel-bottom { flex-direction: column; align-items: flex-end; }
  .sel-grid { grid-template-columns: repeat(6, 56px); }
  .sel-hint { text-align: right; }
}
/* sideways and narrow: six tiles no longer fit beside the card, so they stack three by two */
@media (max-height: 520px) and (max-width: 820px) {
  .sel-grid { grid-template-columns: repeat(3, 56px); }
}
@media (max-width: 760px) and (orientation: portrait) {
  #vsSelect { grid-template: "top" auto "card" auto "." 1fr "bottom" auto / 1fr; }
  .sel-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); flex-basis: 100%; }
  .sel-actions { flex-basis: 100%; justify-content: space-between; }
  .sel-actions .btn.big { flex: 1; justify-content: center; }
}

.vs-end .fired-big { color: var(--y); }
.vs-end .fired-big.lose { color: var(--red); }
.ve-rows { border-collapse: collapse; font-size: var(--fs-body); min-width: min(86vw, 380px); background: rgba(7,5,10,.6); }
.ve-rows td { padding: 4px 12px; border-bottom: 1px dashed rgba(255,255,255,.18); text-align: right; }
.ve-rows td:first-child { text-align: left; color: rgba(255,255,255,.7); }
.ve-rows th { font-family: var(--display); font-weight: 400; letter-spacing: .1em; padding: 8px 12px; text-align: right; color: var(--y); }
.ve-rows th:first-child { text-align: left; }
#vsEnd { background: rgba(7,5,10,.55); }

/* the HUD in versus: a guard bar under each HP bar, a round clock, no score */
.guard { display: none; height: 6px; margin-top: 4px; background: rgba(0,0,0,.6); transform: skewX(-18deg); overflow: hidden; }
.guard i { display: block; height: 100%; background: #9fd8ff; transform-origin: left; transition: transform .1s; }
.opp .guard i { transform-origin: right; }
.guard.low i { background: var(--red); }
body.vs .guard { display: block; }
body.vs #hudScore, body.vs #invoice, body.vs .intro-skip { display: none; }

/* title on phones. Upright: the three cards stacked, the text links under them. Sideways: one row. */
@media (max-width: 560px) {
  #title .modes { flex-direction: column; width: min(100%, 360px); gap: 12px; }
  #title .modes .btn { flex: none; width: 100%; }
  .sub { margin-top: 12px; }
  .blurb { margin-bottom: 4px; }
}
@media (max-width: 560px) and (max-height: 740px) {
  .fine { display: none; }
  .card-holes { display: none; }
  .blurb br { display: none; }
}
@media (max-height: 520px) {
  #title .modes { gap: 12px; }
  .sub { margin-top: 8px; }
  .title-wrap { gap: 8px; }
  .card-holes { display: none; }
}

/* ---------- THE RING: stakes, money and the wallet ---------- */
.sub .tok { font-weight: 400; color: var(--ok); }
.chip.ca { margin: 16px auto 0; color: #fff; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.2); font-size: var(--fs-cap); letter-spacing: .12em; }
.chip.ca b { font-weight: 800; letter-spacing: .02em; }

.stake { color: var(--ink); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.seg button { min-height: var(--h3); border: 2px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer;
  font: 400 var(--fs-label)/1 var(--display); letter-spacing: .06em; }
.seg button.on { background: var(--y); box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
#stakeAmt, .w-form input, .w-form select { width: 100%; margin-top: 8px; min-height: var(--h3); padding: 0 12px; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  font: 400 var(--fs-action)/1 var(--display); letter-spacing: .04em; -webkit-user-select: text; user-select: text; border-radius: 0; }
#stakeAmt:focus, .w-form input:focus { outline: none; border-color: #c9162f; box-shadow: inset 0 -4px 0 #c9162f; }
.stake-note { margin: 8px 0 0; font-size: var(--fs-cap); line-height: 1.5; color: #444; letter-spacing: .04em; }
.stake-line { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.stake-line b { font: 400 var(--fs-label)/1 var(--display); letter-spacing: .1em; color: var(--y); text-shadow: 2px 2px 0 var(--ink); }
.stake-line span { font-size: var(--fs-cap); color: rgba(255,255,255,.8); letter-spacing: .06em; }
.sel-top em { font-style: normal; font-size: var(--fs-cap); letter-spacing: .12em; color: var(--y); }
.sel-top em:empty { display: none; }
.ve-money { margin: 4px 0 12px; font: 400 var(--fs-head)/1 var(--display); letter-spacing: .04em; text-shadow: 3px 3px 0 var(--ink); }
.ve-money:empty { display: none; }
.ve-money.up { color: var(--ok); }
.ve-money.down { color: var(--red); }

.wallet-btn { position: fixed; z-index: 40; top: calc(12px + var(--safe-t)); right: 12px; color: #fff; background: rgba(7,5,10,.72);
  border: 1px solid rgba(255,255,255,.25); font-size: var(--fs-cap); letter-spacing: .12em; font-weight: 800; backdrop-filter: blur(4px); }
.wallet-btn.on { border-color: var(--ok); color: var(--ok); }
body.vs .wallet-btn, body:has(#hud:not(.hidden)) .wallet-btn { display: none; }
#walletPanel { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(7,5,10,.72); padding: 16px; }
.w-card { width: min(92vw, 460px); max-height: calc(100dvh - 32px); overflow-y: auto; transform: rotate(-.6deg); }
.w-x { position: absolute; top: 8px; right: 8px; width: var(--h3); height: var(--h3); border: 0; background: none; color: var(--ink); cursor: pointer; font-size: var(--fs-label); }
.w-addr { margin: 8px 0 12px; font-size: var(--fs-cap); word-break: break-all; color: #333; -webkit-user-select: text; user-select: text; }
.w-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.w-row .btn { flex: 1; transform: none; }
.w-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.w-links .chip { color: var(--ink); border: 2px solid var(--ink); font-size: var(--fs-cap); font-weight: 800; letter-spacing: .06em; text-decoration: none; }
.w-practice { margin: 12px 0 0; padding: 8px 12px; background: #fff3c4; border-left: 4px solid var(--y); font-size: var(--fs-cap); line-height: 1.5; color: #333; }
.w-bal { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 12px 0; font: 400 var(--fs-action)/1.1 var(--display); color: var(--ink); }
.w-bal dt { letter-spacing: .08em; }
.w-bal dd { margin: 0; text-align: right; }
.w-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: end; }
.w-form .chip { min-height: var(--h3); margin-top: 8px; border: 2px solid var(--ink); color: var(--ink); font-weight: 800; }
.w-fine { margin: 8px 0 0; font-size: var(--fs-cap); line-height: 1.5; color: #555; }
.w-fine:empty { display: none; }
.w-msg { margin: 12px 0 0; font-size: var(--fs-body); line-height: 1.4; color: #333; }
.w-msg:empty { display: none; }
.w-msg.bad { color: #c9162f; }
.w-msg.good { color: #127a3a; }
.w-card .btn.ghost { color: var(--ink); }
.w-card .btn.ghost:hover, .w-card .btn.ghost:focus-visible { color: #c9162f; }
/* a phone on its side: the stake slip and the two buttons have to share ~360 px of height */
@media (max-height: 520px) {
  #vsMenu .vs-wrap { width: min(100%, 720px); display: grid; grid-template-columns: 1.1fr 1fr; grid-template-areas: 'head head' 'stake pick' 'status status' 'back back'; gap: 8px 16px; }
  #vsMenu .vs-head { grid-area: head; }
  #vsMenu .vs-head p { display: none; }
  #vsMenu .stake { grid-area: stake; padding: 8px 12px; }
  #vsMenu .vs-pick { grid-area: pick; gap: 8px; }
  #vsMenu .vs-pick .btn small { display: none; }
  #vsMenu #vmStatus { grid-area: status; }
  #vsMenu > .vs-wrap > .menu:last-child { grid-area: back; }
  #vsMenu .seg button { min-height: 36px; }
  #stakeAmt { min-height: 36px; font-size: var(--fs-label); }
  .stake-note { margin-top: 4px; }
}
/* the wallet chip would sit on top of the opponent's line and the result screen */
body:has(#vsSelect:not(.hidden)) .wallet-btn, body:has(#vsEnd:not(.hidden)) .wallet-btn { display: none; }
/* result of a 1v1: the buttons stay on screen however tall the stats get */
#vsEnd .vs-end > .menu.row { position: sticky; bottom: 0; z-index: 2; align-self: stretch; justify-content: center; flex-wrap: wrap; gap: 12px;
  padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(rgba(7,5,10,0), rgba(7,5,10,.92) 35%); }
#vsEnd .ve-rows { font-size: var(--fs-cap); }
@media (max-height: 760px) { #vsEnd .fired-big { font-size: clamp(56px, 13vh, 120px); } }
