:root {
  --panel-top: rgba(24, 44, 82, .88);
  --panel-bottom: rgba(11, 22, 44, .92);
  --line: rgba(255, 255, 255, .09);
  --gold-2: #ffd977;
  --dim: rgba(226, 236, 252, .66);
  --booth-w: calc(320 / 1520 * 100%);
}

/* ---------- Header ---------- */
.derby-head { text-align: center; padding: 70px 16px 6px; position: relative; z-index: 45; }
.kicker {
  font-size: .78rem; font-weight: 700; letter-spacing: .26em; text-transform: uppercase; color: var(--gold-2);
}
.derby-head h1 {
  font-size: clamp(3rem, 7.5vw, 5.6rem); margin: 4px 0 0; line-height: .95;
  background: linear-gradient(180deg, #fff 30%, #ffe08a 70%, #f0b432);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #8f1515) drop-shadow(0 10px 24px rgba(0, 0, 0, .45));
}
.derby-head .meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.derby-head .meta span {
  font-size: .85rem; font-weight: 600; padding: 5px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line);
}

.mute {
  position: fixed; top: 44px; right: 16px; z-index: 60; font-size: 1.25rem; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25); backdrop-filter: blur(6px);
}

/* ---------- Panels ---------- */
.lobby, .broadcast { position: relative; z-index: 45; max-width: 1500px; margin: 22px auto; padding: 0 16px; }
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 20px; align-items: start; }
.panel {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .07);
  backdrop-filter: blur(8px);
}
.panel-head { margin-bottom: 14px; }
.panel-head h2 {
  font-family: "Fredoka", sans-serif; font-size: 1.3rem; margin: 0; letter-spacing: .02em;
  display: flex; align-items: center; gap: 10px;
}
.panel-head h2::before {
  content: ""; width: 6px; height: 1.1em; border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-2), var(--red));
}
.panel-head p { margin: 4px 0 0 16px; color: var(--dim); font-size: .9rem; }

/* ---------- Race card ---------- */
.race-info-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.race-info { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 16px; }
.redraw-btn {
  font: 700 .85rem "Fredoka", sans-serif; color: #fff; cursor: pointer; padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(246, 195, 67, .45); transition: background .15s, transform .1s;
}
.redraw-btn:hover { background: rgba(246, 195, 67, .18); }
.redraw-btn:active { transform: scale(.96); }
.redraw-btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.redraw-btn:disabled { opacity: .4; cursor: not-allowed; }
.race-info span {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px; background: rgba(246, 195, 67, .12); border: 1px solid rgba(246, 195, 67, .35); color: var(--gold-2);
}
.runner-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.runner-tile {
  display: grid; grid-template-columns: 24px 64px minmax(0, 1fr) auto; align-items: center; gap: 8px 12px;
  padding: 12px 14px 12px 10px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line); border-top: 4px solid var(--c);
  border-radius: 16px; transition: transform .15s, background .15s, box-shadow .15s;
}
.runner-tile:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .08); }
.runner-tile:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.runner-tile.backed { box-shadow: 0 0 0 1px rgba(246, 195, 67, .65), 0 8px 22px rgba(246, 195, 67, .14); }
.tile-num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); font-weight: 700; font-size: .78rem; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.tile-av, .ic-av, .podium-av {
  display: grid; place-items: center; overflow: hidden; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #ffffff, #cfe0f2);
}
.tile-av { width: 64px; height: 64px; border: 2px solid var(--c); }
.portrait { width: 100%; height: 100%; object-fit: cover; display: block; }
.reindeer-icon { width: 100%; height: 100%; display: block; overflow: visible; }
.tile-info { min-width: 0; }
.tile-info b { display: block; font-size: 1.05rem; }
.tile-info small { display: block; color: var(--dim); font-size: .78rem; line-height: 1.3; }
.tile-odds {
  align-self: start; font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--gold-2);
  background: rgba(246, 195, 67, .12); border: 1px solid rgba(246, 195, 67, .3); padding: 3px 10px; border-radius: 999px;
}
.tile-stats { grid-column: 1 / -1; display: grid; gap: 4px; }
.tile-record, .ic-record {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  font-size: .8rem; color: var(--dim); font-variant-numeric: tabular-nums;
}
.tile-record { padding-top: 8px; border-top: 1px solid var(--line); }
.rec b { color: #fff; font-size: .95rem; }
.form { display: inline-flex; align-items: center; gap: 3px; }
.form i {
  font-style: normal; font-weight: 800; font-size: .72rem; width: 19px; height: 19px; border-radius: 5px;
  display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: #fff;
}
.form i.f1 { background: linear-gradient(180deg, #ffe08a, #e0a52a); color: #3a2600; }
.form i.f2 { background: linear-gradient(180deg, #eef2f7, #aab4c2); color: #1d2533; }
.form i.f3 { background: linear-gradient(180deg, #f2c49a, #b8743a); color: #2e1700; }
.debut { font-style: italic; }
.tile-backers { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.tile-backers:empty { display: none; }
.tile-backers i {
  font-style: normal; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--red); box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.resting { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.resting-label { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-right: 4px; }
.resting-chip {
  font-size: .75rem; padding: 2px 9px 2px 7px; border-radius: 999px; color: var(--dim);
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-left: 3px solid var(--c);
}

/* ---------- Bet slip ---------- */
#players { display: grid; gap: 8px; }
.player {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 78px 56px 22px; gap: 6px; align-items: center;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-left: 4px solid var(--c);
  padding: 7px; border-radius: 12px; transition: box-shadow .15s, border-color .15s;
}
.player.active { border-color: rgba(246, 195, 67, .65); border-left-color: var(--c); box-shadow: 0 0 0 1px rgba(246, 195, 67, .35); }
.player input, .player select {
  font: 600 .88rem "Fredoka", sans-serif; padding: 6px 8px; border-radius: 8px; min-width: 0; width: 100%;
  border: 1px solid transparent; background: rgba(255, 255, 255, .95); color: var(--ink);
}
.player input:focus, .player select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(246, 195, 67, .3); }
.player .stake { display: flex; align-items: center; gap: 3px; font-size: .9rem; }
.player .bank { font-weight: 700; color: var(--gold-2); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.player .bank::after { content: " 🍪"; }
.player .remove { background: none; border: none; color: #fff; font-size: 1rem; cursor: pointer; opacity: .45; }
.player .remove:hover { opacity: 1; }
.player .bettype { grid-column: 2 / 4; display: flex; gap: 6px; min-width: 0; }
.player .bettype select { flex: 1; }
.bet-actions { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.bet-actions .btn { font-size: .9rem; padding: .5em 1.1em; }
.link-btn { background: none; border: none; color: var(--dim); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; }
#startBtn { width: 100%; margin-top: 18px; }

.btn.big { font-size: 1.35rem; padding: .85em 1.4em; position: relative; overflow: hidden; }
.btn.big::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);
  animation: shimmer 2.6s ease-in-out infinite;
}
@keyframes shimmer { 60%, 100% { transform: translateX(120%); } }

/* ---------- Broadcast screen ---------- */
.screen {
  position: relative; overflow: hidden; border-radius: 18px; background: #0a1428;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 0 0 5px rgba(246, 195, 67, .28), 0 30px 80px rgba(0, 0, 0, .55);
}
.arena {
  display: block; width: 100%; height: auto; background: #e8f1fa;
  transform-origin: var(--fx, 39.5%) var(--fy, 74%);
  transition: transform 1.4s cubic-bezier(.6, 0, .2, 1), transform-origin .7s ease;
}
.arena text { user-select: none; }
.cinematic .arena { will-change: transform; }
.screen.establishing .arena { transform: scale(1.3); transition-duration: 3.2s; }
.screen.rollcall .arena { transform: scale(2.6); }

.infield-logo {
  font-family: "Mountains of Christmas", cursive; font-size: 60px; font-weight: 700; fill: #fff;
  paint-order: stroke; stroke: #134a28; stroke-width: 7px; stroke-linejoin: round;
}
.infield-sub { font: 700 13px "Fredoka", sans-serif; letter-spacing: 4px; fill: rgba(255, 255, 255, .8); }

.live-bug {
  position: absolute; top: 14px; left: 14px; display: none; align-items: center; gap: 7px; z-index: 4;
  background: #d42a2a; padding: 4px 11px 4px 9px; border-radius: 6px; font-weight: 800; font-size: .8rem;
  letter-spacing: .12em; box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.racing-on .live-bug { display: flex; }
.lap-counter {
  position: absolute; top: 14px; left: 92px; z-index: 4; display: none;
  background: rgba(4, 10, 24, .82); border: 1px solid rgba(246, 195, 67, .5); color: var(--gold-2);
  padding: 4px 12px; border-radius: 6px; font-weight: 800; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
}
.racing-on .lap-counter { display: block; }
.runner.benched, .chip.benched { display: none; }
.live-bug .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: twinkle .6s infinite alternate; }

/* ---------- Cinematic intro ---------- */
.letterbox {
  position: absolute; left: 0; right: 0; height: 0; z-index: 6; background: #04070d;
  transition: height .7s cubic-bezier(.6, 0, .2, 1);
}
.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }
.cinematic .letterbox { height: 10%; }

.intro-title {
  position: absolute; left: 0; right: var(--booth-w); top: 50%; z-index: 7; text-align: center;
  transform: translateY(-50%); pointer-events: none; opacity: 0; transition: opacity .5s;
}
.intro-title::before {
  content: ""; position: absolute; inset: -34px 0; z-index: -1;
  background: linear-gradient(90deg, transparent, rgba(4, 10, 24, .9) 14%, rgba(4, 10, 24, .9) 86%, transparent);
  border-block: 1px solid rgba(246, 195, 67, .45);
}
.intro-title.show { opacity: 1; }
.intro-title h2 {
  font-size: clamp(2.4rem, 6vw, 5.4rem); margin: 6px 0; line-height: 1;
  background: linear-gradient(180deg, #fff 30%, #ffd977); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #8f1515) drop-shadow(0 0 30px rgba(255, 210, 90, .45));
}
.intro-title.show h2 { animation: title-in 1.1s cubic-bezier(.2, 1, .3, 1); }
@keyframes title-in { from { letter-spacing: .25em; opacity: 0; transform: scale(1.15); } }
.intro-title .sub { font-weight: 600; color: var(--dim); letter-spacing: .08em; }

.intro-card {
  position: absolute; left: 45%; width: 33%; top: 50%; z-index: 7; pointer-events: none;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 16px 18px; border-radius: 18px; opacity: 0; transform: translate(60px, -50%);
  background: linear-gradient(135deg, rgba(9, 20, 42, .94), rgba(22, 42, 78, .94));
  border: 1px solid rgba(255, 255, 255, .14); border-top: 4px solid var(--c);
  box-shadow: 0 24px 50px rgba(0, 0, 0, .5);
}
.intro-card.show { animation: card-in .5s cubic-bezier(.2, 1.15, .4, 1) forwards; }
@keyframes card-in { to { opacity: 1; transform: translate(0, -50%); } }
.ic-av { width: clamp(64px, 7.5vw, 116px); aspect-ratio: 1; border: 4px solid var(--c); box-shadow: 0 0 24px color-mix(in srgb, var(--c) 60%, transparent); }
.ic-kicker { font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-2); }
.ic-name { font-size: clamp(1rem, 1.9vw, 1.8rem); font-weight: 700; line-height: 1.1; margin: 2px 0; }
.ic-tag { font-size: clamp(.72rem, 1vw, .92rem); color: var(--dim); font-style: italic; }
.ic-stats { display: grid; gap: 4px; margin-top: 8px; }
.ic-record { margin-top: 6px; font-size: .74rem; }
.stat { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; gap: 8px; font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.stat i { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); position: relative; overflow: hidden; }
.stat i::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--v); border-radius: 3px;
  background: linear-gradient(90deg, var(--c), var(--gold-2)); animation: bar-fill .8s .15s both;
}
@keyframes bar-fill { from { width: 0; } }
.ic-odds { align-self: start; text-align: center; font-weight: 800; font-size: clamp(1.1rem, 1.8vw, 1.7rem); color: var(--gold-2); font-variant-numeric: tabular-nums; }
.ic-odds small { display: block; font-size: .58rem; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); font-weight: 700; }

.skip-intro {
  position: absolute; bottom: calc(10% + 12px); right: calc(var(--booth-w) + 14px); z-index: 8; display: none;
  font: 700 .85rem "Fredoka", sans-serif; color: #fff; cursor: pointer; padding: 6px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .3); backdrop-filter: blur(4px);
}
.skip-intro:hover { background: rgba(0, 0, 0, .75); }
.cinematic .skip-intro { display: block; }

.runner { transition: opacity .3s; }
.rollcall .runner { opacity: .25; }
.rollcall .runner.featured { opacity: 1; }
.runner.featured .gallop { transform: scale(1.3); }
.runner.featured .sprite { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 10px #ffd977); }

/* ---------- Positions ticker ---------- */
.ticker {
  display: flex; height: 50px; margin-top: 12px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, #13284d, #0a1730); border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
.ticker-label {
  flex: none; display: grid; place-items: center; padding: 0 18px;
  background: linear-gradient(135deg, #d42a2a, #8f1515);
  font-weight: 800; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase;
}
.ticker-track { position: relative; flex: 1; }
.chip {
  position: absolute; top: 7px; bottom: 7px; left: calc(var(--rank, 0) * 100% / var(--n, 5) + 3px); width: calc(100% / var(--n, 5) - 6px);
  display: flex; align-items: center; gap: 5px; padding-right: 6px; overflow: hidden; white-space: nowrap;
  background: rgba(255, 255, 255, .06); border-left: 4px solid var(--c); border-radius: 8px; font-size: .85rem;
  transition: left .45s cubic-bezier(.4, 1.3, .5, 1);
}
.chip .pos { flex: none; width: 20px; text-align: center; font-weight: 800; font-size: .85rem; color: var(--gold-2); }
.chip .chip-num {
  flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); font-weight: 700; font-size: .62rem;
}
.chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chip .tag { flex: none; font-size: .7rem; color: var(--gold-2); font-weight: 700; }
.ticker.stolen .ticker-track::after {
  content: "😈  THE GRINCH STOLE THE POSITIONS!  😈"; position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; font-weight: 800; letter-spacing: .06em;
  background: repeating-linear-gradient(-45deg, #2d5a12 0 14px, #3b7417 14px 28px);
  animation: stun .15s linear infinite;
}

/* ---------- Crowd & runners ---------- */
.elf { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 2.4s ease-in-out infinite; }
.elf.v1 { animation-delay: -.4s; } .elf.v2 { animation-delay: -.9s; }
.elf.v3 { animation-delay: -1.3s; } .elf.v4 { animation-delay: -1.8s; }
.racing .elf { animation: hop .55s ease-in-out infinite; }
.racing .elf.v1 { animation-delay: -.1s; } .racing .elf.v2 { animation-delay: -.2s; }
.racing .elf.v3 { animation-delay: -.3s; } .racing .elf.v4 { animation-delay: -.45s; }
.racing .wild .elf { animation: cheer .32s ease-in-out infinite; }
.racing.roar .elf { animation: cheer .28s ease-in-out infinite; }
@keyframes sway { 50% { transform: translateY(-2px); } }
@keyframes hop { 50% { transform: translateY(-4px); } }
@keyframes cheer { 50% { transform: translateY(-14px); } }
/* The monitor's copy of the crowd stays still: animating it twice costs too many frames. */
.pip .elf { animation: none !important; }

.sign { transform-box: fill-box; transform-origin: 50% 100%; animation: wave 1.1s ease-in-out infinite; }
.sign:nth-of-type(odd) { animation-delay: -.5s; }
@keyframes wave { 50% { transform: rotate(5deg) translateY(-3px); } }

.gallop { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .3s; }
.racing .gallop { animation: gallop .3s ease-in-out infinite; animation-delay: var(--d); }
@keyframes gallop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-4deg); }
}
.racing .leg { animation: leg-swing .3s ease-in-out infinite alternate; animation-delay: var(--d); }
.racing .leg.l2 { animation-delay: calc(var(--d) - .05s); }
.racing .leg.l3 { animation-delay: calc(var(--d) - .15s); }
.racing .leg.l4 { animation-delay: calc(var(--d) - .2s); }
@keyframes leg-swing { from { transform: rotate(34deg); } to { transform: rotate(-34deg); } }
.red-nose { animation: nose-glow .7s ease-in-out infinite alternate; }
@keyframes nose-glow { to { fill: #ff8080; } }

.runner.leader .sprite { filter: drop-shadow(0 0 5px gold) drop-shadow(0 0 2px gold); }
.runner .medal { opacity: 0; transition: opacity .3s; }
.runner.done .medal { opacity: 1; }

.puff { transform-box: fill-box; transform-origin: center; animation: puff .7s ease-out forwards; }
@keyframes puff { to { transform: scale(2.6); opacity: 0; } }

/* ---------- Chaos ---------- */
.present {
  transform-box: fill-box; transform-origin: center;
  animation: present-in .45s cubic-bezier(.3, 1.8, .5, 1), present-shake .5s .45s ease-in-out infinite;
}
.present.opened { animation: prize-pop .6s cubic-bezier(.3, 1.8, .5, 1) forwards; }
@keyframes present-in { from { transform: scale(0) rotate(-90deg); } }
@keyframes present-shake { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes prize-pop { 0% { transform: scale(.3); } 60% { transform: scale(1.6) translateY(-8px); } 100% { transform: scale(1.2) translateY(-4px); } }
.sparkle { transform-box: fill-box; transform-origin: center; animation: sparkle .9s ease-out forwards; }
@keyframes sparkle { from { transform: scale(.2); } 50% { transform: scale(1.3); } to { transform: scale(.6); opacity: 0; } }

.runner .bubble { opacity: 0; transition: opacity .2s; }
.runner.bubbling .bubble { opacity: 1; animation: twinkle .35s infinite alternate; }
.runner.spin .gallop { animation: spin .45s linear infinite; }
.runner.stunned .gallop { animation: stun .1s linear infinite; }
.runner.napping .gallop { animation: none; transform: rotate(-14deg) translateY(4px); }
.runner.napping .leg, .runner.spin .leg { animation: none; }
.racing .runner.turbo .gallop, .racing .runner.turbo .leg { animation-duration: .1s; }
.runner.turbo .sprite { filter: drop-shadow(0 0 8px #ff7a00) drop-shadow(0 0 4px #ffd000); }
.runner.confused .gallop { animation: gallop .3s ease-in-out infinite, wobble .5s ease-in-out infinite; }
.runner.hop .gallop { animation: hop-over .4s ease-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stun { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes wobble { 50% { transform: rotate(18deg); } }
@keyframes hop-over { 50% { transform: translateY(-30px) rotate(-12deg); } }

.penguin { transform-box: fill-box; transform-origin: 50% 100%; animation: waddle .25s ease-in-out infinite alternate; }
@keyframes waddle { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.candy { transform-box: fill-box; transform-origin: center; animation: candy-fall 1.2s ease-in forwards; }
@keyframes candy-fall { to { transform: translateY(160px) rotate(540deg); opacity: 0; } }
.splat { transform-box: fill-box; transform-origin: center; animation: splat .6s ease-out forwards; }
@keyframes splat { from { transform: scale(.3); } 40% { transform: scale(1.7); } to { transform: scale(1.4); opacity: 0; } }
.grinch { transform-box: fill-box; transform-origin: center; animation: grinch .4s ease-in-out infinite alternate; }
@keyframes grinch { from { transform: rotate(-15deg) scale(.9); } to { transform: rotate(15deg) scale(1.15); } }

.blizzard {
  position: absolute; top: 0; bottom: 0; left: 0; right: var(--booth-w); z-index: 3;
  pointer-events: none; opacity: 0; transition: opacity .6s;
  background:
    radial-gradient(circle, #fff 2px, transparent 3px) 0 0 / 34px 34px,
    radial-gradient(circle, rgba(255, 255, 255, .8) 1.5px, transparent 2.5px) 9px 13px / 21px 21px,
    rgba(235, 245, 255, .6);
  animation: blizzard .5s linear infinite;
}
.blizzard.on { opacity: 1; }
@keyframes blizzard { to { background-position: -68px 68px, -51px 55px, 0 0; } }

/* ---------- Elf commentator ---------- */
.booth {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--booth-w); z-index: 5;
  container-type: size; pointer-events: none;
  background: linear-gradient(180deg, #4d1a14, #250906);
  box-shadow: inset 4px 0 0 var(--gold), inset 12px 0 24px rgba(0, 0, 0, .4);
}
.booth::before {
  content: ""; position: absolute; top: 4px; left: 8px; right: 0; height: 14px;
  background:
    radial-gradient(circle at 8px 7px, #ffd23b 4px, transparent 5px) 0 0 / 32px 14px,
    radial-gradient(circle at 24px 7px, #ff4b4b 4px, transparent 5px) 0 0 / 32px 14px;
  animation: twinkle 1s infinite alternate;
}
.booth-logo { position: absolute; top: 9%; left: 0; right: 0; text-align: center; }
.booth-logo b { display: block; font-size: 9cqw; color: var(--gold-2); letter-spacing: .04em; }
.booth-logo span { font-size: 4.4cqw; color: rgba(255, 220, 170, .7); }
.monitor {
  position: absolute; top: 4%; left: 6%; width: 88%;
  transform: scale(0) rotate(-10deg); transform-origin: 50% 170%;
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.monitor.on { transform: none; }
.tv {
  position: relative; aspect-ratio: 5 / 3; overflow: hidden; background: #000;
  border: 1.6cqw solid #1a1a1a; border-radius: 3cqw;
  box-shadow: 0 0 0 .9cqw var(--gold), 0 8px 20px rgba(0, 0, 0, .55);
}
.pip { display: block; width: 100%; height: 100%; }
.cam-tag {
  position: absolute; top: 4%; left: 4%; font-size: 4cqw; font-weight: 800; letter-spacing: .08em;
  background: rgba(212, 42, 42, .9); padding: .1em .5em; border-radius: 4px;
  animation: twinkle .6s infinite alternate;
}
.monitor-caption {
  margin-top: 2.2cqw; padding: .35em .65em; border-radius: 7px; font-weight: 700; font-size: 4.6cqw;
  background: linear-gradient(90deg, #c42020, #8f1515); border-left: 1.5cqw solid var(--gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.speech {
  position: absolute; top: 38%; left: 6%; width: 88%; max-height: 27%; overflow: hidden;
  background: #fffdf7; color: var(--ink); border-radius: 5cqw; padding: .55em .8em;
  font-size: 5.4cqw; font-weight: 600; line-height: 1.25; box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
}
.speech:empty { display: none; }
.speech.pop { animation: speech-pop .3s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes speech-pop { from { transform: scale(.85); } }

.host { position: absolute; bottom: 1%; left: 50%; height: 34%; transform: translateX(-50%); overflow: visible; }
.host.host-3d { height: 42%; aspect-ratio: 4 / 5; bottom: 2%; }
.host.replaced { display: none; }
.elf3d-canvas { display: block; width: 100%; height: 100%; }
.host .elf-body { transform-origin: 80px 194px; animation: host-bob 1.1s ease-in-out infinite; }
.host .hat { transform-origin: 80px 46px; animation: hat-swing 1.6s ease-in-out infinite; }
.host .eyes { transform-origin: 80px 66px; animation: blink 4s infinite; }
.host .brows { transition: transform .2s; }
.host .mouth { transform-origin: 80px 84px; transform: scaleY(.25); }
.host .arm-mic { transform-origin: 56px 104px; }
.host .arm-point { transform-origin: 104px 104px; animation: host-wave 1.4s ease-in-out infinite; transition: transform .3s; }
.host .head { transform-origin: 80px 96px; }
.host.talking .mouth { animation: yap .13s ease-in-out infinite alternate; }
.host.talking .arm-mic { animation: mic-bob .5s ease-in-out infinite; }
.host.talking .head { animation: head-tilt .9s ease-in-out infinite; }
.host.pointing .arm-point { animation: none; transform: rotate(-125deg); }
.host.excited .elf-body { animation: host-jump .42s ease-in-out infinite; }
.host.excited .arm-point { animation: host-wave-fast .22s ease-in-out infinite; }
.host.excited .brows { transform: translateY(-5px); }
.host.excited .eyes { animation: none; transform: scale(1.25); }
@keyframes host-bob { 50% { transform: translateY(-4px) rotate(-2deg); } }
@keyframes host-jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22px) rotate(5deg); } }
@keyframes hat-swing { 50% { transform: rotate(8deg); } }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes yap { from { transform: scaleY(.2); } to { transform: scaleY(1.15); } }
@keyframes mic-bob { 50% { transform: rotate(10deg); } }
@keyframes head-tilt { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes host-wave { 50% { transform: rotate(-30deg); } }
@keyframes host-wave-fast { 0%, 100% { transform: rotate(-150deg); } 50% { transform: rotate(-95deg); } }

/* ---------- Countdown ---------- */
.countdown {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(circle, rgba(4, 10, 24, .35), rgba(4, 10, 24, .7));
  font-family: "Mountains of Christmas", cursive; font-size: clamp(5rem, 20vw, 15rem); font-weight: 700;
}
.countdown span {
  background: linear-gradient(180deg, #fff 35%, #ffd977); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #8f1515) drop-shadow(0 0 40px rgba(255, 210, 90, .6));
  animation: zoom .9s ease-out forwards;
}
@keyframes zoom { from { transform: scale(2.5); opacity: 0; } 30% { transform: scale(1); opacity: 1; } to { transform: scale(.8); opacity: 0; } }
.hidden { display: none !important; }

/* ---------- Results ---------- */
.results {
  position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px;
  background: rgba(4, 10, 24, .72); backdrop-filter: blur(5px);
}
.results-card {
  width: min(700px, 100%); max-height: 90vh; overflow: auto; text-align: center;
  background: linear-gradient(180deg, #1a3263, #0c1a36);
  border: 1px solid rgba(255, 255, 255, .14); border-top: 5px solid var(--gold); border-radius: 24px; padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: drop .6s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes drop { from { transform: translateY(-80px) scale(.85); opacity: 0; } }
.results-card h2 {
  font-size: 2.6rem; margin: 2px 0 14px;
  background: linear-gradient(180deg, #fff 30%, #ffd977); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 6px 0 18px; }
.step { flex: 1; max-width: 200px; }
.step .who { display: grid; justify-items: center; gap: 2px; margin-bottom: 8px; }
.step .who b { font-size: .95rem; }
.step .who small { color: var(--gold-2); font-weight: 700; }
.podium-av { width: 72px; height: 72px; border: 3px solid var(--c); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 55%, transparent); }
.step.p1 .podium-av { width: 96px; height: 96px; animation: wiggle .6s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.step .block {
  border-radius: 12px 12px 0 0; display: grid; place-items: center; font-size: 2rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .05)); border: 1px solid rgba(255, 255, 255, .18);
}
.step.p1 .block { height: 120px; background: linear-gradient(180deg, #ffe08a, #e0a52a); }
.step.p2 .block { height: 86px; }
.step.p3 .block { height: 62px; }
.payouts { display: grid; gap: 6px; margin-bottom: 18px; }
.payout {
  --tone: var(--dim);
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; text-align: left;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-left: 5px solid var(--tone);
  border-radius: 10px; padding: 9px 12px; color: var(--tone);
}
.payout.up { --tone: #5be38a; background: rgba(46, 204, 113, .13); border-color: rgba(91, 227, 138, .45); border-left-color: var(--tone); }
.payout.down { --tone: #ff6b6b; background: rgba(231, 76, 60, .12); border-color: rgba(255, 107, 107, .4); border-left-color: var(--tone); }
.payout .line b { color: inherit; }
.payout .change {
  font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; color: var(--tone); background: color-mix(in srgb, var(--tone) 18%, transparent);
}
.payout .bal { font-weight: 700; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

@media (max-width: 1100px) {
  .lobby { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .player { grid-template-columns: 1fr 1.4fr 70px; }
  .player .bank { grid-column: 1 / 3; text-align: left; }
  .chip .nm { display: none; }
}

/* ---------- Phone betting (only shown when the CHRIStmas Games server is running) ---------- */
.phone-join { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 12px; border-radius: 16px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 217, 119, .35); }
.phone-qr { flex: none; width: 92px; height: 92px; padding: 6px; border-radius: 10px; background: #fff; }
.phone-qr svg { display: block; width: 100%; height: 100%; }
.phone-text { display: grid; gap: 4px; font-size: .9rem; line-height: 1.35; color: rgba(222, 232, 252, .8); }
.phone-text > b { font-size: 1.05rem; color: #fff; }
.phone-code b { font-size: 1.15rem; letter-spacing: .2em; color: var(--gold-2, #ffd977); }
.player.on-phone { position: relative; }
.player.on-phone::before { content: "📱"; position: absolute; top: -9px; left: -7px; font-size: .95rem; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
