/* Lineup: fight night. Arena-dark ground, a red corner and a blue corner that own whole
   regions, championship gold only for the titles at the end. Spacing on an 8px grid. */

:root {
  --ground: #121318;
  --raised: #1b1d24;
  --line: #2e313c;
  --text: #f4f2ee;
  --muted: #a9acb9;
  --red: #d7261f;
  --blue: #2457e0;
  --gold: #f0bd45;
  --gold-ink: #2a1f05;
  --display: "Archivo", system-ui, sans-serif;
  --u: 8px;
  --r: 4px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 17px/1.45 var(--display);
  font-stretch: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
::selection { background: var(--text); color: var(--ground); }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
button, input { font: inherit; color: inherit; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--u) * 2) calc(var(--u) * 2) calc(var(--u) * 16);
  padding-top: max(calc(var(--u) * 2), env(safe-area-inset-top));
}

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- condensed caps: the fight-poster voice ---------- */

.wordmark, .room-code, .bout-q, .corner-name, .vs, .verdict h3, .champ h2, .paranoia-title,
.btn, .group h2, .section, .belt-who, .coin-face, .corner-count, .told-secret {
  font-stretch: 62%;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

/* ---------- buttons, fields, toggles ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--u);
  width: 100%; min-height: 56px; padding: 0 calc(var(--u) * 3);
  border: 0; border-radius: var(--r);
  background: var(--text); color: var(--ground);
  font-size: 22px; font-weight: 850; cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { background: var(--raised); color: var(--muted); cursor: default; transform: none; }
.btn.plain { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn.plain:hover { box-shadow: inset 0 0 0 2px var(--muted); }
.btn.small { width: auto; min-height: 44px; font-size: 17px; padding: 0 calc(var(--u) * 2); }
.btn.leave { color: var(--text); box-shadow: inset 0 0 0 2px var(--muted); }

.link {
  background: none; border: 0; padding: var(--u) 0; min-height: 44px;
  color: var(--muted); text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}
.link:hover { color: var(--text); }

.field {
  width: 100%; min-height: 56px; padding: 0 calc(var(--u) * 2);
  border: 2px solid var(--line); border-radius: var(--r);
  background: var(--raised); color: var(--text); font-size: 19px;
  caret-color: var(--text);
}
.field::placeholder { color: #8d90a0; }
.field:focus { outline: none; border-color: var(--text); }
.field.code { width: 128px; flex: none; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 800; text-align: center; }

.choice { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; background: var(--line); border-radius: var(--r); padding: 2px; }
.choice button {
  min-height: 48px; border: 0; border-radius: 2px; background: var(--ground); color: var(--muted);
  font-weight: 700; cursor: pointer;
}
.choice button[aria-pressed="true"] { background: var(--text); color: var(--ground); }
.choice button:disabled { cursor: default; }

.stepper { display: flex; align-items: center; gap: calc(var(--u) * 2); }
.stepper button {
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 2px solid var(--line); border-radius: var(--r); background: transparent; cursor: pointer;
}
.stepper .value { font-size: 32px; font-weight: 850; font-stretch: 62%; min-width: 2ch; text-align: center; }

.hint { color: var(--muted); font-size: 15px; margin-top: var(--u); }

/* ---------- home ---------- */

.home { display: flex; flex-direction: column; gap: calc(var(--u) * 2); padding-top: calc(var(--u) * 4); }
.marquee { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; height: 16px; margin-bottom: var(--u); }
.marquee .red { height: 100%; background: var(--red); }
.marquee .blue { height: 100%; background: var(--blue); }
.marquee-vs { position: absolute; left: 50%; top: 50%; translate: -50% -50%; padding: 0 var(--u); background: var(--ground); font-size: 18px; font-weight: 900; color: var(--muted); }
.wordmark { font-size: 96px; line-height: 0.85; font-weight: 900; letter-spacing: -0.02em; }
.lede { font-size: 19px; color: var(--muted); max-width: 32ch; margin-bottom: calc(var(--u) * 2); }
.join { margin-top: calc(var(--u) * 3); padding-top: calc(var(--u) * 3); border-top: 1px solid var(--line); display: grid; gap: calc(var(--u) * 2); }
.label { color: var(--muted); font-size: 15px; }
.row { display: flex; gap: var(--u); }
.row .btn { flex: 1; }

.photo-pick {
  display: flex; align-items: center; gap: calc(var(--u) * 2); text-align: left;
  padding: calc(var(--u) * 2); border: 2px dashed var(--line); border-radius: var(--r);
  background: transparent; cursor: pointer;
}
.photo-pick b { display: block; font-weight: 700; }
.photo-pick small { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; }
.photo-pick .face.m { color: var(--muted); }
.photo-pick .face.has { border-color: var(--text); }

/* ---------- faces ---------- */

.face {
  position: relative; flex: none; display: inline-grid; place-items: center; overflow: hidden;
  width: 36px; height: 36px; border-radius: 2px;
  background: var(--raised); box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 800; font-size: 13px; font-stretch: 62%; color: var(--muted);
}
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face.xs { width: 32px; height: 32px; font-size: 12px; }
.face.m { width: 56px; height: 56px; font-size: 18px; }
.face.l { width: 88px; height: 88px; font-size: 28px; }
.face.xl { width: 128px; height: 128px; font-size: 40px; }
.face.off { opacity: 0.4; }

/* ---------- lobby ---------- */

.lobby { display: flex; flex-direction: column; }
.code-block { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 2); }
.room-code { font-size: 88px; line-height: 0.9; font-weight: 900; letter-spacing: 0.04em; }
.code-help { color: var(--muted); margin-top: var(--u); }
.group { margin-top: calc(var(--u) * 5); }
.group h2, .section { font-size: 22px; font-weight: 850; margin-bottom: calc(var(--u) * 2); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; }
.group-head .hint { margin: 0; }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--u); }
.fighter { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 2px; background: var(--raised); }
.fighter img { width: 100%; height: 100%; object-fit: cover; }
.fighter-initials { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; font-weight: 900; font-stretch: 62%; color: var(--muted); }
.fighter-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: var(--u);
  background: var(--ground);
  font-weight: 800; font-stretch: 62%; text-transform: uppercase; font-size: 17px; line-height: 1.05;
  overflow-wrap: anywhere;
}
.tag {
  position: absolute; top: var(--u); left: var(--u); padding: 0 var(--u); border-radius: 2px;
  background: var(--ground); color: var(--muted); font-size: 12px; font-weight: 700;
}
.lobby-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--u); margin-top: calc(var(--u) * 2); }

.decks { display: grid; gap: 2px; background: var(--line); border-radius: var(--r); overflow: hidden; }
.group .decks { margin-top: var(--u); }
.deck {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: calc(var(--u) * 2);
  min-height: 56px; padding: var(--u) calc(var(--u) * 2);
  border: 0; background: var(--ground); text-align: left; cursor: pointer;
}
.deck:disabled { cursor: default; }
.tick { width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 2px; }
.deck[aria-pressed="true"] .tick { background: var(--text); border-color: var(--text); color: var(--ground); }
.deck[aria-pressed="false"] .deck-name { color: var(--muted); }
.deck-name { display: flex; align-items: center; gap: var(--u); font-weight: 700; }
.deck-count { color: var(--muted); font-size: 15px; }
.adult { padding: 0 4px; border-radius: 2px; box-shadow: inset 0 0 0 2px var(--text); color: var(--text); font-size: 12px; font-weight: 800; }

.switch-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 2);
  padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
}
.switch-row:disabled { cursor: default; }
.switch-row b { display: block; font-size: 22px; font-weight: 850; font-stretch: 62%; text-transform: uppercase; }
.switch-row small { display: block; color: var(--muted); font-size: 15px; line-height: 1.4; margin-top: 4px; }
.switch { flex: none; width: 56px; height: 32px; border-radius: 16px; background: var(--line); position: relative; transition: background-color 0.2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform 0.25s var(--ease), background-color 0.2s; }
.switch-row[aria-checked="true"] .switch { background: var(--text); }
.switch-row[aria-checked="true"] .switch::after { transform: translateX(24px); background: var(--ground); }
.leave-link { align-self: flex-start; margin-top: calc(var(--u) * 4); }

/* ---------- action bar (thumb zone) ---------- */

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: calc(var(--u) * 2) calc(var(--u) * 2) max(calc(var(--u) * 2), env(safe-area-inset-bottom));
  background: var(--ground); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.actionbar > * { width: 100%; max-width: 448px; }
.actionbar .link { width: auto; }
.waiting { color: var(--muted); text-align: center; padding: var(--u) 0; }

/* ---------- game: top bar ---------- */

.topbar { margin: calc(var(--u) * -1) 0 calc(var(--u) * 2); }
.topbar-line { display: flex; align-items: center; justify-content: space-between; gap: var(--u); }
.guide { display: flex; align-items: baseline; gap: var(--u); flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.guide strong { color: var(--text); font-weight: 800; }
.guide-deck::before { content: "·"; margin-right: var(--u); }
.menu-btn { min-height: 44px; padding: 0 calc(var(--u) * 2); border: 2px solid var(--line); border-radius: var(--r); background: none; cursor: pointer; font-weight: 700; font-size: 15px; }
.scores { display: flex; flex-wrap: wrap; gap: var(--u); padding: var(--u) 0 2px; }
.score { position: relative; display: flex; align-items: center; gap: var(--u); padding: 2px var(--u) 2px 2px; border-radius: 2px; background: var(--raised); flex: none; }
.score .pts { font-weight: 850; font-stretch: 62%; font-size: 19px; }
.score .mark { position: absolute; left: 2px; right: 2px; bottom: -4px; height: 3px; background: var(--line); }
.score.done .mark { background: var(--text); }
/* points won this round stay lit in the score bar until the next round */
.score.gained { background: var(--text); color: var(--ground); }

/* ---------- the bout ---------- */

.bout { margin-bottom: calc(var(--u) * 2); }
.bout-lead { color: var(--muted); }
.bout-q { font-weight: 900; line-height: 0.92; margin-top: 4px; overflow-wrap: anywhere; hyphens: auto; }
.bout-q.xl { font-size: 60px; }
.bout-q.l { font-size: 48px; }
.bout-q.m { font-size: 38px; }
.bout-q.s { font-size: 30px; line-height: 0.98; }

.ring {
  --a: 50; --b: 50;
  position: relative; display: grid; gap: 4px;
  grid-template-columns: var(--cols, 1fr 1fr);
  transition: grid-template-columns 1.1s var(--ease);
}
.corner {
  position: relative; display: block; overflow: hidden; min-width: 0;
  height: 100%; min-height: 220px; width: 100%; padding: 0; border: 0; border-radius: 2px;
  color: #fff; text-align: left; cursor: pointer;
  transition: opacity 0.25s, transform 0.15s var(--ease), filter 0.25s;
}
.ring.result .corner { height: calc(var(--u) * 36); cursor: default; }
/* the vote screen fills the phone: corners take whatever height the question leaves */
.game.voting { display: flex; flex-direction: column; min-height: 520px; }
.game.voting .ring { flex: 1 1 auto; min-height: 0; max-height: 520px; }
.corner.red { background: var(--red); }
.corner.blue { background: var(--blue); }
.corner-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.corner-initials { position: absolute; inset: 0 0 56px; display: grid; place-items: center; font-size: 96px; font-weight: 900; font-stretch: 62%; color: rgb(255 255 255 / 0.35); }
.corner-band {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--u);
  padding: calc(var(--u) * 2);
}
.corner.red .corner-band { background: var(--red); }
.corner.blue .corner-band { background: var(--blue); }
.corner-name { font-size: 30px; font-weight: 900; line-height: 0.9; overflow-wrap: break-word; hyphens: auto; min-width: 0; }
.corner-name.long { font-size: 23px; }
.corner-count { font-size: 44px; font-weight: 900; line-height: 0.8; }
.corner:active { transform: scale(0.985); }
.ring.decided .corner[aria-pressed="false"] { opacity: 0.45; filter: saturate(0.4); }
.pick-frame { position: absolute; inset: 0; z-index: 3; box-shadow: inset 0 0 0 6px #fff; pointer-events: none; }
.pick-tag {
  position: absolute; top: var(--u); left: var(--u); z-index: 4; padding: 4px var(--u); border-radius: 0 0 2px 0;
  background: #fff; color: var(--ground); font-size: 16px; font-weight: 900; font-stretch: 62%; text-transform: uppercase;
}
.vs {
  position: absolute; left: calc(var(--a) * 1%); top: 38%; translate: -50% -50%; z-index: 5;
  min-width: 48px; height: 48px; padding: 0 8px; display: grid; place-items: center; border-radius: 24px;
  background: var(--ground); color: var(--text); font-size: 22px; font-weight: 900;
  transition: left 1.1s var(--ease);
}
.vs:empty { display: none; }
.ring.result .corner.lost .corner-name { font-size: 20px; }
.ring.result .corner.sliver .corner-name { display: none; }
.ring.result .corner.sliver .corner-band { justify-content: center; padding-inline: 0; }
.ring.result .corner.lost img, .ring.result .corner.lost .corner-initials { filter: grayscale(1) brightness(0.7); }

.verdict { margin-top: calc(var(--u) * 3); }
.verdict h3 { font-size: 40px; font-weight: 900; line-height: 0.95; }
.verdict p { color: var(--muted); margin-top: var(--u); font-size: 18px; }

.backers { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 2); margin-top: calc(var(--u) * 3); }
.backer-head { font-size: 14px; font-weight: 800; text-transform: uppercase; padding-bottom: var(--u); margin-bottom: var(--u); border-bottom: 3px solid; }
.backer.red .backer-head { border-color: var(--red); }
.backer.blue .backer-head { border-color: var(--blue); }
.backer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--u); }
.backer li { display: flex; align-items: center; gap: var(--u); min-width: 0; }
.backer li span:not(.face):not(.gain) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gain { margin-left: auto; font-weight: 850; font-size: 15px; color: var(--text); }
.nobody { color: var(--muted); }

/* ---------- paranoia ---------- */

.whisper { padding: calc(var(--u) * 3) 0 calc(var(--u) * 2); border-top: 3px solid var(--text); }
.whisper-lead { color: var(--muted); font-weight: 700; margin-bottom: var(--u); }
.waiting-room { display: grid; justify-items: start; gap: calc(var(--u) * 2); }
.waiting-room p { color: var(--muted); font-size: 18px; }
.paranoia-title { font-size: 44px; font-weight: 900; line-height: 0.92; }
.pick-help { color: var(--muted); margin: var(--u) 0 calc(var(--u) * 2); }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--u); }
.pick {
  display: flex; align-items: center; gap: calc(var(--u) * 2); min-height: 72px; padding: var(--u);
  border: 2px solid var(--line); border-radius: var(--r); background: var(--raised); text-align: left;
  font-weight: 800; font-stretch: 62%; font-size: 20px; text-transform: uppercase; cursor: pointer; min-width: 0;
}
.pick span:last-child { overflow-wrap: anywhere; line-height: 1; }
.pick:hover { border-color: var(--muted); }
.pick:active { background: var(--text); color: var(--ground); }

.named { display: grid; justify-items: center; text-align: center; gap: calc(var(--u) * 2); padding-top: var(--u); }
.named-lead { color: var(--muted); font-weight: 700; }
.named .face.xl { box-shadow: inset 0 0 0 1px var(--line); }

.coin {
  position: relative; width: 132px; height: 132px; margin: calc(var(--u) * 4) auto calc(var(--u) * 2);
  transform-style: preserve-3d; perspective: 600px;
}
.coin-face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  backface-visibility: hidden; font-size: 30px; font-weight: 900;
  border: 3px solid var(--line);
}
.coin-face.heads { background: var(--text); color: var(--ground); }
.coin-face.tails { background: #3a3d4a; color: var(--text); transform: rotateY(180deg); }
.coin.tails { transform: rotateY(180deg); }
.coin.spin.heads { animation: flip-heads 1.6s var(--ease) both; }
.coin.spin.tails { animation: flip-tails 1.6s var(--ease) both; }
@keyframes flip-heads { from { transform: rotateY(0) translateY(0); } 40% { transform: rotateY(900deg) translateY(-56px); } to { transform: rotateY(1800deg) translateY(0); } }
@keyframes flip-tails { from { transform: rotateY(0) translateY(0); } 40% { transform: rotateY(900deg) translateY(-56px); } to { transform: rotateY(1980deg) translateY(0); } }
.coin-help { color: var(--muted); text-align: center; max-width: 30ch; margin: 0 auto; }
.told { text-align: center; }
.told.delayed { animation: arrive 0.5s var(--ease) 1.5s both; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } }
.told-lead { color: var(--muted); font-weight: 700; margin-bottom: var(--u); }
.told-secret { font-size: 34px; font-weight: 900; line-height: 0.95; }

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

.champ { display: grid; justify-items: start; gap: calc(var(--u) * 2); padding-top: var(--u); }
.champ-faces { display: flex; gap: var(--u); }
.champ-faces .face { box-shadow: inset 0 0 0 4px var(--gold); }
.champ h2 { font-size: 48px; font-weight: 900; line-height: 0.92; }
.champ p { color: var(--muted); }
.section { margin-top: calc(var(--u) * 5); }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.standings li { display: flex; align-items: center; gap: calc(var(--u) * 2); padding: var(--u) 0; border-bottom: 1px solid var(--line); }
.standings .who { flex: 1; font-weight: 700; }
.standings .pts { font-size: 26px; font-weight: 900; font-stretch: 62%; }
.belts { display: grid; gap: calc(var(--u) * 2); margin-top: calc(var(--u) * 2); }
.belt { display: flex; align-items: stretch; border-radius: var(--r); overflow: hidden; background: var(--gold); color: var(--gold-ink); }
.belt .face.m { width: 88px; height: auto; min-height: 88px; border-radius: 0; box-shadow: none; }
.belt-plate { display: grid; gap: 2px; padding: calc(var(--u) * 2) calc(var(--u) * 2); min-width: 0; }
.belt-who { font-size: 24px; font-weight: 900; line-height: 1; }
.belt-title { font-weight: 700; line-height: 1.25; }
.belt-share { font-size: 14px; font-weight: 600; }

/* ---------- menu, toast, status ---------- */

.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: calc(var(--u) * 3) calc(var(--u) * 2) max(calc(var(--u) * 3), env(safe-area-inset-bottom));
  border: 0; border-radius: var(--r) var(--r) 0 0; background: var(--raised); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }
.sheet .stack { display: grid; gap: var(--u); }
.sheet .link { justify-self: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--u) * 13); z-index: 20; translate: -50% 16px;
  max-width: calc(100% - 32px); padding: calc(var(--u) * 2) calc(var(--u) * 2); border-radius: var(--r);
  background: var(--text); color: var(--ground); font-weight: 700; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, translate 0.3s var(--ease);
}

#toast.show { opacity: 1; translate: -50% 0; }
.connecting { color: var(--muted); text-align: center; padding-top: 30vh; }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding: var(--u); text-align: center; background: var(--text); color: var(--ground); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-delay: 0ms !important; }
}
