:root {
  --bg: #0d0f1a;
  --bg2: #151a2e;
  --card: #1b2140;
  --line: #2b3360;
  --text: #eef1ff;
  --muted: #9aa3cc;
  --accent: #ffcc33;
  --accent2: #29d4ff;
  --good: #3ddc84;
  --bad: #ff5c6c;
  --felt: #0f6b3a;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #262d5c 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
button { font: inherit; }
.hidden { display: none !important; }

/* barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(13, 15, 26, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: .5px; white-space: nowrap; }
@media (max-width: 420px) { .logo { font-size: 17px; } .topbar { gap: 8px; padding: 10px 12px; } .pill { padding: 6px 9px; } }
.logo span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.pill.chips { color: var(--accent); font-weight: 700; cursor: default; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
.conn.on { background: var(--good); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 30px; margin: 10px 0 6px; }
h2 { font-size: 22px; margin: 26px 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: #1a1400; font-weight: 700;
  transition: transform .08s, filter .15s;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.alt { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.blue { background: var(--accent2); color: #001a22; }
.btn.red { background: var(--bad); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 14px; }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
label.field { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
input, select {
  font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* cartes de l'accueil */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.game-card {
  position: relative; overflow: hidden; display: block;
  border-radius: 18px; padding: 20px; min-height: 190px; color: #fff;
  border: 1px solid rgba(255,255,255,.08);
  transition: transform .15s, box-shadow .15s;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.game-card .ico { font-size: 52px; line-height: 1; }
.game-card h3 { margin: 14px 0 4px; font-size: 22px; }
.game-card p { margin: 0; color: rgba(255,255,255,.8); font-size: 15px; }
.game-card .tags { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.35); }
.g-car { background: linear-gradient(135deg, #e5413b, #7a1630); }
.g-moto { background: linear-gradient(135deg, #f39a1f, #8a3b07); }
.g-roul { background: linear-gradient(135deg, #1d9b5a, #0b3d2a); }
.g-bj { background: linear-gradient(135deg, #3256d6, #1a1f5c); }

table.scores { width: 100%; border-collapse: collapse; font-size: 15px; }
table.scores td, table.scores th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.scores th { color: var(--muted); font-weight: 600; }
table.scores td:last-child, table.scores th:last-child { text-align: right; }

/* fenêtre modale */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0,0,0,.65); padding: 16px; }
.modal .panel { width: min(420px, 100%); }
.modal h2 { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: #000c; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); text-align: center;
  animation: toast .25s ease-out;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* jeux de course */
.stage { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.game-full .stage { height: min(72vh, 640px); }
.hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; font-weight: 700; text-shadow: 0 2px 4px #000; }
.hud .box { background: rgba(0,0,0,.45); padding: 6px 10px; border-radius: 8px; font-size: 15px; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  background: rgba(0,0,0,.35); font-size: 64px; font-weight: 900; text-shadow: 0 4px 12px #000;
  pointer-events: none;
}
.overlay.msg { font-size: 30px; }
.touch { position: absolute; bottom: 12px; left: 12px; right: 12px; display: none; justify-content: space-between; pointer-events: none; }
.touch .pad { display: flex; gap: 10px; pointer-events: auto; }
.touch button {
  width: 68px; height: 68px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.14); color: #fff; font-size: 26px; touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.touch button.on { background: rgba(255,204,51,.5); }
@media (pointer: coarse) { .touch { display: flex; } }

.lobby-list { display: grid; gap: 8px; margin-top: 10px; }
.lobby-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--bg2); border-radius: 10px; border: 1px solid var(--line); }
.players { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.player-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.track-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.track-pick button { background: var(--bg2); color: var(--text); border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; text-align: left; }
.track-pick button.sel { border-color: var(--accent); }
.track-pick canvas { width: 100%; height: 80px; display: block; margin-bottom: 6px; }
.results ol { padding-left: 22px; margin: 8px 0; }
.results li { margin: 4px 0; }

/* casino */
.chips-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  width: 50px; height: 50px; border-radius: 50%; border: 4px dashed rgba(255,255,255,.75);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.4); touch-action: manipulation;
}
.chip.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.c1 { background: #8a8fa8; } .c5 { background: #d23c3c; } .c25 { background: #1f9d55; }
.c100 { background: #222; } .c500 { background: #7a3fd1; }
.felt { background: radial-gradient(ellipse at 50% 0%, #1a8a4f, var(--felt) 70%); border-radius: 20px; padding: 16px; border: 6px solid #5a3412; box-shadow: inset 0 0 40px rgba(0,0,0,.5); }

.status-line { min-height: 28px; font-weight: 700; font-size: 18px; text-align: center; margin: 8px 0; }
.win { color: var(--good); } .lose { color: var(--bad); }
