/* ============================================================
   FINKEN | AQUA SYSTEMS — Prize Drawing
   Broadcast-style lottery draw for the Aqua RO System giveaway.
   Fixed 1920x1080 stage, JS-scaled to fit any screen (record-safe).
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand: navy sampled from the Finken logo, aqua from the fair flyer */
  --navy-void:   #03192a;
  --navy-abyss:  #041f34;
  --navy-deep:   #062b47;
  --navy:        #093b60;
  --navy-mid:    #14456e;
  --aqua-pale:   #c4e1f4;
  --aqua:        #5ec8f2;
  --aqua-bright: #8ceaff;
  --gold:        #f5c451;
  --pb-red:      #d21f2b;
  --pb-red-lt:   #f4685c;
  --pb-red-dk:   #7d0c16;
  --gold-bright: #ffe4a0;
  --gold-deep:   #b8862a;
  --white:       #ffffff;

  --ink-1: rgba(255, 255, 255, 0.96);
  --ink-2: rgba(197, 226, 245, 0.72);
  --ink-3: rgba(160, 199, 227, 0.48);

  --font-display: 'Anton', 'Arial Narrow', sans-serif;
  --font-ui: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Archivo', system-ui, sans-serif;

  --glow-aqua: 0 0 60px rgba(94, 200, 242, 0.45);

  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- 2. Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- 3. Stage (fixed 1920x1080, scaled by JS) ---------- */
#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* Positioned + scaled explicitly by fitStage(). Grid/flex centering is not
   usable here: browsers fall back to start alignment for items larger than
   their container, which knocks the frame off-centre. */
#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  transform-origin: 0 0;
  background:
    radial-gradient(80% 60% at 50% 32%, rgba(20, 69, 110, 0.85) 0%, transparent 62%),
    radial-gradient(60% 50% at 12% 88%, rgba(9, 59, 96, 0.55) 0%, transparent 70%),
    radial-gradient(55% 45% at 90% 12%, rgba(94, 200, 242, 0.12) 0%, transparent 70%),
    linear-gradient(168deg, var(--navy-abyss) 0%, var(--navy-void) 55%, #020e18 100%);
}

/* Slow-drifting caustic light, like sun through water */
#stage::before {
  content: '';
  position: absolute;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(38% 26% at 22% 30%, rgba(94, 200, 242, 0.16), transparent 70%),
    radial-gradient(30% 22% at 78% 62%, rgba(140, 234, 255, 0.12), transparent 70%),
    radial-gradient(26% 30% at 55% 85%, rgba(9, 59, 96, 0.5), transparent 70%);
  filter: blur(28px);
  animation: caustics 26s ease-in-out infinite alternate;
}

@keyframes caustics {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-3%, 2%, 0) scale(1.08); }
  100% { transform: translate3d(2.5%, -2.5%, 0) scale(1.03); }
}

/* Film grain — kills gradient banding on video */
#stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Vignette that tightens during the draw */
#vignette {
  position: absolute;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 45%, transparent 40%, rgba(2, 12, 21, 0.55) 78%, rgba(2, 12, 21, 0.9) 100%);
  opacity: 0.55;
  transition: opacity 1.2s ease;
}
#stage[data-phase='suspense'] #vignette { opacity: 1; }

/* ---------- 4. Canvas layers ---------- */
#fx-back,
#fx-front {
  position: absolute;
  inset: 0;
  width: 1920px;
  height: 1080px;
  pointer-events: none;
}
/* #fx-back lives inside #screen-draw, layered between .chamber (10) and
   .chamber__gloss (14). #fx-front is a stage-level sibling and must clear
   both the draw screen (20) and the winner screen (45). */
#fx-back  { z-index: 12; }
#fx-front { z-index: 50; }

/* ---------- 5. Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.screen.is-active { opacity: 1; visibility: visible; }

/* Chamber + slots live on the draw screen but must sit under the canvas
   layers in the right order, so they get explicit z-indices. */

/* ---------- 6. Shared bits ---------- */
.rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(94, 200, 242, 0.7), transparent);
}

.lockup { width: 100%; height: auto; }

/* ============================================================
   SETUP SCREEN
   ============================================================ */
#screen-setup {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 64px 96px 48px;
  gap: 40px;
}

.setup__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; }
.setup__head .lockup { width: 400px; }
.setup__title {
  font-family: var(--font-display);
  font-size: 60px;
  line-height: 0.94;
  letter-spacing: 0.005em;
  color: var(--white);
}
.setup__title span { color: var(--aqua); }
.setup__sub { font-family: var(--font-ui); font-size: 22px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-top: 10px; }

.setup__body { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; min-height: 0; }

.panel {
  background: linear-gradient(180deg, rgba(20, 69, 110, 0.32), rgba(6, 43, 71, 0.22));
  border: 1px solid rgba(94, 200, 242, 0.18);
  border-radius: 22px;
  padding: 34px 36px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  backdrop-filter: blur(4px);
}
.panel__title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--aqua-pale);
  margin-bottom: 6px;
}
.panel__hint { font-size: 15px; line-height: 1.6; color: var(--ink-3); margin-bottom: 24px; }

/* Dropzone */
#dropzone {
  flex: 1;
  min-height: 260px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  text-align: center;
  padding: 32px;
  border: 2px dashed rgba(94, 200, 242, 0.35);
  border-radius: 16px;
  background: rgba(3, 25, 42, 0.35);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  cursor: pointer;
}
#dropzone:hover,
#dropzone.is-over {
  border-color: var(--aqua-bright);
  background: rgba(94, 200, 242, 0.1);
  transform: translateY(-2px);
}
#dropzone svg { width: 58px; height: 58px; opacity: 0.75; }
.dropzone__main { font-family: var(--font-ui); font-size: 28px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.dropzone__sub { font-size: 14px; color: var(--ink-3); max-width: 42ch; line-height: 1.6; }

#paste-area {
  display: none;
  flex: 1;
  min-height: 220px;
  width: 100%;
  resize: none;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgba(94, 200, 242, 0.28);
  background: rgba(3, 25, 42, 0.6);
  color: var(--ink-1);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
}
#paste-area:focus { outline: 2px solid var(--aqua); outline-offset: 2px; }
#screen-setup.is-pasting #dropzone { display: none; }
#screen-setup.is-pasting #paste-area { display: block; }

.setup__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

/* Entry preview */
.preview__count {
  font-family: var(--font-display);
  font-size: 76px;
  line-height: 1;
  color: var(--aqua-bright);
  text-shadow: 0 0 40px rgba(94, 200, 242, 0.5);
}
.preview__count small {
  display: block;
  font-family: var(--font-ui);
  font-size: 20px;
  letter-spacing: 0.26em;
  color: var(--ink-3);
  text-shadow: none;
  margin-top: 4px;
}
#preview-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 22px -12px 0;
  padding: 0 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 200, 242, 0.4) transparent;
}
#preview-scroll::-webkit-scrollbar { width: 8px; }
#preview-scroll::-webkit-scrollbar-thumb { background: rgba(94, 200, 242, 0.35); border-radius: 4px; }

.entry-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.entry-table th {
  position: sticky;
  top: 0;
  background: #0b3050;
  text-align: left;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  z-index: 1;
}
.entry-table td { padding: 9px 12px; border-top: 1px solid rgba(94, 200, 242, 0.1); color: var(--ink-2); }
.entry-table td.t-ticket { font-family: ui-monospace, Menlo, monospace; color: var(--gold); letter-spacing: 0.08em; }
.entry-table td.t-name { color: var(--ink-1); font-weight: 600; }

.empty-state { display: grid; place-content: center; justify-items: center; gap: 10px; flex: 1; text-align: center; color: var(--ink-3); }
.empty-state strong { font-family: var(--font-ui); font-size: 24px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid rgba(94, 200, 242, 0.4);
  color: var(--aqua-pale);
  background: rgba(94, 200, 242, 0.08);
  transition: background 0.2s, border-color 0.2s, transform 0.15s, color 0.2s;
  white-space: nowrap;
}
.btn:hover { background: rgba(94, 200, 242, 0.2); border-color: var(--aqua); color: var(--white); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn--ghost { border-color: rgba(197, 226, 245, 0.2); color: var(--ink-3); background: transparent; }
.btn--ghost:hover { color: var(--ink-1); border-color: rgba(197, 226, 245, 0.45); background: rgba(255, 255, 255, 0.05); }
.btn--gold { border-color: rgba(245, 196, 81, 0.5); color: var(--gold-bright); background: rgba(245, 196, 81, 0.1); }
.btn--gold:hover { background: rgba(245, 196, 81, 0.22); border-color: var(--gold); color: var(--white); }
.btn--lg { padding: 18px 40px; font-size: 22px; }

/* ============================================================
   READY SCREEN — the title card
   ============================================================ */
#screen-ready {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: stretch;   /* full-height columns so the badge can be placed absolutely */
  padding: 0 110px;
  gap: 60px;
}

.ready__left { display: flex; flex-direction: column; justify-content: center; gap: 28px; }
.ready__left .lockup { width: 520px; }

.ready__headline {
  font-family: var(--font-display);
  font-size: 132px;
  line-height: 0.86;
  letter-spacing: 0.005em;
  color: var(--white);
  text-shadow: 0 0 54px rgba(94, 200, 242, 0.26);
}
.ready__headline em {
  font-style: normal;
  display: block;
  color: var(--aqua-bright);
}
.ready__prize {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 32px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--aqua-pale);
  max-width: 20ch;
  line-height: 1.25;
}

.ready__stats { display: flex; align-items: center; gap: 40px; margin-top: 6px; }
.stat__value {
  font-family: var(--font-display);
  font-size: 68px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.stat__label {
  font-family: var(--font-ui);
  font-size: 17px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 6px;
}
.stat__divider { width: 1px; height: 62px; background: rgba(94, 200, 242, 0.25); }

.ready__cta { display: flex; align-items: center; gap: 22px; margin-top: 14px; }

/* The big draw button */
.draw-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 26px 62px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 0.08em;
  color: var(--navy-void);
  background: linear-gradient(150deg, var(--gold-bright), var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 18px 46px rgba(245, 196, 81, 0.32), inset 0 2px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.18s var(--ease-back), box-shadow 0.25s;
  isolation: isolate;
}
.draw-btn::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 2px solid rgba(245, 196, 81, 0.5);
  animation: pulse-ring 2.4s ease-out infinite;
  z-index: -1;
}
@keyframes pulse-ring {
  0%   { transform: scale(1);    opacity: 0.9; }
  70%  { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}
.draw-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 26px 62px rgba(245, 196, 81, 0.46), inset 0 2px 0 rgba(255, 255, 255, 0.7); }
.draw-btn:active { transform: translateY(0) scale(0.99); }
.draw-btn:disabled { filter: grayscale(0.8); opacity: 0.4; cursor: not-allowed; }
.draw-btn:disabled::after { display: none; }

/* Prize art */
.ready__right { position: relative; display: grid; place-items: center; }
.prize-art {
  position: relative;
  width: 580px;
  filter: drop-shadow(0 40px 70px rgba(0, 0, 0, 0.6));
  animation: float 7s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-18px) rotate(-0.6deg); }
}
.prize-glow {
  position: absolute;
  width: 660px;
  height: 660px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 200, 242, 0.3) 0%, rgba(94, 200, 242, 0.08) 45%, transparent 70%);
  filter: blur(20px);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.85; }
  50%      { transform: scale(1.09); opacity: 1; }
}

.ready__fineprint {
  position: absolute;
  left: 110px;
  bottom: 46px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-3);
  max-width: 60ch;
}

/* ============================================================
   DRAW SCREEN
   ============================================================ */
#screen-draw { display: block; }

/* Top bar */
.draw__top {
  position: absolute;
  top: 46px;
  left: 72px;
  right: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 22;
}
.draw__top .lockup { width: 340px; opacity: 0.95; }

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid rgba(245, 196, 81, 0.45);
  background: rgba(245, 196, 81, 0.1);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-bright);
}
.live-tag__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.25; } }

/* Side rails */
.rail {
  position: absolute;
  top: 190px;
  width: 250px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.rail--left  { left: 72px; }
.rail--right { right: 72px; text-align: right; }

.rail__card {
  border: 1px solid rgba(94, 200, 242, 0.16);
  border-radius: 16px;
  padding: 20px 22px;
  background: linear-gradient(180deg, rgba(20, 69, 110, 0.28), rgba(6, 43, 71, 0.14));
}
.rail__label {
  font-family: var(--font-ui);
  font-size: 15px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.rail__value {
  font-family: var(--font-display);
  font-size: 46px;
  line-height: 1.05;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.rail__value--aqua { color: var(--aqua-bright); }
.rail--left .prize-mini { width: 100%; filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.5)); }

/* --- Chamber --- */
.chamber {
  position: absolute;
  left: 960px;
  top: 390px;
  width: 532px;
  height: 532px;
  margin: -266px 0 0 -266px;
  border-radius: 50%;
  z-index: 10;
  background: conic-gradient(from 205deg,
    #0d3c5f 0%, #3f74a0 8%, #bcdcf0 15%, #4d84ad 24%,
    #0d3c5f 36%, #26597f 48%, #9dc8e2 58%, #2a5f89 68%,
    #113d61 80%, #5d94bc 90%, #0d3c5f 100%);
  box-shadow:
    0 0 0 3px rgba(3, 25, 42, 0.9),
    0 40px 90px rgba(0, 0, 0, 0.6),
    var(--glow-aqua);
  transition: box-shadow 0.6s ease;
}
#stage[data-phase='churn'] .chamber,
#stage[data-phase='draw'] .chamber {
  box-shadow: 0 0 0 3px rgba(3, 25, 42, 0.9), 0 40px 90px rgba(0, 0, 0, 0.6), 0 0 110px rgba(94, 200, 242, 0.75);
}

.chamber__well {
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(6, 43, 71, 0.55) 0%, rgba(3, 25, 42, 0.92) 100%);
  box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.7), inset 0 -6px 24px rgba(94, 200, 242, 0.12);
}

/* Glass reflections — above the ball canvas */
.chamber__gloss {
  position: absolute;
  left: 960px;
  top: 390px;
  width: 532px;
  height: 532px;
  margin: -266px 0 0 -266px;
  border-radius: 50%;
  z-index: 14;
  pointer-events: none;
  background:
    radial-gradient(58% 40% at 32% 17%, rgba(255, 255, 255, 0.26), transparent 62%),
    radial-gradient(30% 20% at 74% 80%, rgba(140, 234, 255, 0.16), transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0 49%, transparent 49.6%);
          mask-image: radial-gradient(circle at 50% 50%, #000 0 49%, transparent 49.6%);
}
/* Specular streak */
.chamber__gloss::after {
  content: '';
  position: absolute;
  left: 16%;
  top: 12%;
  width: 30%;
  height: 16%;
  border-radius: 50%;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.5), transparent 70%);
  filter: blur(6px);
  transform: rotate(-28deg);
}

/* Extraction tube: chamber bottom -> slot rack */
.tube {
  position: absolute;
  left: 960px;
  top: 650px;
  width: 74px;
  height: 88px;
  margin-left: -37px;
  z-index: 13;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(90deg,
    rgba(13, 60, 95, 0.9) 0%, rgba(120, 170, 205, 0.35) 18%,
    rgba(200, 230, 248, 0.22) 42%, rgba(120, 170, 205, 0.3) 70%,
    rgba(13, 60, 95, 0.9) 100%);
  border-left: 2px solid rgba(157, 200, 226, 0.5);
  border-right: 2px solid rgba(157, 200, 226, 0.5);
  box-shadow: inset 0 0 22px rgba(94, 200, 242, 0.22);
}

/* --- Slot rack --- */
.rack {
  position: absolute;
  left: 50%;
  top: 730px;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 26px 34px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(9, 59, 96, 0.55), rgba(3, 25, 42, 0.7));
  border: 1px solid rgba(94, 200, 242, 0.22);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.rack__sep { width: 2px; height: 78px; background: linear-gradient(180deg, transparent, rgba(226, 60, 66, 0.55), transparent); }

.slot {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(6, 43, 71, 0.9), rgba(3, 25, 42, 0.95));
  border: 2px dashed rgba(94, 200, 242, 0.22);
  box-shadow: inset 0 6px 18px rgba(0, 0, 0, 0.6);
}
.slot__ball {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 50px;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--navy-void);
  opacity: 0;
  transform: scale(0.2);
  background:
    radial-gradient(circle at 34% 26%, #ffffff 0%, #f7fbff 32%, #d4e2ee 66%, #8ba6bb 100%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), inset 0 -10px 20px rgba(9, 59, 96, 0.4), inset 0 8px 14px rgba(255, 255, 255, 0.7);
}
.slot--power .slot__ball {
  color: #fff;
  background: radial-gradient(circle at 34% 26%, #ffd9d2 0%, var(--pb-red-lt) 26%, var(--pb-red) 62%, var(--pb-red-dk) 100%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), inset 0 -10px 20px rgba(90, 8, 14, 0.5), inset 0 8px 14px rgba(255, 255, 255, 0.5);
}
.slot.is-filled .slot__ball {
  opacity: 1;
  animation: ball-land 0.62s var(--ease-back) forwards;
}
@keyframes ball-land {
  0%   { transform: scale(0.35) translateY(-40px); opacity: 0; }
  55%  { transform: scale(1.16) translateY(0);     opacity: 1; }
  72%  { transform: scale(0.94); }
  86%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
.slot.is-filled { border-style: solid; border-color: rgba(94, 200, 242, 0.5); }
.slot--power.is-filled { border-color: rgba(226, 60, 66, 0.7); box-shadow: inset 0 6px 18px rgba(0,0,0,.6), 0 0 44px rgba(210, 31, 43, 0.55); }

/* Halo ping when a ball lands */
.slot__ping {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid rgba(140, 234, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}
.slot.is-filled .slot__ping { animation: ping 0.72s ease-out forwards; }
.slot--power.is-filled .slot__ping { border-color: rgba(244, 104, 92, 0.95); }
@keyframes ping {
  0%   { transform: scale(0.8); opacity: 0.95; }
  100% { transform: scale(1.7); opacity: 0; }
}

.rack__caption {
  position: absolute;
  left: 50%;
  top: 908px;
  transform: translateX(-50%);
  z-index: 24;
  font-family: var(--font-ui);
  font-size: 17px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Name ticker --- */
.ticker {
  position: absolute;
  left: 50%;
  top: 930px;
  transform: translateX(-50%);
  z-index: 25;
  width: 1400px;
  height: 96px;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#stage[data-phase='churn'] .ticker,
#stage[data-phase='draw'] .ticker,
#stage[data-phase='suspense'] .ticker,
#stage[data-phase='lock'] .ticker { opacity: 1; }

.ticker__name {
  font-family: var(--font-display);
  font-size: 68px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--white);
  text-transform: uppercase;
  white-space: nowrap;
  filter: blur(var(--tick-blur, 0px));
  opacity: var(--tick-opacity, 1);
  transform: scale(var(--tick-scale, 1));
  will-change: filter, transform;
}
#stage[data-phase='lock'] .ticker__name {
  color: var(--gold-bright);
  text-shadow: 0 0 50px rgba(245, 196, 81, 0.7);
}

/* Screen shake on ball lock */
@keyframes shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20%  { transform: translate3d(-7px, 4px, 0); }
  40%  { transform: translate3d(6px, -3px, 0); }
  60%  { transform: translate3d(-4px, -4px, 0); }
  80%  { transform: translate3d(3px, 3px, 0); }
}
#stage.is-shaking > *:not(#vignette) { animation: shake 0.34s ease-out; }

/* White flash */
#flash {
  position: absolute;
  inset: 0;
  z-index: 58;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, #ffffff, rgba(197, 226, 245, 0.85) 45%, transparent 75%);
  opacity: 0;
}
#flash.is-firing { animation: flash 0.85s ease-out forwards; }
@keyframes flash {
  0%   { opacity: 0; }
  9%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   WINNER SCREEN
   ============================================================ */
#screen-winner {
  z-index: 45;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 0 100px;
  text-align: center;
}
#screen-winner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(70% 60% at 50% 44%, rgba(245, 196, 81, 0.16), transparent 68%);
  pointer-events: none;
}

.winner__eyebrow {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.58em;
  text-transform: uppercase;
  color: var(--aqua);
  opacity: 0;
  animation: rise 0.7s var(--ease-out-quint) 0.05s forwards;
}
.winner__word {
  font-family: var(--font-display);
  font-size: 190px;
  line-height: 0.84;
  letter-spacing: 0.05em;
  background: linear-gradient(178deg, #fff8e4 8%, var(--gold-bright) 38%, var(--gold) 62%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  filter: drop-shadow(0 12px 40px rgba(245, 196, 81, 0.45));
  opacity: 0;
  animation: slam 0.72s var(--ease-back) 0.12s forwards;
}
@keyframes slam {
  0%   { opacity: 0; transform: scale(1.9);   filter: blur(22px) drop-shadow(0 12px 40px rgba(245,196,81,.45)); }
  60%  { opacity: 1; transform: scale(0.965); filter: blur(0)    drop-shadow(0 12px 40px rgba(245,196,81,.45)); }
  100% { opacity: 1; transform: scale(1);     filter: blur(0)    drop-shadow(0 12px 40px rgba(245,196,81,.45)); }
}

.winner__card {
  margin-top: 22px;
  padding: 38px 84px 34px;
  border-radius: 26px;
  border: 1px solid rgba(245, 196, 81, 0.4);
  background: linear-gradient(180deg, rgba(20, 69, 110, 0.5), rgba(6, 43, 71, 0.32));
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
  animation: rise 0.7s var(--ease-out-quint) 0.42s forwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(34px); }
  to   { opacity: 1; transform: translateY(0); }
}

.winner__name {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 92px;
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--white);
  text-shadow: 0 0 60px rgba(140, 234, 255, 0.35);
}
.winner__name.is-long { font-size: 68px; }
.winner__name.is-xlong { font-size: 52px; }

.winner__meta {
  margin-top: 14px;
  font-family: var(--font-ui);
  font-size: 28px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--aqua-pale);
}

.winner__ticket {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}
.winner__ticket-label {
  font-family: var(--font-ui);
  font-size: 17px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 8px;
}
/* The digits are injected into this span, so it has to be the flex row */
#winner-ticket { display: flex; align-items: center; gap: 10px; }
.tk-digit {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: -0.01em;
  color: var(--navy-void);
  background: linear-gradient(180deg, #ffffff, #d4e2ee);
  box-shadow: inset 0 -4px 8px rgba(9, 59, 96, 0.3);
}
.tk-digit--power {
  color: #fff;
  background: linear-gradient(180deg, var(--pb-red-lt), var(--pb-red));
  box-shadow: inset 0 -4px 8px rgba(90, 8, 14, 0.45);
}
/* Breathing room between the five whites and the Powerball */
.tk-sep { width: 14px; }

.winner__prize {
  margin-top: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  opacity: 0;
  animation: rise 0.7s var(--ease-out-quint) 0.72s forwards;
}
.winner__prize img { width: 168px; filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55)); }
.winner__prize-text { text-align: left; }
.winner__prize-name {
  font-family: var(--font-display);
  font-size: 46px;
  line-height: 1;
  color: var(--white);
}
.winner__prize-sub {
  font-family: var(--font-ui);
  font-size: 22px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 8px;
}

.winner__actions {
  margin-top: 40px;
  display: flex;
  gap: 14px;
  opacity: 0;
  animation: rise 0.6s var(--ease-out-quint) 1s forwards;
}

/* ============================================================
   CONTROL BAR (chrome — hidden with H, and during the draw)
   ============================================================ */
#controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(3, 20, 34, 0.82);
  border: 1px solid rgba(94, 200, 242, 0.22);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  transition: opacity 0.35s ease, transform 0.35s ease;
  font-family: var(--font-ui);
}
#controls.is-hidden { opacity: 0; transform: translate(-50%, 22px); pointer-events: none; }

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.ctl:hover { background: rgba(94, 200, 242, 0.16); color: var(--white); }
.ctl.is-off { color: rgba(197, 226, 245, 0.35); }
.ctl kbd {
  font-family: var(--font-body);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(197, 226, 245, 0.13);
  color: var(--ink-3);
  letter-spacing: 0;
}
.ctl__sep { width: 1px; height: 22px; background: rgba(94, 200, 242, 0.2); margin: 0 4px; }

.speed-group { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(94, 200, 242, 0.08); }
.speed-opt {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  transition: background 0.18s, color 0.18s;
}
.speed-opt.is-on { background: var(--aqua); color: var(--navy-void); }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  z-index: 110;
  padding: 12px 24px;
  border-radius: 999px;
  background: rgba(3, 20, 34, 0.94);
  border: 1px solid rgba(94, 200, 242, 0.3);
  font-family: var(--font-ui);
  font-size: 17px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--aqua-pale);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.is-on { opacity: 1; transform: translate(-50%, 0); }
#toast.is-error { border-color: rgba(255, 130, 130, 0.5); color: #ffc9c9; }

/* Clean-frame mode hides every operator affordance */
body.is-clean #controls { opacity: 0; pointer-events: none; }
