/* Pixel stadium: night-time 8-bit football. Midnight navy, field green, one floodlight
   yellow. Thin outlined boxes with notched pixel corners, pixel type, no glow. */
:root {
  --night: #070e24;
  --navy: #0e1b3e;
  --navy-2: #142550;
  --line: #7fd08a;        /* mint outline for buttons and the main boxes */
  --line-dim: #2d4a7c;    /* quiet outline for inputs and rows */
  --yellow: #ffd23f;
  --field: #2f7a3a;
  --field-2: #2a6e34;
  --chalk: #eef3e6;
  --muted: #9fb2d0;
  --red: #ff5f5f;
  --red-text: #ff9090;
  --green: #6fd18a;
  --t0: #c9d1df;   /* Common */
  --t1: #5fe08a;   /* Uncommon */
  --t2: #5ab8ff;   /* Rare */
  --t3: #c58bff;   /* Epic */
  --t4: #ffb84a;   /* Legendary */
  --title: "Press Start 2P", monospace;
  --label: "Silkscreen", monospace;
  --body: "VT323", monospace;
  --arena: min(92vw, 470px);
  --n: 4px;   /* size of the notch cut from each corner */
}

* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::placeholder { color: var(--muted); opacity: 1; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--night);
  color: var(--chalk);
  font: 21px/1.25 var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: none;
}
main { position: relative; max-width: 720px; margin: 0 auto; padding: 20px 16px 56px; }
.screen { display: flex; flex-direction: column; align-items: center; gap: 18px; }

/* Notched corners: the one shape every box and button shares. */
.panel, .btn, input, select, .chip, .mode, .tcard, .scorebug, .rule, .player-list li,
.log li, .standings li, .leaders li, .career div, .profile-code[open], .badge, .settings-summary {
  clip-path: polygon(var(--n) 0, calc(100% - var(--n)) 0, 100% var(--n), 100% calc(100% - var(--n)),
    calc(100% - var(--n)) 100%, var(--n) 100%, 0 calc(100% - var(--n)), 0 var(--n));
}

h2 { margin: 0 0 8px; font: 700 18px/1.2 var(--label); letter-spacing: .04em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 18px; margin: 0; }
.center-text { text-align: center; margin: 0; }

/* ---------- home ---------- */
.stadium { position: relative; width: 100%; max-width: 620px; margin-top: 4px; border: 3px solid var(--line); clip-path: polygon(var(--n) 0, calc(100% - var(--n)) 0, 100% var(--n), 100% calc(100% - var(--n)), calc(100% - var(--n)) 100%, var(--n) 100%, 0 calc(100% - var(--n)), 0 var(--n)); }
.stadium canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; aspect-ratio: 160 / 100; }
/* The title sits on the jumbotron drawn in the canvas (x 43-117, y 9-43 of 160x100). */
.logo {
  position: absolute; left: 26.9%; width: 46.2%; top: 9%; height: 34%;
  margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35em;
  font: 400 clamp(13px, 4.3vw, 27px)/1 var(--title); color: var(--yellow); text-align: center; text-transform: uppercase;
}
.logo span { display: block; }
.tag { max-width: 36ch; margin: 0; text-align: center; color: var(--muted); }

/* ---------- panels & inputs ---------- */
.panel {
  width: 100%; max-width: 440px;
  background: var(--navy);
  border: 3px solid var(--line-dim);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.panel.wide { max-width: 620px; }
label { font-size: 19px; color: var(--muted); }
input, select {
  width: 100%;
  font: 22px var(--body);
  color: var(--chalk);
  background: var(--night);
  border: 3px solid var(--line-dim);
  padding: 7px 12px;
  outline: none;
  border-radius: 0;
}
select { appearance: none; background-image: linear-gradient(var(--muted), var(--muted)), linear-gradient(var(--muted), var(--muted)); background-size: 8px 2px, 4px 2px; background-position: calc(100% - 14px) 48%, calc(100% - 16px) 62%; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus { border-color: var(--yellow); }
input:disabled, select:disabled { opacity: .55; }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 24px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 0 0 auto; }

.btn {
  font: 700 16px/1 var(--label); letter-spacing: .06em; text-transform: uppercase;
  color: var(--chalk); background: var(--navy-2);
  border: 3px solid var(--line-dim);
  padding: 13px 22px; cursor: pointer; white-space: nowrap;
  border-radius: 0;
}
.btn:hover:not(:disabled) { border-color: var(--line); }
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:focus-visible { outline: none; border-color: var(--chalk); background: var(--line-dim); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { color: var(--yellow); border-color: var(--line); background: var(--navy); }
.btn.primary:hover:not(:disabled) { background: var(--line); color: var(--night); }
.btn.primary:focus-visible { background: var(--line); color: var(--night); border-color: var(--chalk); }
.btn.ghost { color: var(--muted); background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { color: var(--chalk); border-color: transparent; }
.btn.small { font-size: 13px; padding: 9px 14px; }
.btn.big { font-size: 20px; padding: 18px 40px; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; padding: 2px 6px; }
.icon-btn:focus-visible { outline: 2px solid var(--chalk); }
.link-btn { background: none; border: 0; padding: 0; color: var(--yellow); font: 19px var(--body); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:focus-visible { outline: 2px solid var(--chalk); outline-offset: 2px; }

.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 18px; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 0; border-top: 2px dashed var(--line-dim); }
.error { color: var(--red-text); min-height: 1.2em; margin: 0; }

.rarity-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.rarity-legend li { font: 700 12px var(--label); padding: 5px 8px; border: 2px solid currentColor; background: var(--night); }

/* ---------- home: profile, solo, career ---------- */
.me-row { display: flex; gap: 14px; align-items: center; }
.me-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* three tiles: each button with its one-line description underneath */
.solo-grid { display: grid; grid-template-rows: auto auto; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px 10px; align-items: start; }
.solo-grid .btn { width: 100%; height: 100%; min-height: 58px; white-space: normal; line-height: 1.3; font-size: 13px; padding: 10px 8px; }
.solo-grid p { margin: 0; font-size: 17px; line-height: 1.15; text-align: center; }
.career { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.career div { background: var(--night); border: 2px solid var(--line-dim); padding: 8px 10px; }
.career dt { font-size: 17px; color: var(--muted); }
.career dd { margin: 4px 0 0; font: 400 15px/1.2 var(--title); }
.career div.t4 dd { color: var(--t4); }
.profile-tools { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.profile-code { width: 100%; color: var(--muted); }
.profile-code summary { cursor: pointer; text-align: center; color: var(--chalk); }
.profile-code[open] { background: var(--navy); border: 3px solid var(--line-dim); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.profile-code p { margin: 0; }

/* ---------- avatars ---------- */
.avatar { display: inline-block; flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border: 0; background: none; }
.avatar canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.big-avatar { width: 84px; height: 84px; cursor: pointer; background: var(--night); border: 3px solid var(--line-dim); padding: 4px; }
.big-avatar:hover { border-color: var(--line); }
.big-avatar:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }
.huge-avatar { width: 150px; height: 150px; background: var(--night); border: 3px solid var(--line-dim); padding: 8px; }
.huge-avatar.wiggle canvas { animation: hop .35s steps(3); }
@keyframes hop { 50% { transform: translateY(-6px); } }

/* ---------- lobby ---------- */
.lobby-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.lobby-buttons { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.big-code { margin: 4px 0 0; font: 400 34px/1 var(--title); letter-spacing: .12em; color: var(--yellow); }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--night); border: 2px solid var(--line-dim); }
.player-list .avatar { width: 34px; height: 34px; }
.player-list .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .remove { background: none; border: 2px solid var(--line-dim); color: var(--muted); width: 28px; height: 28px; cursor: pointer; font: 18px var(--body); line-height: 1; }
.player-list .remove:hover { color: var(--chalk); border-color: var(--red); }
.player-list .remove:focus-visible { outline: 2px solid var(--chalk); }
.badge { font: 700 11px var(--label); padding: 3px 6px; background: var(--navy-2); color: var(--muted); white-space: nowrap; text-transform: uppercase; }
.badge.host { color: var(--night); background: var(--yellow); }
.badge.you { color: var(--night); background: var(--green); }
.dot { width: 8px; height: 8px; background: var(--green); flex: 0 0 auto; }
.dot.off { background: var(--line-dim); }
.bot-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  font: inherit; color: var(--chalk); cursor: pointer;
  background: var(--night); border: 3px solid var(--line-dim); padding: 14px;
}
.mode b { font: 400 14px/1 var(--title); }
.mode span { font-size: 18px; color: var(--muted); }
.mode:hover:not(:disabled) { border-color: var(--line); }
.mode:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }
.mode[aria-checked="true"] { border-color: var(--yellow); background: var(--navy-2); }
.mode[aria-checked="true"] b { color: var(--yellow); }
.mode[data-preset="hard"] b { color: var(--red-text); }
.mode:disabled { cursor: default; }
.mode:disabled:not([aria-checked="true"]) { opacity: .5; }
.lobby-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 2px; }

.settings-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.settings-head h2 { margin: 0; }
.settings-summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  cursor: pointer; list-style: none; font: 700 16px var(--label); text-transform: uppercase; letter-spacing: .04em;
}
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary > span:first-child::after { content: " +"; color: var(--muted); }
.settings[open] .settings-summary > span:first-child::after { content: " -"; }
.settings-summary:focus-visible { outline: 3px solid var(--chalk); outline-offset: 4px; }
.settings:not([open]) { gap: 0; }
.pool { margin: 0; color: var(--muted); font: 18px var(--body); text-transform: none; letter-spacing: 0; }
.pool b { color: var(--yellow); font: 400 14px var(--title); }
.pool.bump b { display: inline-block; animation: hop .3s steps(2); }
fieldset { border: 0; border-top: 2px dashed var(--line-dim); margin: 6px 0 0; padding: 12px 0 0; display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
legend { font: 700 14px var(--label); color: var(--chalk); padding: 0 8px 0 0; text-transform: uppercase; letter-spacing: .04em; }
fieldset label { display: flex; flex-direction: column; gap: 4px; }
fieldset .toggle, fieldset .chips { grid-column: 1 / -1; }
fieldset.hard { border-top-color: var(--red); }
fieldset.hard legend { color: var(--red-text); }
.toggle { flex-direction: row !important; align-items: center; gap: 10px !important; color: var(--chalk); cursor: pointer; }
.toggle input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--yellow); padding: 0; clip-path: none; }
.toggle.master span { color: var(--yellow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 700 12px var(--label); text-transform: uppercase; color: var(--muted); background: var(--night); border: 2px solid var(--line-dim); padding: 7px 10px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--yellow); color: var(--night); border-color: var(--yellow); }
.chip:hover:not(:disabled):not([aria-pressed="true"]) { border-color: var(--line); }
.chip:disabled { cursor: default; opacity: .6; }
.chip:focus-visible { outline: 2px solid var(--chalk); outline-offset: 2px; }

/* ---------- game ---------- */
.scorebug { width: 100%; display: flex; align-items: stretch; background: var(--navy); border: 3px solid var(--line-dim); font-size: 19px; color: var(--muted); }
.scorebug > * { padding: 5px 12px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.scorebug b { color: var(--chalk); font-weight: 400; }
.bug-code { background: var(--yellow); color: var(--night); font: 700 13px var(--label); }
.bug-code b { color: var(--night); }
.bug-rules { flex: 1; overflow: hidden; text-overflow: ellipsis; display: block !important; line-height: 1.6; }
.bug-count { border-left: 3px solid var(--line-dim); }

.rules-banner { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.rule { font: 700 13px/1 var(--label); text-transform: uppercase; letter-spacing: .03em; padding: 9px 12px; color: var(--chalk); background: #b8322c; border: 2px solid #ff8f8f; }
.rule small { font: 17px var(--body); text-transform: none; letter-spacing: 0; opacity: .9; margin-right: 6px; }
.rule.letter { background: var(--yellow); border-color: #fff0a8; color: var(--night); }
.rule.team { background: var(--t2); border-color: #bfe3ff; color: var(--night); }
.rule.next { background: var(--night); border: 2px dashed var(--line-dim); color: var(--muted); }
.rule.flip { animation: drop .4s steps(4); }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

/* The table is a pixel football field seen from above. */
.arena {
  position: relative; width: var(--arena); height: var(--arena); margin: 30px 0 4px;
  border: 3px solid var(--line);
  background:
    linear-gradient(var(--chalk), var(--chalk)) center / 100% 2px no-repeat,
    repeating-linear-gradient(0deg, transparent 0 calc(12.5% - 2px), rgba(216, 236, 210, .28) calc(12.5% - 2px) 12.5%),
    repeating-linear-gradient(0deg, var(--field) 0 6.25%, var(--field-2) 6.25% 12.5%);
}
.ring {
  --rot: 0deg;
  position: absolute; inset: 9%; border-radius: 50%;
  border: 2px dashed rgba(238, 243, 230, .45);
  transform: rotate(var(--rot));
  transition: transform .6s cubic-bezier(.3, 1.2, .4, 1);
}
.ring.instant, .ring.instant .seat { transition: none !important; }
.seat {
  --r: calc(var(--arena) / 2 - 44px);
  position: absolute; left: 50%; top: 50%;
  width: 104px; margin: -36px 0 0 -52px;
  transform: rotate(var(--a)) translateY(calc(var(--r) * -1)) rotate(calc(-1 * (var(--a) + var(--rot))));
  transition: transform .6s cubic-bezier(.3, 1.2, .4, 1);
  text-align: center;
}
.chipcard { position: relative; display: block; padding: 2px 6px 5px; background: var(--navy); border: 3px solid var(--line-dim); }
.seat .chipcard .avatar { width: 40px; height: 40px; display: block; margin: -26px auto 0; }
.seat .sname { display: block; font-size: 19px; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .hearts { display: block; font-size: 15px; letter-spacing: .08em; color: var(--red); min-height: 1.1em; line-height: 1.1; }
.seat .hearts .empty { color: var(--line-dim); }
.seat .meter { display: block; height: 4px; margin: 3px 2px 0; background: var(--night); }
.seat .meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s steps(6); }
.seat .meter.full i { background: var(--yellow); }
.seat .pts { position: absolute; top: -10px; right: -8px; font: 400 9px/1 var(--title); background: var(--yellow); color: var(--night); padding: 4px 5px; }
.seat .afk { position: absolute; top: -10px; left: -8px; font: 700 10px/1 var(--label); background: var(--red); color: var(--night); padding: 3px 4px; }
.seat.active .chipcard { border-color: var(--yellow); transform: scale(1.12); }
.seat.active .chipcard .avatar canvas { animation: hop .8s steps(2) infinite; }
.seat.me .sname { color: var(--yellow); }
.seat.out .chipcard { opacity: .4; filter: grayscale(1); }
.seat.out .sname { text-decoration: line-through; }
.seat.offline .chipcard { border-style: dashed; }
.seat.hit .chipcard { animation: shake .4s steps(4); }

.clock { position: absolute; left: 50%; top: 50%; width: 44%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.clock svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; shape-rendering: crispEdges; }
.clock-bg { fill: var(--night); stroke: var(--line-dim); stroke-width: 8; }
.clock-fg { fill: none; stroke: var(--yellow); stroke-width: 8; stroke-linecap: butt; stroke-dasharray: 339.3; stroke-dashoffset: 0; }
.clock.hurry .clock-fg { stroke: var(--red); }
.clock-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16%; text-align: center; }
.time { font: 400 clamp(26px, 8.5vw, 44px)/1 var(--title); font-variant-numeric: tabular-nums; }
.time.tick { animation: hop .2s steps(2); }
.clock.hurry .time { color: var(--red); }
.turn-name { font-size: 18px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 8px; }
.typing { color: var(--muted); font-size: 17px; min-height: 1.2em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing:not(:empty)::after { content: "_"; animation: blink 1s steps(1) infinite; color: var(--yellow); }
@keyframes blink { 50% { opacity: 0; } }

/* pixel trading card for every correct answer */
.card-slot { position: absolute; inset: -8%; display: grid; place-items: center; pointer-events: none; }
.tcard {
  --tc: var(--t0);
  width: 70%; aspect-ratio: 5 / 6;
  background: var(--navy); border: 4px solid var(--tc);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 10px 8px; text-align: center; overflow: hidden; position: relative;
  animation: card-move 1.9s cubic-bezier(.2, .9, .25, 1) forwards;
}
.tcard .tier { font: 700 13px/1 var(--label); color: var(--tc); text-transform: uppercase; letter-spacing: .06em; }
.tcard .who { font: 400 clamp(10px, 2.8vw, 14px)/1.35 var(--title); text-wrap: balance; color: var(--chalk); }
.tcard .meta { font-size: 18px; color: var(--muted); }
.tcard .plus { font: 400 20px/1 var(--title); color: var(--tc); }
.tcard.foil::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 255, 255, .16) 10px 14px);
  animation: blink .3s steps(1) 3;
}
@keyframes card-move {
  0% { transform: translateY(18px) scale(.7); }
  16% { transform: translateY(-4px) scale(1.04); }
  26% { transform: translateY(0) scale(1); }
  78% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(60%) scale(.4); opacity: 0; }
}
.t0 { --tc: var(--t0); color: var(--t0); }
.t1 { --tc: var(--t1); color: var(--t1); }
.t2 { --tc: var(--t2); color: var(--t2); }
.t3 { --tc: var(--t3); color: var(--t3); }
.t4 { --tc: var(--t4); color: var(--t4); }
.tcard.t0, .tcard.t1, .tcard.t2, .tcard.t3, .tcard.t4 { color: var(--chalk); }

.flag { position: absolute; left: 50%; top: 14%; font-size: 34px; animation: flag 1.2s steps(6) forwards; pointer-events: none; }
.flag span { position: absolute; left: 110%; top: 30%; font: 400 12px var(--title); color: var(--yellow); white-space: nowrap; }
@keyframes flag {
  0% { transform: translate(-50%, -120%); opacity: 0; }
  30% { transform: translate(-50%, 0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(-50%, 0); opacity: 0; }
}
.float {
  position: absolute; font: 400 12px var(--title); white-space: nowrap; pointer-events: none;
  transform: translate(-50%, -50%); animation: float-up 1.4s steps(7) forwards; z-index: 5;
  text-shadow: 2px 2px 0 var(--night);
}
@keyframes float-up { from { opacity: 0; transform: translate(-50%, -20%); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -220%); } }

.dock { width: 100%; max-width: 620px; display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.dock-clock { display: none; }
.guess { width: 100%; display: flex; gap: 10px; }
.guess input { font-size: 24px; }
.guess.myturn input { border-color: var(--yellow); }
.queued { margin: 0; font-size: 19px; color: var(--yellow); text-align: center; }
.queued b { color: var(--chalk); font-weight: 400; }
.flash { min-height: 1.3em; margin: 0; text-align: center; }
.flash.good { color: var(--green); }
.flash.bad { color: var(--red-text); }
.flash.warn { color: var(--yellow); }
.flash.pop { animation: hop .2s steps(2); }
.shake { animation: shake .35s steps(4); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.log-panel { padding: 14px 16px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.log li { display: grid; grid-template-columns: 2em 1fr auto; gap: 8px; align-items: center; padding: 5px 10px; background: var(--night); border: 2px solid var(--line-dim); border-left: 6px solid var(--tc, var(--line-dim)); }
.log li.new { animation: drop .3s steps(3); }
.log .num { color: var(--muted); }
.log .pl { color: var(--chalk); }
.log .by { color: var(--muted); font-size: 17px; display: block; }
.log .side { text-align: right; font-size: 17px; }
.log .side .tiername { display: block; font: 700 11px var(--label); text-transform: uppercase; }
.log .side .meta { color: var(--muted); }
.empty { color: var(--muted); }
.log li.empty, .leaders li.empty { display: block; border-left-width: 2px; }
.leaders li.empty::before { content: none; }

/* ---------- game over ---------- */
.over { position: fixed; inset: 0; z-index: 30; background: rgba(4, 8, 22, .88); display: flex; align-items: center; justify-content: center; padding: 16px; }
.over-panel { border-color: var(--line); animation: drop .3s steps(3); }
.over-title { margin: 4px 0 10px; font: 400 clamp(18px, 5vw, 26px)/1.3 var(--title); color: var(--yellow); }
.standings { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: place; }
.standings li { counter-increment: place; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--night); border: 2px solid var(--line-dim); }
.standings li::before { content: counter(place); font: 400 13px var(--title); color: var(--muted); width: 1.4em; }
.standings li:first-child { border-color: var(--yellow); }
.standings li:first-child::before { color: var(--yellow); }
.standings .avatar { width: 30px; height: 30px; }
.standings .pname { flex: 1; }
.standings .score { font: 400 12px var(--title); color: var(--yellow); }

/* ---------- leaderboard ---------- */
.leaders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: place; }
.leaders li { counter-increment: place; display: grid; grid-template-columns: 2em 40px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; background: var(--night); border: 2px solid var(--line-dim); animation: drop .3s steps(3) both; }
.leaders li::before { content: counter(place); font: 400 13px var(--title); color: var(--muted); }
.leaders li:nth-child(1)::before { color: var(--yellow); }
.leaders li:nth-child(2)::before { color: var(--t0); }
.leaders li:nth-child(3)::before { color: var(--t4); }
.leaders li.me { border-color: var(--yellow); }
.leaders .avatar { width: 40px; height: 40px; }
.leaders .who { min-width: 0; }
.leaders .who b { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaders .who span { font-size: 17px; color: var(--muted); }
.leaders .big { font: 400 15px var(--title); color: var(--yellow); text-align: right; }
.leaders .big small { display: block; font: 16px var(--body); color: var(--muted); margin-top: 4px; }

/* ---------- avatar builder ---------- */
.avatar-dialog { border: 0; padding: 0; background: none; max-width: min(540px, calc(100vw - 32px)); width: 100%; color: var(--chalk); }
.avatar-dialog::backdrop { background: rgba(4, 8, 22, .85); }
.avatar-dialog[open] .panel { max-width: none; border-color: var(--line); animation: drop .3s steps(3); }
.builder { display: flex; gap: 16px; align-items: flex-start; }
.builder-parts { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.part-label { font-size: 18px; color: var(--muted); margin-bottom: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border: 3px solid var(--night); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--chalk); outline: 2px solid var(--night); }
.swatch:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.builder .chip { padding: 6px 9px; font-size: 11px; }
.builder-actions { justify-content: flex-end; }

/* ---------- confetti (square pixels) ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 8px; height: 8px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--spin)); } }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .mode { flex-direction: row; align-items: baseline; gap: 12px; }
  .mode b { min-width: 5.2em; }
}
@media (max-width: 480px) {
  body { font-size: 20px; }
  .clock { width: 42%; }
  .seat { width: 90px; margin-left: -45px; }
  .seat .sname { font-size: 18px; }
  .seat .chipcard .avatar { width: 34px; height: 34px; margin-top: -22px; }
  fieldset { grid-template-columns: 1fr; }
  .bug-rules { display: none !important; }
  .scorebug { justify-content: space-between; }
  .solo-grid { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: 1fr; }
  .solo-grid .btn { min-height: 0; }
  .solo-grid p { margin: -2px 0 6px; }
  .builder { flex-direction: column; align-items: center; }
  .huge-avatar { width: 120px; height: 120px; }
  .career { grid-template-columns: repeat(2, 1fr); }
  .big-code { font-size: 28px; }
}

/* Answer area: inline on big screens, docked above the keyboard on phones. */
@media (max-width: 700px) {
  body.in-game main { padding-bottom: calc(var(--dock-h, 120px) + 24px); }
  body.in-game .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: none;
    padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--navy); border-top: 3px solid var(--line);
    transform: translateY(calc(-1 * var(--kb, 0px)));
    gap: 4px;
  }
  body.in-game .dock .flash { order: -2; min-height: 1.25em; font-size: 18px; line-height: 1.25; }
  body.in-game .dock .queued { order: -1; font-size: 18px; }
  body.in-game .dock-clock {
    display: flex; align-items: center; justify-content: center; flex: 0 0 auto; min-width: 44px;
    font: 400 20px/1 var(--title); color: var(--yellow); font-variant-numeric: tabular-nums;
  }
  body.in-game .dock-clock.hurry { color: var(--red); }
  body.in-game .dock-clock.idle { color: var(--muted); font-size: 14px; }
  body.in-game .dock .guess { gap: 8px; }
  body.in-game .dock .guess input { min-width: 0; padding: 6px 10px; }
  body.in-game .dock .btn { padding: 11px 14px; font-size: 14px; margin-right: 4px; }
  /* Keyboard open: drop the extras and shrink the table to fit what's left of the screen. */
  body.in-game.kb-open .scorebug, body.in-game.kb-open .log-panel { display: none; }
  body.in-game.kb-open main { padding-top: 8px; }
  body.in-game.kb-open { --arena: max(220px, min(92vw, calc(var(--vvh, 400px) - var(--dock-h, 110px) - 70px))); }
  body.in-game.kb-open .arena { margin-top: 22px; }
  /* Smaller name tags; zoom also scales the move out from the center, so divide it back out. */
  body.in-game.kb-open .seat { zoom: .74; --r: calc((var(--arena) / 2 - 30px) / .74); }
  body.in-game.kb-open .seat .meter { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* These would end invisible; show them still instead (the script removes them). */
  .tcard, .flag, .float { animation: none !important; }
  .confetti { display: none; }
}
