:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1e242d;
  --line: #2a313c;
  --text: #e8ecf1;
  --muted: #93a0b0;
  --gold: #ffcb45;
  --gold-2: #ffb000;
  --green: #35c26b;
  --red: #ff5d5d;
  --accent: #4c8dff;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1b222c 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: rgba(14,17,22,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.whoami { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 18px 16px 64px; }
.loading { color: var(--muted); text-align: center; padding: 40px; }

h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 20px; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 16px; }

.tabs { display: flex; gap: 8px; margin: 0 0 18px; flex-wrap: wrap; }
.tab {
  flex: 1; min-width: 96px; text-align: center; padding: 11px 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14px; user-select: none;
}
.tab.active { color: #17110a; background: linear-gradient(180deg, var(--gold), var(--gold-2)); border-color: transparent; }

button, .btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 12px;
  padding: 12px 16px; color: #17110a;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
}
button.secondary, .btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--red); border: 1px solid #4a2630; padding: 8px 12px; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.block { width: 100%; }

input, select {
  font: inherit; width: 100%; padding: 12px 12px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; }
.field { margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* Login */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-wrap .card { padding: 22px; }

/* Leaderboard */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li {
  display: flex; align-items: center; gap: 12px; padding: 11px 6px;
  border-bottom: 1px solid var(--line);
}
.lb li:last-child { border-bottom: 0; }
.rank {
  flex: 0 0 34px; height: 34px; width: 34px; display: grid; place-items: center;
  border-radius: 10px; font-weight: 800; background: var(--panel-2); color: var(--muted);
}
.lb li.top1 .rank { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #17110a; }
.lb li.top2 .rank { background: #c7ccd4; color: #17110a; }
.lb li.top3 .rank { background: #cd7f45; color: #17110a; }
.lb .nm { flex: 1; font-weight: 600; }
.lb .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb .pts small { color: var(--muted); font-weight: 500; margin-left: 4px; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.open { background: #123324; color: var(--green); }
.pill.closed { background: #2a2230; color: var(--muted); }
.pill.done { background: #10233f; color: var(--accent); }

.round-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); }
.round-row:last-child { border-bottom: 0; }
.round-row .lbl { font-weight: 600; }

.empty { color: var(--muted); text-align: center; padding: 18px; }

/* Modal / vote popup */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,6,10,.7); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px; z-index: 20;
}
.modal {
  width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { padding: 20px 20px 6px; text-align: center; }
.award-badge {
  display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  font-size: 28px; font-weight: 900; color: #17110a; margin: 0 auto 8px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2)); box-shadow: 0 6px 18px rgba(255,176,0,.35);
}
.award-title { font-size: 20px; font-weight: 800; }
.award-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pick-list { padding: 12px; max-height: 46vh; overflow: auto; }
.pick {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 14px; margin: 6px 0; border-radius: 12px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); font-weight: 600;
}
.pick:active { transform: scale(.99); }
.pick .av {
  flex: 0 0 34px; height: 34px; width: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #2c3540; color: var(--gold); font-weight: 800;
}
.modal-foot { padding: 12px 16px 18px; display: flex; gap: 10px; }
.steps { display: flex; gap: 6px; justify-content: center; padding: 8px 0 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--gold); }
.dot.done { background: var(--green); }

.review-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; }
.review-row .p { font-weight: 800; width: 30px; color: var(--gold); }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #22303f; color: var(--text); padding: 12px 18px; border-radius: 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow); z-index: 40; max-width: 90vw;
}
.toast.err { background: #3a1f26; border-color: #5b2b34; }
.hidden { display: none !important; }

.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.admin-list li:last-child { border-bottom: 0; }
.admin-list .nm { flex: 1; font-weight: 600; }
.admin-list .un { color: var(--muted); font-size: 13px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.tag { font-size: 12px; color: var(--muted); }

/* Invite / QR card */
.invite-card { display: flex; gap: 16px; align-items: center; }
.invite-qr { background: #fff; border-radius: 12px; padding: 8px; flex: 0 0 auto; line-height: 0; }
.invite-qr img { display: block; image-rendering: pixelated; border-radius: 4px; }
.invite-body { flex: 1; min-width: 0; }
.invite-url { margin-top: 8px; display: inline-block; font-weight: 800; color: #17110a;
  background: linear-gradient(180deg, var(--gold), var(--gold-2)); padding: 6px 14px; border-radius: 999px; }

/* Entrance animations */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes rowin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes dropin { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.card { animation: rowin .32s ease backwards; }
.lb li { animation: rowin .34s ease backwards; }
.lb li:nth-child(1) { animation-delay: .03s; } .lb li:nth-child(2) { animation-delay: .06s; }
.lb li:nth-child(3) { animation-delay: .09s; } .lb li:nth-child(4) { animation-delay: .12s; }
.lb li:nth-child(5) { animation-delay: .15s; } .lb li:nth-child(6) { animation-delay: .18s; }
@media (prefers-reduced-motion: reduce) { *, .card, .lb li { animation: none !important; } }

/* Confetti + MVP reveal */
.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.reveal-overlay {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  background: radial-gradient(circle at 50% 22%, #2a1f45 0%, #0b0710 72%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  animation: fadein .3s ease;
}
.reveal-skip { position: absolute; top: 16px; right: 16px; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.reveal-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 44vh; justify-content: center; }
.reveal-kicker { letter-spacing: 6px; color: var(--gold); font-weight: 800; font-size: 15px; }
.reveal-title { font-size: 46px; font-weight: 900; line-height: 1;
  background: linear-gradient(180deg, var(--gold), var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.reveal-sub { color: var(--muted); }
.reveal-place { font-size: 22px; font-weight: 800; color: var(--muted); letter-spacing: 3px; animation: dropin .45s ease; }
.reveal-place.mvp { color: var(--gold); font-size: 28px; }
.reveal-name { font-size: 13vw; font-weight: 900; line-height: 1.02; animation: pop .5s cubic-bezier(.2,1.5,.4,1); }
.reveal-name.mvp { background: linear-gradient(180deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 60px rgba(255,203,69,.35); }
@media (min-width: 560px) { .reveal-name { font-size: 64px; } }
.reveal-pts { font-size: 20px; color: var(--gold); font-weight: 800; animation: fadein .8s ease; }
.reveal-controls { margin-top: 28px; }
.reveal-next { font-size: 18px; padding: 15px 30px; border-radius: 14px; }

/* Welcome flash (first login) */
.reveal-overlay.fade-out { opacity: 0; transition: opacity .42s ease; }
.welcome-flash { cursor: pointer; }
.welcome-to { font-size: 26px; letter-spacing: 1px; -webkit-text-fill-color: var(--muted); color: var(--muted); background: none; margin-bottom: -2px; }
.welcome-name { font-size: 16vw; }
@media (min-width: 560px) { .welcome-name { font-size: 76px; } }

/* Avatars */
.av { flex: 0 0 34px; height: 34px; width: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #2c3540; color: var(--gold); font-weight: 800; font-size: 13px; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb .av { margin-right: 2px; }
.header-av { width: 30px; height: 30px; flex: 0 0 30px; cursor: pointer; border: 1px solid var(--line); }
.reveal-avatar { width: 42vw; max-width: 210px; height: 42vw; max-height: 210px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: #2c3540; color: var(--gold); font-weight: 900; font-size: 56px;
  margin-bottom: 8px; box-shadow: 0 12px 44px rgba(0,0,0,.45); animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
.reveal-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reveal-avatar.mvp { border: 3px solid var(--gold); box-shadow: 0 0 70px rgba(255,203,69,.5); }

/* Selfie capture */
.photo-prompt { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.selfie-cam { padding: 12px; }
.selfie-cam video { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 16px; background: #000; transform: scaleX(-1); display: block; }
.selfie-preview { padding: 12px; }
.selfie-preview img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 16px; display: block; }

/* Scrolling player marquee (big selfies) */
.ticker {
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); margin: 0 0 16px; padding: 14px 0; box-shadow: var(--shadow);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}
.ticker-track { display: flex; width: max-content; animation: marquee var(--dur, 30s) linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-right: 30px; }
.ticker-av {
  width: 88px; height: 88px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: #2c3540; color: var(--gold); font-weight: 900; font-size: 30px;
  border: 2px solid var(--line); box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.ticker-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ticker-name { font-weight: 700; font-size: 14px; white-space: nowrap; color: var(--text); }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } }
