:root {
  --bg: #070914;
  --bg-2: #101827;
  --card: rgba(255,255,255,0.08);
  --card-strong: rgba(255,255,255,0.14);
  --line: rgba(255,255,255,0.14);
  --text: #f8fafc;
  --muted: #a7b0c3;
  --accent: #f97316;
  --accent-2: #22d3ee;
  --good: #22c55e;
  --bad: #ef4444;
  --warning: #facc15;
  --shadow: 0 24px 80px rgba(0,0,0,0.45);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(34, 211, 238, 0.22), transparent 28rem),
    radial-gradient(circle at 85% 12%, rgba(249, 115, 22, 0.22), transparent 28rem),
    linear-gradient(135deg, #050712 0%, #0b1020 52%, #111827 100%);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.track-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(120deg, transparent 0 47%, rgba(255,255,255,0.045) 48% 52%, transparent 53% 100%),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 160px 160px, 56px 56px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 95%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 20, 0.72);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: .8rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #facc15);
  box-shadow: 0 14px 32px rgba(249,115,22,.35);
}
.brand strong { display: block; letter-spacing: -0.03em; }
.brand small { color: var(--muted); display: block; margin-top: .05rem; }
.nav-links { display: flex; align-items: center; gap: .4rem; }
.nav-links a {
  padding: .65rem .85rem;
  border-radius: 999px;
  color: var(--muted);
  transition: .2s ease;
}
.nav-links a:hover { color: var(--text); background: var(--card); }

.app-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 1.3rem;
  align-items: stretch;
  margin-top: 1rem;
}
.card, .panel, .loading-card {
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.055));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.card { padding: clamp(1.3rem, 4vw, 2.3rem); }
.panel { padding: 1.1rem; }
.loading-card { padding: 2rem; margin-top: 3rem; color: var(--muted); }

.kicker {
  display: inline-flex;
  gap: .5rem;
  align-items: center;
  padding: .45rem .75rem;
  border: 1px solid rgba(34, 211, 238, .35);
  border-radius: 999px;
  background: rgba(34, 211, 238, .10);
  color: #c9fbff;
  font-weight: 700;
  font-size: .88rem;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.045em; }
h1 { font-size: clamp(3rem, 8vw, 6.8rem); line-height: .88; margin: 1rem 0; }
h2 { font-size: clamp(1.7rem, 4vw, 3rem); line-height: 1; }
h3 { font-size: 1.2rem; }
p { color: var(--muted); line-height: 1.65; }
.lead { font-size: 1.12rem; max-width: 68ch; }
.accent-text { color: var(--accent); }

.cta-row { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.5rem; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: .9rem 1.1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  cursor: pointer;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--line);
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
  font-weight: 800;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.16); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(135deg, #f97316, #facc15); color: #111827; border-color: transparent; box-shadow: 0 18px 34px rgba(249,115,22,.28); }
.btn.danger { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .45); }
.btn.good { background: rgba(34, 197, 94, .18); border-color: rgba(34, 197, 94, .45); }
.btn.small { padding: .6rem .75rem; min-height: 36px; font-size: .9rem; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
  padding: 1.1rem;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.stat-card strong { display: block; font-size: 1.8rem; }
.stat-card span { color: var(--muted); font-size: .92rem; }

.form { display: grid; gap: .9rem; margin-top: 1rem; }
label { display: grid; gap: .38rem; color: var(--muted); font-size: .92rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: rgba(3, 7, 18, .64);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .9rem 1rem;
  outline: none;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(34,211,238,.12); }
select option { background: #101827; color: var(--text); }

.quiz-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .18em;
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 950;
  padding: .35rem .7rem;
  border-radius: 18px;
  background: rgba(250,204,21,.12);
  border: 1px solid rgba(250,204,21,.35);
  color: #fef3c7;
}

.qr-box {
  background: #fff;
  color: #111827;
  border-radius: 24px;
  padding: 1rem;
  display: grid;
  place-items: center;
  min-height: 220px;
}
.qr-fallback { color: #111827; text-align: center; word-break: break-all; }

.round-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.06);
}
.question-list { display: grid; gap: .75rem; margin-top: 1rem; }
.question-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .8rem;
  padding: .85rem;
  background: rgba(0,0,0,.18);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.qnum {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(34,211,238,.15);
  color: #c9fbff;
  font-weight: 900;
}

.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: .78rem .85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #e2e8f0; background: rgba(255,255,255,.06); font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; }
td { color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.rank { font-weight: 950; color: var(--text); }
.score { font-size: 1.25rem; font-weight: 950; color: var(--text); }

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}
.podium-card {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.3rem;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.05));
}
.podium-card.first { min-height: 230px; border-color: rgba(250,204,21,.48); box-shadow: 0 20px 60px rgba(250,204,21,.1); }
.podium-card .emoji { font-size: 2.3rem; }
.podium-card strong { font-size: 1.3rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border-radius: 999px;
  padding: .38rem .68rem;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: .86rem;
}
.status-pill.open { color: #bbf7d0; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.status-pill.closed { color: #fecaca; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); }

.admin-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 1rem; align-items: start; }
.admin-sidebar { position: sticky; top: 92px; display: grid; gap: 1rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .8rem; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(420px, calc(100% - 2rem));
  padding: 1rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, .94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateY(140%);
  opacity: 0;
  transition: .25s ease;
  z-index: 40;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.good { border-color: rgba(34,197,94,.5); }
.toast.bad { border-color: rgba(239,68,68,.5); }

.footer-note { color: var(--muted); font-size: .88rem; margin-top: 1rem; }
.big-screen { width: min(1500px, calc(100% - 2rem)); }
.big-screen h1 { font-size: clamp(4rem, 9vw, 9rem); }
.big-screen .lead { font-size: clamp(1.1rem, 2vw, 1.7rem); }
.big-screen .question-item { font-size: clamp(1rem, 1.6vw, 1.45rem); }

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  background: hsl(var(--hue), 90%, 60%);
  animation: fall 2.4s linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(740deg); opacity: .4; }
}

@media (max-width: 880px) {
  .hero, .grid.two, .grid.three, .grid.four, .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .nav-links { display: none; }
  .podium { grid-template-columns: 1fr; }
  table { min-width: 720px; }
}

@media print {
  .topbar, .cta-row, .admin-sidebar, .toast { display: none !important; }
  body { background: #fff; color: #111; }
  .card, .panel { box-shadow: none; border-color: #ddd; background: #fff; }
}
