:root {
  --bg: #0d0b1f;
  --bg2: #17142f;
  --card: #1f1b3d;
  --card2: #2a2550;
  --line: #3a3466;
  --text: #f4f1ff;
  --muted: #a49fc9;
  --pink: #ff3d8b;
  --cyan: #2de2e6;
  --yellow: #ffd23f;
  --green: #3ddc84;
  --red: #ff5a5f;
  --violet: #8b5cf6;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100%; }
body { background: radial-gradient(1200px 600px at 10% -10%, #2b1a5a 0%, transparent 60%), radial-gradient(900px 500px at 110% 10%, #0f3a4a 0%, transparent 55%), var(--bg); background-attachment: fixed; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--cyan); }
.hidden { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-b)); }
.wrap.wide { max-width: 980px; }

/* ---- en-tête ---- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.logo { font-weight: 900; letter-spacing: -0.03em; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(var(--pink), var(--violet), var(--cyan), var(--pink)); box-shadow: 0 0 18px #ff3d8b88; }
.top .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.pill strong { color: var(--text); letter-spacing: 0.12em; }
.net { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.net.off { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ---- cartes, formulaires ---- */
.card { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 18px; }
.card h2 small { color: var(--muted); font-weight: 500; font-size: 14px; }
label.field { display: block; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
label.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=url], select {
  width: 100%; padding: 14px 14px; border-radius: 14px; border: 1px solid var(--line); background: #0f0d24; outline: none; font-size: 17px;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px #2de2e633; }
input.code-input { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-size: 30px; font-weight: 800; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--text); }
.check input { width: 22px; height: 22px; accent-color: var(--pink); }
input[type=range] { width: 100%; accent-color: var(--pink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; cursor: pointer; background: var(--card2); color: var(--text); text-decoration: none; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--pink), var(--violet)); box-shadow: 0 8px 24px #ff3d8b44; }
.btn.cyan { background: linear-gradient(135deg, #18b8c9, var(--cyan)); color: #04222a; }
.btn.green { background: var(--green); color: #052611; }
.btn.red { background: var(--red); color: #2a0506; }
.btn.yellow { background: var(--yellow); color: #2a2000; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.big { padding: 18px; font-size: 19px; border-radius: 18px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.icon { padding: 8px; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: var(--red); min-height: 1.4em; font-size: 14px; }

/* ---- segments / onglets ---- */
.seg { display: flex; background: #0f0d24; border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { white-space: nowrap; font-size: 15px; flex: 1; border: 0; background: transparent; padding: 10px 8px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.mode-cards label { border: 2px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; background: #0f0d24; }
.mode-cards input { display: none; }
.mode-cards label:has(input:checked) { border-color: var(--pink); background: #2a1238; }
.mode-cards b { display: block; font-size: 17px; margin-bottom: 4px; }
.mode-cards small { color: var(--muted); }

/* ---- listes de titres ---- */
.tracks { list-style: none; margin: 0; padding: 0; }
.tracks li { display: flex; align-items: center; gap: 8px; padding: 9px 4px; border-bottom: 1px solid #2c2756; }
.tracks li:last-child { border-bottom: 0; }
.tracks .meta { flex: 1; min-width: 0; }
.tracks .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracks .a { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracks img, .tracks .noimg { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--card2); flex: 0 0 44px; display: grid; place-items: center; font-size: 18px; }
.src { font-size: 11px; padding: 2px 6px; border-radius: 6px; font-weight: 800; letter-spacing: .04em; }
.src.deezer { background: #a238ff33; color: #d7a6ff; }
.src.local { background: #2de2e622; color: var(--cyan); }
.tracks input.start { width: 52px; flex: 0 0 52px; padding: 6px 8px; font-size: 14px; border-radius: 8px; }
.list-scroll { max-height: 50vh; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; }

/* ---- jeu ---- */
.round-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.round-head .n { font-weight: 900; font-size: 20px; }
.timer { height: 10px; border-radius: 99px; background: #0f0d24; overflow: hidden; margin: 6px 0 16px; border: 1px solid var(--line); }
.timer > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); transform-origin: left; }
.timer.paused > i { background: var(--yellow); }

.buzz-zone { display: grid; place-items: center; padding: 10px 0 18px; }
.buzzer { width: min(74vw, 300px); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer; font-size: 44px; font-weight: 900; letter-spacing: 0.04em; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff8fbd, var(--pink) 45%, #b0115a 100%);
  box-shadow: 0 14px 0 #7c0a3e, 0 22px 50px #ff3d8b66, inset 0 -8px 20px #0003; transition: transform .07s, box-shadow .07s; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.buzzer:active:not(:disabled), .buzzer.pressed { transform: translateY(10px); box-shadow: 0 4px 0 #7c0a3e, 0 10px 30px #ff3d8b66, inset 0 -8px 20px #0003; }
.buzzer:disabled { background: radial-gradient(circle at 35% 30%, #6d6890, #3e3a62 60%, #2b2848); box-shadow: 0 14px 0 #1d1a36, inset 0 -8px 20px #0003; color: #aaa6cc; font-size: 22px; cursor: default; }
.buzzer.win { background: radial-gradient(circle at 35% 30%, #a6ffcf, var(--green) 50%, #13894a); box-shadow: 0 14px 0 #0b5a30, 0 22px 60px #3ddc8466; font-size: 26px; color: #052611; }
.state-msg { text-align: center; font-size: 20px; font-weight: 750; margin: 6px 0 4px; }
.state-sub { text-align: center; color: var(--muted); margin-bottom: 8px; }

.choices { display: grid; gap: 10px; }
.choice { border: 0; border-radius: 16px; padding: 18px 16px; font-weight: 750; font-size: 17px; text-align: left; cursor: pointer; color: #fff; min-height: 64px; transition: transform .08s, opacity .2s; }
.choice:active { transform: scale(.98); }
.choice.c0 { background: #e0457b; } .choice.c1 { background: #3b82f6; } .choice.c2 { background: #e6a817; color: #241800; } .choice.c3 { background: #22a06b; }
.choice.dim { opacity: .3; }
.choice.picked { outline: 4px solid #fff; }
.choice.good { outline: 4px solid var(--green); opacity: 1; }
.choice.bad { outline: 4px solid var(--red); }

.reveal { display: flex; gap: 14px; align-items: center; }
.reveal img, .reveal .noimg { width: 92px; height: 92px; border-radius: 14px; object-fit: cover; background: var(--card2); flex: 0 0 92px; display: grid; place-items: center; font-size: 36px; }
.reveal .title { font-size: 20px; font-weight: 850; line-height: 1.2; }
.reveal .artist { color: var(--cyan); font-weight: 700; }
.reveal .album { color: var(--muted); font-size: 14px; }
.results { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 10px; border-radius: 999px; background: var(--card2); font-size: 14px; font-weight: 650; }
.chip.gain { background: #3ddc8422; color: var(--green); }
.chip.loss { background: #ff5a5f22; color: var(--red); }
.big-points { font-size: 40px; font-weight: 900; text-align: center; margin: 8px 0 0; }
.big-points.zero { color: var(--muted); font-size: 22px; }

/* ---- tableau des scores ---- */
.board { position: relative; transition: height .3s; }
.board .r { position: absolute; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-radius: 14px; transition: transform .55s cubic-bezier(.2,.8,.2,1), background .3s; }
.board .r.me { background: #ffffff10; }
.board .rank { width: 26px; text-align: center; font-weight: 900; color: var(--muted); }
.board .r:nth-child(1) .rank { color: var(--yellow); }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #120e26; flex: 0 0 34px; }
.av.k0 { background: #ff3d8b; } .av.k1 { background: #2de2e6; } .av.k2 { background: #ffd23f; } .av.k3 { background: #3ddc84; }
.av.k4 { background: #8b5cf6; color: #fff; } .av.k5 { background: #ff8a3d; } .av.k6 { background: #60a5fa; } .av.k7 { background: #f472b6; }
.board .nm { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .nm .off { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.board .sc { font-weight: 900; font-variant-numeric: tabular-nums; font-size: 18px; }
.board .delta { font-size: 13px; font-weight: 800; color: var(--green); min-width: 44px; text-align: right; }
.board .delta.neg { color: var(--red); }
.board .r.buzzing { background: #3ddc8433; }
.board .r.out { opacity: .5; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 10px 0 18px; }
.podium .step { flex: 1; max-width: 140px; text-align: center; }
.podium .block { border-radius: 14px 14px 6px 6px; display: grid; place-items: center; font-size: 30px; font-weight: 900; margin-top: 8px; }
.podium .p1 .block { height: 130px; background: linear-gradient(180deg, var(--yellow), #b88a00); color: #2a2000; }
.podium .p2 .block { height: 95px; background: linear-gradient(180deg, #d8dcef, #8c91ad); color: #1c1f33; }
.podium .p3 .block { height: 70px; background: linear-gradient(180deg, #ffa36b, #b4561e); color: #2a1102; }
.podium .who { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium .pts { color: var(--muted); font-size: 14px; }

/* ---- animateur ---- */
.code-big { font-size: 46px; font-weight: 900; letter-spacing: 0.18em; text-align: center; line-height: 1; margin: 6px 0; background: linear-gradient(90deg, var(--pink), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.link-line { text-align: center; color: var(--muted); font-size: 14px; word-break: break-all; margin-bottom: 12px; }
.players-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 999px; background: var(--card2); font-weight: 650; font-size: 14px; border: 0; cursor: pointer; }
.pchip .av { width: 24px; height: 24px; flex-basis: 24px; font-size: 12px; }
.pchip.off { opacity: .5; }
.secret { border: 2px dashed var(--line); border-radius: 16px; padding: 14px; cursor: pointer; text-align: center; user-select: none; }
.secret.shown { border-style: solid; border-color: var(--cyan); text-align: left; }
.buzz-banner { border-radius: 18px; padding: 16px; background: linear-gradient(135deg, #0f5132, #146c43); margin-bottom: 14px; animation: pop .25s ease-out; }
.buzz-banner .who { font-size: 26px; font-weight: 900; margin-bottom: 12px; }
.judge { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.judge .btn { padding: 14px 6px; font-size: 15px; flex-direction: column; gap: 2px; }
.judge .btn small { font-weight: 600; opacity: .8; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sticky-bottom { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--bg) 35%); z-index: 5; }
.room-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #2c2756; }
.room-item:last-child { border-bottom: 0; }
.room-item .meta { flex: 1; }

.toast { width: max-content; position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: #000d; border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; z-index: 100; max-width: 90vw; animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateX(var(--tx, 0)) scale(.92); opacity: 0; } to { transform: translateX(var(--tx, 0)) scale(1); opacity: 1; } }
.toast { --tx: -50%; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.pulse { animation: pulse 1.2s infinite; }
.flash-good { animation: fgood .6s; } .flash-bad { animation: fbad .6s; }
@keyframes fgood { 0% { background: #3ddc8466; } 100% { background: transparent; } }
@keyframes fbad { 0% { background: #ff5a5f66; } 100% { background: transparent; } }

@media (min-width: 900px) {
  .game-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
}
