:root {
  --bg: #14123a; --bg2: #221f5c; --card: rgba(255,255,255,0.08); --line: rgba(255,255,255,0.14);
  --txt: #f4f3ff; --muted: #a9a6d6; --accent: #ffc23c; --accent2: #ff4d5a; --ok: #2ed47a;
  --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(ellipse at 50% 0%, #2c2878 0%, var(--bg) 60%, #0b0a24 100%) fixed; color: var(--txt);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overscroll-behavior: none; }
body { overflow-x: hidden; }
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(1.5px 1.5px at 12% 18%, #fff8, transparent), radial-gradient(1px 1px at 70% 30%, #fff9, transparent),
  radial-gradient(1.5px 1.5px at 40% 70%, #fff6, transparent), radial-gradient(1px 1px at 85% 80%, #fff8, transparent),
  radial-gradient(1px 1px at 25% 90%, #fff7, transparent), radial-gradient(1.5px 1.5px at 55% 8%, #fff9, transparent),
  radial-gradient(1px 1px at 92% 52%, #fff6, transparent), radial-gradient(1px 1px at 6% 55%, #fff7, transparent); }
.hidden { display: none !important; }
.screen { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 14px calc(18px + var(--safe-b)); min-height: 100%; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.9em; }
h1 { font-size: 2.4rem; margin: 4px 0 0; letter-spacing: 0.5px; font-weight: 900; }
h1 span { color: var(--accent); }
h2 { margin: 8px 0 14px; }
.logo { text-align: center; margin: 6px 0 14px; }
.logo-art { display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-3deg); } }
.tag { color: var(--muted); margin: 6px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 12px 0; backdrop-filter: blur(4px); }
.lbl { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 2px 0 8px; font-weight: 700; }
input { width: 100%; font: inherit; font-size: 1.1rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: rgba(0,0,0,0.25); color: var(--txt); outline: none; margin-bottom: 10px; }
input:focus { border-color: var(--accent); }
#code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.btn { font: inherit; font-weight: 800; font-size: 1rem; border: 0; border-radius: 14px; padding: 12px 18px; color: #241d05; background: linear-gradient(180deg, #ffd46a, #ffb31f); box-shadow: 0 4px 0 #b97c06; cursor: pointer; white-space: nowrap; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b97c06; }
.btn.big { width: 100%; font-size: 1.2rem; padding: 16px; }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }
.btn.ghost { background: rgba(255,255,255,0.1); color: var(--txt); box-shadow: none; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.45; }
.colors { display: flex; gap: 12px; }
.colors button { width: 52px; height: 52px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; position: relative; box-shadow: inset 0 -5px 0 rgba(0,0,0,0.2); }
.colors button.sel { border-color: #fff; transform: scale(1.08); }
.colors button.taken { opacity: 0.25; }
.colors button.sel::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 1.3rem; text-shadow: 0 1px 2px #0008; }
.foot { text-align: center; color: var(--muted); font-size: 0.85rem; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-color: var(--accent); }
.joininfo { font-size: 1.05rem; margin-bottom: 10px; text-align: center; }

.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.bigcode { font-size: 2.6rem; font-weight: 900; letter-spacing: 8px; color: var(--accent); line-height: 1; }
.plist { list-style: none; margin: 0 0 12px; padding: 0; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-weight: 700; }
.plist li:last-child { border-bottom: 0; }
.dot { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25); }
.plist .tagx { margin-left: auto; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.off { opacity: 0.45; }
.set { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.set > span { font-weight: 700; font-size: 0.95rem; }
.seg { display: flex; background: rgba(0,0,0,0.25); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; font: inherit; font-weight: 700; border: 0; background: transparent; color: var(--muted); padding: 9px 4px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #241d05; }
.seg.ro button { pointer-events: none; }
.rules p { margin: 7px 0; line-height: 1.35; font-size: 0.95rem; }
.sticky { position: sticky; bottom: 0; padding: 10px 0 calc(4px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--bg) 30%); }

/* ---------- jeu ---------- */
#game { padding: calc(6px + var(--safe-t)) 6px calc(6px + var(--safe-b)); height: 100dvh; display: flex; flex-direction: column; max-width: 640px; }
.hud { display: flex; align-items: stretch; gap: 6px; margin-bottom: 6px; }
.chips { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 12px; background: rgba(0,0,0,0.3); border: 2px solid transparent; min-width: 0; transition: transform .15s; }
.chip.me { border-color: currentColor; }
.chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; font-weight: 700; color: var(--txt); }
.chip .sc { font-size: 1.15rem; font-weight: 900; color: var(--txt); font-variant-numeric: tabular-nums; }
.chip .wins { font-size: 0.65rem; color: var(--accent); }
.chip.bump { transform: scale(1.08); }
.chip.hurt { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }
.hudmid { width: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.timer { font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--accent2); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.roundlbl { font-size: 0.7rem; color: var(--muted); }
.iconbtn { position: absolute; top: -4px; right: -2px; font: inherit; font-size: 1.1rem; background: none; border: 0; color: var(--muted); padding: 2px 6px; cursor: pointer; }
.boardwrap { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { width: 100%; height: 100%; display: block; touch-action: none; }
.bottombar { display: flex; align-items: center; gap: 10px; padding: 6px 4px 0; min-height: 40px; }
.myarrows { display: flex; gap: 6px; }
.myarrows .slot { width: 34px; height: 34px; border-radius: 10px; background: rgba(0,0,0,0.3); display: grid; place-items: center; font-size: 1.1rem; position: relative; overflow: hidden; border: 2px solid rgba(255,255,255,0.12); }
.myarrows .slot .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: currentColor; }
.hint { flex: 1; color: var(--muted); font-size: 0.8rem; text-align: right; line-height: 1.2; }
.picker { position: absolute; width: 0; height: 0; z-index: 5; }
.picker button { position: absolute; width: 46px; height: 46px; margin: -23px; border-radius: 50%; border: 2px solid #fff; background: rgba(20,18,58,0.92); color: #fff; font-size: 1.2rem; cursor: pointer; }
.picker button[data-d="0"] { left: 0; top: -50px; } .picker button[data-d="2"] { left: 0; top: 50px; }
.picker button[data-d="1"] { left: 50px; top: 0; } .picker button[data-d="3"] { left: -50px; top: 0; }
.effects { position: absolute; top: 6px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; flex-wrap: wrap; }
.effects span { background: rgba(10,8,40,0.85); border-radius: 20px; padding: 4px 10px; font-weight: 800; font-size: 0.85rem; border: 1px solid var(--line); }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: rgba(10,8,40,0.55); border-radius: 14px; padding: 16px; z-index: 6; }
.overlay .big { font-size: 5rem; font-weight: 900; text-shadow: 0 6px 0 rgba(0,0,0,0.3); animation: pop .5s; }
.overlay .sub { font-size: 1.1rem; font-weight: 800; margin-top: 4px; }
.overlay .small { color: var(--muted); margin-top: 6px; }
@keyframes pop { from { transform: scale(2.2); opacity: 0; } }
.roul { background: rgba(10,8,40,0.92); border: 3px solid var(--accent); border-radius: 22px; padding: 16px 22px; min-width: 230px; animation: pop .3s; }
.roul .em { font-size: 3.4rem; }
.roul .nm { font-size: 1.4rem; font-weight: 900; color: var(--accent); }
.roul .who { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.roul.ovl { pointer-events: none; }
.res { width: 100%; max-width: 360px; background: rgba(10,8,40,0.92); border-radius: 20px; padding: 16px; border: 1px solid var(--line); }
.res h3 { margin: 0 0 10px; }
.res .line { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-weight: 800; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
.res .line:last-child { border-bottom: 0; }
.res .line .v { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- podium ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: 230px; margin: 10px 0; }
.pod { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; animation: rise .8s backwards; }
.pod .who { font-weight: 800; text-align: center; font-size: 0.9rem; margin-bottom: 6px; word-break: break-word; }
.pod .blk { width: 100%; border-radius: 12px 12px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 8px; font-weight: 900; font-size: 1.8rem; color: #241d05; box-shadow: inset 0 -8px 0 rgba(0,0,0,0.15); }
.pod .blk small { font-size: 0.75rem; font-weight: 700; }
@keyframes rise { from { transform: translateY(80px); opacity: 0; } }
.comments .cm { background: var(--card); border-left: 5px solid; border-radius: 12px; padding: 10px 12px; margin: 8px 0; animation: rise .6s backwards; }
.comments .cm b { display: block; margin-bottom: 3px; }
table.sc { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.sc th, table.sc td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
table.sc td:first-child, table.sc th:first-child { text-align: left; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; width: 100%; height: 100%; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); }
.sheet .btn { width: 100%; margin-top: 8px; }
.kick { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-weight: 700; }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(70px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 40; pointer-events: none; }
.toast { background: rgba(10,8,40,0.95); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; font-weight: 700; animation: pop .3s; max-width: 90%; text-align: center; }

/* grand écran (télé) */
@media (min-aspect-ratio: 1/1) and (min-width: 800px) {
  #game { max-width: none; flex-direction: row; gap: 14px; }
  .hud { flex-direction: column; width: 260px; }
  .chips { grid-template-columns: 1fr; align-content: start; }
  .chip .nm { font-size: 1rem; } .chip .sc { font-size: 1.6rem; }
  .hudmid { width: auto; } .timer { font-size: 2.6rem; }
  .bottombar { display: none; }
}
