/* ============================================================
   RISO FIGHT NIGHT — two-ink risograph fight poster meets arcade VS screen
   ============================================================ */
@import url("/static/vendor/fonts/fonts.css");

:root {
  --paper: #F2EBDD;
  --paper-hi: #FBF7EE;
  --paper-lo: #E3D8C3;
  --ink: #1D1A17;
  --ink-soft: #6B6258;
  --p1: #FF6C2F;
  --p2: #0078BF;
  --pass: #00A95C;
  --fail: #E8364F;
  --accent: #FFE800;

  --bw: 2.5px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --f-display: "Bowlby One", "Arial Black", sans-serif;
  --f-ui: "Archivo", system-ui, sans-serif;
  --f-code: "Martian Mono", ui-monospace, Menlo, monospace;
  --halftone-p2: radial-gradient(var(--p2) 32%, transparent 34%) 0 0 / 7px 7px;
  --halftone-ink: radial-gradient(var(--ink) 22%, transparent 24%) 0 0 / 6px 6px;
  --hatch-fail: repeating-linear-gradient(45deg, #E8364F26 0 4px, transparent 4px 8px);
  --ease-slam: cubic-bezier(.2, 1.6, .4, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 500 16px/1.45 var(--f-ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* paper grain */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .13;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[hidden] { display: none !important; }
a { color: inherit; }
code { font-family: var(--f-code); font-size: .88em; background: var(--paper-lo); padding: 0 .3em; border: 1px solid #1D1A1733; }
::selection { background: var(--accent); color: var(--ink); }

/* ---------- primitives ---------- */
.ink-box {
  background: var(--paper-hi);
  border: var(--bw) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow);
}
.label {
  font: 800 12px/1.2 var(--f-ui);
  font-stretch: 62%;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.soft { color: var(--ink-soft); }
.display { font-family: var(--f-display); font-weight: 400; text-transform: uppercase; line-height: .95; letter-spacing: -.01em; }
.misreg { text-shadow: 3px 2px 0 var(--p1), -3px -2px 0 var(--p2); }
.num { font-weight: 900; font-stretch: 125%; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: 900 15px/1 var(--f-ui);
  font-stretch: 110%;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper-hi);
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 60ms, box-shadow 60ms;
  user-select: none;
}
.btn:hover { background: var(--accent); }
.btn:active, .btn.pressed { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); background: var(--paper-lo); }
.btn--go { background: var(--accent); box-shadow: var(--shadow); padding: 16px 26px; font-size: 18px; }
.btn--go:hover { background: #fff36b; }
.btn--p1 { background: var(--p1); }
.btn--p2 { background: var(--p2); color: var(--paper-hi); }
.btn--p1:hover { background: #ff8a57; }
.btn--p2:hover { background: #1a8ad0; }
.btn--sm { padding: 7px 11px; font-size: 12px; }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--paper-lo); }

.input {
  font: 600 17px var(--f-ui);
  padding: 12px 14px;
  width: 100%;
  background: var(--paper-hi);
  color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: 0;
  box-shadow: inset 3px 3px 0 var(--paper-lo);
  outline: none;
}
.input:focus { background: #fffbe0; box-shadow: inset 3px 3px 0 var(--accent); }

.tape {
  display: inline-block;
  background: var(--accent);
  color: var(--ink);
  padding: 6px 22px;
  font: 800 13px var(--f-ui);
  font-stretch: 70%;
  letter-spacing: .12em;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
  clip-path: polygon(0 0, 100% 0, 98% 50%, 100% 100%, 0 100%, 2% 50%);
}
.tape--red { background: var(--fail); color: var(--paper-hi); }
.tape--ink { background: var(--ink); color: var(--accent); }

.stamp {
  display: inline-block;
  padding: 2px 10px;
  border: 4px double currentColor;
  transform: rotate(-7deg);
  font: 900 14px/1.3 var(--f-ui);
  font-stretch: 125%;
  letter-spacing: .1em;
  text-transform: uppercase;
  animation: stamp .16s var(--ease-slam);
  white-space: nowrap;
}
.stamp--pass { color: var(--pass); }
.stamp--pass::before { content: "✓ "; }
.stamp--fail { color: var(--fail); background: var(--hatch-fail); }
.stamp--fail::before { content: "✗ "; }
.stamp--wait { color: var(--ink-soft); animation: none; transform: none; border-style: dashed; border-width: 2px; }
.stamp--big { font-size: 42px; border-width: 8px; padding: 4px 22px; }
@keyframes stamp { from { transform: rotate(-7deg) scale(1.6); opacity: 0; } }

/* segmented progress */
.prog { display: flex; gap: 4px; padding: 4px; border: var(--bw) solid var(--ink); background: var(--paper-lo); min-height: 32px; }
.prog__seg { flex: 1; min-width: 6px; height: 20px; border: 2px solid var(--ink); background: var(--paper-hi); transition: background .22s steps(4); }
.prog--p1 .prog__seg.on { background: var(--p1); }
.prog--p2 .prog__seg.on { background: var(--halftone-p2), var(--paper-hi); }
.prog--tall .prog__seg { height: 30px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  border-bottom: var(--bw) solid var(--ink);
  background: var(--paper);
  position: relative; z-index: 5;
}
.logo {
  font: 400 26px/1 var(--f-display);
  text-decoration: none;
  letter-spacing: -.01em;
}
.topbar__mid { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.who { font-weight: 800; }
.conn-dot { width: 10px; height: 10px; border: 2px solid var(--ink); background: var(--pass); display: inline-block; }
.conn-dot.off { background: var(--fail); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- lobby / login ---------- */
.poster {
  max-width: 1080px; margin: 0 auto; padding: 48px 20px 80px;
}
.poster__head { text-align: center; margin-bottom: 38px; position: relative; }
.poster__title {
  font: 400 clamp(64px, 14vw, 168px)/.86 var(--f-display);
  margin: 0;
  letter-spacing: -.02em;
  text-shadow: 6px 4px 0 var(--p1), -5px -3px 0 var(--p2);
  mix-blend-mode: multiply;
}
.poster__sub { margin-top: 18px; }
.poster__sub[hidden], .poster__burst[hidden] { display: none; }
.poster__burst {
  position: absolute; right: 4%; top: -8px;
  width: 132px; height: 132px;
  display: grid; place-items: center; text-align: center;
  font: 900 15px/1.05 var(--f-ui); font-stretch: 75%; text-transform: uppercase;
  transform: rotate(12deg);
  isolation: isolate;
}
/* the ink outline is a second, slightly larger copy of the star behind it: a real border would be
   cut off at every point by the clip-path */
.poster__burst::before, .poster__burst::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  clip-path: polygon(50% 0, 61% 14%, 79% 7%, 80% 25%, 98% 29%, 88% 45%, 100% 59%, 83% 67%, 87% 86%, 68% 84%, 57% 100%, 45% 87%, 27% 96%, 23% 78%, 4% 74%, 13% 58%, 0 44%, 16% 35%, 11% 16%, 30% 16%, 39% 1%);
}
.poster__burst::before { background: var(--ink); }
.poster__burst::after { background: var(--accent); transform: scale(.93); }
/* one centred block: separate grid children would spread to the star's top and bottom edges */
.poster__burst-in { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; line-height: .95; }
.poster__burst-stage { font-size: 1em; letter-spacing: .04em; }
.poster__burst-num { font-size: 2.2em; }
.split { display: grid; grid-template-columns: 1fr 1.35fr; gap: 34px; align-items: start; }
.panel { padding: 22px; }
.panel h2 { margin: 0 0 14px; font: 400 30px/1 var(--f-display); text-transform: uppercase; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.error-line { color: var(--fail); font-weight: 800; min-height: 1.4em; }

.fight-cards { display: grid; gap: 14px; }
.fight-card {
  display: grid; grid-template-columns: 92px 1fr auto; align-items: stretch;
  background: var(--paper-hi);
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow-sm);
  /* torn-ticket notches */
  -webkit-mask: radial-gradient(circle 9px at 92px 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 9px at 92px 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 9px at 92px 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 9px at 92px 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
}
.fight-card__code {
  display: grid; place-items: center;
  border-right: 2.5px dashed var(--ink);
  font: 400 24px/1 var(--f-display);
  background: var(--accent);
}
.fight-card__body { padding: 12px 16px; min-width: 0; }
.fight-card__names { font: 400 20px/1.1 var(--f-display); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fight-card__names .p1 { color: var(--p1); }
.fight-card__names .p2 { color: var(--p2); }
.fight-card__names .open { color: var(--ink-soft); font-family: var(--f-ui); font-weight: 800; font-size: 14px; letter-spacing: .08em; }
.fight-card__actions { display: flex; gap: 8px; align-items: center; padding: 10px 12px; }
.phase-chip { display: inline-block; padding: 1px 7px; border: 2px solid var(--ink); background: var(--paper); margin-right: 8px; }
.phase-chip.live { background: var(--fail); color: var(--paper-hi); border-color: var(--fail); }
.empty-note { padding: 28px; text-align: center; border: 2.5px dashed var(--ink-soft); color: var(--ink-soft); font-weight: 700; }

/* ---------- VS header ---------- */
.vs {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  border-bottom: var(--bw) solid var(--ink);
  background: var(--paper-lo);
  position: relative;
}
.vs__p { padding: 12px 26px; min-height: 76px; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.vs__p--1 { background: var(--p1); clip-path: polygon(0 0, 100% 0, 96% 100%, 0 100%); }
.vs__p--2 { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); text-align: right; align-items: flex-end;
  clip-path: polygon(4% 0, 100% 0, 100% 100%, 0 100%); }
.vs__p--empty { background: var(--paper-lo); color: var(--ink-soft); }
.vs__name { font: 400 clamp(22px, 3vw, 40px)/1 var(--f-display); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.vs__meta { font: 800 12px var(--f-ui); font-stretch: 70%; letter-spacing: .08em; text-transform: uppercase; display: flex; gap: 12px; }
.vs__p--2 .vs__name { text-shadow: 2px 2px 0 var(--ink); }
.vs__mid { display: grid; place-items: center; padding: 0 10px; min-width: 120px; }
.vs__vs { font: 400 56px/1 var(--f-display); mix-blend-mode: multiply; text-shadow: 3px 2px 0 var(--p1), -3px -2px 0 var(--p2); }
.vs__timer { font: 900 24px/1 var(--f-ui); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.vs__timer.hot { color: var(--fail); }
.dc { background: var(--ink); color: var(--accent); padding: 0 6px; }

/* ---------- waiting room ---------- */
.waiting { padding: 40px 20px 60px; max-width: 1100px; margin: 0 auto; }
.slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; align-items: stretch; min-height: 320px; }
.slot {
  border: var(--bw) solid var(--ink);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 28px; text-align: center;
}
.slot--1 { background: var(--p1); clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%); padding-right: 12%; }
.slot--2 { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); clip-path: polygon(10% 0, 100% 0, 100% 100%, 0 100%); padding-left: 12%; }
.slot--open { background: repeating-linear-gradient(-45deg, var(--paper-lo) 0 14px, var(--paper) 14px 28px); color: var(--ink); }
.slot__name { font: 400 clamp(30px, 5vw, 60px)/1 var(--f-display); text-transform: uppercase; word-break: break-all; }
.slot--2 .slot__name { text-shadow: 3px 3px 0 var(--ink); }
.slot__insert { font: 400 26px/1.05 var(--f-display); text-transform: uppercase; opacity: .7; }
.slots__vs { display: grid; place-items: center; font: 400 96px/1 var(--f-display); margin: 0 -30px; z-index: 2; text-shadow: 4px 3px 0 var(--p1), -4px -3px 0 var(--p2); mix-blend-mode: multiply; }
.crowd { margin-top: 36px; }
.crowd__list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.stub { padding: 4px 12px; background: var(--paper-hi); border: 2px solid var(--ink); font-weight: 800; font-size: 13px; transform: rotate(var(--r, 0deg)); }
.share { margin-top: 30px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.share code { font-size: 16px; padding: 8px 12px; background: var(--paper-hi); border: var(--bw) solid var(--ink); }

/* ---------- arena (player view) ---------- */
.arena {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) minmax(290px, 350px);
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 62px - 78px - 46px); /* topbar, VS header, status strip */
  min-height: 560px;
}
.col { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.prompt { padding: 16px 18px; overflow: auto; flex: 1; }
.prompt h1 { font: 400 30px/1 var(--f-display); text-transform: uppercase; margin: 6px 0 10px; }
.prompt__story { font-size: 15px; margin: 0 0 16px; font-style: italic; }
.prompt h3 { margin: 16px 0 6px; }
.prompt p { margin: 0; font-size: 15px; }
.prompt__note { margin-top: 14px; padding: 8px 10px; background: var(--accent); border: 2px solid var(--ink); font-weight: 800; font-size: 13px; }
.example { border: 2px solid var(--ink); margin-top: 8px; background: var(--paper); display: grid; grid-template-columns: 1fr 1fr; }
.example > div { padding: 6px 9px; min-width: 0; }
.example > div + div { border-left: 2px dashed var(--ink); background: var(--paper-hi); }
.io-pre { margin: 2px 0 0; font: 400 13px/1.5 var(--f-code); white-space: pre-wrap; word-break: break-word; }
.io-pre--out { font-weight: 700; }
.task { background: var(--accent); border: 2px solid var(--ink); padding: 8px 12px; margin: 4px 0 10px; }
.task p { font-size: 17px !important; font-weight: 800; margin: 2px 0 0; line-height: 1.3; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 15px; }
.prompt .note { font-size: 13px; margin-top: 12px; }
.copy-btn { font: 800 10px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; border: 1.5px solid var(--ink); background: var(--paper-hi); cursor: pointer; padding: 2px 6px; }
.copy-btn:hover { background: var(--accent); }

.editor-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-frame { flex: 1; min-height: 0; border: var(--bw) solid var(--ink); box-shadow: var(--shadow); background: var(--paper-hi); position: relative; }
.editor-frame--p1 { border-color: var(--p1); border-width: 5px; box-shadow: 6px 6px 0 var(--ink); }
.editor-frame--p2 { border-color: var(--p2); border-width: 5px; box-shadow: 6px 6px 0 var(--ink); }
.editor-frame .CodeMirror { height: 100%; }
.editor-bar { display: flex; align-items: center; gap: 12px; padding: 10px 0 0; }
.editor-bar .spacer { flex: 1; }
.locked {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  background: #F2EBDDb3;
  backdrop-filter: grayscale(1);
}
.kbd { font: 700 11px var(--f-code); border: 1.5px solid var(--ink); padding: 1px 5px; background: var(--paper-hi); }

.tests { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.tests__summary { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.tests__count { font: 900 34px/1 var(--f-ui); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.ticket { border: 2px solid var(--ink); background: var(--paper); margin-bottom: 8px; }
.ticket__head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; gap: 8px; cursor: pointer; }
.ticket__num { font: 800 12px var(--f-ui); font-stretch: 70%; letter-spacing: .08em; text-transform: uppercase; }
.ticket__body { border-top: 2px dashed var(--ink); padding: 8px 10px; display: grid; gap: 6px; }
.ticket--fail { background: var(--hatch-fail), var(--paper-hi); }
.ticket--pass .ticket__head { padding: 4px 10px; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.diff > div { background: var(--paper-hi); border: 1.5px solid var(--ink); padding: 4px 6px; min-width: 0; }
.stderr { background: var(--ink); color: #ffd8cf; padding: 6px 8px; font: 400 12px/1.45 var(--f-code); white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 160px; overflow: auto; }
.hint { background: var(--accent); border: 2px solid var(--ink); padding: 6px 9px; font-weight: 700; font-size: 14px; }
.hint::before { content: "HINT ▶ "; font-weight: 900; font-stretch: 70%; letter-spacing: .08em; }
.opp { padding: 12px; }
.cheer-count { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.cheer-latest { font-size: 13px; font-weight: 700; margin-top: 4px; min-height: 1.3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- spectator view ---------- */
.spectate { padding: 16px; display: grid; gap: 14px; }
.spec-prompt { padding: 12px 16px; display: flex; gap: 18px; align-items: baseline; flex-wrap: wrap; }
.spec-prompt h2 { font: 400 24px/1 var(--f-display); margin: 0; text-transform: uppercase; }
.spec-prompt details { flex-basis: 100%; }
.spec-prompt summary { cursor: pointer; font-weight: 800; }
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.duel__side { display: flex; flex-direction: column; gap: 8px; position: relative; min-width: 0; }
.duel__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.duel__name { font: 400 22px/1 var(--f-display); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel__side--1 .duel__name { color: var(--p1); }
.duel__side--2 .duel__name { color: var(--p2); }
.duel .editor-frame { height: 46vh; min-height: 280px; flex: none; }
.lane { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.running-tag { background: var(--ink); color: var(--accent); padding: 1px 7px; font: 800 11px var(--f-ui); letter-spacing: .08em; animation: blink .6s steps(2) infinite; }
.paste-tag { background: var(--paper-hi); border: 2px solid var(--ink); padding: 0 6px; font: 800 11px var(--f-ui); letter-spacing: .06em; transform: rotate(-4deg); display: inline-block; }
.tabs { display: none; }

.cheer-deck { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cheer-side { padding: 14px; border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm); display: grid; gap: 10px; }
.cheer-side--1 { background: var(--p1); }
.cheer-side--2 { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); }
.cheer-side__title { font: 400 22px/1 var(--f-display); text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.cheer-side--2 .cheer-side__title { text-shadow: 2px 2px 0 var(--ink); }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-btn {
  font-size: 26px; line-height: 1; padding: 10px 0;
  background: var(--paper-hi); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform 60ms, box-shadow 60ms;
}
.emoji-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.text-cheer { display: flex; gap: 8px; }
.text-cheer .input { font-size: 15px; padding: 9px 10px; }
.cheer-side--2 .btn { color: var(--ink); }
.hype { height: 14px; border: 2px solid var(--ink); background: var(--paper-hi); position: relative; overflow: hidden; }
.hype__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width .3s steps(5); }
.hype.fire .hype__fill { background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, var(--fail) 8px 16px); animation: slide 0.6s linear infinite; background-size: 22.6px 22.6px; }
@keyframes slide { to { background-position: 22.6px 0; } }
.fire-tag { font: 900 11px var(--f-ui); letter-spacing: .12em; background: var(--fail); color: var(--paper-hi); padding: 1px 6px; transform: rotate(-3deg); display: inline-block; }

.predict { padding: 14px; display: grid; gap: 10px; text-align: center; }
.predict__bar { display: flex; height: 26px; border: var(--bw) solid var(--ink); }
.predict__bar > div { transition: flex-grow .4s; display: grid; place-items: center; font: 900 13px var(--f-ui); min-width: 0; overflow: hidden; }
.predict__bar .a { background: var(--p1); flex: 1; }
.predict__bar .b { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); flex: 1; }

.run-log { padding: 12px 14px; max-height: 220px; overflow: auto; }
.run-log ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.run-log li { display: flex; gap: 8px; align-items: center; }
.swatch { width: 12px; height: 12px; border: 2px solid var(--ink); display: inline-block; flex: none; }
.swatch--1 { background: var(--p1); }
.swatch--2 { background: var(--halftone-p2), var(--p2); }

/* ---------- floating reactions ---------- */
.floaty {
  position: absolute; bottom: -40px;
  display: flex; flex-direction: column; align-items: center;
  animation: floatUp 2.8s linear forwards;
}
.floaty__emoji { font-size: 38px; line-height: 1; filter: drop-shadow(2px 2px 0 var(--ink)); }
.floaty__from { font: 800 10px var(--f-ui); letter-spacing: .05em; background: var(--ink); color: var(--paper-hi); padding: 0 4px; margin-top: 2px; white-space: nowrap; }
.floaty--big .floaty__emoji { font-size: 64px; }
.floaty--big .floaty__from { font-size: 14px; padding: 1px 6px; }
@keyframes floatUp {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  10% { opacity: 1; transform: translate(calc(var(--wobble) * .3), -8vh) scale(1.1); }
  35% { transform: translate(var(--wobble), -26vh) scale(1); }
  65% { transform: translate(calc(var(--wobble) * -1), -46vh); opacity: 1; }
  100% { transform: translate(0, -70vh); opacity: 0; }
}

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; overflow: auto; }
.overlay--count { background: var(--accent); }
.count-vs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 20px; width: min(1100px, 94vw); }
.count-vs__p { text-align: center; }
.count-vs__p .display { font-size: clamp(30px, 5vw, 64px); }
.count-vs__p--1 .display { color: var(--p1); text-shadow: 3px 3px 0 var(--ink); }
.count-vs__p--2 .display { color: var(--p2); text-shadow: 3px 3px 0 var(--ink); }
.count-num { font: 400 clamp(140px, 22vw, 240px)/1 var(--f-display); text-align: center; animation: slam .18s var(--ease-slam), shake .12s .18s; }
.count-num.c5, .count-num.c2 { color: var(--ink); }
.count-num.c4 { color: var(--p1); text-shadow: 6px 4px 0 var(--ink); }
.count-num.c3 { color: var(--p2); text-shadow: 6px 4px 0 var(--ink); }
.count-num.c1 { color: var(--fail); text-shadow: 6px 4px 0 var(--ink); }
.count-label { text-align: center; margin-top: 14px; }
.chance { display: flex; height: 22px; border: var(--bw) solid var(--ink); margin: 18px auto 0; width: min(560px, 80vw); }
.chance > div { display: grid; place-items: center; font: 900 12px var(--f-ui); font-stretch: 110%; }
.chance .a { background: var(--p1); }
.chance .b { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); }
.release-tape { position: fixed; left: -5vw; right: -5vw; top: 42%; z-index: 60; text-align: center; font: 400 clamp(40px, 8vw, 96px)/1.1 var(--f-display); padding: 14px 0; transform: rotate(-6deg); animation: tapeIn .26s ease-out; background: var(--fail); color: var(--paper-hi); border-top: var(--bw) solid var(--ink); border-bottom: var(--bw) solid var(--ink); pointer-events: none; }
@keyframes slam { from { transform: scale(2.4) rotate(-8deg); opacity: 0; } }
@keyframes shake { 25% { transform: translate(2px, -2px); } 50% { transform: translate(-2px, 1px); } 75% { transform: translate(1px, 2px); } }
@keyframes tapeIn { from { transform: translateX(-120%) rotate(-6deg); } }

/* announcer: slides in from the left edge, clear of the centred callouts */
#ann-slot { position: fixed; left: 0; top: 34vh; z-index: 55; pointer-events: none; }
.ann { display: grid; justify-items: start; gap: 4px; transform: rotate(-4deg); transform-origin: left center; animation: tapeIn .32s var(--ease-slam); }
.ann.ann--out { animation: pu-ann-out .45s ease-in forwards; }
@keyframes pu-ann-out { to { transform: translateX(-110%) rotate(-4deg); } }
.ann__text {
  font: 400 clamp(26px, 4vw, 48px)/1 var(--f-display); text-transform: uppercase; letter-spacing: -.01em;
  background: var(--accent); color: var(--ink); padding: 10px 34px 10px 22px;
  border-top: var(--bw) solid var(--ink); border-bottom: var(--bw) solid var(--ink);
  clip-path: polygon(0 0, 100% 0, 97% 50%, 100% 100%, 0 100%);
  text-shadow: 3px 3px 0 color-mix(in srgb, var(--p1) 70%, transparent);
}
.ann--p2 .ann__text { text-shadow: 3px 3px 0 color-mix(in srgb, var(--p2) 70%, transparent); }
.ann--comeback .ann__text, .ann--flawless .ann__text { background: var(--ink); color: var(--accent); }
.ann__sub { font: 800 14px var(--f-ui); font-stretch: 80%; letter-spacing: .1em; text-transform: uppercase; background: var(--paper-hi); border: 2px solid var(--ink); padding: 3px 12px; margin-left: 18px; box-shadow: var(--shadow-sm); }
.ann--p1 .ann__sub { border-left: 8px solid var(--p1); }
.ann--p2 .ann__sub { border-left: 8px solid var(--p2); }
.ann--big .ann__text { font-size: 84px; padding: 16px 60px 16px 36px; }
.ann--big .ann__sub { font-size: 26px; padding: 6px 18px; }
.titles { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: middle; }
.title-stamp { font: 900 10px/1 var(--f-ui); font-stretch: 110%; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); border: 2px solid var(--ink); padding: 2px 5px; transform: rotate(-3deg); background: var(--paper-hi); white-space: nowrap; }
.title-stamp--champ { background: var(--accent); }
.title-stamp--fire { background: var(--fail); color: var(--paper-hi); }
.bc-body .title-stamp { font-size: 14px; padding: 3px 7px; }
.headlines { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0; }
.headlines .tape { transform: rotate(var(--r, -2deg)); font-size: 15px; }
.headlines--big .tape { font-size: 24px; padding: 8px 28px; }
@media (prefers-reduced-motion: reduce) { .ann, .ann.ann--out { animation: none; } }

.callout { position: fixed; left: 50%; top: 88px; z-index: 40; transform: translateX(-50%) rotate(-2deg); font-size: 20px; padding: 10px 30px; animation: stamp .2s var(--ease-slam); box-shadow: var(--shadow); }

.overlay--win { background: var(--paper); }
.win { width: min(1200px, 96vw); padding: 30px 0 50px; display: grid; gap: 22px; position: relative; }
.win__burst {
  position: fixed; inset: -50%; z-index: -1; opacity: .9;
  background: repeating-conic-gradient(var(--burst, var(--p1)) 0 9deg, transparent 9deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 70%);
          mask: radial-gradient(circle, #000 20%, transparent 70%);
  animation: spin 40s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.win__head { text-align: center; position: relative; }
.win__name { font: 400 clamp(56px, 11vw, 170px)/.9 var(--f-display); text-transform: uppercase; margin: 0; word-break: break-all; }
.win__name.p1 { color: var(--p1); text-shadow: 5px 4px 0 var(--ink); }
.win__name.p2 { color: var(--p2); text-shadow: 5px 4px 0 var(--ink); }
.win__ko { position: absolute; right: 6%; top: -10px; }
.win__stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.stat { padding: 10px 18px; text-align: center; background: var(--paper-hi); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm); min-width: 130px; }
.stat__v { font: 900 30px/1.1 var(--f-ui); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.stat__v.up { color: var(--pass); }
.stat__v.down { color: var(--fail); }
.solutions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.solution { border: var(--bw) solid var(--ink); background: var(--paper-hi); box-shadow: var(--shadow-sm); position: relative; min-width: 0; }
.solution--loser { filter: grayscale(1); transform: rotate(1.2deg); }
.solution__head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: var(--bw) solid var(--ink); }
.solution--1 .solution__head { background: var(--p1); }
.solution--2 .solution__head { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); }
.solution pre { margin: 0; padding: 12px; font: 400 13px/1.5 var(--f-code); max-height: 320px; overflow: auto; white-space: pre; }
.solution .stamp { position: absolute; right: 16px; top: 52px; background: var(--paper-hi); }
.win__actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- host controls ---------- */
.host-bar { position: fixed; left: 12px; bottom: 12px; z-index: 30; padding: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--ink); border: var(--bw) solid var(--ink); }
.host-bar .label { color: var(--accent); padding: 0 6px; }
.host-bar .btn--ghost:hover { background: #ffffff1a; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: grid; gap: 8px; }
.toast { padding: 10px 14px; font-weight: 800; max-width: 340px; animation: stamp .16s var(--ease-slam); transform: none; }
.toast.out { opacity: 0; transition: opacity .3s; }
.toast.bad { background: var(--fail); color: var(--paper-hi); }

/* ---------- leaderboard ---------- */
.standings { max-width: 1000px; margin: 0 auto; padding: 40px 20px 80px; }
.standings h1 { font: 400 clamp(48px, 8vw, 96px)/.9 var(--f-display); margin: 0 0 8px; text-transform: uppercase; }
table.sheet { width: 100%; border-collapse: collapse; background: var(--paper-hi); border: var(--bw) solid var(--ink); box-shadow: var(--shadow); }
.sheet th { text-align: left; padding: 10px 12px; background: var(--ink); color: var(--paper-hi); font: 800 12px var(--f-ui); font-stretch: 62%; letter-spacing: .1em; text-transform: uppercase; }
.sheet td { padding: 10px 12px; border-bottom: 1px solid #1D1A1740; }
.sheet tr:nth-child(even) td { background: var(--paper); }
.sheet tr:nth-child(5n) td { border-bottom: 2px solid var(--ink); }
.sheet .rank { font: 400 22px var(--f-display); width: 60px; }
.sheet .name { font-weight: 800; font-size: 18px; }
.sheet .elo { font: 900 22px var(--f-ui); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.rosette { display: inline-grid; place-items: center; width: 34px; height: 34px; background: var(--accent); border: 2px solid var(--ink);
  clip-path: polygon(50% 0, 63% 25%, 91% 20%, 78% 45%, 100% 62%, 72% 70%, 70% 98%, 50% 82%, 30% 98%, 28% 70%, 0 62%, 22% 45%, 9% 20%, 37% 25%); font: 400 15px var(--f-display); }
.tally { font-family: var(--f-code); letter-spacing: -.1em; }
.records { margin-top: 36px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.record { padding: 12px 14px; }
.record__time { font: 900 26px var(--f-ui); font-stretch: 125%; }

/* ---------- CodeMirror: cm-s-riso ---------- */
.cm-s-riso.CodeMirror { font: 400 14px/1.55 var(--f-code); font-stretch: 87%; background: var(--paper-hi); color: var(--ink); }
.cm-s-riso .CodeMirror-gutters { background: var(--paper-lo); border-right: 2px dashed var(--ink); }
.cm-s-riso .CodeMirror-linenumber { color: var(--ink-soft); }
.cm-s-riso .CodeMirror-cursor { border-left: 3px solid var(--cursor, var(--ink)); }
.cm-s-riso .CodeMirror-selected, .cm-s-riso.CodeMirror-focused .CodeMirror-selected { background: var(--sel, #FFE80080); }
.cm-s-riso .CodeMirror-line::selection, .cm-s-riso .CodeMirror-line > span::selection, .cm-s-riso .CodeMirror-line > span > span::selection { background: var(--sel, #FFE80080); }
.cm-s-riso .cm-keyword { font-weight: 700; color: var(--ink); }
.cm-s-riso .cm-builtin { color: #7A3E00; font-weight: 600; }
.cm-s-riso .cm-string { background: linear-gradient(transparent 55%, #FFE800aa 55%); color: var(--ink); }
.cm-s-riso .cm-number { text-decoration: underline dotted; text-underline-offset: 3px; }
.cm-s-riso .cm-comment { font-style: italic; color: var(--ink-soft); }
.cm-s-riso .cm-def { text-decoration: underline; text-decoration-thickness: 2px; }
.cm-s-riso .cm-variable-2, .cm-s-riso .cm-property { color: #174a6b; }
.cm-s-riso .cm-operator { color: var(--fail); font-weight: 700; }
.cm-s-riso .CodeMirror-matchingbracket { background: var(--accent); color: var(--ink) !important; outline: 1px solid var(--ink); }
.p1-editor { --cursor: var(--p1); --sel: #FF6C2F59; }
.p2-editor { --cursor: var(--p2); --sel: #0078BF4d; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .arena { grid-template-columns: 1fr; height: auto; }
  .editor-frame { min-height: 360px; }
  .prompt { max-height: none; }
}
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .poster__burst { width: 84px; height: 84px; font-size: 11px; right: 0; top: -34px; }
  .slots { grid-template-columns: 1fr; min-height: 0; gap: 10px; }
  .slots__vs { margin: -6px 0; font-size: 60px; }
  .slot--1, .slot--2 { clip-path: none; padding: 26px; }
  .vs__mid { min-width: 76px; }
  .vs__vs { font-size: 34px; }
  .vs__p { padding: 10px 14px; min-height: 64px; }
  .vs__meta { gap: 6px; flex-wrap: wrap; }
  .win__ko { position: static; display: inline-block; margin-top: 10px; }
  .stamp--big { font-size: 28px; }
  .vs__meta span:nth-child(3) { display: none; }
  .topbar__mid .label.soft { display: none; }
  .host-bar { top: auto; bottom: 12px; right: 12px; }
  .duel { grid-template-columns: 1fr; }
  .tabs { display: flex; gap: 8px; }
  .duel[data-tab="0"] .duel__side--2, .duel[data-tab="1"] .duel__side--1 { display: none; }
  .cheer-deck { grid-template-columns: 1fr; gap: 0; }
  .cheer-side { box-shadow: none; }
  .emoji-grid { grid-template-columns: repeat(3, 1fr); }
  .emoji-btn { font-size: 30px; padding: 14px 0; }
  .solutions { grid-template-columns: 1fr; }
  .fight-card { grid-template-columns: 70px 1fr; }
  .fight-card__actions { grid-column: 1 / -1; border-top: 2px dashed var(--ink); }
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .count-vs { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .12s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
  .floaty { animation: fadeHold 1.2s forwards !important; bottom: 20% !important; }
  .win__burst { animation: none !important; }
  @keyframes fadeHold { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
}

/* ---------- broadcast (1920×1080 projector) ---------- */
.bc { height: 100vh; display: grid; grid-template-rows: auto auto 1fr 44px 56px; overflow: hidden; }
/* slim strip above the ticker: shadow tag | crowd names | sound/music (nothing floats over the players) */
.bc__strip { display: flex; align-items: center; gap: 14px; padding: 0 18px; min-width: 0; position: relative; z-index: 30; }
.bc__strip .bc-roster, .bc__strip .sh-tag { position: static; flex: 0 1 auto; min-width: 0; max-width: none; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc__strip .bc-roster { flex: 1 1 0; }
/* sound/music sit over the strip's reserved right end (fixed, so they stay reachable on the intermission screen too) */
.bc-body #audio-controls { position: fixed; right: 12px; bottom: 63px; z-index: 50; }
.bc__strip { padding-right: 300px; }
.bc__strip .tape { transform: none; padding-top: 5px; padding-bottom: 5px; clip-path: none; }
.bc .vs__p { min-height: 120px; padding: 16px 40px; }
.bc .vs__name { font-size: clamp(34px, 3.4vw, 64px); }
.bc .vs__meta { font-size: 16px; }
.bc .vs__vs { font-size: 84px; }
.bc .vs__timer { font-size: 38px; }
.bc__prompt { display: flex; align-items: baseline; gap: 22px; padding: 10px 30px; border-bottom: var(--bw) solid var(--ink); background: var(--paper-hi); }
.bc__prompt h2 { font: 400 32px/1 var(--f-display); margin: 0; text-transform: uppercase; }
.bc__prompt .soft { font-size: 18px; }
.bc__stage { display: grid; grid-template-columns: 70px 1fr 1fr 70px; gap: 18px; padding: 18px; min-height: 0; }
.tower { display: flex; flex-direction: column-reverse; gap: 5px; padding: 5px; border: var(--bw) solid var(--ink); background: var(--paper-lo); position: relative; }
.tower__seg { flex: 1; border: 2px solid var(--ink); background: var(--paper-hi); transition: background .22s steps(4); }
.tower--1 .tower__seg.on { background: var(--p1); }
.tower--2 .tower__seg.on { background: var(--halftone-p2), var(--paper-hi); }
.bc__side { position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.bc__side .editor-frame { flex: 1; min-height: 0; border-width: 10px; }
.bc__side .CodeMirror { font-size: 20px; }
.bc__sidehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bc__sidehead .hype { flex: 1; max-width: 50%; height: 20px; }
.bc__lane { position: absolute; top: 0; bottom: 0; width: 260px; pointer-events: none; overflow: hidden; z-index: 20; }
.bc__lane--0 { left: 0; }
.bc__lane--1 { right: 0; }
.ticker { background: var(--ink); color: var(--accent); overflow: hidden; display: flex; align-items: center; border-top: var(--bw) solid var(--ink); position: relative; }
.ticker__label { background: var(--accent); color: var(--ink); height: 100%; display: grid; place-items: center; padding: 0 18px; font: 400 22px var(--f-display); z-index: 2; flex: none; }
.ticker__track { display: flex; gap: 60px; white-space: nowrap; padding-left: 100%; animation: marquee var(--dur, 30s) linear infinite; font: 700 22px var(--f-ui); }
.ticker__item .who1 { color: var(--p1); }
.ticker__item .who2 { color: #5fb8ff; }
@keyframes marquee { to { transform: translateX(-100%); } }
.bc__read { position: absolute; left: 50%; top: 150px; transform: translateX(-50%) rotate(-.6deg); width: min(1100px, 80vw); max-height: calc(100vh - 330px); overflow: auto; z-index: 22; }
.bc__read .prompt { font-size: 19px; padding: 22px 30px; }
.bc__read .prompt h1 { font-size: 46px; }
.bc__read .prompt p, .bc__read .prompt__story { font-size: 19px; }
.bc__read .io-pre { font-size: 17px; }
.bc__read .copy-btn { display: none; }
.bc__predict { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); width: 520px; z-index: 25; padding: 10px 14px; }
.bc-intermission { height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; padding: 50px 60px; align-items: center; }
.bc-intermission .poster__title { font-size: clamp(90px, 10vw, 190px); text-align: left; }
.qr { background: var(--paper-hi); padding: 16px; display: inline-block; }
.qr svg, .qr img { display: block; width: 240px; height: 240px; }
.join-url { font: 400 clamp(22px, 2.3vw, 40px)/1.1 var(--f-display); margin: 14px 0; white-space: nowrap; }
.bc-board .sheet td { padding: 8px 12px; font-size: 20px; }
.bc-live { margin-top: 20px; display: grid; gap: 10px; }
.bc-host { position: fixed; right: 16px; top: 16px; z-index: 80; padding: 12px; display: grid; gap: 8px; max-width: 360px; }
.bc-body .callout { top: 150px; font-size: 34px; }

/* ---------- hints, console, checks, crowd messages ---------- */
.hints { padding: 12px 14px; max-height: 42%; overflow: auto; flex: none; }
.hints__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.hint-item { border: 2px solid var(--ink); margin-top: 6px; background: var(--paper); }
.hint-item > button { all: unset; box-sizing: border-box; width: 100%; display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 7px 10px; cursor: pointer; font-weight: 700; font-size: 14px; }
.hint-item > button:hover { background: var(--accent); }
.hint-item > button:disabled { cursor: default; background: transparent; }
.hint-cost { font: 900 11px var(--f-ui); font-stretch: 110%; color: var(--fail); white-space: nowrap; }
.hint-item--open { background: var(--paper-hi); }
.hint-item__body { border-top: 2px dashed var(--ink); padding: 8px 10px; font-size: 14px; white-space: pre-wrap; }
.console { margin-top: 12px; border: var(--bw) solid var(--ink); background: var(--ink); color: var(--paper-hi); min-height: 110px; max-height: 190px; overflow: auto; padding: 8px 12px; }
.console .label { color: var(--accent); }
.console pre { margin: 4px 0 0; font: 400 13px/1.5 var(--f-code); white-space: pre-wrap; word-break: break-word; }
.console .err { color: #ffb4a6; }
.console .muted { color: #b5ab9c; }
.checks { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.checks li { display: flex; gap: 8px; align-items: baseline; }
.checks .ok { color: var(--pass); font-weight: 900; }
.checks .no { color: var(--fail); font-weight: 900; }
.fail-card { margin-top: 12px; border: 2px solid var(--ink); background: var(--hatch-fail), var(--paper-hi); padding: 10px; display: grid; gap: 8px; }
.solved-card { margin-top: 12px; padding: 12px; border: var(--bw) solid var(--ink); background: var(--pass); color: var(--paper-hi); font-weight: 800; }
.opp { padding: 12px; }
.crowd-box { padding: 12px; flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.crowd-msgs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; flex: 1; }
.crowd-msgs li { background: var(--paper); border: 2px solid var(--ink); padding: 5px 9px; font-size: 14px; animation: stamp .16s var(--ease-slam); transform: none; }
.crowd-msgs li b { margin-right: 4px; }
.pen { background: var(--fail); color: var(--paper-hi); padding: 0 6px; font-weight: 900; }
.deadline-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 45; padding: 10px 22px; font-size: 16px; box-shadow: var(--shadow); }
/* ---------- status strip + first-time how-to (room) ---------- */
.status-strip {
  --dot: var(--paper-lo);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 20px; min-height: 46px;
  background: var(--paper-hi);
  border-bottom: var(--bw) solid var(--ink);
  font-weight: 800; font-size: 15px;
}
.status-strip::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--ink); background: var(--dot); flex: none; }
.status-strip--read { --dot: var(--accent); }
.status-strip--go { --dot: var(--p1); }
.status-strip--live { --dot: var(--fail); }
.status-strip--live::before { animation: blink 1.2s steps(2) infinite; }
.status-strip--done { --dot: var(--pass); }
.status-strip__text { min-width: 0; }
.status-strip .num { font-size: 1.05em; }
.howto { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 20px; background: var(--accent); border-bottom: var(--bw) solid var(--ink); }
.howto ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 20px; flex: 1; flex-wrap: wrap; }
.howto li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; max-width: 320px; }
.howto__n { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; background: var(--ink); color: var(--accent); font: 400 13px/1 var(--f-display); transform: rotate(-4deg); }

/* ---------- lobby: rejoin banner + account ---------- */
.rejoin { display: flex; align-items: center; gap: 16px; padding: 12px 16px; margin-bottom: 26px; flex-wrap: wrap; }
.rejoin__code { font: 400 26px/1 var(--f-display); background: var(--accent); border: var(--bw) solid var(--ink); padding: 6px 10px; transform: rotate(-2deg); }
.rejoin__text { flex: 1; font-weight: 800; font-size: 17px; min-width: 200px; }
.rejoin--live { background: var(--hatch-fail), var(--paper-hi); }
.account { margin-top: 12px; border-top: 2px dashed var(--ink); padding-top: 10px; }
.account summary { cursor: pointer; }
.account .input { font-size: 15px; padding: 9px 11px; }

/* ---------- hint ladder ---------- */
.nudge { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border: 2px dashed var(--ink-soft); font-size: 13px; }
.nudge--on { border: 2px solid var(--ink); background: var(--paper-hi); animation: stamp .16s var(--ease-slam); transform: none; }
.nudge__body { font-weight: 700; font-size: 14px; margin-top: 2px; }
.free-tag { flex: none; font: 900 10px/1 var(--f-ui); letter-spacing: .1em; text-transform: uppercase; padding: 4px 6px; background: var(--pass); color: var(--paper-hi); border: 2px solid var(--ink); transform: rotate(-3deg); }
.hint-item__title { display: grid; gap: 1px; text-align: left; }
.hint-item__tier { font: 800 10px var(--f-ui); font-stretch: 70%; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.hint-item--locked { opacity: .55; border-style: dashed; }
.hint-item--armed { background: var(--paper-hi); box-shadow: var(--shadow-sm); }
.hint-item--armed > button { background: var(--accent); }
.hint-cost--paid { color: var(--ink-soft); }
.hint-cost--locked { color: var(--ink-soft); }
.hint-confirm { border-top: 2px dashed var(--ink); padding: 8px 10px; display: grid; gap: 6px; font-size: 14px; }
.hint-tally { margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--ink); font-size: 13px; font-weight: 700; }
.hint-tally b { font-size: 15px; }

/* ---------- checks ---------- */
.tests__count.ok { color: var(--pass); }
.tests__count.no { color: var(--fail); }
.checks .check { display: grid; grid-template-columns: 16px 26px 1fr; gap: 6px; align-items: baseline; }
.check__num { font: 800 11px var(--f-ui); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.check__text { min-width: 0; overflow-wrap: anywhere; }
.check__text code { white-space: pre-wrap; }
.check--first .check__text { font-weight: 800; }
.checks .check__detail { display: block; }
.checks-passed { margin-top: 10px; font-size: 14px; }
.checks-passed summary { cursor: pointer; font-weight: 900; list-style: none; display: inline-block; padding: 2px 8px; border: 2px solid var(--pass); }
.checks-passed summary::-webkit-details-marker { display: none; }
.checks-passed[open] summary { background: var(--pass); color: var(--paper-hi); }
.checks-passed[open] summary .ok { color: inherit; }
.checks-passed .checks { opacity: .8; }
.fail-card { margin-top: 6px; }
.fail-card__why { font-weight: 800; font-size: 14px; }
.diff2 { display: grid; border: 2px solid var(--ink); background: var(--paper-hi); font-size: 13px; }
.diff__row { display: grid; grid-template-columns: 22px 1fr 1fr; min-width: 0; }
.diff__row + .diff__row { border-top: 1px solid #1D1A1733; }
.diff__row > * { padding: 3px 6px; min-width: 0; }
.diff__row--head { background: var(--paper-lo); }
.diff__row--bad { background: var(--hatch-fail), var(--paper-hi); }
.diff__n { font: 800 11px var(--f-ui); color: var(--ink-soft); text-align: center; border-right: 1px dashed var(--ink); }
.diff__row--bad .diff__n { color: var(--fail); }
.diff__cell { font: 400 12.5px/1.5 var(--f-code); background: none; border: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff__cell + .diff__cell { border-left: 1px dashed var(--ink); }
.diff__mark { background: var(--accent); outline: 1.5px solid var(--ink); font-weight: 700; }
.diff__missing { color: var(--fail); font-style: italic; font-family: var(--f-ui); font-weight: 700; }
.diff__caret { color: var(--fail); font-weight: 900; }

/* ---------- crowd messages on the player's screen ---------- */
.unread { display: inline-block; padding: 1px 6px; background: var(--fail); color: var(--paper-hi); letter-spacing: .06em; transform: rotate(-3deg); animation: stamp .16s var(--ease-slam); }
.crowd-msgs li.fresh { background: var(--accent); }
.crowd-box--flash { animation: crowdFlash .9s steps(3); }
@keyframes crowdFlash { 0%, 66% { box-shadow: 6px 6px 0 var(--p1); border-color: var(--p1); } }

.bc__qr { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bc__qr .qr { padding: 6px; }
.bc__qr .qr svg { width: 84px; height: 84px; }
.bc__prompt { align-items: center; }

/* ---------- languages: settings chip, new-room picker, last-run-output strip ---------- */
.lang-chip { display: inline-flex; vertical-align: middle; border: 2px solid var(--ink); font: 800 11px/1 var(--f-ui); font-stretch: 80%; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; margin-right: 8px; }
.lang-chip > b { background: var(--ink); color: var(--paper-hi); padding: 3px 6px; font-weight: 900; }
.lang-chip > span { background: var(--paper-hi); color: var(--ink); padding: 3px 6px; }
.lang-chip[data-diff="easy"] > span { background: var(--pass); color: var(--paper-hi); }
.lang-chip[data-diff="medium"] > span { background: var(--accent); }
.lang-chip[data-diff="hard"] > span { background: var(--fail); color: var(--paper-hi); }
.lang-chip > span.lang-chip__items { background: var(--p1); color: var(--ink); border-left: 2px solid var(--ink); }
.lang-chip--lg { font-size: 16px; border-width: var(--bw); }
.lang-chip--lg > b, .lang-chip--lg > span { padding: 6px 10px; }
.topbar__mid .lang-chip { margin: 0; }
.records-lang { margin-top: 28px; }
.records-lang__head { display: flex; align-items: center; gap: 12px; margin: 0; }
.records-lang .records { margin-top: 12px; }

.picker { display: grid; gap: 6px; }
.seg { display: flex; border: var(--bw) solid var(--ink); background: var(--paper); }
.seg button { all: unset; box-sizing: border-box; flex: 1; text-align: center; cursor: pointer; padding: 7px 4px; font: 900 12px/1.1 var(--f-ui); font-stretch: 105%; letter-spacing: .06em; text-transform: uppercase; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button:hover:not(:disabled) { background: var(--accent); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--accent); }
.seg button:disabled { cursor: not-allowed; color: var(--ink-soft); background: repeating-linear-gradient(45deg, #1D1A1712 0 3px, transparent 3px 7px); }
.seg button small { display: block; font: 700 9px/1 var(--f-ui); letter-spacing: .08em; margin-top: 2px; }
.seg--sm button { padding: 5px 4px; font-size: 11px; }

.run-out { background: var(--ink); color: var(--paper-hi); border: var(--bw) solid var(--ink); border-left: 8px solid var(--p1); flex: none; min-width: 0; }
.run-out--p2 { border-left-color: var(--p2); }
.run-out__head { display: flex; justify-content: space-between; gap: 8px; padding: 4px 10px 0; font: 800 11px var(--f-ui); font-stretch: 80%; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.run-out--p1 .run-out__head { color: var(--p1); }
.run-out--p2 .run-out__head { color: #5fb8ff; }
.run-out__tag { color: var(--paper-hi); }
.run-out--compile .run-out__tag, .run-out--error .run-out__tag, .run-out--timeout .run-out__tag { background: var(--fail); padding: 0 6px; }
.run-out__body { margin: 0; padding: 4px 10px 8px; font: 400 13px/1.45 var(--f-code); white-space: pre-wrap; word-break: break-word; max-height: 8.9em; overflow: hidden; }
.run-out__body--muted, .run-out__muted { color: #b5ab9c; }
.run-out__err { color: #ffb4a6; }
.bc__side .run-out__head { font-size: 15px; padding: 6px 14px 0; }
.bc__side .run-out__body { font-size: 18px; max-height: 7.4em; padding: 4px 14px 10px; }

/* C / Java tokens from the clike mode */
.cm-s-riso .cm-type, .cm-s-riso .cm-variable-3 { color: #174a6b; font-weight: 600; }
.cm-s-riso .cm-meta { color: #7A3E00; }

/* ---- head-to-head "tale of the tape" ---- */
.h2h { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin: 12px auto; padding: 6px 14px;
  background: var(--paper-hi); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%;
  transform: rotate(-.6deg); font: 800 14px var(--f-ui); font-stretch: 75%; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.h2h__tag { background: var(--ink); color: var(--accent); padding: 2px 8px; font-size: 11px; letter-spacing: .12em; }
.h2h__side { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.h2h__side b { font-weight: 800; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h2h__side--p1 b { color: var(--p1); }
.h2h__side--p2 b { color: var(--p2); }
.h2h__side i { font: 400 28px/1 var(--f-display); font-style: normal; font-variant-numeric: tabular-nums; }
.h2h__side i.lead { text-shadow: 2px 2px 0 var(--accent); }
.h2h__dash { font: 400 24px/1 var(--f-display); color: var(--ink-soft); }
.h2h__draws, .h2h__first { color: var(--ink-soft); }
.h2h--big { font-size: 22px; padding: 10px 22px; }
.h2h--big .h2h__tag { font-size: 16px; }
.h2h--big .h2h__side i { font-size: 48px; }
.slots__h2h { grid-column: 1 / -1; }
.vs__h2h { font: 900 13px var(--f-ui); font-stretch: 110%; text-align: center; margin-top: 2px; letter-spacing: .06em; }
.plink { color: inherit; text-decoration: none; border-bottom: 2px solid var(--accent); }
.plink:hover { background: var(--accent); }
/* ---- player profile ---- */
.profile { max-width: 900px; margin: 0 auto; padding: 32px 16px 80px; }
.profile h1 { font: 400 clamp(40px, 9vw, 88px)/.9 var(--f-display); margin: 0 0 10px; text-transform: uppercase; overflow-wrap: anywhere; }
.profile__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 22px 0 8px; }
.profile__stat { background: var(--paper-hi); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm); padding: 10px 12px; }
.profile__stat .v { font: 400 34px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.profile h2 { font: 400 clamp(28px, 6vw, 40px)/1 var(--f-display); margin: 40px 0 12px; text-transform: uppercase; }
.rival { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; background: var(--paper-hi); border: var(--bw) solid var(--ink); margin-bottom: 10px; }
.rival__name { font: 800 20px var(--f-ui); overflow-wrap: anywhere; }
.rival__rec { font: 400 28px/1 var(--f-display); font-variant-numeric: tabular-nums; text-align: right; }
.rival__bar { grid-column: 1 / -1; display: flex; height: 10px; border: 2px solid var(--ink); background: var(--paper-lo); }
.rival__bar .w { background: var(--pass); } .rival__bar .d { background: var(--ink-soft); } .rival__bar .l { background: var(--fail); }

/* base-language-only warning under run output */
.lang-note { margin-top: 8px; padding: 6px 10px; border: 2px dashed currentColor; font-size: 14px; font-weight: 600; }
/* Spectator code view: cursor line of the player being watched + follow indicator */
.cm-s-riso .cc-follow-line { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.follow-badge { position: absolute; right: 10px; bottom: 8px; z-index: 6; font: 700 11px/1 var(--f-code); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 8px; background: var(--ink); color: var(--paper-hi); border: 0; cursor: pointer; opacity: .85; }
.follow-badge[hidden] { display: none; }
/* ---------- home: log in / create account card ---------- */
.authcard { position: relative; }
.authcard__tape { position: absolute; right: 14px; top: -12px; transform: rotate(3deg); }
.authcard[data-mode="signup"] h2 { font-size: 34px; }
.authcard [hidden] { display: none !important; }
.authcard__hint { font-size: 12px; margin-top: -6px; }
.authcard__rules { margin: 0; padding-left: 20px; font-size: 14px; display: grid; gap: 2px; }
.authcard .btn--go { width: 100%; }
.authcard__switch { margin: 4px 0 0; text-align: center; font-weight: 700; }
.linkbtn { font: inherit; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; color: var(--ink); background: var(--accent);
  border: 0; border-bottom: var(--bw) solid var(--ink); padding: 2px 6px; cursor: pointer; }
.linkbtn:hover { background: #fff36b; }
.linkbtn:focus-visible { outline: 3px solid var(--p1, var(--ink)); outline-offset: 2px; }
.follow-badge:hover, .follow-badge:focus-visible { opacity: 1; background: var(--p1, var(--ink)); }
/* ---------- post-match code review + exits ---------- */
.win__home { font-size: 18px; padding: 12px 22px; }
.review { display: grid; gap: 10px; }
.review__title { display: flex; align-items: baseline; gap: 12px; font-size: 20px; }
.review__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.review__grid--3 { grid-template-columns: repeat(3, 1fr); }
.review__pane { border: var(--bw) solid var(--ink); background: var(--paper-hi); box-shadow: var(--shadow-sm); min-width: 0; }
.review__pane--dim .review__frame { filter: grayscale(.8); opacity: .92; }
.review__pane--scratch { outline: 3px dashed var(--accent); outline-offset: 3px; }
.review__head { gap: 10px; flex-wrap: wrap; justify-content: flex-start; }
.review__head--p1 { background: var(--p1); }
.review__head--p2 { background: var(--halftone-p2), var(--p2); color: var(--paper-hi); }
.review__name { font-size: 20px; margin-right: auto; }
.review__crown { font: 700 12px/1 var(--f-display, inherit); letter-spacing: .12em; padding: 4px 8px; background: var(--paper-hi); color: var(--ink); border: 2px solid var(--ink); transform: rotate(-3deg); }
.review__frame .CodeMirror { height: auto; max-height: 360px; }
.review__frame .CodeMirror-scroll { max-height: 360px; }
.review__bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: var(--bw) solid var(--ink); flex-wrap: wrap; }
.review__note { font-size: 12px; }
@media (max-width: 760px) {
  .review__grid, .review__grid--3 { grid-template-columns: 1fr; }
  .win__home { width: 100%; text-align: center; }
  .review__frame .CodeMirror, .review__frame .CodeMirror-scroll { max-height: 280px; }
}
/* ---------- spectator roster (who's in the crowd) ---------- */
.roster { display: flex; flex-wrap: wrap; gap: 6px; }
.rchip { padding: 2px 9px; background: var(--paper-hi); border: 2px solid var(--ink); font-weight: 800; font-size: 13px; color: var(--ink); text-decoration: none; }
a.rchip:hover { background: var(--accent, #FFD23F); }
.rchip--p1 { box-shadow: 3px 0 0 var(--p1); }
.rchip--p2 { box-shadow: 3px 0 0 var(--p2); }
.rchip--more { border-style: dashed; font-weight: 700; }
.roster-btn { font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); background: none; border: 0; border-bottom: 2px dashed var(--ink-soft); padding: 0; cursor: pointer; }
.roster-btn:hover, .roster-btn[aria-expanded="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.roster-pop { position: absolute; top: calc(100% + 6px); left: 20px; z-index: 40; width: min(420px, calc(100vw - 28px)); max-height: 50vh; overflow: auto;
  background: var(--paper); border: var(--bw) solid var(--ink); box-shadow: var(--shadow-sm); padding: 10px 12px; }
.roster-pop__head { font: 400 18px var(--f-display); text-transform: uppercase; margin-bottom: 8px; }
.roster-pop[hidden] { display: none; }
.bc-roster { position: fixed; right: 14px; bottom: 96px; z-index: 30; max-width: min(46vw, 760px); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-roster .s1 { color: #ff9a6b; } .bc-roster .s2 { color: #7cc4ff; }

/* ---------- phones: compact room topbar, nothing pushes past the viewport ---------- */
@media (max-width: 600px) {
  .topbar { gap: 8px 10px; padding: 8px 12px; }
  .logo { font-size: 22px; }
  .topbar__right { order: 2; margin-left: auto; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
  .topbar__mid { order: 3; flex: 1 1 100%; flex-wrap: wrap; gap: 8px 10px; }
  .who { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .roster-btn { white-space: nowrap; }
  .share code { display: block; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
  .share .btn { flex: none; }
  .host-bar { max-width: calc(100vw - 24px); }
  .host-bar .btn { white-space: nowrap; }
}
@media (max-width: 600px) {
  .win__name { font-size: clamp(34px, 10.5vw, 56px); word-break: normal; overflow-wrap: anywhere; }
  .win__stats { flex-wrap: wrap; }
}
/* phones: tables scroll sideways inside their own box instead of widening the page */
@media (max-width: 600px) {
  .standings { padding: 28px 12px 60px; }
  table.sheet { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sheet th, .sheet td { padding: 8px 8px; white-space: nowrap; }
  .sheet .rank { width: auto; font-size: 18px; }
  .sheet .name { font-size: 16px; }
  .sheet .elo { font-size: 18px; }
}
@media (max-width: 600px) {
  .sheet td.name { white-space: normal; min-width: 130px; max-width: 190px; }
  .sheet td.name .titles { display: flex; margin: 4px 0 0; }
}

/* ---------- roomend: win-screen rematch countdown + tinker panel ---------- */
.win__rematch { position: relative; overflow: hidden; font-size: 20px; padding: 14px 30px; min-width: 240px; }
.win__rematch-fill { position: absolute; left: 0; bottom: 0; height: 6px; width: 100%; background: var(--ink); transform-origin: left; animation: rematch-drain linear forwards; }
.win__rematch-text { position: relative; }
.win__rematch .num { display: inline-block; min-width: 2ch; }
@keyframes rematch-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.overlay--tinker { background: rgba(20, 18, 28, .72); padding: 16px; }
.tinker { width: min(900px, 96vw); background: var(--paper-hi); display: grid; gap: 0; }
.tinker__head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: var(--bw) solid var(--ink); font-size: 22px; }
.tinker__head .btn { margin-left: auto; }
.tinker__frame .CodeMirror { height: auto; min-height: 160px; max-height: 50vh; }
.tinker__frame .CodeMirror-scroll { max-height: 50vh; }
.tinker__bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-top: var(--bw) solid var(--ink); }
.tinker__note { font-size: 12px; }
.tinker__results { padding: 10px 14px; border-top: var(--bw) solid var(--ink); max-height: 32vh; overflow: auto; }
@media (max-width: 700px) { .win__rematch { width: 100%; min-width: 0; } .win__actions .btn { flex: 1 1 100%; } }
/* small text-style action (e.g. win screen "or tinker with your code") */
.textlink { font: inherit; font-weight: 800; font-size: 14px; background: none; border: 0; padding: 4px 2px; color: var(--ink);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.textlink:hover { background: var(--accent); }
