/* ==========================================================================
   Gala Quiz — black / red / a hint of orange
   ========================================================================== */

:root {
  --bg: #070707;
  --bg-2: #0f0f10;
  --panel: #151516;
  --panel-2: #1d1d1f;
  --line: #2a2a2d;
  --line-strong: #3a3a3e;
  --text: #f6f3f2;
  --muted: #9b9597;
  --dim: #5f5a5c;

  --red: #e3132c;
  --red-hi: #ff2d45;
  --red-deep: #7d0a17;
  --red-glow: rgba(227, 19, 44, 0.45);
  --orange: #ff7a1a;
  --orange-hi: #ffa04d;
  --orange-glow: rgba(255, 122, 26, 0.45);

  --opt-0: #e3132c;
  --opt-1: #ff7a1a;
  --opt-2: #2d2d31;
  --opt-3: #8a0c1c;

  --radius: 14px;
  --radius-lg: 22px;
  --font-display: 'Bebas Neue', 'Oswald', 'Impact', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(227, 19, 44, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 122, 26, 0.08), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
.display-font {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.02;
  margin: 0;
}

a {
  color: var(--orange);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227, 19, 44, 0.25);
}

.muted {
  color: var(--muted);
}

.accent {
  color: var(--orange);
}

.hidden {
  display: none !important;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-body);
  letter-spacing: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.btn:hover {
  border-color: var(--dim);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--red-hi), var(--red));
  border-color: var(--red);
  box-shadow: 0 8px 30px -10px var(--red-glow);
}

.btn-primary:hover {
  border-color: var(--orange);
}

.btn-orange {
  background: linear-gradient(180deg, var(--orange-hi), var(--orange));
  border-color: var(--orange);
  color: #1a0a00;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 9px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.chip-red {
  border-color: var(--red);
  color: var(--red-hi);
}

.chip-orange {
  border-color: var(--orange);
  color: var(--orange);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.brand-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--red-deep), var(--red) 45%, var(--orange));
}

/* ---------- Connection banner & toasts ---------- */

.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--red);
  color: #fff;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem;
  transform: translateY(-100%);
  transition: transform 0.25s;
}

.conn-banner.show {
  transform: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 140%);
  background: var(--panel-2);
  border: 1px solid var(--orange);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  transition: transform 0.25s;
  box-shadow: 0 10px 40px -10px #000;
}

.toast.show {
  transform: translate(-50%, 0);
}

/* ---------- Answer option tiles (shared) ---------- */

.opt {
  --c: var(--opt-0);
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  border: 2px solid transparent;
  background: var(--c);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-weight: 700;
  color: #fff;
  transition: transform 0.1s, opacity 0.25s, filter 0.25s, box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
}

.opt-1 {
  --c: var(--opt-1);
  color: #1a0a00;
}

.opt-2 {
  --c: var(--opt-2);
}

.opt-3 {
  --c: var(--opt-3);
}

.opt .letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--font-display);
  font-size: 1.15em;
  font-weight: 400;
  color: #fff;
}

.opt .label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Player (phone)
   ========================================================================== */

.player {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.player main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.p-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.p-team {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--orange);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-hero {
  text-align: center;
  padding: 24px 0 8px;
}

.p-hero h1 {
  font-size: clamp(2.6rem, 12vw, 4rem);
}

.p-hero h1 .accent {
  display: block;
}

.p-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.p-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.table-btn {
  position: relative;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.table-btn:active {
  transform: scale(0.97);
}

.table-btn strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.table-btn small {
  color: var(--muted);
  font-size: 0.78rem;
}

.table-btn.taken {
  opacity: 0.55;
}

.table-btn.taken small {
  color: var(--orange);
}

.table-btn.selected {
  border-color: var(--orange);
  background: linear-gradient(180deg, rgba(255, 122, 26, 0.14), rgba(255, 122, 26, 0.04));
}

.p-wait {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px 0;
}

.p-wait h2 {
  font-size: clamp(2.2rem, 10vw, 3.2rem);
}

.pulse-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--red);
  position: relative;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--orange);
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid var(--red);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  from {
    transform: scale(1);
    opacity: 0.8;
  }
  to {
    transform: scale(1.7);
    opacity: 0;
  }
}

.teammates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.teammates span {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.timerbar {
  height: 8px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.timerbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--red), var(--orange));
  transform-origin: left;
  border-radius: inherit;
}

.timerbar.low i {
  background: var(--red-hi);
}

.p-q {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.25rem, 5.4vw, 1.6rem);
  line-height: 1.25;
  letter-spacing: 0;
}

.p-opts {
  display: grid;
  gap: 12px;
}

.p-opts .opt {
  min-height: 70px;
  font-size: 1.1rem;
  width: 100%;
}

.p-opts .opt .by {
  position: absolute;
  right: 12px;
  top: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0;
}

.p-opts.has-pick .opt:not(.picked) {
  opacity: 0.38;
  filter: saturate(0.6);
}

.p-opts .opt.picked {
  border-color: #fff;
  box-shadow: 0 0 0 4px var(--orange-glow), 0 12px 40px -12px var(--c);
}

.p-opts .opt.picked .by {
  opacity: 0.9;
}

.p-opts.locked .opt {
  pointer-events: none;
}

.p-opts.locked:not(.has-pick) .opt {
  opacity: 0.4;
  filter: saturate(0.5);
}

.typed {
  display: grid;
  gap: 10px;
}

.typed input {
  font-size: 1.15rem;
  padding: 0.9rem 1rem;
}

.typed .btn {
  padding: 0.95rem;
  font-size: 1.05rem;
}

.p-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.p-note strong {
  color: var(--text);
}

.result {
  flex: 1;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 32px 20px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.result.good {
  background: radial-gradient(circle at 50% 30%, rgba(255, 122, 26, 0.35), transparent 65%), var(--panel);
  border-color: var(--orange);
}

.result.bad {
  background: radial-gradient(circle at 50% 30%, rgba(227, 19, 44, 0.3), transparent 65%), var(--panel);
  border-color: var(--red-deep);
}

.result .big-icon {
  font-size: 4.5rem;
  line-height: 1;
}

.result h2 {
  font-size: clamp(2.8rem, 13vw, 4.2rem);
}

.result .pts {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--orange);
}

.answer-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
}

.rank-big {
  font-family: var(--font-display);
  font-size: clamp(5rem, 28vw, 8rem);
  line-height: 0.9;
  background: linear-gradient(180deg, var(--orange-hi), var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mini-board {
  display: grid;
  gap: 6px;
  width: 100%;
}

.mini-board div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 600;
}

.mini-board div.me {
  border-color: var(--orange);
  background: rgba(255, 122, 26, 0.1);
}

.mini-board span:last-child {
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.85rem;
  padding: 6px;
}

/* ==========================================================================
   Big-screen display
   ========================================================================== */

.display {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: clamp(14px, 1.15vw, 26px);
}

.d-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2em;
  padding: 1.1em 2.2em;
}

.d-title {
  font-family: var(--font-display);
  font-size: 2.2em;
  letter-spacing: 0.06em;
}

.d-title span {
  color: var(--red);
}

.d-head .d-meta {
  display: flex;
  align-items: center;
  gap: 1em;
  color: var(--muted);
  font-weight: 600;
}

.d-body {
  flex: 1;
  min-height: 0;
  padding: 0.6em 2.2em 2em;
  display: flex;
  flex-direction: column;
}

.fullscreen-hint {
  position: fixed;
  right: 14px;
  bottom: 12px;
  font-size: 12px;
  color: var(--dim);
}

/* Lobby */
.d-lobby {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 3em;
  align-items: center;
}

.d-join h1 {
  font-size: 5.6em;
}

.d-join h1 em {
  font-style: normal;
  color: var(--red);
}

.d-join .url {
  margin-top: 0.4em;
  font-size: 1.9em;
  font-weight: 700;
  color: var(--orange);
  word-break: break-all;
}

.d-steps {
  margin: 1.4em 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 0.9em;
  font-size: 1.5em;
  font-weight: 600;
  color: var(--muted);
}

.d-steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: 0.8em;
}

.d-steps li::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.1em;
}

.d-steps b {
  color: var(--orange);
}

.qr-box {
  margin-top: 1.4em;
  width: 15em;
  height: 15em;
  padding: 0.8em;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 6px var(--red), 0 0 80px -10px var(--red-glow);
}

.qr-box img {
  width: 100%;
  height: 100%;
  display: block;
}

.d-tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10em, 1fr));
  gap: 0.8em;
  align-content: center;
}

.d-table {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.9em 1em;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s;
}

.d-table strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.45em;
  line-height: 1.05;
  letter-spacing: 0.03em;
  min-height: 2.1em;
  overflow-wrap: anywhere;
}

.d-table small {
  color: var(--muted);
  font-weight: 600;
}

.d-table.active {
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(227, 19, 44, 0.18), rgba(227, 19, 44, 0.04));
}

.d-table.active small {
  color: var(--orange);
}

/* Question */
.d-question {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.6em;
}

.d-qrow {
  display: flex;
  align-items: flex-start;
  gap: 2em;
}

.d-qtext {
  flex: 1;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 3em;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.ring {
  position: relative;
  flex: none;
  width: 8.5em;
  height: 8.5em;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 9;
}

.ring .track {
  stroke: var(--panel-2);
}

.ring .bar {
  stroke: url(#ringGrad);
  stroke-linecap: round;
}

.ring .num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 3.6em;
}

.ring.low .num {
  color: var(--red-hi);
  animation: beat 1s ease-in-out infinite;
}

.ring.done .num {
  font-size: 1.6em;
  color: var(--orange);
  animation: none;
}

@keyframes beat {
  50% {
    transform: scale(1.12);
  }
}

.d-multi {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.6em;
  font-size: 0.32em;
}

.multi-hint {
  align-self: flex-start;
}

.d-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 1em;
  min-height: 0;
}

.d-opts .opt {
  font-size: 2em;
  padding: 0.6em 0.8em;
  border-radius: var(--radius-lg);
}

.d-opts .opt .count {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.1em;
  opacity: 0;
  transition: opacity 0.3s;
}

.d-opts .opt .fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 0.28em;
  width: 0;
  background: rgba(255, 255, 255, 0.85);
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.d-opts.revealed .opt {
  opacity: 0.25;
  filter: grayscale(0.7);
}

.d-opts.revealed .opt.correct {
  opacity: 1;
  filter: none;
  border-color: #fff;
  box-shadow: 0 0 0 6px var(--orange), 0 0 90px -10px var(--orange-glow);
  transform: scale(1.02);
}

.d-opts.revealed .opt .count {
  opacity: 1;
}

.d-opts .opt .tick {
  display: none;
  font-size: 1.1em;
}

.d-opts.revealed .opt.correct .tick {
  display: inline;
}

.d-strip {
  display: flex;
  align-items: center;
  gap: 1.4em;
}

.d-strip .count-big {
  flex: none;
  font-family: var(--font-display);
  font-size: 2.4em;
  color: var(--orange);
  white-space: nowrap;
}

.d-strip .count-big small {
  font-size: 0.5em;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  margin-left: 0.3em;
}

.team-pills {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.team-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.35em 0.9em;
  font-weight: 700;
  font-size: 0.95em;
  color: var(--dim);
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.team-pill.in {
  color: #1a0a00;
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 24px -4px var(--orange-glow);
  animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.team-pill.right {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.team-pill.right em {
  font-style: normal;
  color: var(--orange-hi);
  margin-left: 0.4em;
}

.team-pill.wrong {
  opacity: 0.35;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  animation: none;
}

@keyframes pop {
  0% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1);
  }
}

/* Name That Tune (typed answers) */
.d-tune {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
}

.tune-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.3em;
}

.tune-hero .sax {
  font-size: 7em;
  line-height: 1;
  filter: drop-shadow(0 0 40px var(--orange-glow));
  animation: sway 2.4s ease-in-out infinite;
}

.tune-hero h1 {
  font-size: 7em;
}

.tune-hero h1 em {
  font-style: normal;
  color: var(--red);
}

.tune-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.6em;
  font-weight: 600;
}

.tune-hero.small .sax {
  font-size: 4.5em;
  animation: none;
}

.tune-hero.small h1 {
  font-size: 4.8em;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-8deg) translateY(0);
  }
  50% {
    transform: rotate(8deg) translateY(-0.1em);
  }
}

.tune-answer {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  padding: 0.5em 0.9em;
  border-radius: var(--radius-lg);
  border: 2px solid var(--orange);
  background: linear-gradient(90deg, rgba(255, 122, 26, 0.18), rgba(227, 19, 44, 0.08));
  box-shadow: 0 0 80px -20px var(--orange-glow);
}

.tune-answer span {
  color: var(--muted);
  font-weight: 700;
  font-size: 1.4em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tune-answer strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 3.6em;
  line-height: 1.05;
  color: var(--orange-hi);
}

.guesses {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.6em;
}

.guess {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 0.6em;
  align-content: center;
  padding: 0.45em 0.8em;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
}

.guess b {
  font-size: 0.85em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess span {
  grid-row: 2;
  font-weight: 700;
  font-size: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess em {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-style: normal;
  font-family: var(--font-display);
  font-size: 1.6em;
}

.guess.ok {
  border-color: var(--orange);
  background: linear-gradient(180deg, rgba(227, 19, 44, 0.35), rgba(227, 19, 44, 0.12));
}

.guess.ok b {
  color: var(--text);
}

.guess.ok em {
  color: var(--orange-hi);
}

.guess.no {
  opacity: 0.55;
}

.guess.no em {
  color: var(--red-hi);
}

.guess.none {
  opacity: 0.3;
}

.guess.none span {
  font-weight: 500;
  font-style: italic;
}

/* Leaderboard */
.d-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.d-board h1 {
  font-size: 4.2em;
}

.d-board h1 em {
  font-style: normal;
  color: var(--red);
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
}

.row {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 1em;
  padding: 0 1.1em;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: top 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), left 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.row .bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(227, 19, 44, 0.28), rgba(255, 122, 26, 0.12));
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.row > *:not(.bar) {
  position: relative;
}

.row .pos {
  width: 2em;
  font-family: var(--font-display);
  font-size: 1.6em;
  color: var(--muted);
}

.row .name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 1.3em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .gain {
  font-weight: 800;
  color: var(--orange);
  font-size: 1em;
}

.row .score {
  font-family: var(--font-display);
  font-size: 1.8em;
  font-variant-numeric: tabular-nums;
  min-width: 3em;
  text-align: right;
}

.row.top1 {
  border-color: var(--orange);
}

.row.top1 .pos {
  color: var(--orange);
}

.row.top2 .pos,
.row.top3 .pos {
  color: var(--red-hi);
}

/* Podium */
.podium {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.5em;
  padding-top: 1em;
}

.podium .step {
  width: 15em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
  text-align: center;
  opacity: 0;
  animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.podium .step .who {
  font-family: var(--font-display);
  font-size: 2.6em;
  line-height: 1;
}

.podium .step .pts {
  color: var(--orange);
  font-weight: 800;
  font-size: 1.3em;
}

.podium .block {
  width: 100%;
  border-radius: 14px 14px 0 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 5em;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
}

.podium .p1 .block {
  height: 30vh;
  font-size: 6em;
  background: linear-gradient(180deg, var(--orange), var(--red));
  box-shadow: 0 0 120px -20px var(--orange-glow);
}

.podium .p1 .who {
  font-size: 3.6em;
  color: var(--orange-hi);
}

.podium .p2 .block {
  height: 20vh;
}

.podium .p3 .block {
  height: 14vh;
}

.podium .p1 {
  animation-delay: 1.4s;
}

.podium .p2 {
  animation-delay: 0.7s;
}

.podium .p3 {
  animation-delay: 0s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.runners {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em 1.4em;
  color: var(--muted);
  font-weight: 600;
  margin-top: 1.2em;
}

.runners b {
  color: var(--text);
}

/* ==========================================================================
   Host panel
   ========================================================================== */

.host {
  min-height: 100vh;
}

.h-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.h-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.h-top h1 {
  font-size: 2.2rem;
}

.h-top h1 span {
  color: var(--red);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  flex-wrap: wrap;
}

.tabs button {
  border: 0;
  background: none;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
}

.tabs button.on {
  background: var(--red);
  color: #fff;
}

.h-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.card + .card {
  margin-top: 16px;
}

.card h3 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.phase-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.h-q {
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.35;
  margin: 0 0 12px;
}

.h-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.h-opts .opt {
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

.h-opts .opt.correct {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--orange);
}

.h-opts .opt .n {
  font-family: var(--font-display);
  font-size: 1.3em;
  font-weight: 400;
}

.h-timer {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--orange);
  line-height: 1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.big-next {
  width: 100%;
  padding: 1.05rem 1.2rem;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.h-table {
  width: 100%;
  border-collapse: collapse;
}

.h-table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px 8px;
}

.h-table td {
  padding: 8px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.h-table td.num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.h-table .tname {
  font-weight: 700;
  min-width: 8.5rem;
}

.h-table .tmembers {
  color: var(--muted);
  font-size: 0.8rem;
}

.ans-badge {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  background: var(--panel-2);
  color: var(--dim);
  border: 1px solid var(--line);
}

.ans-badge.a0 {
  background: var(--opt-0);
  color: #fff;
}

.ans-badge.a1 {
  background: var(--opt-1);
  color: #1a0a00;
}

.ans-badge.a2 {
  background: var(--opt-2);
  color: #fff;
  border-color: var(--line-strong);
}

.ans-badge.a3 {
  background: var(--opt-3);
  color: #fff;
}

.ans-badge.ok {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}

.mark span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mark b {
  flex: none;
  font-size: 1rem;
}

.mark b i {
  font-style: normal;
  font-size: 0.7rem;
  margin-left: 2px;
  opacity: 0.8;
}

.mark.ok {
  border-color: var(--orange);
  background: rgba(255, 122, 26, 0.14);
}

.mark.ok b {
  color: var(--orange);
}

.mark.no b {
  color: var(--red-hi);
}

.mark:hover {
  border-color: var(--text);
}

.h-answer {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--orange);
  background: rgba(255, 122, 26, 0.08);
}

.h-answer strong {
  font-size: 1.3rem;
  color: var(--orange-hi);
}

.h-answer .p-label {
  margin: 0;
}

.ed-typed {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.adj {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.adj button {
  padding: 0.25rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  font-size: 0.8rem;
  font-weight: 700;
}

.adj button:hover {
  border-color: var(--orange);
}

.login {
  max-width: 380px;
  margin: 14vh auto 0;
  padding: 0 16px;
}

.login .card {
  display: grid;
  gap: 14px;
}

.login h1 {
  font-size: 3rem;
}

.login h1 span {
  color: var(--red);
}

.err {
  color: var(--red-hi);
  font-weight: 600;
  min-height: 1.2em;
  margin: 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Editors */
.ed-q {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg-2);
  display: grid;
  gap: 10px;
}

.ed-q + .ed-q {
  margin-top: 12px;
}

.ed-q-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ed-q-head .qn {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--orange);
  width: 2.4rem;
}

.ed-q-head .spacer {
  flex: 1;
}

.ed-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ed-opt {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ed-opt label {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-display);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
}

.ed-opt input[type='radio'] {
  display: none;
}

.ed-opt input[type='radio']:checked + label {
  background: var(--orange);
  border-color: var(--orange);
  color: #1a0a00;
}

.ed-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ed-meta label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.ed-meta input {
  width: 6rem;
}

.ed-table {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ed-table + .ed-table {
  margin-top: 8px;
}

.ed-table .idx {
  width: 2rem;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.ed-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(21, 21, 22, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px 12px;
}

.ed-bar .dirty {
  color: var(--orange);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.switch input {
  width: auto;
  accent-color: var(--red);
  transform: scale(1.3);
}

@media (max-width: 900px) {
  .h-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .ed-opts,
  .h-opts {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Printable table cards
   ========================================================================== */

.cards-page {
  padding: 24px 16px;
}

.cards-toolbar {
  max-width: 1100px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.cards {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.tcard {
  background: #0a0a0a;
  border: 2px solid var(--red);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
  break-inside: avoid;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.tcard .kicker {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--orange);
  font-weight: 700;
}

.tcard h2 {
  font-size: 2.6rem;
  min-height: 2.1em;
  display: grid;
  place-items: center;
}

.tcard img {
  width: 190px;
  height: 190px;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
}

.tcard p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

@media print {
  body {
    background: #fff;
  }
  .cards-toolbar {
    display: none;
  }
  .cards {
    grid-template-columns: 1fr 1fr;
  }
}

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