:root {
  --bg: #0f0b24;
  --bg2: #1b1440;
  --panel: rgba(28, 20, 66, 0.72);
  --panel-solid: #1d1545;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4efff;
  --muted: #a99fd0;
  --pink: #ff4fd8;
  --cyan: #2ee6ff;
  --gold: #ffcf4a;
  --orange: #ff7a3d;
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
  --display: 'Bungee', 'Space Mono', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--mono);
  overflow: hidden; display: grid; grid-template-columns: 300px 1fr; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--mono); background: rgba(255,255,255,.1); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 7px; font-size: .85em; }
code { font-family: var(--mono); color: var(--cyan); }

/* ---------- synthwave background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.sky { position: absolute; inset: 0; background: linear-gradient(180deg, #07051a 0%, #1a0f45 38%, #4a1866 58%, #12092e 58.2%, #0b0720 100%); }
.stars { position: absolute; inset: 0 0 45% 0; background-image:
  radial-gradient(1px 1px at 10% 20%, #fff8, transparent), radial-gradient(1px 1px at 30% 70%, #fff6, transparent),
  radial-gradient(1.5px 1.5px at 55% 15%, #fffa, transparent), radial-gradient(1px 1px at 75% 40%, #fff7, transparent),
  radial-gradient(1px 1px at 88% 12%, #fff9, transparent), radial-gradient(1px 1px at 20% 45%, #fff5, transparent),
  radial-gradient(1.5px 1.5px at 65% 55%, #fff6, transparent), radial-gradient(1px 1px at 42% 33%, #fff8, transparent);
  animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { to { opacity: .5; } }
.sun { position: absolute; left: 50%; top: 58%; width: 46vmin; height: 23vmin; transform: translate(-50%, -100%); border-radius: 23vmin 23vmin 0 0;
  background: repeating-linear-gradient(180deg, transparent 0 55%, #12092e 55% 60%, transparent 60% 68%, #12092e 68% 75%, transparent 75% 82%, #12092e 82% 91%, transparent 91%),
    linear-gradient(180deg, #ffe76a 0%, #ff9d4a 45%, #ff3fa4 100%);
  background-size: 100% 100%; filter: drop-shadow(0 0 60px #ff3fa488); opacity: .85; }
.mountains { position: absolute; left: 0; right: 0; top: 46%; height: 12.2%;
  background: linear-gradient(180deg, #2a1150, #12092e);
  clip-path: polygon(0 100%, 0 60%, 6% 30%, 12% 55%, 20% 10%, 28% 50%, 35% 35%, 42% 70%, 50% 45%, 58% 72%, 66% 25%, 74% 55%, 82% 15%, 90% 50%, 96% 35%, 100% 55%, 100% 100%); opacity: .95; }
.floor { position: absolute; left: -50%; right: -50%; top: 58%; bottom: 0; perspective: 240px; overflow: hidden; }
.grid-lines { position: absolute; inset: -100% 0 0 0; transform: rotateX(62deg); transform-origin: 50% 100%;
  background-image: linear-gradient(90deg, #ff4fd866 2px, transparent 2px), linear-gradient(0deg, #ff4fd866 2px, transparent 2px);
  background-size: 80px 80px; animation: drive 2.4s linear infinite; mask-image: linear-gradient(transparent 20%, #000 70%); }
@keyframes drive { to { background-position: 0 80px; } }
body[data-screen="game"] .bg .grid-lines { animation-play-state: paused; }

/* ---------- sidebar ---------- */
.side { position: relative; z-index: 2; display: flex; flex-direction: column; padding: 18px 14px; gap: 10px;
  background: linear-gradient(180deg, rgba(15,10,40,.92), rgba(15,10,40,.78)); border-right: 1px solid var(--line); backdrop-filter: blur(10px); }
.side-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: .2em; padding: 0 6px; font-weight: 700; }
:is(.side, .main, .overlay) .players { display: flex; flex-direction: column; gap: 7px; flex: 1; overflow: auto; }
:is(.side, .main, .overlay) .pl { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 7px; border-radius: 14px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, transparent), rgba(255,255,255,.03));
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); animation: slidein .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes slidein { from { transform: translateX(-30px); opacity: 0; } }
:is(.side, .main, .overlay) .pl .av { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 26px;
  background: var(--c); box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 0 18px color-mix(in srgb, var(--c) 50%, transparent); }
:is(.side, .main, .overlay) .pl .av.wave { animation: wave .6s; }
@keyframes wave { 30% { transform: translateY(-10px) rotate(-12deg) scale(1.15); } 60% { transform: rotate(10deg); } }
:is(.side, .main, .overlay) .pl .pi { flex: 1; min-width: 0; }
:is(.side, .main, .overlay) .pl .pn { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:is(.side, .main, .overlay) .pl .ps { font-size: 11px; color: var(--muted); }
:is(.side, .main, .overlay) .pl .pts { font-family: var(--display); font-size: 18px; color: var(--gold); text-shadow: 0 2px 0 #0006; }
:is(.side, .main, .overlay) .pl.off { opacity: .45; filter: grayscale(.7); }
:is(.side, .main, .overlay) .pl.empty { background: transparent; border: 1px dashed var(--line); animation: none; opacity: .55; }
:is(.side, .main, .overlay) .pl.empty .av { background: rgba(255,255,255,.05); box-shadow: none; color: var(--muted); font-size: 20px; }
:is(.side, .main, .overlay) .join { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
:is(.side, .main, .overlay) .join img { width: 96px; height: 96px; border-radius: 10px; background: #fff; image-rendering: pixelated; }
:is(.side, .main, .overlay) .join-text { display: flex; flex-direction: column; gap: 3px; font-size: 12px; min-width: 0; }
:is(.side, .main, .overlay) .join-text span { color: var(--muted); }
:is(.side, .main, .overlay) .join-text code { font-size: 11px; word-break: break-all; }

/* ---------- main ---------- */
.main { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 0; padding: 18px 34px 0; }
:is(.side, .main, .overlay) .top { display: flex; align-items: center; justify-content: space-between; }
:is(.side, .main, .overlay) .logo { display: flex; align-items: baseline; gap: 4px; filter: drop-shadow(0 4px 0 #2a0b48) drop-shadow(0 0 22px #ff4fd866); transform: rotate(-3deg); }
:is(.side, .main, .overlay) .logo .l1 { font-family: var(--display); font-size: 52px; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff6b0 0%, #ffcf4a 35%, #ff7a3d 60%, #ff3fa4 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1px #fff5; }
:is(.side, .main, .overlay) .logo .l2 { font-family: 'Monoton', var(--display); font-size: 46px; color: var(--cyan); text-shadow: 0 0 6px var(--cyan), 0 0 24px #2ee6ffaa; transform: translateY(6px); }
:is(.side, .main, .overlay) .top-actions { display: flex; gap: 8px; }
:is(.side, .main, .overlay) .icon-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 16px; backdrop-filter: blur(8px); }
:is(.side, .main, .overlay) .icon-btn:hover { border-color: var(--pink); }
body.muted #mute { opacity: .5; }

:is(.side, .main, .overlay) .welcome { display: none; align-items: center; gap: 40px; margin: 26px 0 10px; padding: 26px; border-radius: 24px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); }
body.no-players .welcome { display: flex; }
body.no-players .join { display: none; }
:is(.side, .main, .overlay) .welcome-qr img { width: 220px; height: 220px; border-radius: 18px; background: #fff; padding: 8px; box-shadow: 0 0 0 4px var(--pink), 0 0 50px #ff4fd877; image-rendering: pixelated; }
:is(.side, .main, .overlay) .welcome h1 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0 0 14px; line-height: 1.15; }
:is(.side, .main, .overlay) .welcome h1 em { font-style: normal; color: var(--gold); }
:is(.side, .main, .overlay) .welcome ol { margin: 0; padding-left: 20px; line-height: 1.9; color: #ddd5ff; }
:is(.side, .main, .overlay) .welcome .tip { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

:is(.side, .main, .overlay) .games { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 18px; }
:is(.side, .main, .overlay) .section-title { display: flex; align-items: baseline; justify-content: space-between; letter-spacing: .25em; font-weight: 700; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
:is(.side, .main, .overlay) .section-title small { letter-spacing: 0; font-weight: 400; }
:is(.side, .main, .overlay) .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; overflow: auto; padding: 18px 12px 40px; margin: -8px -12px 0; scrollbar-width: none; grid-auto-rows: max-content; align-content: start; }
:is(.side, .main, .overlay) .card { text-align: left; padding: 0; border: none; border-radius: 20px; overflow: hidden; background: var(--panel-solid);
  box-shadow: 0 0 0 2px var(--line), 0 10px 30px #0006; transition: transform .18s cubic-bezier(.2,1.4,.4,1), box-shadow .18s; position: relative; display: flex; flex-direction: column; }
:is(.side, .main, .overlay) .card.sel { transform: translateY(-6px) scale(1.03); box-shadow: 0 0 0 4px var(--accent), 0 0 40px color-mix(in srgb, var(--accent) 60%, transparent), 0 20px 40px #0008; z-index: 2; }
:is(.side, .main, .overlay) .card.sel::after { content: 'Ⓐ JOUER'; position: absolute; right: 12px; top: 12px; background: var(--accent); color: #12092e; font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 99px; }
:is(.side, .main, .overlay) .cover { aspect-ratio: 16 / 9; position: relative; overflow: hidden; background: #000; }
:is(.side, .main, .overlay) .cover img, :is(.side, .main, .overlay) .detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
:is(.side, .main, .overlay) .badge { position: absolute; left: 10px; top: 10px; background: var(--gold); color: #2a0b48; font-weight: 700; font-size: 11px; padding: 3px 8px; border-radius: 99px; }
:is(.side, .main, .overlay) .gen-cover { width: 100%; height: 100%; display: grid; place-items: center; font-size: 80px;
  background: radial-gradient(circle at 50% 120%, var(--accent), transparent 70%), linear-gradient(135deg, #2a1660, #120b30); }
:is(.side, .main, .overlay) .card .meta { padding: 12px 16px 16px; }
:is(.side, .main, .overlay) .card h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0 0 4px; }
:is(.side, .main, .overlay) .card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; min-height: 36px; }
:is(.side, .main, .overlay) .chips { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
:is(.side, .main, .overlay) .chips span, :is(.side, .main, .overlay) .tags span { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.07); border: 1px solid var(--line); color: #d9d0ff; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; background: rgba(8,5,25,.7); backdrop-filter: blur(8px); }
.overlay.open { display: grid; animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
:is(.side, .main, .overlay) .detail-card { width: min(1000px, 90vw); display: grid; grid-template-columns: 1.1fr 1fr; border-radius: 28px; overflow: hidden; background: var(--panel-solid);
  box-shadow: 0 0 0 3px var(--accent), 0 0 80px color-mix(in srgb, var(--accent) 40%, transparent); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
:is(.side, .main, .overlay) .detail-cover { background: #000; min-height: 100%; }
:is(.side, .main, .overlay) .detail-cover .gen-cover { font-size: 140px; }
:is(.side, .main, .overlay) .detail-body { padding: 30px; display: flex; flex-direction: column; gap: 6px; }
:is(.side, .main, .overlay) .detail-body h2 { font-family: var(--display); font-weight: 400; font-size: 40px; margin: 8px 0 0; color: var(--accent); text-shadow: 0 3px 0 #0007; }
:is(.side, .main, .overlay) .detail-body .tagline { color: var(--gold); margin: 0; }
:is(.side, .main, .overlay) .detail-body p { color: #d9d0ff; line-height: 1.55; margin: 6px 0; font-size: 14px; }
:is(.side, .main, .overlay) .tags { display: flex; gap: 6px; flex-wrap: wrap; }
:is(.side, .main, .overlay) .controls { display: grid; gap: 8px; margin: 10px 0; }
:is(.side, .main, .overlay) .controls div { display: flex; gap: 12px; align-items: center; font-size: 14px; }
:is(.side, .main, .overlay) .controls kbd { min-width: 64px; text-align: center; }
:is(.side, .main, .overlay) .detail-actions { display: flex; gap: 12px; margin-top: auto; padding-top: 14px; align-items: center; }
:is(.side, .main, .overlay) .btn { border: 1px solid var(--line); background: rgba(255,255,255,.07); padding: 12px 22px; border-radius: 14px; font-weight: 700; font-size: 16px; }
:is(.side, .main, .overlay) .btn.primary { background: linear-gradient(180deg, var(--gold), var(--orange)); color: #2a0b48; border: none; box-shadow: 0 4px 0 #9a3a12, 0 0 30px #ff7a3d77; }
:is(.side, .main, .overlay) .warn { color: var(--gold); font-size: 13px; flex: 1; }

:is(.side, .main, .overlay) .results-card { width: min(820px, 92vw); text-align: center; padding: 30px; border-radius: 28px; background: var(--panel-solid); box-shadow: 0 0 0 3px var(--gold), 0 0 80px #ffcf4a44; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
:is(.side, .main, .overlay) .results-card h2 { font-family: var(--display); font-weight: 400; margin: 0; color: var(--gold); font-size: 30px; }
:is(.side, .main, .overlay) .podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 24px 0 18px; min-height: 260px; }
:is(.side, .main, .overlay) .pod { width: 170px; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: rise .6s cubic-bezier(.2,1.4,.4,1) both; }
:is(.side, .main, .overlay) .pod.second { animation-delay: .25s; } :is(.side, .main, .overlay) .pod.third { animation-delay: .4s; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
:is(.side, .main, .overlay) .pav { font-size: 56px; width: 88px; height: 88px; display: grid; place-items: center; border-radius: 22px; background: var(--c); box-shadow: inset 0 -6px 0 #0004, 0 0 30px var(--c); }
:is(.side, .main, .overlay) .pod.first .pav { width: 108px; height: 108px; font-size: 70px; animation: bob 1.2s ease-in-out infinite; }
:is(.side, .main, .overlay) .pod.first .pav::before { content: '👑'; position: absolute; transform: translateY(-62px); font-size: 36px; }
@keyframes bob { 50% { transform: translateY(-8px); } }
:is(.side, .main, .overlay) .pname { font-weight: 700; font-size: 16px; }
:is(.side, .main, .overlay) .pscore { color: var(--muted); font-size: 12px; }
:is(.side, .main, .overlay) .pblock { width: 100%; border-radius: 12px 12px 0 0; display: grid; place-items: center; font-family: var(--display); font-size: 40px; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 80%, #fff 0%), color-mix(in srgb, var(--c) 40%, #12092e)); }
:is(.side, .main, .overlay) .pod.first .pblock { height: 120px; } :is(.side, .main, .overlay) .pod.second .pblock { height: 84px; } :is(.side, .main, .overlay) .pod.third .pblock { height: 60px; }
:is(.side, .main, .overlay) .rlist { display: flex; flex-direction: column; gap: 6px; max-width: 520px; margin: 0 auto; }
:is(.side, .main, .overlay) .rrow { display: grid; grid-template-columns: 40px 36px 1fr auto 50px; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: color-mix(in srgb, var(--c) 18%, transparent); text-align: left; }
:is(.side, .main, .overlay) .rav { font-size: 22px; } :is(.side, .main, .overlay) .rs { color: var(--muted); font-size: 13px; } :is(.side, .main, .overlay) .rp { color: var(--gold); font-weight: 700; text-align: right; }
:is(.side, .main, .overlay) .hint { color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ---------- party mode ---------- */
:is(.side, .main, .overlay) .kicker { font-size: 13px; letter-spacing: .28em; font-weight: 700; color: var(--cyan); }
/* lobby tile */
.main .card.party-tile { background: linear-gradient(160deg, #3a1a6e, #1d1545 60%); }
.main .card.party-tile::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--spin, 0deg), var(--pink), var(--gold), var(--cyan), var(--pink));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spin 4s linear infinite; }
@property --spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --spin: 360deg; } }
.main .party-cover { width: 100%; height: 100%; display: grid; place-items: center; position: relative; overflow: hidden;
  background: radial-gradient(circle at 50% 110%, #ffcf4a, #ff4fd8 45%, #2a1660 80%); }
.main .party-cover span { font-size: 78px; filter: drop-shadow(0 6px 0 #0005); animation: bob 1.6s ease-in-out infinite; }
.main .party-cover em { position: absolute; bottom: 10px; font-style: normal; font-family: var(--display); font-size: 26px; letter-spacing: 6px; color: #fff; text-shadow: 0 3px 0 #2a0b48, 0 0 20px #ff4fd8; }

/* setup */
.overlay .party-card { width: min(980px, 94vw); max-height: 94vh; overflow: auto; padding: 28px 32px; border-radius: 28px; background: var(--panel-solid);
  box-shadow: 0 0 0 3px var(--gold), 0 0 90px #ffcf4a44; animation: pop .35s cubic-bezier(.2,1.4,.4,1); display: flex; flex-direction: column; gap: 12px; }
.overlay .party-head h2 { font-family: var(--display); font-weight: 400; font-size: 36px; margin: 4px 0 6px; color: var(--gold); text-shadow: 0 3px 0 #0007; }
.overlay .prow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-radius: 16px; border: 2px solid transparent; background: rgba(255,255,255,.04); transition: border-color .15s, background .15s, transform .15s; }
.overlay .prow.focus { border-color: var(--gold); background: rgba(255,207,74,.1); transform: scale(1.01); box-shadow: 0 0 24px #ffcf4a33; }
.overlay .prow label { display: flex; flex-direction: column; gap: 2px; }
.overlay .prow label b { font-size: 20px; }
.overlay .prow label small { color: var(--muted); font-size: 12px; }
.overlay .stepper { display: flex; align-items: center; gap: 10px; }
.overlay .stepper button { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.08); font-size: 18px; }
.overlay .stepper button:disabled { opacity: .25; cursor: default; }
.overlay .stepper button:not(:disabled):hover { border-color: var(--gold); }
.overlay .stepper .sval { min-width: 64px; text-align: center; font-family: var(--display); font-weight: 400; font-size: 40px; color: var(--gold); text-shadow: 0 3px 0 #9a3a12; }
.overlay .stepper .sval.bump { animation: bump .3s cubic-bezier(.2,1.6,.4,1); }
@keyframes bump { 40% { transform: scale(1.45); } }
.overlay .playlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 6px 2px; }
.overlay .pchip { display: flex; flex-direction: column; gap: 6px; font-size: 13px; text-align: center; }
.overlay .playlist.deal .pchip { animation: deal .45s cubic-bezier(.2,1.4,.4,1) var(--d) both; }
@keyframes deal { from { transform: translateY(-30px) rotate(-8deg) scale(.7); opacity: 0; } }
.overlay .pcov { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 2px var(--accent), 0 6px 18px #0007; }
.overlay .pcov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.overlay .pcov .gen-cover { font-size: 40px; }
.overlay .pnum { position: absolute; left: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #12092e; font-weight: 700; }
.overlay .prounds { position: absolute; right: 6px; top: 6px; padding: 2px 8px; border-radius: 99px; background: #12092ecc; color: var(--gold); font-weight: 700; }
.overlay .psummary { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; color: #d9d0ff; font-size: 15px; padding: 4px 4px 0; }
.overlay .psummary b { color: var(--gold); font-size: 18px; }
.overlay .psummary .scale { margin-left: auto; color: var(--muted); font-size: 13px; }
.overlay .pactions { display: flex; gap: 12px; }
.overlay .pactions .prow { padding: 4px; background: none; flex: 0 0 auto; }
.overlay .pactions .prow:last-child { flex: 1; }
.overlay .pactions .prow:last-child .btn { width: 100%; font-size: 20px; padding: 16px; }
.overlay .btn:disabled { opacity: .4; cursor: default; }
.overlay .party-card .hint { margin: 0; text-align: center; }
.overlay .toggle { width: 104px; height: 46px; border-radius: 99px; border: 1px solid var(--line); background: rgba(255,255,255,.08); position: relative; flex: none; }
.overlay .toggle::before { content: ''; position: absolute; top: 5px; left: 5px; width: 36px; height: 36px; border-radius: 50%; background: #6b6290; transition: transform .25s cubic-bezier(.2,1.5,.4,1), background .2s; }
.overlay .toggle span { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.overlay .toggle.on { background: linear-gradient(90deg, var(--orange), var(--pink)); border-color: transparent; box-shadow: 0 0 20px #ff7a3d66; }
.overlay .toggle.on::before { transform: translateX(58px); background: #fff; }
.overlay .toggle.on span { right: auto; left: 16px; color: #fff; }
.overlay .toggle.bump { animation: bump .3s cubic-bezier(.2,1.6,.4,1); }
.overlay .x2 { color: var(--orange); font-style: normal; text-shadow: 0 0 12px #ff7a3d88; }
.overlay .intro-card.final { box-shadow: 0 0 0 3px var(--orange), 0 0 120px #ff7a3daa; animation: slam .5s cubic-bezier(.2,1.5,.4,1), firepulse 1s .5s ease-in-out infinite alternate; }
@keyframes firepulse { to { box-shadow: 0 0 0 5px var(--gold), 0 0 160px #ff4fd8aa; } }
.overlay .double-tag { display: inline-block; margin-bottom: 10px; padding: 6px 18px; border-radius: 99px; font-family: var(--display); font-size: 18px; color: #2a0b48;
  background: linear-gradient(90deg, var(--gold), var(--orange), var(--gold)); background-size: 200% 100%; box-shadow: 0 4px 0 #9a3a12, 0 0 30px #ff7a3d;
  animation: stamp .5s cubic-bezier(.2,1.6,.4,1) .2s both, shine 1.4s linear infinite; }

/* match intro */
.overlay .intro-card { width: min(620px, 90vw); text-align: center; padding: 26px 30px 22px; border-radius: 28px; background: var(--panel-solid);
  box-shadow: 0 0 0 3px var(--accent), 0 0 100px color-mix(in srgb, var(--accent) 50%, transparent); animation: slam .5s cubic-bezier(.2,1.5,.4,1); }
@keyframes slam { from { transform: scale(1.6) rotate(-4deg); opacity: 0; } }
.overlay .intro-cover { aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; margin: 14px 0; box-shadow: 0 10px 30px #0008; }
.overlay .intro-cover img { width: 100%; height: 100%; object-fit: cover; display: block; animation: kenburns 3.4s ease-out both; }
@keyframes kenburns { from { transform: scale(1.18); } }
.overlay .intro-card h2 { font-family: var(--display); font-weight: 400; font-size: 46px; margin: 0; color: var(--accent); text-shadow: 0 4px 0 #0008; }
.overlay .intro-card .sub { color: var(--gold); margin: 6px 0 12px; font-weight: 700; }
.overlay .intro-controls { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 14px; color: #d9d0ff; }
.overlay .intro-bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); margin-top: 18px; overflow: hidden; }
.overlay .intro-bar i { display: block; height: 100%; background: var(--accent); animation: fill 3.4s linear both; }
@keyframes fill { from { width: 0; } to { width: 100%; } }

/* vote for the next game */
.overlay .vq { width: 100%; height: 100%; display: grid; place-items: center; font-size: 42px; background: radial-gradient(circle at 50% 120%, #ffcf4a, #ff4fd8 50%, #2a1660 85%); }
.overlay .ncov.vq { font-size: 26px; }
.overlay .vote-card { width: min(1120px, 95vw); padding: 24px 28px 18px; border-radius: 28px; background: var(--panel-solid); box-shadow: 0 0 0 3px var(--gold), 0 0 90px #ffcf4a44; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.overlay .vote-head { text-align: center; margin-bottom: 18px; }
.overlay .vote-head h2 { font-family: var(--display); font-weight: 400; font-size: 42px; margin: 4px 0; color: var(--gold); text-shadow: 0 3px 0 #0007; }
.overlay .vsub { margin: 0; color: #d9d0ff; font-size: 16px; min-height: 1.4em; }
.overlay .vsub .vtime { font-family: var(--display); font-weight: 400; color: #fff; font-size: 20px; }
.overlay .vopts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.overlay .vopt { position: relative; border-radius: 20px; overflow: hidden; background: #1b1440; box-shadow: 0 0 0 2px var(--line), 0 10px 30px #0006;
  transition: transform .25s cubic-bezier(.2,1.4,.4,1), box-shadow .25s, opacity .3s, filter .3s; animation: deal .5s cubic-bezier(.2,1.4,.4,1) var(--d) both; }
.overlay .vcov { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #000; }
.overlay .vcov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.overlay .vcount { position: absolute; right: 10px; top: 10px; min-width: 46px; text-align: center; padding: 2px 10px; border-radius: 14px; font-family: var(--display); font-size: 30px;
  background: #0f0b24dd; color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.overlay .vcount.bump { animation: bump .35s cubic-bezier(.2,1.6,.4,1); }
.overlay .vbody { padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 4px; }
.overlay .vbody b { font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--accent); }
.overlay .vbody small { color: var(--muted); font-size: 13px; line-height: 1.35; min-height: 2.7em; }
.overlay .vvoters { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 16px 16px; min-height: 58px; align-content: flex-start; }
.overlay .vvoters span { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 24px; background: var(--c); box-shadow: inset 0 -3px 0 #0004, 0 0 12px var(--c); animation: stamp .35s cubic-bezier(.2,1.6,.4,1); }
.overlay .vopt.lead { box-shadow: 0 0 0 3px var(--accent), 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent); }
.overlay .vopt.spin { transform: scale(1.05); box-shadow: 0 0 0 4px var(--gold), 0 0 50px #ffcf4a88; }
.overlay .vopt.win { transform: scale(1.08); z-index: 2; box-shadow: 0 0 0 5px var(--gold), 0 0 90px var(--accent); }
.overlay .vopt.lose { opacity: .35; filter: grayscale(.7); transform: scale(.94); }
.overlay .vbar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); margin-top: 18px; overflow: hidden; }
.overlay .vbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--gold)); animation: drain linear forwards; }
.overlay .vbar.stop i { animation-play-state: paused; }
@keyframes drain { from { width: 100%; } to { width: 0; } }
.overlay .vote-card .hint { text-align: center; margin: 12px 0 0; }

/* standings */
.overlay .stand-card { width: min(900px, 94vw); padding: 24px 30px 20px; border-radius: 28px; background: var(--panel-solid); box-shadow: 0 0 0 3px var(--cyan), 0 0 90px #2ee6ff33; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.overlay .stand-head { text-align: center; position: relative; margin-bottom: 18px; }
.overlay .stand-head h2 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 4px 0 0; color: var(--gold); text-shadow: 0 3px 0 #0007; }
.overlay .leader-flash { min-height: 44px; }
.overlay .leader-flash span { display: inline-block; margin-top: 8px; padding: 6px 18px; border-radius: 99px; font-family: var(--display); font-size: 18px; color: #12092e;
  background: linear-gradient(90deg, var(--gold), #fff3b0, var(--gold)); background-size: 200% 100%; box-shadow: 0 0 30px var(--c), 0 4px 0 #9a3a12;
  animation: stamp .5s cubic-bezier(.2,1.6,.4,1), shine 1.6s linear infinite; position: relative; z-index: 3; }
@keyframes stamp { from { transform: scale(2.4) rotate(-6deg); opacity: 0; } }
@keyframes shine { to { background-position: -200% 0; } }
.overlay .board { position: relative; margin-top: 4px; }
.overlay .srow { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--rh) - 8px); translate: 0 calc(var(--y) * var(--rh));
  transition: translate .75s cubic-bezier(.3,1.35,.45,1), box-shadow .3s; display: grid; grid-template-columns: 44px 48px minmax(0, 1.3fr) 1fr 64px 76px 46px; align-items: center; gap: 10px;
  padding: 0 14px 0 8px; border-radius: 14px; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 28%, #1d1545), #1d1545 70%); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  animation: slidein .4s cubic-bezier(.2,1.4,.4,1) both; }
.overlay .srow.rising { z-index: 2; box-shadow: 0 0 0 2px #42e695aa, 0 10px 30px #0009; }
.overlay .srow.falling { z-index: 0; opacity: .92; }
.overlay .srank { font-family: var(--display); font-size: 24px; text-align: center; color: #fff; }
.overlay .sav { width: calc(var(--rh) - 20px); height: calc(var(--rh) - 20px); max-width: 44px; max-height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px;
  background: var(--c); box-shadow: inset 0 -4px 0 #0004; }
.overlay .sname { display: flex; flex-direction: column; min-width: 0; }
.overlay .sname b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay .sname small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay .sbar { height: 12px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.overlay .sbar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 60%, #fff), var(--c)); box-shadow: 0 0 12px var(--c);
  transition: width .9s cubic-bezier(.2,.9,.3,1); }
.overlay .sgain { font-family: var(--display); font-size: 22px; color: var(--gold); text-align: right; opacity: 0; transform: scale(.3); }
.overlay .srow.gain .sgain { animation: gainpop .5s cubic-bezier(.2,1.8,.4,1) forwards; }
.overlay .srow.counted .sgain { animation: gainpop .5s cubic-bezier(.2,1.8,.4,1) forwards, gainfade .6s .9s forwards; }
@keyframes gainpop { 0% { opacity: 0; transform: scale(.3) translateY(10px); } 60% { opacity: 1; transform: scale(1.5); } 100% { opacity: 1; transform: scale(1); } }
@keyframes gainfade { to { opacity: .35; transform: scale(.85); } }
.overlay .srow.gain .sav { animation: wave .6s; }
.overlay .stotal { font-family: var(--display); font-size: 30px; text-align: right; color: #fff; text-shadow: 0 2px 0 #0007; font-variant-numeric: tabular-nums; }
.overlay .smove { font-weight: 700; font-size: 15px; opacity: 0; }
.overlay .smove.up { color: #42e695; animation: movein .4s .45s forwards; }
.overlay .smove.down { color: #ff4f6d; animation: movein .4s .45s forwards; }
@keyframes movein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.overlay .srow.leader { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 34px #ffcf4a66; z-index: 3; }
.overlay .srow.leader .srank { font-size: 0; }
.overlay .srow.leader .srank::after { content: '👑'; font-size: 28px; display: inline-block; animation: stamp .5s cubic-bezier(.2,1.6,.4,1), bob 1.2s .5s ease-in-out infinite; }
.overlay .stand-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.overlay .next { display: flex; align-items: center; gap: 12px; }
.overlay .next.final { color: #d9d0ff; }
.overlay .next.final b { color: var(--gold); }
.overlay .ncov { width: 96px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; flex: none; }
.overlay .ncov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.overlay .ncov .gen-cover { font-size: 26px; }
.overlay .next small { display: block; font-size: 11px; letter-spacing: .2em; color: var(--muted); }
.overlay .next b { font-size: 18px; }
.overlay .next em { font-style: normal; color: var(--gold); margin-left: 8px; font-size: 13px; }
.overlay .stand-foot .hint { margin: 0; }
.overlay .stand-card .when-done, .overlay .stand-card.done .when-anim { display: none; }
.overlay .stand-card.done .when-done { display: inline; color: var(--gold); font-weight: 700; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* final */
.overlay .final-card { width: min(760px, 94vw); max-height: 96vh; overflow: auto; text-align: center; padding: 26px 30px 20px; border-radius: 28px; background: var(--panel-solid);
  box-shadow: 0 0 0 3px var(--gold), 0 0 120px #ffcf4a55; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.overlay .champ-wrap { position: relative; padding: 10px 0 6px; animation: champin .7s cubic-bezier(.2,1.6,.4,1) var(--reveal) both; }
@keyframes champin { from { transform: scale(.2); opacity: 0; } }
.overlay .rays { position: absolute; left: 50%; top: 42%; width: 520px; height: 520px; margin: -260px 0 0 -260px; z-index: 0; pointer-events: none; opacity: .5;
  background: repeating-conic-gradient(#ffcf4a33 0 10deg, transparent 10deg 20deg); border-radius: 50%; mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  animation: rotate 14s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }
.overlay .champs { position: relative; z-index: 1; display: flex; justify-content: center; gap: 26px; }
.overlay .champ { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.overlay .champ-av { position: relative; width: 120px; height: 120px; border-radius: 30px; display: grid; place-items: center; font-size: 78px; background: var(--c);
  box-shadow: inset 0 -8px 0 #0004, 0 0 60px var(--c); animation: bob 1.2s ease-in-out infinite; }
.overlay .champ-av::before { content: '👑'; position: absolute; top: -46px; font-size: 46px; animation: stamp .6s cubic-bezier(.2,1.6,.4,1) var(--reveal) both; }
.overlay .champ-name { font-family: var(--display); font-size: 26px; color: #fff; text-shadow: 0 3px 0 #0008, 0 0 20px var(--c); }
.overlay .champ-wrap h2 { position: relative; font-family: var(--display); font-weight: 400; font-size: 40px; margin: 10px 0 0; color: var(--gold); text-shadow: 0 4px 0 #9a3a12, 0 0 40px #ff7a3d; }
.overlay .champ-pts { position: relative; color: #d9d0ff; font-size: 16px; }
.overlay .champ-pts b { font-family: var(--display); font-weight: 400; font-size: 30px; color: #fff; }
.overlay .final-list { display: flex; flex-direction: column; gap: 6px; max-width: 560px; margin: 18px auto 0; }
.overlay .frow { display: grid; grid-template-columns: 52px 40px 1fr auto 90px; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 12px; text-align: left;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 26%, transparent), rgba(255,255,255,.03)); animation: rise .5s cubic-bezier(.2,1.4,.4,1) var(--d) both; }
.overlay .frow.champ-row { box-shadow: 0 0 0 2px var(--gold); }
.overlay .frank { font-family: var(--display); font-size: 18px; text-align: center; }
.overlay .fav { font-size: 24px; }
.overlay .fname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay .fwins { color: var(--muted); font-size: 13px; }
.overlay .ftotal { font-family: var(--display); font-size: 22px; text-align: right; color: var(--gold); }
.overlay .ftotal small { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.overlay .recap-row { display: flex; align-items: center; gap: 16px; margin: 16px auto 0; max-width: 620px; padding: 10px 14px; border-radius: 16px;
  background: rgba(46,230,255,.07); border: 1px solid rgba(46,230,255,.25); color: #d9d0ff; font-size: 14px; text-align: left; justify-content: center; }
.overlay .recap-row.ready { animation: pop .45s cubic-bezier(.2,1.5,.4,1); justify-content: flex-start; }
.overlay .recap-thumb { height: 96px; border-radius: 10px; box-shadow: 0 6px 20px #0008; }
.overlay .recap-txt { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.overlay .recap-txt b { color: #fff; font-size: 16px; }
.overlay .recap-qr { width: 96px; height: 96px; border-radius: 10px; background: #fff; padding: 4px; image-rendering: pixelated; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 30; pointer-events: none; }

/* ---------- game stage ---------- */
.stage { position: fixed; inset: 0; z-index: 10; display: none; background: #000; overflow: hidden; }
body[data-screen="game"] > .stage { display: block; }
body[data-screen="game"] > .side, body[data-screen="game"] > .main { visibility: hidden; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 50; pointer-events: none;
  font-family: var(--display); font-size: 22vmin; color: var(--gold); text-shadow: 0 8px 0 #9a3a12, 0 0 60px #ff7a3d; }
.countdown.pop { animation: cd .8s ease-out; }
@keyframes cd { from { transform: scale(2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } to { transform: scale(.9); opacity: .2; } }
.banner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); z-index: 50; pointer-events: none;
  font-family: var(--display); font-size: 6vmin; color: #fff; text-shadow: 0 5px 0 #0008, 0 0 30px var(--pink); animation: pop .35s cubic-bezier(.2,1.4,.4,1); white-space: nowrap; }
.banner.out { opacity: 0; transition: opacity .4s; }

/* ---------- records ---------- */
.record-splash { position: fixed; left: 50%; top: 9%; z-index: 46; transform: translateX(-50%); display: none; text-align: center; pointer-events: none;
  padding: 18px 40px 16px; border-radius: 26px; background: linear-gradient(180deg, #2a1660ee, #12092eee); box-shadow: 0 0 0 3px var(--gold), 0 0 80px #ffcf4a88; }
.record-splash.show { display: block; animation: rsin .6s cubic-bezier(.2,1.6,.4,1), rsout .5s 3.7s forwards; }
@keyframes rsin { from { transform: translateX(-50%) scale(2.2) rotate(-6deg); opacity: 0; } }
@keyframes rsout { to { transform: translateX(-50%) translateY(-30px) scale(.9); opacity: 0; } }
.record-splash .rs-kick { font-family: var(--display); font-size: 40px; color: var(--gold); text-shadow: 0 4px 0 #9a3a12, 0 0 30px #ff7a3d;
  background: linear-gradient(90deg, #ffcf4a, #fff3b0, #ffcf4a); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shine 1.4s linear infinite; }
.record-splash .rs-who { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; font-size: 22px; }
.record-splash .rs-who b { color: var(--c); }
.record-splash .rs-av { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 28px; background: var(--c); box-shadow: 0 0 20px var(--c); }
.record-splash .rs-score { font-family: var(--display); font-size: 46px; color: #fff; line-height: 1.1; margin-top: 4px; }
.record-splash .rs-score small { font-family: var(--mono); font-size: 18px; color: var(--muted); }
.record-splash .rs-game { color: var(--muted); font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }
.overlay .rbadge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: var(--gold); color: #2a0b48; font-size: 11px; font-weight: 700; animation: stamp .45s cubic-bezier(.2,1.6,.4,1); }
.overlay .rec-line { margin-top: 12px; color: #d9d0ff; font-size: 14px; min-height: 1.2em; }
.overlay .hof { margin-top: 6px; padding: 10px 12px; border-radius: 14px; background: rgba(255,207,74,.07); border: 1px solid rgba(255,207,74,.25); display: flex; flex-direction: column; gap: 6px; }
.overlay .hof.empty { color: var(--muted); font-size: 13px; }
.overlay .hof-title { font-size: 11px; letter-spacing: .25em; font-weight: 700; color: var(--gold); }
.overlay .hof-board small { display: block; color: var(--muted); font-size: 11px; margin: 2px 0; }
.overlay .hof-row { display: grid; grid-template-columns: 28px 24px 1fr auto; gap: 6px; align-items: center; font-size: 13px; }
.overlay .hof-row .n { color: var(--c); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay .hof-row .s { color: #fff; font-weight: 700; }

/* ---------- emoji reactions ---------- */
.reactions { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.react-fly { position: absolute; left: var(--x); bottom: -90px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  animation: floatup 3.4s cubic-bezier(.25,.6,.3,1) forwards; will-change: transform, opacity; }
.react-fly .re { font-size: calc(68px * var(--s)); line-height: 1; filter: drop-shadow(0 0 14px var(--c)) drop-shadow(0 4px 0 #0006);
  animation: wiggle .6s ease-in-out infinite alternate; }
.react-fly .rn { font: 700 13px var(--mono); padding: 2px 9px; border-radius: 99px; background: var(--c); color: #12092e; white-space: nowrap; box-shadow: 0 2px 0 #0005; }
@keyframes floatup {
  0% { transform: translate(-50%, 0) scale(.3); opacity: 0; }
  10% { transform: translate(-50%, -12vh) scale(1.15); opacity: 1; }
  20% { transform: translate(-50%, -20vh) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--drift)), -82vh) rotate(var(--rot)) scale(.9); opacity: 0; }
}
@keyframes wiggle { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }

/* ---------- misc ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; box-shadow: 0 10px 30px #0008; animation: slidein .3s; font-size: 14px; }
.toast.out { opacity: 0; transform: translateY(10px); transition: .4s; }
.offline-msg { display: none; position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 99; background: #ff4f6d; color: #fff; padding: 8px 16px; border-radius: 99px; font-weight: 700; }
body.offline .offline-msg { display: block; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; overflow-x: auto; }
  :is(.side, .main, .overlay) .players { flex-direction: row; }
  :is(.side, .main, .overlay) .welcome { flex-direction: column; text-align: center; }
}
