:root {
  --bg: #0f1420; --bg2: #171d2c; --panel: #1e2638; --line: #2c3650; --text: #e8ecf5; --muted: #9aa5bf;
  --accent: #ffb300; --accent2: #40c4ff; --ok: #69f0ae; --ko: #ff5252; --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: .01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
p { margin: 0 0 .75rem; } a { color: var(--accent2); }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: .7rem 1.1rem; background: var(--accent); color: #111; font-weight: 700; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--ko); color: #fff; }
button.small { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
input, select, textarea { font: inherit; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent2); border-color: transparent; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 440px; }
.brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }
.brand b { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-size: .95rem; }
.chip .dot { width: .7rem; height: .7rem; border-radius: 50%; }
.chip.off { opacity: .45; }
.stack > * + * { margin-top: .9rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .5 } 50% { opacity: 1 } }
.toast { position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: .6rem 1rem; border-radius: 10px; z-index: 50; box-shadow: 0 8px 30px #0008; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 700; background: var(--bg2); color: var(--muted); }
.badge.alive { background: #1f4d3a; color: var(--ok); } .badge.quiz { background: #4d3a1f; color: var(--accent); } .badge.off { background: #3a1f1f; color: var(--ko); } .badge.lobby { background: #1f2f4d; color: var(--accent2); }

/* ---- Jeu ---- */
.game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0a0d16; }
.hud { display: flex; align-items: center; gap: .8rem; padding: .4rem .8rem; background: var(--bg2); border-bottom: 1px solid var(--line); font-size: .9rem; min-height: 2.6rem; }
.hud .me { font-weight: 700; }
.hud .stats { display: flex; gap: .9rem; color: var(--muted); }
.hud .stats b { color: var(--text); }
.stage { flex: 1; position: relative; min-height: 0; }
canvas.arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.standings { position: absolute; right: .5rem; top: .5rem; background: #0f1420cc; border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; font-size: .8rem; min-width: 10rem; backdrop-filter: blur(4px); }
.standings div { display: flex; justify-content: space-between; gap: .6rem; padding: .1rem 0; }
.standings .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; }
.standings .me { color: var(--accent); font-weight: 700; }
.controls-hint { position: absolute; left: .6rem; bottom: .5rem; font-size: .75rem; color: var(--muted); background: #0f1420aa; padding: .25rem .5rem; border-radius: 6px; }
.touch { position: absolute; inset: 0; pointer-events: none; display: none; }
.touch.on { display: block; }
.touch .pad { position: absolute; left: 1rem; bottom: 1rem; width: 9.5rem; height: 9.5rem; pointer-events: auto; }
.touch .pad button { position: absolute; width: 3rem; height: 3rem; border-radius: 50%; background: #ffffff22; color: #fff; border: 1px solid #ffffff44; font-size: 1.2rem; padding: 0; }
.touch .pad .up { left: 3.25rem; top: 0 } .touch .pad .down { left: 3.25rem; bottom: 0 } .touch .pad .left { left: 0; top: 3.25rem } .touch .pad .right { right: 0; top: 3.25rem }
.touch .fire { position: absolute; right: 1.2rem; bottom: 1.5rem; width: 5rem; height: 5rem; border-radius: 50%; background: #ff525288; color: #fff; border: 2px solid #ff5252; font-size: 1rem; pointer-events: auto; }

/* ---- Quiz ---- */
.overlay { position: fixed; inset: 0; background: #0a0d16dd; display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 20; backdrop-filter: blur(3px); }
.quiz { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; width: 100%; max-width: 560px; box-shadow: 0 20px 60px #000a; }
.quiz .head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .6rem; color: var(--muted); font-size: .9rem; }
.quiz .progress { display: flex; gap: .3rem; margin-bottom: 1rem; }
.quiz .progress i { flex: 1; height: .4rem; border-radius: 4px; background: var(--line); }
.quiz .progress i.done { background: var(--ok); } .quiz .progress i.cur { background: var(--accent); }
.quiz .q { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; line-height: 1.35; }
.quiz .choices { display: grid; gap: .55rem; }
.quiz .choices button { text-align: left; background: var(--bg2); color: var(--text); border: 1px solid var(--line); padding: .8rem 1rem; font-weight: 500; display: flex; gap: .7rem; align-items: center; }
.quiz .choices button:hover:not(:disabled) { border-color: var(--accent2); }
.quiz .choices button .k { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.quiz .feedback { border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.quiz .feedback.ok { background: #1f4d3a; color: var(--ok); }
.quiz .feedback.ko { background: #4d1f1f; color: #ffb4b4; }
.quiz .feedback b { color: #fff; }
.quiz .death { color: var(--ko); font-weight: 700; margin-bottom: .4rem; }

/* ---- Fin / classement ---- */
.podium { width: 100%; max-width: 560px; }
.podium table { width: 100%; border-collapse: collapse; }
.podium td, .podium th { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
.podium td.num, .podium th.num { text-align: right; }
.podium tr.me td { color: var(--accent); font-weight: 700; }

/* ---- Écran tableau ---- */
.ecran { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.ecran header { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.6rem; background: var(--bg2); border-bottom: 1px solid var(--line); }
.ecran header .url { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.ecran .lobby { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; padding: 2rem; align-items: start; }
.ecran .lobby .qr { background: #fff; padding: 12px; border-radius: 16px; width: 320px; height: 320px; }
.ecran .lobby .qr svg { width: 100%; height: 100%; display: block; }
.ecran .lobby .chip { font-size: 1.4rem; padding: .5rem 1rem; }
.ecran .play { display: grid; grid-template-columns: 1fr 300px; min-height: 0; }
.ecran .play .stage { position: relative; }
.ecran .side { border-left: 1px solid var(--line); padding: 1rem; overflow: auto; background: var(--bg2); }
.ecran .side .line { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
.ecran .side .line .dot { width: .8rem; height: .8rem; border-radius: 50%; flex: none; }
.ecran .side .line .n { flex: 1; } .ecran .side .line .s { font-weight: 700; font-variant-numeric: tabular-nums; }
.ecran .side .line.quiz .n::after { content: " · quiz"; color: var(--accent); font-size: .8rem; }
.ecran .side .line.off { opacity: .4; }
.ecran .big { font-size: 2.2rem; }

/* ---- Admin ---- */
.admin { max-width: 1200px; margin: 0 auto; padding: 1rem 1.2rem 3rem; }
.admin header { display: flex; align-items: center; gap: 1rem; padding: .6rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .4rem; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid transparent; }
.tabs button.on { background: var(--panel); color: var(--text); border-color: var(--line); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } .ecran .lobby, .ecran .play { grid-template-columns: 1fr; } }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.status-line { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: center; }
.status-line .phase { font-weight: 800; font-size: 1.1rem; }
.qitem { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .6rem; background: var(--bg2); }
.qitem .t { font-weight: 600; margin-bottom: .3rem; }
.qitem ol { margin: 0 0 .3rem 1.2rem; padding: 0; color: var(--muted); font-size: .9rem; }
.qitem ol li.good { color: var(--ok); font-weight: 600; }
.qform .choice { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.qform .choice input[type=radio] { width: auto; }
.link-box { background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: .7rem .9rem; font-family: ui-monospace, monospace; word-break: break-all; }
.err { color: var(--ko); font-size: .9rem; }
