:root {
  color-scheme: dark;
  --ink: #fbf9ff;
  --muted: #b8b7d4;
  --ground: #0b0920;
  --surface: #15122d;
  --surface-raised: #1c1839;
  --line: rgba(174, 175, 235, .18);
  --violet: #786cff;
  --violet-hot: #b49aff;
  --blue: #69c7ff;
  --wine: #9c3d6b;
  --pink: #ff8fbb;
  --mint: #63dfbd;
  --danger: #ff719d;
  --focus: #69c7ff;
  --radius: 14px;
  font-family: Nunito, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--ground); scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 7%, rgba(120, 108, 255, .23), transparent 28%),
    radial-gradient(circle at 5% 72%, rgba(156, 61, 107, .2), transparent 29%),
    radial-gradient(circle at 55% 105%, rgba(105, 199, 255, .1), transparent 33%),
    var(--ground);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection { color: #130d21; background: var(--mint); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: #4b3e67; border: 2px solid var(--ground); border-radius: 999px; }

.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ambient span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .14; }
.ambient span:nth-child(1) { width: 38rem; height: 38rem; background: var(--violet); top: -26rem; right: -8rem; }
.ambient span:nth-child(2) { width: 24rem; height: 24rem; background: #3d8cff; bottom: -16rem; left: -8rem; }
.ambient span:nth-child(3) { width: 16rem; height: 16rem; background: var(--mint); top: 44%; right: -14rem; }

.topbar {
  width: min(1180px, calc(100% - 40px));
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: var(--ground); background: linear-gradient(145deg, var(--blue), var(--violet-hot)); font: 700 21px/1 Fredoka, sans-serif; transform: rotate(-4deg); }
.live-state { display: flex; align-items: center; gap: 8px; color: var(--mint); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.live-dot { width: 9px; height: 9px; background: var(--mint); border-radius: 50%; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 36px; }

.command-stage { min-height: 430px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr); align-items: center; gap: clamp(46px, 7vw, 100px); }
.round-label { margin: 0 0 14px; color: var(--violet-hot); font-weight: 700; font-size: .92rem; text-transform: uppercase; letter-spacing: .1em; }
h1, h2 { font-family: Fredoka, sans-serif; text-wrap: balance; }
h1 { max-width: 780px; margin: 0; font-size: clamp(3.5rem, 7.3vw, 6rem); line-height: .91; letter-spacing: -.035em; text-transform: uppercase; }
.stage-subtitle { max-width: 62ch; margin: 24px 0 28px; color: var(--muted); line-height: 1.65; font-size: 1rem; }

.command-copy { width: min(100%, 440px); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 11px 12px 11px 18px; border: 1px solid #514368; border-radius: var(--radius); background: #171321; cursor: pointer; text-align: left; transition: background .2s ease, transform .2s ease, border-color .2s ease; }
.command-copy:hover { background: #1d1829; border-color: #776493; transform: translateY(-2px); }
.command-copy span:first-child { color: var(--muted); font-size: .84rem; }
.command-copy strong { font-family: Fredoka, sans-serif; font-size: 1.45rem; letter-spacing: .01em; }
.copy-feedback { padding: 8px 12px; border-radius: 9px; color: var(--ground); background: var(--blue); font-size: .82rem; font-weight: 800; }

.counter-reel { position: relative; min-height: 310px; display: flex; flex-direction: column; justify-content: center; padding: 40px 44px 50px; color: var(--ground); background: linear-gradient(145deg, var(--violet), var(--pink)); overflow: hidden; box-shadow: 0 28px 65px rgba(0, 0, 0, .34); transform: rotate(1.5deg); }
.counter-reel::before, .counter-reel::after { content: ''; position: absolute; left: 0; width: 100%; height: 13px; background: radial-gradient(circle at 6px -1px, transparent 6px, #0a0811 6.5px) 0 0 / 24px 13px repeat-x; }
.counter-reel::before { top: 0; transform: rotate(180deg); }
.counter-reel::after { bottom: 0; }
.counter-number { font: 700 clamp(7rem, 16vw, 12rem)/.72 Fredoka, sans-serif; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.counter-caption { margin-top: 28px; font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.reel-edge { position: absolute; width: 120px; height: 120px; right: -58px; bottom: -52px; border: 22px solid rgba(255,255,255,.12); border-radius: 50%; }

.winner-strip { min-height: 92px; margin: 18px 0 64px; padding: 22px 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.winner-strip > div { display: grid; gap: 4px; }
.winner-label { color: var(--mint); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.winner-strip strong { font-size: 1.1rem; }
.winner-detail { color: var(--muted); font-size: .88rem; text-align: right; }

.roster-section { min-height: 380px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 22px; }
.section-heading h2 { margin: 0 0 5px; font-size: clamp(2.1rem, 4vw, 3rem); line-height: 1; text-transform: uppercase; letter-spacing: -.02em; }
.section-heading p { margin: 0; color: var(--muted); }
.admin-actions { display: flex; gap: 10px; }
.primary-action, .secondary-action { min-height: 46px; border: 0; border-radius: 11px; padding: 0 18px; font-weight: 700; cursor: pointer; transition: transform .2s ease, background .2s ease, opacity .2s ease; }
.primary-action { color: var(--ground); background: linear-gradient(120deg, var(--violet-hot), var(--pink)); }
.primary-action:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-2px); }
.secondary-action { color: var(--muted); background: var(--surface-raised); }
.secondary-action:hover:not(:disabled) { color: var(--ink); background: #251f34; }
button:disabled { opacity: .34; cursor: not-allowed; }

.roster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border-radius: var(--radius); overflow: hidden; }
.ticket { min-width: 0; min-height: 72px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; background: var(--surface); animation: ticket-in .44s cubic-bezier(.22,1,.36,1) both; }
.ticket-index { flex: 0 0 auto; color: var(--blue); font: 700 1rem/1 Fredoka, sans-serif; font-variant-numeric: tabular-nums; }
.ticket-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.empty-state { grid-column: 1 / -1; min-height: 250px; padding: 28px; display: flex; align-items: center; justify-content: center; gap: 20px; background: var(--surface); color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }
.empty-state p { margin: 0; }
.empty-state code { color: var(--violet-hot); font-weight: 700; }
.empty-ticket { width: 48px; height: 62px; display: grid; place-items: center; color: var(--ground); background: var(--muted); font: 700 1.6rem/1 Fredoka, sans-serif; opacity: .7; }

footer { margin-top: 28px; padding-top: 24px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.panel-access { border: 0; padding: 8px 0; color: var(--violet-hot); background: transparent; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }

dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 16px; background: #12101c; box-shadow: 0 30px 100px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(5, 3, 10, .82); backdrop-filter: blur(8px); }
.access-dialog { width: min(430px, calc(100% - 30px)); padding: 0; }
.access-dialog form { position: relative; padding: 30px; }
.access-dialog h2 { margin: 0 0 10px; font-size: 2rem; text-transform: uppercase; }
.access-dialog p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.access-dialog label { display: block; margin-bottom: 8px; font-size: .83rem; font-weight: 700; }
.access-dialog input { width: 100%; height: 48px; padding: 0 12px; color: var(--ink); border: 1px solid #514368; border-radius: 10px; background: #0c0a13; caret-color: var(--mint); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: #211b2d; font-size: 1.4rem; cursor: pointer; }
.full { width: 100%; margin-top: 10px; }
.form-error { min-height: 20px; margin: 8px 0 0 !important; color: var(--danger) !important; font-size: .82rem; }

.draw-dialog { width: min(680px, calc(100% - 30px)); padding: 0; overflow: hidden; }
.draw-content { min-height: 360px; padding: 48px 32px 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ground); background: linear-gradient(145deg, var(--violet), var(--pink)); text-align: center; }
.draw-content p { margin: 0 0 30px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.draw-content strong { max-width: 100%; margin-bottom: 48px; font: 700 clamp(3.8rem, 11vw, 7.5rem)/.88 Fredoka, sans-serif; letter-spacing: -.03em; overflow-wrap: anywhere; }
.draw-content .primary-action { color: #181020; background: var(--mint); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: min(460px, calc(100% - 30px)); padding: 12px 16px; color: var(--ink); border-radius: 10px; background: #272033; box-shadow: 0 14px 40px rgba(0,0,0,.4); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes ticket-in { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0); } }

@media (max-width: 780px) {
  .topbar, main { width: min(100% - 28px, 680px); }
  .topbar { height: 66px; }
  main { padding-top: 36px; }
  .command-stage { min-height: auto; grid-template-columns: 1fr; gap: 38px; }
  h1 { font-size: clamp(3.25rem, 16vw, 5rem); }
  .counter-reel { min-height: 230px; transform: none; }
  .counter-number { font-size: clamp(7rem, 36vw, 10rem); }
  .winner-strip { align-items: flex-start; flex-direction: column; margin: 46px 0; }
  .winner-detail { text-align: left; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .admin-actions { width: 100%; }
  .admin-actions button { flex: 1; }
  .roster { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 470px) {
  .brand span:last-child { display: none; }
  .live-state { font-size: .72rem; }
  .command-copy { grid-template-columns: 1fr auto; }
  .command-copy span:first-child { grid-column: 1 / -1; }
  .roster { grid-template-columns: 1fr; }
  .admin-actions { flex-direction: column-reverse; }
  footer { align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
