:root {
  --bg: #0b0e17; --panel: #141927; --line: #232a3d; --text: #e8ecf4; --muted: #8791a8;
  --accent: #5b8cff; --win: #39d98a; --lose: #ff4d5e; --warn: #ffb020;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
/* téléphone : pas de surbrillance au toucher, pas de tirer-pour-recharger en plein vol */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior-y: none; }
body { background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; touch-action: manipulation; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06122e; font-weight: 700; } /* texte foncé : contraste 5,9:1 sur l'accent */
button.ghost { background: transparent; border-style: dashed; width: 100%; margin-top: 10px; color: var(--warn); }
input { font-size: 16px; background: #0e1220; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* encoche et barre du bas (viewport-fit=cover) : env(safe-area-inset-*) s'ajoute aux marges, et vaut 0 ailleurs */
header { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 12px calc(16px + env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .12em; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: 0; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.balance, .stat { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
.balance small, .stat small { color: var(--muted); font-weight: 400; font-size: 12px; }

main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px calc(16px + env(safe-area-inset-right, 0px)) 16px calc(16px + env(safe-area-inset-left, 0px)); max-width: 1200px; width: 100%; margin: 0 auto; }
.stage { min-width: 0; }
.history { display: flex; gap: 6px; overflow: hidden; height: 26px; margin-bottom: 10px; }
.chip { flex: none; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.chip.low { color: var(--lose); } .chip.mid { color: var(--text); } .chip.high { color: var(--win); } .chip.moon { color: var(--warn); }

.canvasWrap { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; aspect-ratio: 16 / 9; min-height: 240px; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.big { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(44px, 9vw, 96px); font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none; text-shadow: 0 2px 24px #000a; }
.big.crashed { color: var(--lose); } .big.cashed { color: var(--win); }
.badge { position: absolute; top: 10px; left: 10px; z-index: 1; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; pointer-events: none; }
.badge.on { color: var(--warn); background: #0b0e17cc; border: 1px solid var(--warn); }
.sub { position: absolute; left: 0; right: 0; bottom: 14%; padding: 0 12px; text-align: center; color: var(--muted); font-weight: 600; pointer-events: none; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; margin-top: 12px; }
[data-mode="score"] .controls { grid-template-columns: 1fr; }
.controls label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.quick { display: flex; gap: 4px; }
.quick button { padding: 10px; }
.action { grid-column: 1 / -1; padding: 16px; font-size: 18px; border-radius: 12px; min-height: 56px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.controls label.check { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; min-height: 32px; cursor: pointer; }
.check input { width: auto; }
.rule { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }
#records { margin-top: 10px; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.opt input { width: auto; }
.install { width: 100%; margin-top: 6px; font-size: 13px; color: var(--muted); }
#iosHelp { margin-top: 10px; }
.action.cash { background: var(--win); border-color: var(--win); color: #04210f; }
/* confirmation (à bord, sorti) : bouton inactif mais pleinement lisible */
.action.done, .action.done:disabled { opacity: 1; background: var(--panel); border-color: var(--line); color: var(--win); }

aside { display: grid; gap: 16px; align-content: start; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; }
.panel h2:not(:first-child) { margin-top: 16px; }
.row { display: grid; gap: 8px; }
#players { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 320px; overflow: auto; }
#players li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; font-variant-numeric: tabular-nums; }
#players li.me { background: #1b2236; }
#players li.won { color: var(--win); } #players li.lost { color: var(--muted); }
[data-mode="stake"] #players li.lost { text-decoration: line-through; }
#players .dot { width: 10px; height: 10px; border-radius: 50%; }
#players .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skins { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.skins button { width: 40px; height: 40px; border-radius: 50%; padding: 0; border-width: 2px; }
.skins button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 12px calc(16px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); }
.overlay { position: fixed; inset: 0; background: #05070dee; display: grid; place-items: center; z-index: 10; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.overlay[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; max-width: 420px; }
.card h1 { margin: 0 0 8px; letter-spacing: .12em; }
.card ul { color: var(--muted); padding-left: 18px; }
.card button { width: 100%; margin-top: 8px; }
.card button + button { background: transparent; }
.modeLink { display: block; font-size: 12px; color: var(--muted); padding: 14px 0 0; min-height: 44px; opacity: .8; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; width: fit-content; max-width: calc(100vw - 32px); text-align: center; overflow-wrap: anywhere; pointer-events: none; background: #000c; border: 1px solid var(--line); padding: 10px 16px; border-radius: 16px; z-index: 20; }
.toast[hidden] { display: none; }

@media (max-width: 820px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .canvasWrap { aspect-ratio: 4 / 3; }
}
