:root {
  --bg: #121836; --bg2: #24306a; --card: rgba(255,255,255,0.08); --line: rgba(255,255,255,0.14);
  --txt: #f3f5ff; --mut: #aab3dc; --acc: #ffd23f; --acc2: #3ddc97; --bad: #ff4d5a; --pink: #ff6fb5;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: radial-gradient(circle at 50% -10%, var(--bg2), var(--bg) 70%); color: var(--txt);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.screen { position: absolute; inset: 0; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; }
h2 { margin: 4px 0; font-size: 22px; }
.logo { text-align: center; margin: 14px 0 4px; }
.logo-art { display: block; margin: 0 auto; filter: drop-shadow(0 8px 12px rgba(0,0,0,.45)); overflow: visible; }
.logo-art .mb1 { animation: roll 2.6s ease-in-out infinite; }
.logo-art .mb2 { animation: roll 2.6s .2s ease-in-out infinite; }
.logo-art .mb3 { animation: roll 2.6s .4s ease-in-out infinite; }
@keyframes roll { 50% { transform: translateX(6px) translateY(-3px); } }
.logo h1 { margin: 6px 0 0; font-size: 38px; letter-spacing: -1px; font-weight: 900; line-height: 1.05; background: linear-gradient(180deg, #fff, #cfd8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo h1 span { display: block; font-size: 17px; letter-spacing: 4px; text-transform: uppercase; color: var(--acc); -webkit-text-fill-color: var(--acc); font-weight: 800; }
.logo .tag { margin: 6px 0 0; color: var(--mut); font-size: 15px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(6px); }
.small { font-size: 14px; color: var(--mut); }
.muted { color: var(--mut); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mut); }
.label { font-size: 14px; color: var(--mut); }
input[type=text], input:not([type]), input[type=password] { background: rgba(0,0,0,0.25); border: 1px solid var(--line); color: var(--txt); padding: 12px 14px; border-radius: 12px; font-size: 17px; outline: none; }
input:focus { border-color: var(--acc); }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,0.1); border-radius: 14px; padding: 14px; font-weight: 700; font-size: 16px; width: 100%; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffe066, #ffc21a); color: #2a2100; border: none; box-shadow: 0 6px 18px rgba(255,200,40,.3); font-size: 18px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mut); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 6px; font-weight: 800; min-width: 0; }
.row .btn { width: auto; padding: 12px 18px; }
.resume { display: flex; flex-direction: column; gap: 8px; }
.resume:empty { display: none; }
.resume button { background: rgba(61,220,151,.15); border: 1px solid rgba(61,220,151,.4); border-radius: 12px; padding: 10px; font-weight: 600; }
.hint { font-size: 13px; color: var(--mut); margin: 0; }
.center { text-align: center; }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset -5px -6px 10px rgba(0,0,0,.35), inset 4px 4px 8px rgba(255,255,255,.55); }
.colors button.on { border-color: #fff; transform: scale(1.12); }
.colors button.taken { opacity: .25; pointer-events: none; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.2); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--acc); color: #2a2100; border-color: var(--acc); }
.set { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mut); margin-bottom: 8px; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--txt); font-size: 15px; }
.switch input { display: none; }
.switch span { width: 46px; height: 26px; border-radius: 13px; background: rgba(255,255,255,.2); position: relative; transition: .2s; flex: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--acc2); }
.switch input:checked + span::after { left: 23px; }
.rules p { margin: 0; font-size: 14px; }

.big-code { font-size: 46px; font-weight: 900; letter-spacing: 10px; text-align: center; color: var(--acc); text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.lobby-head { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0,0,0,.18); border-radius: 12px; animation: pop .3s; }
.players li .host { margin-left: auto; font-size: 13px; color: var(--acc); white-space: nowrap; }
.players li.off { opacity: .5; }
.players li .watch, .players li .bot { color: var(--mut); font-weight: 600; font-size: 13px; }
.players li .x { margin-left: auto; width: 30px; height: 30px; border-radius: 10px; border: none; background: rgba(0,0,0,.3); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.ball { display: inline-block; vertical-align: middle; width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset -3px -4px 6px rgba(0,0,0,.4), inset 3px 3px 5px rgba(255,255,255,.65); }

/* ---------- course ---------- */
#game { padding: 0; gap: 0; max-width: none; }
.hud { position: absolute; left: 0; right: 0; top: 0; z-index: 2; padding: calc(8px + var(--safe-t)) 10px 14px; background: linear-gradient(180deg, rgba(5,8,25,.65), rgba(5,8,25,0)); pointer-events: none; }
.hud-top { display: flex; align-items: center; gap: 8px; }
.hud-top > * { pointer-events: auto; }
.pos { min-width: 54px; height: 46px; padding: 0 8px; border-radius: 14px; background: rgba(0,0,0,.45); display: flex; align-items: baseline; justify-content: center; gap: 1px; font-weight: 900; font-size: 28px; line-height: 46px; }
.pos small { font-size: 14px; opacity: .8; }
.pos.p1 { background: linear-gradient(180deg, #ffe066, #f0b400); color: #2a2100; }
.race-info { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.race-info b { font-size: 16px; }
.race-info span { font-size: 13px; color: #dfe4ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { font-weight: 800; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.45); padding: 6px 9px; border-radius: 12px; font-size: 15px; }
.clock:empty { display: none; }
.clock.urgent { background: var(--bad); animation: pulse .8s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.icon { position: relative; flex: none; background: rgba(0,0,0,.4); border: none; width: 40px; height: 40px; border-radius: 12px; font-size: 21px; line-height: 1; }
.stage { position: absolute; inset: 0; z-index: 1; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hint-drag { position: absolute; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 7px 14px; border-radius: 20px; font-size: 14px; white-space: nowrap; pointer-events: none; z-index: 3; }
.watch-tag { position: absolute; left: 50%; bottom: calc(68px + var(--safe-b)); transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 5px 14px; border-radius: 16px; font-size: 14px; white-space: nowrap; pointer-events: none; z-index: 3; text-align: center; }
.watch-tag small { display: block; font-size: 11px; color: var(--mut); }
.chips-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto; padding: 14px 10px calc(8px + var(--safe-b)); background: linear-gradient(0deg, rgba(5,8,25,.6), rgba(5,8,25,0)); scrollbar-width: none; }
.chips-bar::-webkit-scrollbar { display: none; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; background: rgba(0,0,0,.45); border-radius: 20px; font-size: 13px; white-space: nowrap; border: 2px solid transparent; flex: none; cursor: pointer; }
.chip b { font-size: 13px; min-width: 14px; text-align: center; }
.chip .ball { width: 16px; height: 16px; }
.chip.me { border-color: rgba(255,255,255,.7); }
.chip.focus { border-color: var(--acc); }
.chip.done { background: rgba(61,220,151,.28); }
.chip.off .ball { filter: grayscale(1); opacity: .6; }
.chip small { color: var(--mut); }

.countdown { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 4; font-size: 120px; font-weight: 900; color: #fff; text-shadow: 0 8px 0 rgba(0,0,0,.35), 0 0 40px rgba(255,210,63,.6); pointer-events: none; white-space: nowrap; }
.countdown.go { color: var(--acc); font-size: 76px; }
.countdown.pop { animation: cd .9s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes cd { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 70% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(.9); opacity: 0; } }
.banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 4; padding: 14px 24px; border-radius: 22px; background: linear-gradient(180deg, #ffe066, #ffbf1a); color: #2a2100; font-size: 26px; font-weight: 900; box-shadow: 0 12px 40px rgba(0,0,0,.45), 0 0 0 4px rgba(255,255,255,.6); pointer-events: none; white-space: nowrap; text-align: center; }
.banner small { display: block; font-size: 15px; font-weight: 700; }
.banner.pop { animation: banner 2.4s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 12% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 20%, 82% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -80%) scale(.9); opacity: 0; } }

/* ---------- panneaux ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; background: rgba(5,8,25,.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
.panel { position: relative; z-index: 1; width: 100%; max-width: 440px; background: linear-gradient(180deg, #2b3a7c, #1b2452); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.5); animation: rise .35s cubic-bezier(.2,1.4,.4,1); max-height: 100%; overflow-y: auto; }
.panel.tall { max-height: calc(100% - var(--safe-t) - var(--safe-b)); }
@keyframes rise { from { transform: translateY(30px) scale(.95); opacity: 0; } }
.results { width: 100%; border-collapse: collapse; }
.results td { padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
.results td.n { text-align: right; font-weight: 800; white-space: nowrap; }
.results td.rk { font-weight: 900; width: 34px; }
.results td.t { color: var(--mut); font-size: 13px; text-align: right; white-space: nowrap; }
.results .plus { color: var(--acc2); }
.bar { height: 5px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
.bar div { height: 100%; background: var(--acc); width: 100%; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: 190px; margin-top: 4px; }
.podium .step { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podium .block { width: 100%; border-radius: 12px 12px 4px 4px; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; font-size: 26px; font-weight: 900; color: rgba(0,0,0,.55); animation: grow .7s cubic-bezier(.2,1.3,.4,1) both; transform-origin: bottom; }
.podium .p1 .block { height: 110px; background: linear-gradient(180deg, #ffe680, #f0b400); animation-delay: .9s; }
.podium .p2 .block { height: 80px; background: linear-gradient(180deg, #f1f4f6, #aeb8c0); animation-delay: .5s; }
.podium .p3 .block { height: 58px; background: linear-gradient(180deg, #f2c39a, #c27a3e); animation-delay: .2s; }
.podium .who { font-weight: 800; font-size: 14px; text-align: center; animation: fadein .4s both; }
.podium .p1 .who { animation-delay: 1.4s; } .podium .p2 .who { animation-delay: 1s; } .podium .p3 .who { animation-delay: .7s; }
.podium .who small { display: block; font-weight: 600; color: var(--mut); }
.podium .crown { font-size: 26px; animation: bob 2s infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-4deg); } }
@keyframes grow { from { transform: scaleY(0); } }
.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: rgba(0,0,0,.2); border-radius: 14px; animation: fadein .5s both; }
.comment .rk { font-weight: 900; font-size: 18px; min-width: 30px; text-align: center; }
.comment p { margin: 2px 0 0; font-size: 14px; }
.comment b { font-size: 15px; }
.comment .pts { margin-left: auto; font-weight: 800; color: var(--acc); white-space: nowrap; }
details summary { cursor: pointer; color: var(--mut); font-size: 14px; }
.scroll { overflow-x: auto; margin-top: 8px; }
.card-table { border-collapse: collapse; font-size: 13px; }
.card-table th, .card-table td { padding: 4px 7px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.card-table td:first-child, .card-table th:first-child { text-align: left; position: sticky; left: 0; background: #1f2a5e; }
.kick { display: flex; flex-wrap: wrap; gap: 6px; }
.kick button { border: 1px solid rgba(255,77,90,.5); background: rgba(255,77,90,.12); border-radius: 10px; padding: 8px 10px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

#toasts { position: fixed; top: calc(70px + var(--safe-t)); left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(0,0,0,.78); padding: 8px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; animation: toast 3.2s forwards; max-width: 90%; text-align: center; }
@keyframes toast { 0% { transform: translateY(-10px); opacity: 0; } 8%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; } }

/* ---------- chat ---------- */
.chat-badge { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.btn .chat-badge { position: static; margin-left: 6px; }
.chat-feed { position: absolute; left: 8px; top: calc(70px + var(--safe-t)); z-index: 3; display: flex; flex-direction: column; gap: 4px; max-width: 70%; pointer-events: none; opacity: .92; }
.bubble { animation: toast 5.2s forwards; }
.bubble .msg, .chat-list .msg { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.6); padding: 6px 10px; border-radius: 14px; font-size: 14px; }
.msg .ball { width: 14px; height: 14px; }
.msg span { word-break: break-word; }
.panel.chat { max-height: 85%; }
.chat-list { flex: 1; min-height: 160px; max-height: 45vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-list .msg { background: rgba(0,0,0,.25); }
.emojis { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.emojis button { font-size: 22px; background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
#chatForm input { letter-spacing: 0; text-transform: none; text-align: left; font-weight: 400; }
img.gif { max-width: 180px; max-height: 140px; border-radius: 10px; display: block; }
.msg:has(img.gif) { flex-wrap: wrap; }
.gif-btn { font-size: 14px !important; font-weight: 900; color: #fff; background: linear-gradient(135deg, #a46bff, #ff6fb5) !important; border: none !important; padding: 6px 12px !important; }
.gif-picker { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.gif-picker input { background: rgba(0,0,0,0.25); border: 1px solid var(--line); color: var(--txt); padding: 10px 12px; border-radius: 12px; font-size: 15px; outline: none; }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-height: 34vh; overflow-y: auto; min-height: 60px; }
.gif-grid button { padding: 0; border: none; background: rgba(0,0,0,.3); border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-credit { font-size: 10px; color: var(--mut); text-align: right; letter-spacing: 1px; }
.panel.chat:has(.gif-picker:not(.hidden)) .chat-list { min-height: 50px; max-height: 16vh; }
.bubble.mini img.gif { max-width: 72px; max-height: 56px; border-radius: 6px; }
.bubble.mini .msg { padding: 4px 8px; font-size: 12px; }

/* version solo : on cache ce qui ne sert qu'en ligne */
body.solo .online { display: none !important; }
body.solo .solo-only.hidden { display: block !important; }
