/* TV display — sized for a 1080p screen viewed from across the room. */
html { font-size: clamp(12px, 1.05vw, 22px); }
body { overflow: hidden; }
.app { position: relative; z-index: 2; height: 100vh; display: flex; flex-direction: column; }

/* Header */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  padding: 0.8rem 1.6rem; background: linear-gradient(180deg, rgba(0,0,0,.35), transparent);
}
.brand { display: flex; align-items: center; gap: 1.4rem; }
.brand .wl { height: 3.6rem; width: auto; }
.brand .wlr { height: 3.3rem; width: auto; }
.title { margin: 0; font-size: 3.4rem; color: var(--gold); text-shadow: 0 3px 0 rgba(0,0,0,.4), 0 0 24px rgba(232,185,49,.35); white-space: nowrap; }
.controls { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; }
.toggle { display: flex; background: rgba(0,0,0,.3); border-radius: 999px; padding: 4px; }
.toggle button { white-space: nowrap; border: 0; background: none; color: var(--cream); padding: .5rem .9rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .95rem; opacity: .75; }
.toggle button.on { background: var(--red); opacity: 1; box-shadow: 0 2px 0 var(--red-deep); }
.icon { background: rgba(0,0,0,.3); border: 0; color: var(--cream); width: 2.5rem; height: 2.5rem; border-radius: 50%; cursor: pointer; font-size: 1.1rem; display: grid; place-items: center; text-decoration: none; }

main { flex: 1; min-height: 0; padding: 0.4rem 2rem 1.4rem; }
.view { height: 100%; display: flex; flex-direction: column; }
.empty { margin: auto; font-size: 2rem; opacity: .8; }
.hint { opacity: .7; font-size: .95rem; margin-top: .8rem; }
kbd { background: rgba(255,255,255,.15); border-radius: 6px; padding: .1em .45em; font-family: inherit; border: 1px solid rgba(255,255,255,.25); }

/* ---------- Leaderboard: racing bars ---------- */
.lb-head-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; font-size: 1.15rem; }
.prize b { color: var(--gold); }
.lb-meta { opacity: .75; }
.lb { position: relative; flex: 1; min-height: 0; }
.lb-row {
  position: absolute; left: 0; right: 0; top: 0; height: var(--rowh);
  display: flex; align-items: center; gap: 1rem;
  transform: translateY(var(--y)); transition: transform 1.1s cubic-bezier(.22,1,.36,1), opacity .5s;
}
.lb-row.out { opacity: .45; }
.lb-rank { width: 2.6rem; text-align: right; font-weight: 800; font-size: calc(var(--rowh) * .36); color: var(--gold-soft); flex: none; }
.lb-track { flex: 1; min-width: 0; display: flex; align-items: center; height: 100%; }
.lb-bar {
  position: relative; height: calc(var(--rowh) * .78); flex: none;
  width: calc(var(--av) + (100% - 24rem - var(--av)) * var(--pct));
  border-radius: 999px; display: flex; align-items: center; justify-content: flex-end;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 4px 14px rgba(0,0,0,.25);
  transition: width 1.1s cubic-bezier(.22,1,.36,1);
}
.lb-bar .players { position: absolute; left: 1.1rem; right: calc(var(--av) + .6rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: calc(var(--rowh) * .22); opacity: .9; }
.lb-av { position: relative; margin-right: -2px; }
.lb-av .avatar { box-shadow: 0 0 0 3px rgba(0,0,0,.15); }
.crown { position: absolute; left: 50%; top: calc(var(--av) * -0.42); transform: translateX(-50%) rotate(-8deg); font-size: calc(var(--av) * .5); filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); animation: bob 1.8s ease-in-out infinite; }
.sparkle { position: absolute; font-size: calc(var(--av) * .3); animation: twinkle 1.6s ease-in-out infinite; }
.sparkle.s1 { right: -10%; top: -8%; }
.sparkle.s2 { left: -14%; bottom: 0; animation-delay: .8s; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-6px) rotate(6deg); } }
@keyframes twinkle { 0%,100% { opacity: 0; transform: scale(.5); } 50% { opacity: 1; transform: scale(1.1); } }
.lb-label { padding-left: 1rem; min-width: 0; }
.lb-name { font-weight: 800; font-size: calc(var(--rowh) * .3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22rem; }
.lb-pts { font-size: calc(var(--rowh) * .22); opacity: .9; white-space: nowrap; }
.lb-pts b { color: var(--gold); font-size: 1.3em; }
.tag { font-size: .7em; padding: .1em .5em; border-radius: 999px; background: rgba(255,255,255,.18); margin-left: .4em; vertical-align: middle; font-weight: 600; }
.lb-row.leader .lb-bar { box-shadow: inset 0 -4px 0 rgba(0,0,0,.15), 0 0 26px rgba(232,185,49,.55); }

/* ---------- Stations board ---------- */
.stations { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 1.4rem; min-height: 0; }
.st { padding: 1.2rem 1.6rem; display: flex; flex-direction: column; min-height: 0; }
.st-head { display: flex; align-items: center; gap: .8rem; font-size: 2.4rem; }
.st-head .festive { color: var(--gold); }
.st-state { margin-left: auto; font-family: var(--body); font-size: 1rem; font-weight: 700; padding: .3em .9em; border-radius: 999px; background: var(--pine-light); }
.st-state.live { background: var(--red); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(200,16,46,0); } 0% { box-shadow: 0 0 0 0 rgba(200,16,46,.6); } }
.st-now { flex: 1; display: flex; align-items: center; justify-content: center; gap: 1.4rem; }
.st-team { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; width: 40%; }
.st-team .nm { font-weight: 800; font-size: 1.5rem; line-height: 1.15; }
.st-team .pl { opacity: .75; font-size: 1rem; }
.st-vs { font-family: var(--festive); font-size: 2.6rem; color: var(--gold); }
.st-free { flex: 1; display: grid; place-items: center; font-size: 1.6rem; opacity: .7; }
.st-timer { text-align: center; opacity: .75; font-variant-numeric: tabular-nums; }
.st-next { border-top: 1px dashed rgba(232,185,49,.35); padding-top: .7rem; margin-top: .6rem; display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; }
.st-next .lbl { color: var(--gold-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
.fill-tag { font-size: .75rem; background: var(--gold); color: var(--ink); border-radius: 999px; padding: .1em .6em; font-weight: 700; }

/* ---------- White elephant ---------- */
.we { flex: 1; display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.4rem; min-height: 0; }
.we-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.we-stage h2 { font-size: 3.4rem; color: var(--gold); margin: 0 0 1rem; }
.we-num { font-size: 1.6rem; font-weight: 700; color: var(--gold-soft); min-height: 2rem; }
.we-card {
  width: min(42rem, 90%); min-height: 13rem; margin: .8rem 0 1.6rem; display: grid; place-items: center; padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  border: 6px solid var(--gold); border-radius: 22px; box-shadow: 0 14px 40px rgba(0,0,0,.4);
  font-size: 4.6rem; font-weight: 800; line-height: 1.1; color: var(--cream);
  background-image: repeating-linear-gradient(45deg, transparent 0 22px, rgba(255,255,255,.05) 22px 44px), linear-gradient(135deg, var(--red), var(--red-deep));
}
.we-card.shuffling { animation: shake .12s infinite; }
.we-card.shuffling span { opacity: .85; filter: blur(.5px); }
.we-card.revealed { animation: pop .6s cubic-bezier(.2,1.6,.4,1); box-shadow: 0 0 60px rgba(232,185,49,.7), 0 14px 40px rgba(0,0,0,.4); }
@keyframes shake { 50% { transform: rotate(-1.2deg) scale(1.01); } }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
.we-actions { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.btn.big { font-size: 1.6rem; padding: .7em 1.6em; }
.we-side { padding: 1.2rem 1.4rem; display: flex; flex-direction: column; min-height: 0; }
.we-side-head { display: flex; justify-content: space-between; align-items: baseline; }
.we-side h3 { margin: 0 0 .6rem; font-size: 1.5rem; color: var(--gold); }
.we-left { font-weight: 700; opacity: .85; }
.we-order { flex: 1; min-height: 4rem; overflow: auto; margin: 0; padding-left: 2.2rem; font-size: 1.25rem; columns: 2; column-gap: 1.6rem; }
.we-order li { padding: .15rem 0; break-inside: avoid; }
.we-order li.latest { color: var(--gold); font-weight: 800; }
.we-add { display: flex; gap: .5rem; margin: .8rem 0; }
.we-add input { flex: 1; padding: .6em .9em; border-radius: 999px; border: 2px solid rgba(232,185,49,.5); background: rgba(255,255,255,.95); color: var(--ink); }
.we-pool-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-bottom: .4rem; }
.we-pool { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 30%; overflow: auto; }
.chip { background: rgba(255,255,255,.12); border-radius: 999px; padding: .25em .4em .25em .8em; display: inline-flex; align-items: center; gap: .3em; }
.chip button { border: 0; background: rgba(0,0,0,.25); color: var(--cream); border-radius: 50%; width: 1.4em; height: 1.4em; cursor: pointer; line-height: 1; padding: 0; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; }
.start { z-index: 80; display: grid; place-items: center; background: rgba(4, 20, 14, .75); cursor: pointer; }
.start-box { padding: 2.4rem 3rem; text-align: center; font-size: 1.3rem; }
.start .keys { opacity: .7; font-size: 1rem; }

.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3rem;
  background: radial-gradient(ellipse at center, #17654c, #072219);
  animation: fadein .35s ease-out;
}
.splash.leaving { animation: fadeout .45s ease-in forwards; }
@keyframes fadein { from { opacity: 0; transform: scale(1.04); } }
@keyframes fadeout { to { opacity: 0; } }
.sp-station { font-size: 1.6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-soft); font-weight: 700; }
.sp-head { font-size: 5rem; margin: .4rem 0 1.4rem; color: var(--gold); text-shadow: 0 4px 0 rgba(0,0,0,.35); }
.sp-teams { display: flex; align-items: center; justify-content: center; gap: 3rem; }
.sp-team { display: flex; flex-direction: column; align-items: center; gap: .8rem; width: 32vw; position: relative; }
.sp-team .avatar { border-width: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.sp-team.winner .avatar { border-color: var(--gold); box-shadow: 0 0 60px rgba(232,185,49,.8); animation: winpop .7s cubic-bezier(.2,1.6,.4,1); }
.sp-team.loser { opacity: .78; }
.sp-team.loser .avatar { border-color: var(--silver); filter: saturate(.75); }
.sp-team .crown { top: -4.5rem; font-size: 5rem; }
.sp-team .nm { font-size: 2.4rem; font-weight: 800; }
.sp-team .pl { font-size: 1.2rem; opacity: .8; }
.sp-score { font-size: 5.5rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cream); min-width: 10rem; }
.sp-score .vs { font-family: var(--festive); color: var(--gold); font-size: 4rem; }
.sp-line { font-family: var(--festive); font-size: 3.6rem; margin-top: 2rem; max-width: 80vw; color: var(--cream); text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.sp-note { margin-top: .8rem; font-size: 1.1rem; opacity: .8; }
@keyframes winpop { 0% { transform: scale(.5); } 100% { transform: scale(1); } }

/* ---------- Finale ---------- */
.finale {
  z-index: 55; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 2rem 2rem 2.5rem;
  background: radial-gradient(ellipse at 50% 120%, rgba(232,185,49,.25), transparent 60%), linear-gradient(180deg, #06131f 0%, #0b2a20 70%, #07190f 100%);
}
.finale-title { position: absolute; top: 2rem; left: 0; right: 0; text-align: center; font-size: 4.4rem; color: var(--gold); margin: 0; text-shadow: 0 0 30px rgba(232,185,49,.4); }
.finale-prize { position: absolute; top: 8.6rem; left: 0; right: 0; text-align: center; font-size: 2.6rem; font-weight: 800; color: var(--cream); animation: glow 1.6s ease-in-out infinite alternate; }
@keyframes glow { to { text-shadow: 0 0 24px rgba(232,185,49,.9); } }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.2rem; width: min(96vw, 110rem); }
.place { flex: 1; max-width: 32rem; display: flex; flex-direction: column; align-items: center; }
.place .who { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; transform: translateY(60%); opacity: 0; transition: transform 1.2s cubic-bezier(.2,1.3,.4,1), opacity .6s; position: relative; z-index: 1; }
.place.revealed .who { transform: translateY(0); opacity: 1; }
.place .who .nm { font-size: 2.2rem; font-weight: 800; }
.place .who .pts { font-size: 1.3rem; color: var(--gold-soft); }
.place .who .pl { opacity: .75; }
.place .who .avatar { border-width: 6px; margin-bottom: .4rem; }
.place.p1 .who .avatar { border-color: var(--gold); box-shadow: 0 0 60px rgba(232,185,49,.8); }
.place.p2 .who .avatar { border-color: var(--silver); }
.place.p3 .who .avatar { border-color: var(--bronze); }
.place .crown { top: -4.6rem; font-size: 4.8rem; }
.step {
  width: 100%; margin-top: 1rem; border-radius: 14px 14px 0 0; display: grid; place-items: center;
  font-family: var(--festive); font-size: 7rem; color: rgba(0,0,0,.35); box-shadow: inset 0 8px 0 rgba(255,255,255,.25), 0 -6px 30px rgba(0,0,0,.3);
  background-image: repeating-linear-gradient(90deg, transparent 0 40px, rgba(255,255,255,.06) 40px 80px);
}
.p1 .step { height: 29vh; background-color: var(--gold); }
.p2 .step { height: 20vh; background-color: #b9c4c9; }
.p3 .step { height: 13vh; background-color: var(--bronze); }
.place.pending .step { animation: drum .12s infinite; }
@keyframes drum { 50% { filter: brightness(1.25); } }
.finale .hint { position: absolute; bottom: .6rem; left: 0; right: 0; text-align: center; }
.st-next .pl-sm { opacity: .7; font-size: .85em; font-weight: 500; }
.lb-players { font-weight: 600; opacity: .85; }
.tag.tb { background: var(--gold); color: var(--ink); }
