:root {
  --bg: #14102a; --bg2: #1d1740; --card: #231c4a; --line: #3a3170;
  --text: #f4f1ff; --muted: #a9a2cf; --accent: #ffc23d; --accent2: #ff5d8f; --ok: #3ddc97; --bad: #ff5d6c;
  --c0: #e84a6f; --c1: #3b82f6; --c2: #f0a92b; --c3: #22b07d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(900px 500px at 15% -10%, #3b1d7a 0%, transparent 60%), radial-gradient(800px 500px at 110% 10%, #1b3d7a 0%, transparent 55%), var(--bg);
  overflow: hidden; height: 100dvh;
}
[hidden] { display: none !important; }
button, input { font-family: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.big { font-size: 20px; font-weight: 800; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.scroll { overflow-y: auto; }
.wrap { width: 100%; max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 90px; display: flex; flex-direction: column; gap: 14px; }
.hero { text-align: center; margin: 6px 0 2px; }
.logo { font-size: 50px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
h1 { margin: 8px 0 4px; font-size: 36px; font-weight: 900; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0; }

.box { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.boxtitle { font-weight: 800; font-size: 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.boxtitle.small { font-size: 14px; margin-top: 14px; color: var(--muted); }
.pill { background: #2f2760; border-radius: 999px; padding: 2px 9px; font-size: 13px; }
.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.lbl:first-child { margin-top: 0; }
input { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #120e28; color: var(--text); font-size: 16px; padding: 0 14px; outline: none; }
input:focus { border-color: var(--accent); }
.code-in { text-transform: uppercase; letter-spacing: 6px; font-weight: 900; text-align: center; flex: 1; }
.check { display: flex; gap: 10px; align-items: center; margin: 14px 0 4px; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.err { color: var(--bad); font-weight: 700; min-height: 1em; margin: 8px 0 0; text-align: center; }

.btn { min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px; font-weight: 800; font-size: 15px; cursor: pointer; color: var(--text); background: #2f2760; box-shadow: 0 3px 0 #1a1540; white-space: nowrap; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1a1540; }
.btn.main { color: #1b1300; background: linear-gradient(180deg, #ffd56b, var(--accent)); box-shadow: 0 3px 0 #b27d00; }
.btn.red { color: #fff; background: linear-gradient(180deg, #ff6b8f, #e0456b); box-shadow: 0 3px 0 #8f2440; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn:disabled { opacity: .45; }
.btn.wide { width: 100%; margin-top: 10px; }
.big-btn { min-height: 58px; font-size: 19px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #2a2257; color: var(--text); font-size: 18px; cursor: pointer; flex: none; }

.seg { display: flex; gap: 6px; background: #120e28; padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; font-size: 14px; cursor: pointer; }
.seg button.sel { background: linear-gradient(180deg, #ffd56b, var(--accent)); color: #1b1300; }
.seg.locked button { cursor: default; }
.seg.locked button:not(.sel) { opacity: .5; }

.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.avatars button { height: 44px; font-size: 24px; border-radius: 12px; border: 2px solid transparent; background: #120e28; cursor: pointer; }
.avatars button.sel { border-color: var(--accent); background: #2f2760; }
.avatars button:disabled { opacity: .25; }

/* salon */
.code { font-size: 52px; font-weight: 900; letter-spacing: 10px; margin: 2px 0 12px; color: var(--accent); }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: #1a1538; border-left: 4px solid var(--c, #888); }
.pl .av { font-size: 26px; width: 34px; text-align: center; }
.pl .nm { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .tag { font-size: 12px; color: var(--muted); }
.pl.off { opacity: .45; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 2px; }

/* jeu */
#game { background: transparent; }
.topbar { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; background: linear-gradient(180deg, #1d1740, #16112f); border-bottom: 1px solid var(--line); flex: none; }
.qnum { font-weight: 900; font-size: 15px; background: #2f2760; border-radius: 9px; padding: 6px 9px; }
.cat { flex: 1; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.myscore { font-weight: 900; color: var(--accent); font-size: 15px; white-space: nowrap; }
.timer { height: 6px; background: #120e28; flex: none; }
.timer div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--accent), var(--bad)); background-size: 300% 100%; border-radius: 0 3px 3px 0; }
.stage { flex: 1; position: relative; overflow-y: auto; padding: 14px 14px 90px; display: flex; flex-direction: column; }
.spect-badge { align-self: center; font-size: 13px; font-weight: 800; background: #2f2760; color: var(--muted); padding: 4px 12px; border-radius: 999px; margin-bottom: 8px; }
.intro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; animation: pop .4s ease; }
.intro-n { font-size: 34px; font-weight: 900; }
.intro-cat { font-size: 22px; font-weight: 800; color: var(--accent); }
.intro-go { color: var(--muted); font-size: 16px; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
.qwrap { width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.qtext { font-size: clamp(20px, 5.6vw, 28px); font-weight: 800; text-align: center; line-height: 1.25; padding: 10px 4px 0; animation: pop .3s ease; }
.countdown { text-align: center; font-size: 30px; font-weight: 900; color: var(--accent); min-height: 36px; }
.countdown.hurry { color: var(--bad); animation: beat .5s infinite alternate; }
@keyframes beat { to { transform: scale(1.15); } }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .answers { grid-template-columns: 1fr; } }
.ans { position: relative; min-height: 84px; border: 0; border-radius: 16px; color: #fff; font-size: 17px; font-weight: 800; padding: 10px 12px 10px 40px; text-align: left; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: opacity .2s, transform .1s, filter .2s; display: flex; align-items: center; line-height: 1.2; }
.ans:active { transform: translateY(2px); }
.ans i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 18px; opacity: .85; }
.ans em { position: absolute; right: 8px; bottom: 6px; font-style: normal; font-size: 16px; letter-spacing: -3px; }
.a0 { --g: var(--c0); } .a1 { --g: var(--c1); } .a2 { --g: var(--c2); } .a3 { --g: var(--c3); }
.ans { background: var(--g); }
.ans:disabled { cursor: default; }
.answers.locked .ans:not(.mine) { opacity: .4; }
.ans.mine { outline: 4px solid #fff; outline-offset: -4px; }
.answers.revealed .ans { opacity: 1; background: #272046; color: #8d86b5; }
.answers.revealed .ans.good { background: var(--g); color: #fff; box-shadow: 0 0 0 4px var(--ok), 0 4px 0 rgba(0,0,0,.35); }
.answers.revealed .ans.good::after { content: '✔'; position: absolute; right: 10px; top: 6px; font-size: 20px; }
.answers.revealed .ans.mine:not(.good) { background: #4a2442; color: #ffd0d8; outline-color: var(--bad); }
.answers.revealed .ans.mine:not(.good)::after { content: '✖'; position: absolute; right: 10px; top: 6px; font-size: 20px; }
.result { text-align: center; font-size: 22px; font-weight: 900; min-height: 0; }
.result.good { color: var(--ok); } .result.bad { color: var(--bad); }
.result small { display: block; font-size: 14px; color: var(--muted); font-weight: 700; }
.note { text-align: center; color: var(--muted); font-size: 15px; }
.answered { text-align: center; color: var(--muted); font-size: 14px; }
.answered .avs { font-size: 22px; letter-spacing: 2px; display: block; margin-top: 4px; }
.board { width: 100%; max-width: 520px; margin: 0 auto; animation: pop .3s ease; }
.board-title { font-size: 24px; font-weight: 900; text-align: center; margin: 6px 0 12px; }
.br { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #1a1538; margin-bottom: 6px; border-left: 5px solid var(--c, #888); }
.br .rk { width: 26px; font-weight: 900; color: var(--muted); text-align: center; }
.br .av { font-size: 26px; }
.br .nm { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br .gain { color: var(--ok); font-weight: 800; font-size: 14px; }
.br .sc { font-weight: 900; color: var(--accent); min-width: 56px; text-align: right; }
.br.me { background: #2b2360; }
.hostbar { position: absolute; left: 0; right: 76px; bottom: 0; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); display: flex; }
.hostbar .btn { flex: 0 1 auto; }

/* fin */
.endtitle { font-size: 28px; margin: 6px 0 0; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; min-height: 200px; }
.pod { flex: 1; max-width: 140px; text-align: center; }
.pod .av { font-size: 40px; }
.pod .nm { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod .sc { color: var(--accent); font-weight: 900; }
.pod .step { margin-top: 6px; border-radius: 12px 12px 0 0; font-size: 28px; font-weight: 900; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; }
.pod.p1 .step { height: 110px; background: linear-gradient(180deg, #ffd56b, #c99112); color: #3b2a00; }
.pod.p2 .step { height: 80px; background: linear-gradient(180deg, #e3e6f0, #9aa0b5); color: #2a2d3a; }
.pod.p3 .step { height: 60px; background: linear-gradient(180deg, #f0b27a, #a8642c); color: #3a1f08; }
.er { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.er:last-child { border-bottom: 0; }
.er .rk { font-weight: 900; width: 28px; color: var(--muted); padding-top: 3px; }
.er .av { font-size: 26px; }
.er .info { flex: 1; min-width: 0; }
.er .nm { font-weight: 800; }
.er .cm { color: var(--muted); font-size: 14px; margin-top: 2px; }
.er .sc { font-weight: 900; color: var(--accent); }
.er .st { font-size: 12px; color: var(--muted); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall 3.2s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* menu */
.sheet-bg { position: fixed; inset: 0; background: rgba(5,3,15,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--bg2); border-radius: 20px 20px 0 0; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); border: 1px solid var(--line); }

/* chat */
.chat-btn { position: fixed; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 15; width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line); background: #2f2760; font-size: 24px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.chat-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent2); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.chat-feed { position: fixed; right: 14px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 64px); z-index: 14; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; max-width: 75vw; }
.chat-feed > div { background: rgba(20,16,42,.92); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; animation: pop .25s ease; }
.chat-feed .gif { max-height: 90px; }
.chat-feed .mini .gif { max-height: 44px; }
.chat-panel { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; height: min(72dvh, 560px); max-width: 520px; margin: 0 auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -10px 40px rgba(0,0,0,.5); }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { font-size: 15px; line-height: 1.35; word-wrap: break-word; }
.msg b { margin-right: 6px; }
.msg .gif { display: block; max-width: 200px; max-height: 160px; border-radius: 10px; margin-top: 4px; }
.emojis { display: flex; gap: 4px; padding: 6px 10px; overflow-x: auto; border-top: 1px solid var(--line); }
.emojis button { font-size: 22px; background: #120e28; border: 0; border-radius: 10px; min-width: 42px; height: 40px; cursor: pointer; }
.emojis .gif-btn { font-size: 13px; font-weight: 900; color: var(--accent); }
.chat-form { display: flex; gap: 6px; padding: 8px 10px; }
.chat-form input { flex: 1; }
.gif-picker { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; max-height: 46%; }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; overflow-y: auto; }
.gif-grid button { padding: 0; border: 0; background: #120e28; border-radius: 8px; overflow: hidden; height: 80px; cursor: pointer; }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-grid .hint { grid-column: 1 / -1; }
.gif-credit { font-size: 11px; color: var(--muted); text-align: right; }
.hint { color: var(--muted); font-size: 14px; }

.toast { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translate(-50%, -250%); visibility: hidden; background: #2f2760; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 40; transition: transform .25s; max-width: 90vw; text-align: center; }
.toast.on { transform: translate(-50%, 0); visibility: visible; }
.conn { position: fixed; left: 0; right: 0; top: 0; background: var(--bad); color: #fff; text-align: center; font-weight: 800; padding: 6px; z-index: 50; font-size: 14px; }
