:root {
  color-scheme: dark;
  --bg: #101010;
  --ink: #fffaf0;
  --muted: #c8c0ad;
  --line: rgba(255, 250, 240, .16);
  --panel: rgba(255, 250, 240, .08);
  --panel-strong: rgba(255, 250, 240, .12);
  --yellow: #ffd447;
  --pink: #ff4f87;
  --blue: #57c7ff;
  --green: #63e6a6;
  --red: #ff6b5f;
  --orange: #ff9f43;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 212, 71, .12), transparent 24%),
    linear-gradient(225deg, rgba(87, 199, 255, .12), transparent 28%),
    radial-gradient(circle at 50% 0%, rgba(255, 79, 135, .18), transparent 32%),
    var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; color: var(--ink); }
button:disabled { cursor: not-allowed; opacity: .45; }

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 22px 14px 48px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 2px 18px;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(40px, 8vw, 76px);
  line-height: .92;
  letter-spacing: 0;
}
h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 5vw, 52px);
  line-height: .98;
  letter-spacing: 0;
}

.eyebrow, .step-label, .round-kicker {
  margin-bottom: 9px;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: 12px;
  font-weight: 950;
}

.muted, .hint { color: var(--muted); }
.hint { margin: 14px 0 0; font-size: 15px; }
.hidden { display: none !important; }

.panel, .round-shell {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.105), rgba(255,255,255,.055));
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel { padding: clamp(18px, 4vw, 30px); margin: 14px 0; }
.setup-panel {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 24px;
  align-items: end;
  min-height: 420px;
}
.setup-copy h2 { max-width: 620px; }
.setup-controls { display: grid; gap: 14px; }

.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
input {
  width: 100%;
  min-width: 0;
  padding: 17px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .22);
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255, 212, 71, .16); }

.players { display: flex; flex-wrap: wrap; gap: 10px; min-height: 48px; }
.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-weight: 900;
}
.player-chip strong { color: var(--muted); }

.primary, .secondary, .danger, .ghost, .input-row button {
  padding: 16px 18px;
  border-radius: 16px;
  font-weight: 950;
  transition: transform .14s ease, filter .14s ease, background .14s ease;
}
.primary { background: linear-gradient(135deg, var(--pink), var(--orange)); }
.secondary { background: linear-gradient(135deg, #356dff, #9a55ff); }
.danger { background: linear-gradient(135deg, #363636, #1f1f1f); border: 1px solid rgba(255,255,255,.12); }
.ghost { background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.small { padding: 10px 12px; font-size: 14px; }
.wide { width: 100%; }
button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }

.spotlight {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 430px;
}
.loader { display: flex; gap: 8px; margin-top: 20px; }
.loader span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--yellow);
  animation: bounce 1s infinite ease-in-out alternate;
}
.loader span:nth-child(2) { animation-delay: .15s; background: var(--blue); }
.loader span:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes bounce { from { transform: translateY(0); opacity: .45; } to { transform: translateY(-10px); opacity: 1; } }

.round-shell {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 18px;
  padding: 18px;
  margin-bottom: 14px;
}
.round-main { min-width: 0; }
.round-main h2 { margin-bottom: 8px; }
.score-panel {
  background: rgba(0, 0, 0, .22);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.scoreboard { display: grid; gap: 8px; }
.score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 13px;
  background: rgba(255,255,255,.08);
  font-weight: 900;
}
.score span { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.score span b {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: var(--muted);
  font-size: 12px;
}
.score.leader { background: rgba(255, 212, 71, .18); }
.score.leader span b { background: var(--yellow); color: #17120a; }
.large { max-width: 520px; }

.category-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 2px 2px;
}
.category-dot {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.category-dot span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: var(--ink);
}
.category-dot.active { color: var(--ink); background: rgba(87, 199, 255, .18); }
.category-dot.done { color: var(--green); }

.phase-panel { overflow: hidden; }
.phase-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.progress-pill, .question-badges span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #17120a;
  font-weight: 950;
}
.question-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.question-badges span:last-child { background: var(--pink); color: white; }

.order-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 8px 0 18px;
}
.order-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 9px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
}
.order-card span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  font-weight: 950;
}
.order-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card em { color: var(--muted); font-style: normal; font-size: 13px; font-weight: 800; }
.order-card.current { background: rgba(255, 212, 71, .18); border-color: rgba(255, 212, 71, .5); }
.order-card.done { opacity: .74; }
.order-card.done span { background: var(--green); color: #062516; }

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
}
.number-card {
  min-height: 104px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.09);
}
.number-card strong { font-size: clamp(28px, 4vw, 44px); line-height: 1; }
.number-card span { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 950; color: var(--muted); }
.number-card.safe { box-shadow: inset 0 -4px 0 rgba(99, 230, 166, .55); }
.number-card.spicy { box-shadow: inset 0 -4px 0 rgba(255, 212, 71, .65); }
.number-card.chaos { box-shadow: inset 0 -4px 0 rgba(255, 79, 135, .75); }
.number-card.taken { background: rgba(0,0,0,.24); color: rgba(255,250,240,.42); }
.number-card.taken span { color: rgba(255,250,240,.46); text-transform: none; letter-spacing: 0; }

.wait-box, .answer {
  padding: 18px;
  border-radius: 18px;
  margin: 14px 0;
  font-weight: 900;
}
.wait-box { background: rgba(87,199,255,.12); color: var(--blue); border: 1px solid rgba(87,199,255,.28); }
.answer { background: rgba(99, 230, 166, .13); color: var(--green); border: 1px solid rgba(99, 230, 166, .3); font-size: clamp(24px, 5vw, 44px); }
.judge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.judge-grid button { min-height: 64px; }

.recap { text-align: left; }
.round-results {
  display: grid;
  gap: 10px;
  max-width: 620px;
  margin: 18px 0;
}
.result-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 13px 14px;
  border-radius: 15px;
  background: rgba(255,255,255,.08);
  font-weight: 900;
}
.result-row b { color: var(--green); font-size: 24px; }
.result-row.lost b { color: var(--red); }
.result-row em { color: var(--muted); font-style: normal; }

@media (max-width: 820px) {
  .setup-panel, .round-shell { grid-template-columns: 1fr; }
  .setup-panel { min-height: auto; }
  .score-panel { order: -1; }
  .number-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .number-card { min-height: 86px; }
}

@media (max-width: 560px) {
  .app { padding-inline: 10px; }
  .masthead { align-items: center; }
  .input-row, .judge-grid { grid-template-columns: 1fr; }
  .phase-head { display: block; }
  .question-badges { justify-content: flex-start; margin-bottom: 12px; }
  .number-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .number-card { min-height: 74px; }
}

@media (max-width: 560px) {
  .masthead {
    position: relative;
    display: block;
    padding-right: 112px;
    min-height: 92px;
  }
  .masthead .ghost {
    position: absolute;
    right: 0;
    top: 14px;
  }
}
.setup-status {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(87, 199, 255, .28);
  background: rgba(87, 199, 255, .12);
  color: var(--blue);
  font-size: 14px;
  font-weight: 900;
}
.setup-status.ready {
  border-color: rgba(99, 230, 166, .3);
  background: rgba(99, 230, 166, .13);
  color: var(--green);
}
.setup-status.error {
  border-color: rgba(255, 107, 95, .35);
  background: rgba(255, 107, 95, .13);
  color: var(--red);
}
