:root {
  color-scheme: dark;
  --navy: #07162f;
  --navy-deep: #041024;
  --blue: #0b4dd8;
  --cyan: #27d7ff;
  --gold: #ff5c00;
  --white: #f7fbff;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --emerald: #6ee7b7;
  --red: #fca5a5;
  --red-bg: rgba(239, 68, 68, 0.15);
  --emerald-bg: rgba(52, 211, 153, 0.18);
  --border: rgba(255, 255, 255, 0.12);
  --panel-bg: rgba(5, 19, 43, 0.78);
}

* { box-sizing: border-box; }

* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

input, textarea, select {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

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

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--white);
  background:
    radial-gradient(circle at 20% 10%, rgba(39, 215, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 90% 0%, rgba(255, 92, 0, 0.12), transparent 22rem),
    linear-gradient(145deg, #07162f 0%, #081d44 46%, #041024 100%);
  min-height: 100vh;
}

body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(39, 215, 255, 0.72) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 92, 0, 0.6) 0 1px, transparent 1.5px);
  background-position: 16px 24px, 80px 90px, 140px 40px;
  background-size: 130px 130px, 190px 190px, 240px 240px;
  opacity: 0.5;
  animation: star-drift 42s linear infinite;
}

body::after {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.75) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(125, 211, 252, 0.48) 0 1px, transparent 1.7px);
  background-position: 42px 80px, 120px 20px;
  background-size: 170px 170px, 260px 260px;
  opacity: 0.32;
  animation: star-twinkle 3.8s ease-in-out infinite alternate;
}

button, input, select { font: inherit; }

.app {
  min-height: 100vh;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  width: 100%;
  max-width: 56rem;
}

.glass-panel {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  border-radius: 16px;
  padding: 24px;
  margin-inline: auto;
}
@media (min-width: 640px) {
  .glass-panel { padding: 40px; }
}

.logo { height: auto; width: 192px; }
@media (min-width: 640px) { .logo { width: 224px; } }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}

.eyebrow-sm {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; font-weight: 900; }
.title-xl { font-size: 2.5rem; line-height: 1.15; }
.title-lg { font-size: 1.875rem; }
.title-md { font-size: 1.5rem; }
@media (min-width: 640px) {
  .title-xl { font-size: 3.5rem; }
}

.lead {
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--slate-200);
}

.feature-grid {
  margin-top: 28px;
  display: grid;
  gap: 12px;
}
@media (min-width: 640px) { .feature-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.feature-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  padding: 16px;
}

.feature-card svg { color: var(--gold); }
.feature-card h2 {
  margin-top: 12px;
  font-size: 1rem;
  color: var(--white);
}
.feature-card p {
  margin: 4px 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--slate-300);
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn-primary {
  background: var(--cyan);
  color: var(--navy);
  width: 100%;
  margin-top: 32px;
  font-size: 1.1rem;
}
.btn-primary:hover { background: white; transform: translateY(-1px); }
.btn-primary:focus { outline: none; box-shadow: 0 0 0 4px rgba(39, 215, 255, 0.3); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--white);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.16); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.form { margin-top: 24px; display: grid; gap: 16px; }
.form label { display: block; }
.form label > span {
  display: block;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--slate-200);
  margin-bottom: 8px;
}
.form input, .form select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  color: var(--white);
  outline: none;
}
.form input:focus, .form select:focus {
  box-shadow: 0 0 0 4px rgba(39, 215, 255, 0.4);
}
.form select option { background: var(--navy); }

.consent {
  display: flex;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--slate-200);
}
.consent input { width: 16px; height: 16px; margin-top: 4px; accent-color: var(--cyan); }

.error {
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.18);
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fee2e2;
}

.waiting-pulse {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 999px;
  background: rgba(39, 215, 255, 0.15);
}
.waiting-pulse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--cyan);
  animation: pulse-ring 1.6s ease-out infinite;
}
.waiting-pulse svg { width: 48px; height: 48px; color: var(--cyan); }

.waiting-stack {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 24px;
}

.participant-count {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 24px;
}
.participant-count p { margin: 0; }
.participant-count .num {
  margin-top: 4px;
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--gold);
}

.countdown-stack {
  display: grid;
  place-items: center;
  gap: 24px;
  text-align: center;
}

.progress-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 160px;
  height: 160px;
  border-radius: 999px;
}
.progress-ring .inner {
  width: 128px;
  height: 128px;
  border-radius: 999px;
  background: var(--navy);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.progress-ring .value {
  font-size: 3rem;
  font-weight: 900;
  color: var(--white);
  line-height: 1;
  text-align: center;
}
.progress-ring .label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--slate-300);
  margin-top: 4px;
  text-align: center;
  text-indent: 0.18em;
}

.quiz-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (min-width: 640px) {
  .quiz-header { flex-direction: row; align-items: center; justify-content: space-between; }
}

.quiz-image {
  margin-top: 24px;
  max-height: 18rem;
  width: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.alternatives {
  margin-top: 28px;
  display: grid;
  gap: 12px;
}

.alt {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  padding: 12px 16px;
  color: var(--white);
  text-align: left;
  cursor: pointer;
  min-height: 4rem;
  font: inherit;
  transition: background 0.2s, border-color 0.2s;
}
.alt:hover { border-color: rgba(39, 215, 255, 0.7); background: rgba(39, 215, 255, 0.1); }
.alt:disabled { cursor: not-allowed; opacity: 0.95; }
.alt.is-selected { border-color: rgba(39, 215, 255, 0.7); background: rgba(39, 215, 255, 0.1); }
.alt.is-correct { border-color: rgba(110, 231, 183, 0.8); background: rgba(52, 211, 153, 0.2); }
.alt.is-wrong { border-color: rgba(252, 165, 165, 0.8); background: rgba(239, 68, 68, 0.22); }

.alt .badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--cyan);
  color: var(--navy);
  font-weight: 900;
  font-size: 1.05rem;
}
.alt.is-correct .badge { background: var(--emerald); color: #064e3b; }
.alt.is-wrong .badge { background: var(--red); color: #7f1d1d; }
.alt .body { flex: 1; font-weight: 600; line-height: 1.4; }
.alt .check { color: var(--gold); }
.alt .check.muted { color: var(--slate-500); }

.feedback {
  margin-top: 20px;
  text-align: center;
  border: 1px solid var(--border);
  background: rgba(7, 22, 47, 0.75);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 900;
}

.explanation {
  margin-top: 16px;
  border-radius: 10px;
  border: 1px solid rgba(252, 165, 165, 0.4);
  background: rgba(127, 29, 29, 0.3);
  padding: 16px;
}
.explanation .eyebrow-sm { color: #fecaca; }
.explanation p { margin: 8px 0 0; font-size: 0.875rem; line-height: 1.5; color: #fee2e2; }

.panel.shake { animation: shake 0.38s ease-in-out; }
.panel.bad { border-color: rgba(252, 165, 165, 0.6); background: rgba(239, 68, 68, 0.15); }
.panel.good { border-color: rgba(110, 231, 183, 0.6); background: rgba(52, 211, 153, 0.15); }

.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.ranking-header .trophy {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: var(--gold);
  color: var(--navy);
  border-radius: 12px;
}
.ranking-table {
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}
.ranking-row {
  display: grid;
  grid-template-columns: 70px minmax(220px, 1fr) 120px 100px 110px;
  gap: 8px;
  padding: 12px 12px;
  align-items: center;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}
.ranking-row.head {
  border-top: 0;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 900;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--slate-300);
}
.ranking-row .pos {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 900;
  color: var(--gold);
}
.ranking-row .pos.gold { color: #ffd700; }
.ranking-row .name { font-weight: 800; color: var(--white); }
.ranking-row .year { color: var(--slate-300); }
.ranking-row .correct { font-weight: 900; color: var(--white); }
.ranking-row .time { font-weight: 600; color: var(--slate-200); }

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

.music-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(7, 22, 47, 0.85);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 35px rgba(39, 215, 255, 0.22);
}
.music-toggle:hover { background: rgba(255, 255, 255, 0.15); }
.music-toggle svg { width: 20px; height: 20px; }
.music-toggle .badge {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 18px;
  height: 18px;
  background: var(--gold);
  color: var(--navy);
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.music-toggle .badge svg { width: 12px; height: 12px; }

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.confetti-piece {
  position: absolute;
  top: -24px;
  border-radius: 2px;
  animation: confetti-fall 1500ms ease-out forwards;
}

.admin {
  min-height: 100vh;
  padding: 40px 16px;
}
.admin-card { max-width: 32rem; margin: 0 auto; }
.admin-actions {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}
@media (min-width: 640px) { .admin-actions { grid-template-columns: 1fr 1fr; } }
.admin-message {
  margin-top: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-100);
}

.icon-inline { display: inline-flex; vertical-align: middle; }

@keyframes pulse-ring {
  0% { transform: scale(0.92); opacity: 0.85; }
  100% { transform: scale(1.18); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}
@keyframes confetti-fall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate3d(var(--confetti-drift, 0), 105vh, 0) rotate(720deg); opacity: 0; }
}
@keyframes star-drift {
  from { background-position: 16px 24px, 80px 90px, 140px 40px; }
  to { background-position: 16px 154px, 80px 280px, 140px 280px; }
}
@keyframes star-twinkle {
  from { opacity: 0.22; }
  to { opacity: 0.48; }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  .confetti-piece { animation: none; display: none; }
}
