:root {
  --bg: #12161c; --panel: #1b222c; --panel-2: #232c39; --text: #eef2f7; --muted: #93a1b5;
  --accent: #3ddc97; --accent-ink: #062a1a; --danger: #ff6b6b; --warn: #ffd166; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid #ffffff12; }
.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: .04em; }
.spacer { flex: 1; }
.chip { background: var(--panel-2); border-radius: 999px; padding: 4px 14px; font-weight: 800; letter-spacing: .18em; }
.conn { font-size: .85rem; color: var(--muted); }
.conn.ok { color: var(--accent); }
.conn.bad { color: var(--danger); }
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 8px 16px; cursor: pointer; color: var(--text); background: var(--panel-2); }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid #ffffff26; }
.btn.big { padding: 14px 28px; font-size: 1.2rem; }
.btn:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }

main { flex: 1; min-height: 0; position: relative; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; color: var(--muted); margin: 0 0 12px; }

.lobby { height: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 40px 6vw; align-items: center; }
.lobby-join { text-align: center; }
.qr { width: min(34vh, 320px); aspect-ratio: 1; margin: 0 auto 18px; background: #fff; padding: 12px; border-radius: var(--radius); }
.qr svg { width: 100%; height: 100%; display: block; }
.code-label { margin: 0; color: var(--muted); }
.code { margin: 0; font-size: clamp(3rem, 12vh, 6rem); font-weight: 900; letter-spacing: .25em; padding-left: .25em; }
.join-url { color: var(--muted); font-size: .9rem; word-break: break-all; }
.lobby-players h2 { margin-top: 0; }

.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 12px; padding: 10px 14px; border: 2px solid transparent; }
.player-list li.current { border-color: var(--accent); background: var(--panel-2); }
.player-list li.out { opacity: .45; }
.player-list li.out .pname { text-decoration: line-through; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 1.25rem; flex: none; border: 3px solid #fff; }
.pname { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #ffffff1a; }
.badge.warn { background: var(--warn); color: #3a2c00; }
.badge.bad { background: var(--danger); color: #3a0000; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; max-width: 140px; }
.dot { width: 10px; height: 10px; border-radius: 2px; border: 1px solid #0006; }
.dot.mort { opacity: .35; }

.game { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; padding: 14px 18px; }
.stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; }
.board { width: min(100%, calc(100vh - 90px)); aspect-ratio: 1; }
.board-svg, .board-3d { width: 100%; height: 100%; display: block; }
.board-3d { border-radius: var(--radius); }
.token.current circle { stroke: var(--warn); stroke-width: 5; }
.token.bankrupt { opacity: 0; }

.dice-overlay, .card-overlay, .center-extra { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.dice-row { display: flex; gap: 22px; background: #000a; padding: 22px 28px; border-radius: 20px; backdrop-filter: blur(4px); }
.die { width: 92px; height: 92px; background: #fff; border-radius: 16px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 12px; gap: 2px; box-shadow: 0 6px 0 #0004; }
.die i { width: 16px; height: 16px; background: #111; border-radius: 50%; place-self: center; visibility: hidden; }
.die i.on { visibility: visible; }
.die.rolling { animation: wobble .18s linear infinite; }
@keyframes wobble { 0% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-6px); } 100% { transform: rotate(-8deg) translateY(0); } }
.card-box { width: min(46%, 420px); background: #fffdf5; color: #222; border-radius: 18px; padding: 22px 24px; text-align: center; box-shadow: 0 18px 50px #000a; border-top: 14px solid var(--card, #f28c28); animation: pop .25s ease-out; }
.card-box .bid { font-size: 3rem; font-weight: 900; margin: 6px 0; }
.card-box .sub { font-size: 1.05rem; font-weight: 600; color: #555; margin-top: 4px; }
.card-box .timer { font-size: 1.6rem; font-weight: 800; color: #c26a00; margin-top: 6px; }
.card-box h4 { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .12em; font-size: .85rem; color: #666; }
.card-box p { margin: 0; font-size: 1.4rem; font-weight: 700; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sidebar { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; }
.sidebar h3 { margin: 6px 0 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.banner { background: var(--panel-2); border-left: 6px solid var(--accent); border-radius: 10px; padding: 12px 14px; font-weight: 700; }
.banner.alert { border-color: var(--danger); }
.log { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; display: flex; flex-direction: column-reverse; gap: 4px; font-size: .92rem; }
.log li { padding: 5px 9px; border-radius: 8px; background: var(--panel); }
.log li:last-child { background: var(--panel-2); font-weight: 600; }

.overlay { position: absolute; inset: 0; background: #000c; display: grid; place-items: center; z-index: 20; }
.overlay-box { background: var(--panel); padding: 36px 48px; border-radius: 20px; text-align: center; max-width: 80vw; }
.overlay-box h2 { margin: 0 0 20px; font-size: 2.4rem; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #2b0000; padding: 10px 20px; border-radius: 10px; font-weight: 700; z-index: 30; }

@media (max-width: 1000px) {
  .lobby { grid-template-columns: 1fr; overflow: auto; padding: 24px; }
  .game { grid-template-columns: 1fr; overflow: auto; }
  .board { width: min(100%, 90vh); }
  body { overflow: auto; }
}
@media (prefers-reduced-motion: reduce) { .die.rolling, .card-box { animation: none; } }

.chip.soft { letter-spacing: normal; font-weight: 700; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chooser { height: 100%; overflow: auto; padding: 40px 6vw; }
.chooser h2 { margin: 0 0 16px; font-size: 1.6rem; }
.chooser-error { background: #ff6b6b22; border: 1px solid var(--danger); color: var(--danger); border-radius: 10px; padding: 10px 14px; font-weight: 700; }
.version-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.version-card { font: inherit; color: var(--text); text-align: left; padding: 0; border: 2px solid transparent; border-radius: var(--radius); background: var(--panel); cursor: pointer; overflow: hidden; display: flex; flex-direction: column; }
.version-card:hover, .version-card:focus-visible { border-color: var(--accent); outline: none; }
.version-card .thumb { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; display: block; }
.version-card .thumb.placeholder { display: grid; place-items: center; font-size: 2.6rem; font-weight: 900; color: #ffffffcc; }
.version-card .vname { padding: 12px 14px; font-weight: 800; }
.jackpot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, calc((100vh - 90px) * 0.2)); pointer-events: none; background: #0008; color: var(--warn); border-radius: 999px; padding: 6px 20px; font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.jackpot.top { top: 14px; transform: translateX(-50%); }
.version-card:disabled { opacity: .5; cursor: wait; }

/* Dés 3D */
.dice-row-3d { padding: 6px; }
.dice-3d { display: block; width: min(520px, 80vw); height: auto; aspect-ratio: 2 / 1; }

/* Icône en image (pions, avatars) */
.avatar .icon-img { width: 78%; height: 78%; object-fit: contain; }
