:root {
  /* Deep indigo canvas */
  --bg-1: #120d2a;
  --bg-2: #17113a;
  --bg-3: #1d1442;

  /* Raised surfaces */
  --bg-card: #1e1740;
  --bg-card-alt: #261d4f;
  --bg-inset: #2d2360;

  /* Cream panel used for question text — the one light surface */
  --cream: #fbf3dd;
  --cream-ink: #1a1235;

  --fg: #ece8ff;
  --muted: #a79fc7;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --primary: #8b5cf6;
  --primary-dark: #6d3ee8;
  --accent: #ffd452;
  --accent-ink: #2a1e05;
  --cyan: #5eead4;

  --red: #f0526b;
  --blue: #3aa9f5;
  --yellow: #ffd452;
  --green: #34d399;
  --gold: #ffd452;
  --silver: #cbd5e1;
  --bronze: #e09456;

  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.45);
  /* Offset "hard shadow" that gives buttons and cards their sticker look */
  --offset: 6px 6px 0 var(--primary-dark);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', 'Noto Sans Thai', Tahoma, sans-serif;
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(900px 600px at 88% 6%, rgba(139, 92, 246, 0.28), transparent 62%),
    radial-gradient(700px 560px at 6% 92%, rgba(94, 234, 212, 0.10), transparent 58%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.045) 1.5px, transparent 1.5px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
  animation: drift 60s linear infinite;
}

@keyframes drift {
  from { background-position: 0 0; }
  to { background-position: 280px 280px; }
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: #fff;
  text-decoration: none;
}

.brand::before {
  content: 'Q';
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--primary-dark);
}

.topbar-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.lang {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px;
}

.lang-btn, .sound-btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.sound-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-strong);
  padding: 0.4rem 0.7rem;
}

.lang-btn:hover, .sound-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.home-main { justify-content: center; }

.title {
  color: #fff;
  font-size: 4rem;
  margin: 0;
  text-align: center;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.05;
  animation: pop-in 0.6s ease-out;
}

/* Second line of the hero headline picks up the amber accent */
.title .hl { color: var(--accent); }

@keyframes pop-in {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

.subtitle {
  color: var(--muted);
  margin-top: 0.4rem;
  text-align: center;
  font-size: 1.1rem;
  max-width: 34ch;
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.6rem;
  box-shadow: var(--shadow-soft);
  width: 100%;
  max-width: 480px;
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.card.alt { background: var(--bg-card-alt); }
.card.wide { max-width: 760px; }
.card.center { text-align: center; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card h1, .card h2 { margin-top: 0; }
.card h1 { font-size: 1.7rem; font-weight: 800; }
.card h2 { font-size: 1.35rem; font-weight: 800; }

form { display: flex; flex-direction: column; gap: 0.75rem; }

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-inset);
  color: var(--fg);
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder { color: var(--muted); opacity: 0.8; }

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25);
}

label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.5rem 0; font-weight: 700; }
label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
label.inline input { max-width: 110px; }

.btn {
  display: inline-block;
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  letter-spacing: 0.2px;
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
  position: relative;
}

/* Sticker press: the button slides into its own offset shadow */
.btn:active { transform: translate(3px, 3px); }
.btn:hover { filter: brightness(1.06); }

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--offset);
}
.btn.primary:active { box-shadow: 3px 3px 0 var(--primary-dark); }

.btn.secondary {
  background: var(--primary);
  color: #fff;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
}
.btn.secondary:active { box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35); }

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  border: 2px solid var(--border-strong);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.btn.ghost:active { transform: translateY(2px); }

.btn.big {
  padding: 1.1rem 2rem;
  font-size: 1.2rem;
  border-radius: 14px;
}

.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 0.25rem 0 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; }
.hidden { display: none !important; }

.pin-display {
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  color: #fff;
  padding: 1.2rem;
  border-radius: 18px;
  text-align: center;
  font-weight: 800;
  margin: 1rem 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  flex: 1;
  /* Keep the PIN optically centred now that the QR sets the row height */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pin-with-qr {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  margin: 1rem 0;
}

.pin-hint {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 0.9rem;
}

.join-url {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
  word-break: break-all;
  margin-top: 0.2rem;
}

.qr-block {
  background: #fff;
  border-radius: 18px;
  padding: 0.7rem 0.7rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 5px 5px 0 var(--primary-dark);
  min-width: 250px;
}

.qr-block img {
  width: 230px;
  height: 230px;
  display: block;
  border-radius: 6px;
}

.qr-caption {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4a2c9b;
  letter-spacing: 0.5px;
}

@media (max-width: 540px) {
  .pin-with-qr { flex-direction: column; }
  .qr-block { min-width: 0; align-self: center; }
}

.pin-display .pin-label {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.pin-display .pin-value {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 10px;
  display: block;
  margin-top: 0.3rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255, 217, 61, 0.55);
}

#player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

#player-list li {
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: var(--fg);
  padding: 0.45rem 0.95rem;
  border-radius: 20px;
  font-weight: 700;
  animation: player-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes player-in {
  from { transform: scale(0.5) translateY(-10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.player-count-banner {
  text-align: center;
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0.4rem 0;
}

.player-count-banner strong {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  display: inline-block;
  min-width: 2.5ch;
  text-align: center;
}

.builder-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  align-items: center;
}

.builder-actions .btn.ghost {
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
}

.builder-actions .btn.primary.big {
  margin-left: auto;
}

@media (max-width: 540px) {
  .builder-actions .btn.primary.big { margin-left: 0; width: 100%; }
}

.question-builder {
  background: var(--bg-card-alt);
  padding: 1rem;
  border-radius: 14px;
  margin: 0.75rem 0;
  border: 2px solid var(--border);
  transition: border-color 0.2s ease;
}

.question-builder:focus-within { border-color: var(--primary); }
.qb-head { display: flex; justify-content: space-between; align-items: center; }
.qb-num { font-size: 1.05rem; color: var(--accent); }
.qb-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }
.qb-answer { display: flex; gap: 0.5rem; align-items: center; }
.qb-answer input[type="text"] { flex: 1; }

.qheader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.q-index-chip {
  background: transparent;
  color: var(--fg);
  padding: 0.3rem 0;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}

/* Pulsing LIVE badge, host screen only */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(240, 82, 107, 0.16);
  border: 1px solid rgba(240, 82, 107, 0.5);
  color: #ff8ea0;
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.8rem;
  letter-spacing: 1.4px;
}

.live-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: live-pulse 1.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(240, 82, 107, 0.6); }
  50% { opacity: 0.55; box-shadow: 0 0 0 6px rgba(240, 82, 107, 0); }
}

.qheader-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.timer-ring {
  --ring-pct: 1;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background:
    conic-gradient(var(--cyan) calc(var(--ring-pct) * 360deg), rgba(94, 234, 212, 0.14) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.07), inset 0 0 0 1px rgba(255,255,255,0.05);
  transition: background 0.4s linear;
}

.timer-ring::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--bg-card);
}

.timer-ring .timer-value {
  position: relative;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.timer-ring.low { animation: timer-pulse 0.8s ease-in-out infinite; }
.timer-ring.low { background: conic-gradient(var(--red) calc(var(--ring-pct) * 360deg), rgba(240, 82, 107, 0.2) 0); }
.timer-ring.low .timer-value { color: #ff8ea0; }

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(240, 82, 107, 0.2); }
  50% { transform: scale(1.07); box-shadow: 0 0 0 8px rgba(240, 82, 107, 0.05); }
}

/* The one light surface: question text on cream, like the reference */
.q-text {
  background: var(--cream);
  color: var(--cream-ink);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0.6rem 0 1.1rem;
  line-height: 1.35;
  padding: 1.15rem 1.4rem;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}

.answer {
  padding: 1.1rem 1rem;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18), inset 0 -4px 0 rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
  text-align: left;
  font-family: inherit;
  animation: answer-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.answer:nth-child(1) { animation-delay: 0.05s; }
.answer:nth-child(2) { animation-delay: 0.12s; }
.answer:nth-child(3) { animation-delay: 0.2s; }
.answer:nth-child(4) { animation-delay: 0.28s; }

@keyframes answer-in {
  from { transform: translateY(20px) scale(0.92); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.answer-shape {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Letter badge, matching the reference's A/B/C/D chips */
.answer-letter {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.answer.idx0 { background: linear-gradient(135deg, #f0526b 0%, #c9304c 100%); }
.answer.idx1 { background: linear-gradient(135deg, #3aa9f5 0%, #1f77c9 100%); }
.answer.idx2 { background: linear-gradient(135deg, #ffd452 0%, #e8ac1c 100%); color: var(--cream-ink); }
.answer.idx3 { background: linear-gradient(135deg, #34d399 0%, #16916a 100%); }
.answer.idx2 .answer-letter { background: rgba(0, 0, 0, 0.18); }

.answer.correct {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 34px rgba(255, 212, 82, 0.55);
  animation: pulse-correct 1.2s ease-in-out infinite;
}

@keyframes pulse-correct {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.answer.wrong { opacity: 0.35; filter: grayscale(0.4); }

.play-answers .answer {
  font-size: 1.6rem;
  min-height: 110px;
  justify-content: center;
  cursor: pointer;
  border: none;
}

.play-answers .answer:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.25), inset 0 -4px 0 rgba(0,0,0,0.2);
}

.play-answers .answer:active { transform: translateY(1px); }

.play-answers .answer-shape { width: 56px; height: 56px; }

.answer.flash { animation: answer-flash 0.45s ease-out; }
@keyframes answer-flash {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.6); }
  100% { transform: scale(1); }
}

.tally {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 1rem 0;
}

.tally-bar {
  background: var(--bg-card-alt);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  position: relative;
  overflow: hidden;
}

.tally-bar .tally-shape { display: inline-flex; gap: 0.5rem; align-items: center; }

.tally-bar { border: 1px solid var(--border); }
.tally-bar.idx0 { background: rgba(240, 82, 107, 0.16); color: #ff97a8; }
.tally-bar.idx1 { background: rgba(58, 169, 245, 0.16); color: #8ccdfa; }
.tally-bar.idx2 { background: rgba(255, 212, 82, 0.16); color: #ffe08f; }
.tally-bar.idx3 { background: rgba(52, 211, 153, 0.16); color: #8ce7c5; }

.tally-bar.winner {
  outline: 2px solid var(--green);
  outline-offset: -2px;
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.28);
}

.tally-bar .count {
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: end;
  gap: 0.8rem;
  margin: 1.4rem 0 1rem;
}

.podium-step {
  background: linear-gradient(180deg, var(--bg-inset), var(--bg-card-alt));
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 1rem 0.6rem;
  text-align: center;
  position: relative;
  animation: podium-rise 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.podium-step:nth-child(1) { animation-delay: 0.25s; }
.podium-step:nth-child(2) { animation-delay: 0s; }
.podium-step:nth-child(3) { animation-delay: 0.5s; }

@keyframes podium-rise {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.podium-rank {
  font-size: 2.2rem;
  font-weight: 900;
  margin-bottom: 0.2rem;
}

.podium-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--fg);
  margin: 0.3rem 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.podium-step.gold {
  padding-top: 1.5rem;
  height: 200px;
  border-color: rgba(255, 212, 82, 0.5);
  box-shadow: 0 0 30px rgba(255, 212, 82, 0.25);
}
.podium-step.gold .podium-rank { color: var(--gold); filter: drop-shadow(0 0 8px rgba(255, 212, 82, 0.6)); }
.podium-step.silver { height: 160px; }
.podium-step.silver .podium-rank { color: var(--silver); }
.podium-step.bronze { height: 140px; }
.podium-step.bronze .podium-rank { color: var(--bronze); }

.medal { display: inline-block; font-size: 2rem; line-height: 1; }

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  font-weight: 800;
  font-size: 1.05rem;
  position: relative;
  overflow: hidden;
  animation: lb-in 0.45s ease-out backwards;
}

.leaderboard li:nth-child(1) { animation-delay: 0.05s; }
.leaderboard li:nth-child(2) { animation-delay: 0.12s; }
.leaderboard li:nth-child(3) { animation-delay: 0.19s; }
.leaderboard li:nth-child(4) { animation-delay: 0.26s; }
.leaderboard li:nth-child(5) { animation-delay: 0.33s; }

@keyframes lb-in {
  from { transform: translateX(-12px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.leaderboard li::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--bar-pct, 0%);
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.42), rgba(139, 92, 246, 0.12));
  z-index: 0;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.leaderboard li > * { position: relative; z-index: 1; }

.leaderboard .rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.95rem;
}

.leaderboard li.rank1 .rank { background: linear-gradient(135deg, #ffd452, #e8a81c); color: #3a2800; }
.leaderboard li.rank2 .rank { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #1f2937; }
.leaderboard li.rank3 .rank { background: linear-gradient(135deg, #e09456, #b4642c); color: #2c1400; }
.leaderboard li.rank1 { border-color: rgba(255, 212, 82, 0.45); }
.leaderboard li.rank2 { border-color: rgba(226, 232, 240, 0.28); }
.leaderboard li.rank3 { border-color: rgba(224, 148, 86, 0.35); }

.leaderboard .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard .score { font-variant-numeric: tabular-nums; font-size: 1.1rem; color: var(--accent); }

.result-banner {
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0;
}

.result-banner.correct {
  color: var(--green);
  animation: bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-banner.wrong {
  color: var(--red);
  animation: shake 0.55s;
}

@keyframes bounce {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.score-big {
  font-size: 2.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  display: block;
  margin: 0.2rem 0;
}

.score-row {
  display: flex;
  justify-content: space-around;
  margin: 1.2rem 0;
}

.score-block {
  text-align: center;
}

.score-block .label {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.answer-progress {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.answer-progress .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

.mascot {
  --mascot-size: 180px;
  width: var(--mascot-size);
  height: var(--mascot-size);
  display: inline-block;
  margin: 0.4rem auto 0.8rem;
  position: relative;
  filter: drop-shadow(0 14px 24px rgba(109, 40, 217, 0.45));
}

.mascot-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mascot-body-group {
  animation: mascot-bob 3.2s ease-in-out infinite;
  transform-origin: 110px 195px;
}

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-6px) scale(1.02, 0.98); }
  70% { transform: translateY(3px) scale(0.98, 1.02); }
}

.mascot-shadow {
  animation: mascot-shadow 3.2s ease-in-out infinite;
  transform-origin: 110px 200px;
}

@keyframes mascot-shadow {
  0%, 100% { transform: scaleX(1); opacity: 0.25; }
  40% { transform: scaleX(0.78); opacity: 0.15; }
  70% { transform: scaleX(1.05); opacity: 0.28; }
}

.mascot-arm {
  transform-origin: center 105px;
  animation: mascot-sway 4s ease-in-out infinite;
}

.mascot-arm-right { animation-delay: -2s; }

@keyframes mascot-sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(6deg); }
}

.mascot-svg.blink .mascot-eye { transform: scaleY(0.08); }
.mascot-eye { transition: transform 0.12s ease; transform-origin: center 100px; }

.mascot-svg.waving .mascot-arm-right {
  animation: mascot-wave 0.9s ease-in-out 2;
  transform-origin: 180px 110px;
}

@keyframes mascot-wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-45deg); }
  75% { transform: rotate(-30deg); }
}

.mascot-svg.cheering .mascot-body-group { animation: mascot-cheer 0.55s ease-in-out 3; }

@keyframes mascot-cheer {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-14px) rotate(2deg); }
}

.mascot-mouth { transition: opacity 0.15s ease; }
.mascot-mouth-open.hidden { display: none; }

.lobby-mascot-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
}

.emoji-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.6rem 0 0.2rem;
  transition: opacity 0.2s ease;
}

.emoji-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.emoji-header .emoji-bar-label { margin: 0; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  flex-direction: row;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb { background: var(--accent-ink); }

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.4);
}

.emoji-bar.disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(1);
}

.emoji-btn {
  background: var(--bg-inset);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  width: 54px;
  height: 54px;
  font-size: 1.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.15s ease;
  padding: 0;
  font-family: inherit;
  user-select: none;
}

.emoji-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 18px rgba(168, 85, 247, 0.35);
  filter: brightness(1.05);
}

.emoji-btn:active { transform: scale(0.92); }

.emoji-bar-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin: 0.5rem 0 0;
  text-transform: uppercase;
  font-weight: 700;
}

.emoji-stream {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  overflow: hidden;
}

.floating-emoji {
  position: absolute;
  font-size: 2.4rem;
  bottom: 0;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
  animation: float-up 3.6s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

.floating-emoji .from {
  display: block;
  font-size: 0.7rem;
  font-family: 'Inter', sans-serif;
  color: #fff;
  background: rgba(26, 11, 61, 0.7);
  padding: 1px 8px;
  border-radius: 10px;
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-weight: 700;
  opacity: 0.85;
}

@keyframes float-up {
  0% {
    transform: translate3d(0, 20px, 0) scale(0.5) rotate(-8deg);
    opacity: 0;
  }
  12% {
    transform: translate3d(calc(var(--sway, 0px) * 0.3), -40px, 0) scale(1.15) rotate(4deg);
    opacity: 1;
  }
  85% {
    transform: translate3d(var(--sway, 0px), -75vh, 0) scale(1.05) rotate(-4deg);
    opacity: 0.95;
  }
  100% {
    transform: translate3d(calc(var(--sway, 0px) * 1.2), -92vh, 0) scale(1.2) rotate(0deg);
    opacity: 0;
  }
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.locked-anim {
  font-size: 4rem;
  animation: spin-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}

@keyframes spin-in {
  from { transform: rotate(-180deg) scale(0); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}

.waiting-spinner {
  display: inline-block;
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 540px) {
  .qb-answers { grid-template-columns: 1fr; }
  .answers { grid-template-columns: 1fr 1fr; }
  .title { font-size: 2.6rem; }
  .pin-display .pin-value { font-size: 2.2rem; letter-spacing: 6px; }
  .podium { gap: 0.4rem; }
  .podium-step { padding: 0.7rem 0.3rem; }
}
