/* Earth vs. the Invaders — 1950s B-movie screen-print styling. */

:root {
  --navy: #1b2238;
  --deep: #10152a;
  --ink: #1b2238;
  --cream: #f3e7cf;
  --paper: #efe2c4;
  --paper-2: #e6d6b3;
  --red: #e0452b;
  --red-d: #b8321c;
  --teal: #2f8c8a;
  --teal-d: #1f6664;
  --mustard: #f0b73a;
  --muted: #8d8267;
  --f-display: 'Bowlby One SC', Impact, sans-serif;
  --f-script: 'Shrikhand', Georgia, serif;
  --f-cond: 'Oswald', 'Arial Narrow', sans-serif;
  --f-type: 'Special Elite', 'Courier New', monospace;
  --f-comic: 'Bangers', Impact, sans-serif;
  --print: 5px 5px 0 rgba(8, 10, 20, 0.55);
  --print-sm: 3px 3px 0 rgba(8, 10, 20, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--deep);
  background-image:
    radial-gradient(rgba(243, 231, 207, 0.05) 1.2px, transparent 1.6px),
    radial-gradient(ellipse at 50% -10%, #25305a 0%, var(--deep) 60%);
  background-size: 9px 9px, 100% 100%;
  color: var(--cream);
  font-family: var(--f-cond);
  font-size: 15px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* paper grain over the whole theatre */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: url('../assets/img/paper.jpg');
  background-size: 512px;
  mix-blend-mode: multiply;
  opacity: 0.18;
  pointer-events: none;
  z-index: 50;
}

button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--f-type); font-size: 0.92em; }
kbd {
  display: inline-block; min-width: 1.7em; padding: 1px 6px; margin: 0 2px;
  font-family: var(--f-cond); font-weight: 600; font-size: 12px; text-align: center;
  color: var(--navy); background: var(--cream); border: 2px solid var(--navy); border-radius: 4px;
  box-shadow: 0 2px 0 var(--navy);
}

#app { height: 100%; }
.screen { display: none; height: 100%; position: relative; }
#app[data-screen='menu'] #screen-menu,
#app[data-screen='setup'] #screen-setup,
#app[data-screen='game'] #screen-game,
#app[data-screen='lab'] #screen-lab { display: block; }

/* ------------------------------------------------------------ buttons & controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px;
  font-family: var(--f-display); font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--cream); background: var(--red);
  border: 3px solid var(--navy); border-radius: 6px;
  box-shadow: var(--print-sm);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(8, 10, 20, 0.55); background: #ea5637; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(8, 10, 20, 0.55); }
.btn:focus-visible, .seg button:focus-visible, .mode:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
a.btn { text-decoration: none; }
.btn.big { font-size: 22px; padding: 14px 34px; }
.btn.small { font-size: 12px; padding: 5px 10px; border-width: 2px; }
.btn.ghost { background: transparent; color: var(--cream); border-color: rgba(243, 231, 207, 0.55); box-shadow: none; }
.btn.ghost:hover { background: rgba(243, 231, 207, 0.1); }
/* ghost buttons on paper (cards, modals, title cards such as the pause screen) print in navy ink */
.card .btn.ghost, .modal .btn.ghost, .titlecard .btn.ghost { color: var(--navy); border-color: var(--navy); }
.card .btn.ghost:hover, .titlecard .btn.ghost:hover { background: rgba(27, 34, 56, 0.08); }

.seg { display: inline-flex; flex-wrap: wrap; border: 2px solid var(--navy); border-radius: 6px; overflow: hidden; background: var(--paper-2); }
.seg button {
  padding: 6px 12px; border: 0; border-right: 2px solid var(--navy); background: transparent;
  color: var(--navy); font-family: var(--f-cond); font-weight: 600; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: rgba(27, 34, 56, 0.08); }
.seg button.on { background: var(--navy); color: var(--mustard); }

select, input[type='number'] {
  font-family: var(--f-cond); font-size: 14px; font-weight: 500; color: var(--navy);
  background: var(--cream); border: 2px solid var(--navy); border-radius: 5px; padding: 6px 8px;
}
select { max-width: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.field > span { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* ------------------------------------------------------------ paper cards */

.card {
  position: relative;
  color: var(--navy);
  background: var(--paper) url('../assets/img/paper.jpg');
  background-size: 420px;
  border: 3px solid var(--navy);
  border-radius: 8px;
  box-shadow: var(--print);
  padding: 18px 20px;
}
.card::before {
  content: ''; position: absolute; inset: 5px;
  border: 1.5px solid rgba(27, 34, 56, 0.35); border-radius: 4px; pointer-events: none;
}
.kicker { font-family: var(--f-cond); font-weight: 600; font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--mustard); }

/* ------------------------------------------------------------ title screen */

.poster-bg {
  position: absolute; inset: 0;
  background: url('../assets/img/poster.jpg') center right / cover no-repeat;
  animation: drift 40s ease-in-out infinite alternate;
}
.poster-bg::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(16, 21, 42, 0.94) 0%, rgba(16, 21, 42, 0.82) 38%, rgba(16, 21, 42, 0.15) 70%, rgba(16, 21, 42, 0.05) 100%),
    linear-gradient(0deg, rgba(16, 21, 42, 0.95) 0%, rgba(16, 21, 42, 0) 30%);
}
@keyframes drift { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.08) translateX(-1.5%); } }

.menu-inner {
  position: relative; z-index: 1; height: 100%;
  display: grid; grid-template-rows: auto 1fr auto; gap: min(18px, 1.8vh);
  padding: calc(var(--pc-bar, 0px) + clamp(6px, 1.6vh, 24px)) clamp(20px, 4vw, 64px) clamp(14px, 3vh, 40px);
  max-width: 1500px;
}

.lockup { max-width: 760px; }
.lockup-kicker { font-family: var(--f-cond); font-weight: 600; letter-spacing: 0.4em; text-transform: uppercase; font-size: 13px; color: var(--mustard); }
.lockup h1 { margin: 6px 0 4px; line-height: 0.86; font-weight: 400; transform: rotate(-3deg); transform-origin: left center; }
.l-earth {
  display: block; font-family: var(--f-display); font-size: clamp(44px, min(8.4vw, 10.5vh), 132px); color: var(--cream); letter-spacing: 0.01em;
  text-shadow: 5px 5px 0 var(--red), 10px 10px 0 var(--navy);
}
.l-vs { display: block; margin: 6px 0 2px 0.2em; }
.l-vs span {
  display: inline-block; padding: 2px 22px 8px; font-family: var(--f-script); font-size: clamp(20px, min(2.6vw, 3.6vh), 40px);
  color: var(--navy); background: var(--mustard); border: 3px solid var(--navy); transform: rotate(-2deg) skewX(-8deg);
  box-shadow: var(--print-sm);
}
.l-invaders {
  display: block; font-family: var(--f-display); font-size: clamp(48px, min(9.6vw, 12vh), 150px); color: var(--red);
  -webkit-text-stroke: 3px var(--cream); paint-order: stroke fill;
  text-shadow: 6px 7px 0 var(--navy);
}
.tagline { margin: min(14px, 1.4vh) 0 0; max-width: 34em; font-size: clamp(14px, 1.25vw, 18px); line-height: 1.4; color: var(--cream); opacity: 0.9; letter-spacing: 0.02em; }
.tagline b { color: var(--mustard); font-weight: 600; }

.modes {
  align-self: start;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: min(14px, 1.5vh) 14px;
  max-width: 900px;
}
.mode {
  position: relative; text-align: left; padding: min(12px, 1.2vh) 14px min(12px, 1.2vh) 22px;
  color: var(--navy); background: var(--paper) url('../assets/img/paper.jpg'); background-size: 380px;
  border: 3px solid var(--navy); border-radius: 7px; box-shadow: var(--print);
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: start;
  transition: transform 0.12s, box-shadow 0.12s;
  /* ticket perforation on the left edge */
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 7px, #000 7.5px) left / 100% 100% no-repeat;
          mask: radial-gradient(circle at 0 50%, transparent 7px, #000 7.5px) left / 100% 100% no-repeat;
}
.mode::after { content: ''; position: absolute; left: 12px; top: 8px; bottom: 8px; border-left: 2px dashed rgba(27, 34, 56, 0.35); }
.mode:hover { transform: translate(-2px, -3px) rotate(-0.6deg); box-shadow: 8px 9px 0 rgba(8, 10, 20, 0.55); }
.mode .tag {
  grid-column: 1 / -1; justify-self: start;
  font-family: var(--f-cond); font-weight: 700; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--cream); background: var(--red); padding: 1px 7px; border-radius: 3px; transform: rotate(-1.5deg);
}
.mode.laya .tag { background: var(--navy); color: var(--mustard); }
.mode.lab .tag { background: var(--teal); }
.mode h3 { margin: 4px 0 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(16px, 1.45vw, 21px); line-height: 1.05; letter-spacing: 0.01em; }
.mode p { grid-column: 1 / -1; margin: 3px 0 0; font-size: 13px; line-height: 1.3; color: #3b3a3a; }
.mode .cast-mini { display: flex; margin-top: 2px; }
.mode .cast-mini img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--navy); margin-left: -8px; background: var(--navy); object-fit: cover; }

.billing { font-family: var(--f-cond); text-transform: uppercase; letter-spacing: 0.08em; color: rgba(243, 231, 207, 0.8); font-size: 13px; display: grid; gap: 5px; max-width: 1100px; }
/* "A PixelCortex game" stamp (games/_shared/studio): stuck on the poster, out of the layout flow. */
.si-stamp { position: absolute; z-index: 2; right: clamp(20px, 4vw, 64px); bottom: clamp(14px, 3vh, 40px); }
@media (max-width: 1100px) { .si-stamp { display: none; } }
/* Short screens: the studio bar takes some height, so the lockup gives a little back. */
@media (max-height: 820px) {
  html.pc-studio .menu-inner { gap: 8px; padding-bottom: 12px; }
  html.pc-studio .l-earth { font-size: clamp(40px, min(8.4vw, 8.6vh), 132px); }
  html.pc-studio .l-invaders { font-size: clamp(44px, min(9.6vw, 9.6vh), 150px); }
  html.pc-studio .tagline { margin-top: 6px; }
  html.pc-studio .modes { row-gap: 8px; }
  html.pc-studio .mode { padding-top: 7px; padding-bottom: 7px; }
}
.billing-cast { font-size: 15px; letter-spacing: 0.12em; color: var(--cream); }
.billing-cast b { color: var(--mustard); font-weight: 600; }
.billing-cast small { font-size: 0.78em; opacity: 0.75; letter-spacing: 0.06em; }
.billing-fine { font-size: 11.5px; opacity: 0.7; letter-spacing: 0.14em; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.12em; text-transform: none; font-family: var(--f-type); }
.status .led { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); border: 2px solid var(--navy); box-shadow: 0 0 0 1px rgba(243,231,207,.3); }
.status.ok .led { background: #7fd08a; }
.status.bad .led { background: var(--red); animation: blink 1s steps(2) infinite; }
.status.warn .led { background: #F0B73A; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ------------------------------------------------------------ setup / casting */

.setup-wrap, .lab-wrap { height: 100%; overflow-y: auto; padding: calc(var(--pc-bar, 0px) + clamp(8px, 2vh, 24px)) clamp(16px, 4vw, 60px) clamp(16px, 3vh, 34px); max-width: 1440px; margin: 0 auto; }
.setup-head { display: grid; grid-template-columns: auto auto 1fr; gap: 22px; align-items: center; margin-bottom: 20px; }
.setup-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(30px, 3.4vw, 50px); color: var(--cream); text-shadow: 4px 4px 0 var(--red); line-height: 1; }
.setup-blurb { font-size: 15px; line-height: 1.4; max-width: 46em; color: rgba(243, 231, 207, 0.85); }

.cast { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.seat { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: start; }
.seat select { width: 100%; }
.seat.off { opacity: 0.72; }
.seat .portrait { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--navy); object-fit: cover; box-shadow: var(--print-sm); background: var(--navy); }
.seat.off .portrait { filter: grayscale(1) brightness(0.8); }
.seat .role { font-family: var(--f-cond); font-weight: 700; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--red-d); }
.seat h4 { margin: 2px 0 8px; font-family: var(--f-display); font-weight: 400; font-size: 22px; line-height: 1; }
.seat .who .seg { margin-bottom: 4px; }
.seat .keys { margin-top: 8px; font-size: 13px; line-height: 1.9; }
.seat .vision-blurb { margin-top: 6px; font-size: 12.5px; line-height: 1.35; color: #4a463d; }
.seat .seat-note { margin-top: 8px; font-size: 12.5px; line-height: 1.35; color: #4a463d; }

.options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; margin-bottom: 18px; }
.opt { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.opt-label { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.opt.disabled { opacity: 0.4; pointer-events: none; }
.seed-row { display: flex; gap: 8px; }
.seed-row input { width: 120px; }

.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 20px; }
.setup-note { margin: 0; max-width: 60em; font-size: 14px; line-height: 1.45; color: rgba(243, 231, 207, 0.8); }

/* ------------------------------------------------------------ game */

#screen-game { display: none; flex-direction: column; }
#app[data-screen='game'] #screen-game { display: flex; }
.gamebar {
  flex: none; display: flex; align-items: center; gap: 22px; padding: 8px 18px; height: 54px;
  background: var(--navy); border-bottom: 3px solid #0a0e1c;
}
.gb-logo { font-family: var(--f-display); font-size: 18px; color: var(--cream); text-shadow: 2px 2px 0 var(--red); white-space: nowrap; }
.gb-logo i { font-family: var(--f-script); font-style: normal; color: var(--mustard); text-shadow: none; font-size: 15px; }
.gb-mode { font-family: var(--f-cond); font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; font-size: 13px; color: var(--mustard); white-space: nowrap; }
.gb-stat { display: flex; flex-direction: column; line-height: 1; }
.gb-stat span { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(243, 231, 207, 0.6); }
.gb-stat b { font-family: var(--f-display); font-weight: 400; font-size: 20px; color: var(--cream); letter-spacing: 0.04em; }
.gb-slow { font-family: var(--f-type); font-size: 12px; color: var(--navy); background: var(--mustard); border: 2px solid #0a0e1c; border-radius: 4px; padding: 3px 8px; white-space: nowrap; }
.gb-slow[hidden] { display: none; }
.gb-keys { margin-left: auto; font-size: 12px; color: rgba(243, 231, 207, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr); gap: 16px; padding: 14px 16px 16px; }
.side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.frame {
  min-height: 0; min-width: 0; align-self: center; aspect-ratio: 4 / 3;
  height: min(100%, calc((100vw - 540px) * 0.75 + 8px)); max-width: calc(100vw - 540px);
  padding: 10px; background: var(--cream); border: 3px solid var(--navy); border-radius: 10px; box-shadow: 8px 8px 0 rgba(8, 10, 20, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.frame-inner { position: relative; width: 100%; height: 100%; border: 3px solid var(--navy); border-radius: 4px; overflow: hidden; background: var(--deep); display: flex; align-items: center; justify-content: center; }
#board { display: block; }

/* player cards */
.pcard { padding: 12px 14px; }
.pcard-head { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: center; }
.pcard-head img { width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--navy); object-fit: cover; background: var(--navy); }
.pcard .role { font-size: 10.5px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; }
.pcard .name { font-family: var(--f-display); font-size: 20px; line-height: 1; }
.pcard .sub { font-size: 12px; color: #4a463d; margin-top: 2px; }
.pcard .score { font-family: var(--f-display); font-size: 34px; line-height: 1; margin-top: 10px; letter-spacing: 0.02em; }
.pcard .lives { display: flex; gap: 4px; margin-top: 6px; min-height: 22px; align-items: center; }
.pcard .lives img { height: 22px; }
.pcard .lives .out { font-family: var(--f-comic); font-size: 18px; color: var(--red); letter-spacing: 0.05em; }
.pcard .pstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; border-top: 1.5px solid rgba(27, 34, 56, 0.3); padding-top: 8px; }
.pcard .pstats div { display: flex; flex-direction: column; }
.pcard .pstats span { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.pcard .pstats b { font-family: var(--f-cond); font-weight: 600; font-size: 16px; }
.pcard.dead .pcard-head img { filter: grayscale(1); }

/* the electronic brain panel */
.brain { padding: 12px 14px 12px; background-color: #e9dcbc; }
.brain-head { display: grid; gap: 2px; }
.brain-title { font-family: var(--f-display); font-size: 14px; letter-spacing: 0.04em; }
.brain-model { font-family: var(--f-type); font-size: 12px; line-height: 1.35; color: #4a463d; }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.gauge { text-align: center; }
.gauge svg { width: 100%; height: auto; display: block; }
.gauge .needle { transition: transform 0.12s ease-out; transform-origin: 50px 52px; }
.gauge .glabel { font-family: var(--f-cond); font-weight: 700; font-size: 11px; letter-spacing: 0.16em; margin-top: -2px; }
.gauge .gval { font-family: var(--f-type); font-size: 12px; }
.gauge.chosen .glabel { color: var(--red-d); }
.gauge.chosen svg .face { fill: #fff6df; }
.gauge.na { opacity: 0.35; }
.brain-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.lamp { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--navy); background: #5a2a22; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); flex: none; }
.lamp.on { background: var(--red); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2), 0 0 0 3px rgba(224, 69, 43, 0.25); }
.lamp.idle { background: #8d8267; }
.brain-row .fire-txt { font-family: var(--f-cond); font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.brain-row .fire-txt small { font-family: var(--f-type); font-size: 12px; text-transform: none; letter-spacing: 0; color: #4a463d; }
.readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.readout div { background: var(--navy); color: var(--mustard); border-radius: 4px; padding: 3px 6px; text-align: center; }
.readout span { display: block; font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(243, 231, 207, 0.6); }
.readout b { font-family: var(--f-type); font-weight: 400; font-size: 14px; }
.ticker { list-style: none; margin: 8px 0 0; padding: 6px 8px; background: #fbf3de; border: 1.5px solid rgba(27, 34, 56, 0.35); border-radius: 3px; font-family: var(--f-type); font-size: 11.5px; line-height: 1.45; height: 7.6em; overflow: hidden; color: #2b2a28; }
.ticker li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticker .q-fatal { color: var(--red-d); }
.ticker .q-dodge { color: var(--teal-d); }
.ticker .q-err { color: var(--red-d); }
.brain .see { margin-top: 8px; width: 100%; }
.brain .err { margin-top: 6px; font-family: var(--f-type); font-size: 12px; color: var(--red-d); }

/* fleet commander */
.tubes { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; align-items: end; height: 84px; margin-top: 10px; padding: 6px; background: var(--navy); border-radius: 4px; }
.tube { position: relative; height: 100%; background: rgba(243, 231, 207, 0.08); border-radius: 3px; overflow: hidden; }
.tube i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--mustard); transition: height 0.12s; }
.tube.chosen i { background: var(--red); }
.tube.na { opacity: 0.25; }
.tube-labels { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; padding: 2px 6px 0; font-family: var(--f-cond); font-size: 10px; text-align: center; color: #4a463d; }

/* dossier (point table) */
.dossier h4 { margin: 0 0 6px; font-family: var(--f-display); font-weight: 400; font-size: 15px; }
.dossier .row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 3px 0; border-bottom: 1px dashed rgba(27, 34, 56, 0.3); }
.dossier .row:last-child { border-bottom: 0; }
.dossier img { width: 40px; height: 34px; object-fit: contain; }
.dossier .pts { font-family: var(--f-display); font-size: 16px; }
.dossier .what { font-size: 13px; color: #3b3a3a; }

/* ------------------------------------------------------------ overlays */

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.count {
  font-family: var(--f-display); font-size: clamp(90px, 16vh, 190px); color: var(--cream);
  text-shadow: 6px 6px 0 var(--red), 12px 12px 0 var(--navy); animation: pop 0.5s ease-out; pointer-events: none;
}
.count.go { font-size: clamp(44px, 7.5vh, 86px); text-align: center; line-height: 1; transform: rotate(-4deg); }
@keyframes pop { from { transform: scale(1.8) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.titlecard {
  text-align: center; padding: 24px 40px; min-width: 50%;
  color: var(--navy); background: var(--paper) url('../assets/img/paper.jpg'); background-size: 420px;
  border: 4px solid var(--navy); box-shadow: 8px 8px 0 rgba(8, 10, 20, 0.6); transform: rotate(-1.5deg);
  animation: pop 0.45s ease-out; pointer-events: none;
}
.titlecard .kicker { color: var(--red-d); }
.titlecard h2 { margin: 4px 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(36px, 6vh, 64px); line-height: 1; }
.titlecard p { margin: 4px 0 0; font-size: 16px; }
.loading { font-family: var(--f-type); font-size: 18px; color: var(--cream); text-align: center; line-height: 1.6; background: rgba(16, 21, 42, 0.85); padding: 20px 30px; border: 2px solid var(--cream); border-radius: 6px; }
.loading .reel { display: inline-block; width: 42px; height: 42px; border-radius: 50%; border: 5px dotted var(--mustard); animation: spin 1.2s linear infinite; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.pausecard { text-align: center; }
.pausecard .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

.results {
  position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; overflow: hidden;
  background: var(--deep) center / cover no-repeat; animation: fadein 0.6s ease-out;
}
.results::before { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(16, 21, 42, 0.96) 18%, rgba(16, 21, 42, 0.35) 60%, rgba(16, 21, 42, 0.1)); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.results-inner { position: relative; align-self: end; padding: 3% 4% 3.2%; }
.results h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(34px, 6.4vh, 70px); line-height: 0.95; color: var(--cream); text-shadow: 5px 5px 0 var(--red), 9px 9px 0 var(--navy); transform: rotate(-2deg); transform-origin: left; }
.results .sub { margin: 12px 0 14px; font-size: 16px; color: rgba(243, 231, 207, 0.9); }
.results .sub b { color: var(--mustard); font-weight: 600; }
.rtable { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 340px); gap: 12px; }
.rcell { padding: 10px 12px; }
.rcell .name { font-family: var(--f-display); font-size: 17px; }
.rcell .score { font-family: var(--f-display); font-size: 30px; line-height: 1.05; }
.rcell .meta { font-size: 12.5px; line-height: 1.45; color: #3b3a3a; }
.rcell.win { outline: 4px solid var(--mustard); outline-offset: -2px; }
.rcell .crown { font-family: var(--f-comic); font-size: 18px; color: var(--red-d); letter-spacing: 0.06em; }
.results .btns { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* ------------------------------------------------------------ modal (what Laya sees) */

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(8, 10, 20, 0.7); }
.modal[hidden] { display: none; }
.modal .sheet { width: min(900px, 92vw); max-height: 86vh; display: flex; flex-direction: column; gap: 10px; }
.modal .sheet h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.modal pre { margin: 0; flex: 1; overflow: auto; background: #fbf3de; border: 2px solid var(--navy); border-radius: 4px; padding: 12px 14px; font-family: var(--f-type); font-size: 12.5px; line-height: 1.5; color: #2b2a28; white-space: pre-wrap; }
.modal .sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }

/* ------------------------------------------------------------ lab */

.lab-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; padding-bottom: 20px; }
.lab-main > * { min-width: 0; }
.lab-config h3, .lab-results h3 { margin: 12px 0 6px; font-family: var(--f-display); font-weight: 400; font-size: 16px; }
.lab-config h3:first-child { margin-top: 0; }
.checks { display: grid; gap: 3px; max-height: 250px; overflow-y: auto; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 2px 0; }
.checks label small { color: var(--muted); }
.checks input { accent-color: var(--red); width: 16px; height: 16px; }
.lab-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lab-commander { display: grid; gap: 4px; }
.lab-actions { display: flex; gap: 10px; margin-top: 16px; }
.lab-main { display: grid; gap: 18px; align-content: start; min-width: 0; }
.lab-live { display: grid; grid-template-columns: minmax(0, 420px) 1fr; gap: 18px; align-items: start; }
.lab-screen { aspect-ratio: 4 / 3; border: 3px solid var(--navy); border-radius: 4px; overflow: hidden; background: var(--deep); display: flex; align-items: center; justify-content: center; }
.lab-bar { height: 16px; border: 2px solid var(--navy); border-radius: 4px; background: var(--paper-2); overflow: hidden; }
.lab-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--red), var(--red) 8px, var(--red-d) 8px, var(--red-d) 16px); transition: width 0.3s; }
.typewriter { font-family: var(--f-type); font-size: 13px; line-height: 1.55; margin-top: 10px; white-space: pre-wrap; }
.lab-results-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lab-results-head h3 { margin: 0; margin-right: auto; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.results-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.results-table th { text-align: left; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--navy); white-space: nowrap; }
.results-table td { padding: 6px 8px; border-bottom: 1px dashed rgba(27, 34, 56, 0.3); white-space: nowrap; }
.results-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--f-cond); font-weight: 500; }
.results-table .bar { display: inline-block; height: 9px; background: var(--red); border: 1.5px solid var(--navy); vertical-align: middle; margin-right: 6px; }
.results-table tr.best td { background: rgba(240, 183, 58, 0.25); }
.empty { font-family: var(--f-type); font-size: 13px; color: #4a463d; padding: 10px 0; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1180px) {
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cast, .options { grid-template-columns: 1fr; }
  .lab-grid { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; overflow-y: auto; }
  .frame { max-width: 100%; height: auto; width: 100%; }
  .side { overflow: visible; }
  body { overflow: auto; }
}
@media (max-width: 640px) {
  .modes { grid-template-columns: 1fr; }
  .setup-head { grid-template-columns: 1fr; }
  .lab-live { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .poster-bg { animation: none; }
  .count, .titlecard, .results { animation: none; }
}
