:root {
  --bg: #14171a;
  --card: #1d2126;
  --card-border: #2b3036;
  --chalk: #edeae0;
  --chalk-dim: #a9a69c;
  --gold: #e3a83b;
  --gold-dim: #8a692a;
  --danger: #c1443b;
  --teal: #3e8e86;

  --font-display: 'Permanent Marker', cursive;
  --font-body: 'Work Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--chalk);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.03), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255,255,255,0.025), transparent 40%);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
}

.btn-gear {
  position: static;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--chalk-dim);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.btn-gear:hover { color: var(--teal); border-color: var(--teal); }

.btn-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #1a1204;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(227, 168, 59, 0.55);
  animation: help-pulse 2s ease-in-out infinite;
}
.btn-help:hover { filter: brightness(1.06); }
.btn-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(26, 18, 4, 0.18);
  font-weight: 800;
  font-size: 13px;
}
.btn-help-text { white-space: nowrap; }

@keyframes help-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 168, 59, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(227, 168, 59, 0); }
}

.brand-actions {
  position: absolute;
  right: -6px;
  display: flex;
  gap: 6px;
  align-items: center;
}

@media (max-width: 600px) {
  .brand-actions { position: static; margin-left: 6px; }
}

/* ---------- Aide / description du jeu ---------- */

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.help-overlay[hidden] { display: none !important; }

.help-modal {
  position: relative;
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 22px 24px 20px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
}

.help-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--chalk-dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.help-close:hover { color: var(--chalk); }

.help-modal h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  margin: 0 28px 12px 0;
  color: var(--gold);
}

.help-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--chalk-dim);
  margin-bottom: 16px;
}

.help-body h3 {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--teal);
  margin: 16px 0 8px;
}

.help-body p { margin: 0 0 10px; color: var(--chalk); }
.help-body strong { color: var(--chalk); }
.help-body em { color: var(--gold); font-style: normal; }

.help-body ol, .help-body ul {
  margin: 0 0 8px;
  padding-left: 1.25rem;
}

.help-body li { margin-bottom: 6px; }

.help-modal .btn-primary {
  width: 100%;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #14171a;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(227,168,59,0.08), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(62,142,134,0.08), transparent 40%);
}
.auth-gate[hidden] { display: none !important; }
.auth-gate-card {
  width: min(400px, 100%);
  background: #1d2126;
  border: 1px solid #2b3036;
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
}
.auth-gate-card .auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
}
.auth-gate-card h1 {
  font-family: 'Permanent Marker', cursive;
  font-weight: 400;
  font-size: 36px;
  margin: 12px 0 6px;
  color: #edeae0;
}
.auth-gate-card .brand-sub {
  color: #a9a69c;
  margin: 0 0 16px;
  font-size: 14px;
}
.auth-gate-card .legal-banner {
  background: rgba(193,68,59,0.12);
  border: 1px solid rgba(193,68,59,0.35);
  color: #e8b4b0;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 18px;
  text-align: left;
}
.gate-btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-bottom: 10px;
  box-sizing: border-box;
  padding: 12px 16px;
}
.auth-gate-card .btn-secondary {
  background: #3e8e86;
  color: #06201e;
}
.auth-gate-card .auth-switch {
  margin: 14px 0 0;
  color: #a9a69c;
  font-size: 13px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}
.player-hello {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--teal);
  font-family: var(--font-mono);
}
.legal-inline { color: var(--danger); font-size: 12px; }

.brand h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 42px;
  letter-spacing: 1px;
  margin: 0;
  color: var(--chalk);
  text-shadow: 0 0 18px rgba(237,234,224,0.08);
}

.brand-sub {
  margin: 6px 0 0;
  color: var(--chalk-dim);
  font-size: 14px;
  letter-spacing: 0.3px;
}

.layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 24px;
  align-items: start;
}

/* ---------- Panneau admin (reglages bookmaker) ---------- */

.admin-panel {
  max-width: 1100px;
  margin: 0 auto 22px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}

.admin-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--chalk-dim);
  font-family: var(--font-mono);
}

.admin-val { color: var(--gold); }

.admin-row input[type="range"] {
  accent-color: var(--gold);
}

.admin-panel .btn-primary {
  grid-column: 1 / -1;
}

.admin-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--chalk-dim);
  opacity: 0.75;
}

@media (max-width: 700px) {
  .admin-panel { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Board ---------- */

.board-panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 16px;
}

.board-wrap {
  position: relative;
  width: 100%;
}

/* Cadre aux dimensions exactes du SVG : la boule se positionne dessus (pas sur le scroll parent) */
.board-stage {
  position: relative;
  width: 100%;
  display: block;
  line-height: 0;
}

#board-svg {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
}

.case-rect {
  fill: rgba(237, 234, 224, 0.04);
  stroke: var(--chalk-dim);
  stroke-width: 2.5;
  filter: url(#chalk-rough);
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.case-rect.done {
  fill: rgba(62, 142, 134, 0.28);
  stroke: var(--teal);
}

.case-rect.active {
  fill: rgba(227, 168, 59, 0.35);
  stroke: var(--gold);
  stroke-width: 3.5;
}

.case-rect.legal {
  fill: rgba(227, 168, 59, 0.42);
  stroke: var(--gold);
  stroke-width: 4;
  cursor: pointer;
  animation: legal-pulse 1.3s ease-in-out infinite;
}
.case-rect.legal:hover {
  fill: rgba(227, 168, 59, 0.65);
  stroke-width: 4.5;
}

.case-label.legal {
  fill: var(--gold);
  cursor: pointer;
  font-weight: bold;
}
.case-label.legal:hover { fill: #f5d078; }

.case-rect.failed {
  fill: rgba(193, 68, 59, 0.4);
  stroke: var(--danger);
  stroke-width: 4;
}

.case-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
  pointer-events: all;
}

@keyframes legal-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.legal-hint {
  fill: var(--gold);
  font-family: var(--font-mono);
  font-size: 12px;
  text-anchor: middle;
  pointer-events: none;
}

.auto-pas-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.auto-pas-label {
  font-size: 12px;
  color: var(--chalk-dim);
  width: 100%;
}
.chip.auto-pas {
  flex: 1;
  min-width: 70px;
}
.chip.auto-pas.selected {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(62, 142, 134, 0.12);
}

.hint-text {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--chalk-dim);
  text-align: center;
}

.case-rect.chapeau {
  stroke: var(--teal);
}
.case-rect.chapeau.done {
  fill: rgba(62, 142, 134, 0.35);
}
.case-rect.chapeau.legal {
  fill: rgba(62, 142, 134, 0.45);
}

.case-label {
  fill: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 15px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.case-label.active { fill: var(--gold); }
.case-label.chapeau { fill: var(--teal); }

.path-line {
  stroke: var(--card-border);
  stroke-width: 2;
  stroke-dasharray: 3 6;
}

.pion {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4e6c1, var(--gold) 60%, var(--gold-dim) 100%);
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), 0 0 0 2px rgba(227, 168, 59, 0.35);
  transform: translate(-50%, -50%);
  transition: left 0.45s cubic-bezier(.34,1.4,.64,1), top 0.45s cubic-bezier(.34,1.4,.64,1);
  left: 32.8%;
  top: 97.8%;
  z-index: 5;
  pointer-events: none;
}

.pion.hop {
  animation: hop 0.45s ease;
}

@keyframes hop {
  0%   { filter: none; }
  40%  { transform: translate(-50%, -70%) scale(1.08); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.pion.fail {
  background: radial-gradient(circle at 35% 30%, #f0c9c4, var(--danger) 60%, #7a2a24 100%);
}

.pion.exploded {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.15);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* --- obstacle apparu sur la case fautive --- */
.case-rect.obstacle {
  stroke: var(--danger);
  stroke-width: 4;
}
.case-label.obstacle {
  fill: var(--danger);
}

.obstacle-icon {
  fill: var(--danger);
  filter: url(#chalk-rough);
  transform-box: fill-box;
  transform-origin: center;
  animation: obstacle-pop 0.3s ease;
}

@keyframes obstacle-pop {
  0%   { transform: scale(0) rotate(-8deg); }
  65%  { transform: scale(1.35) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* --- explosion de particules (effet grenade) --- */
.explosion-particle {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: particle-fly 0.75s cubic-bezier(.2,.8,.3,1) forwards;
  animation-delay: var(--delay, 0s);
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 0 6px 1px currentColor;
}

@keyframes particle-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1); opacity: 0; }
}

.shockwave {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid var(--danger);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0.9;
  pointer-events: none;
  z-index: 5;
  animation: shockwave-expand 0.55s ease-out forwards;
}

@keyframes shockwave-expand {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(9); opacity: 0; }
}

.screen-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 50%), rgba(193,68,59,0.35), transparent 60%);
  pointer-events: none;
  z-index: 4;
  animation: flash-fade 0.5s ease-out forwards;
}

@keyframes flash-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- tremblement de la planche à l'impact --- */
.board-wrap.shake {
  animation: shake-anim 0.45s ease;
}

@keyframes shake-anim {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(7px, -6px); }
  45% { transform: translate(-6px, -3px); }
  60% { transform: translate(6px, 4px); }
  75% { transform: translate(-4px, -2px); }
  90% { transform: translate(3px, 2px); }
}

.status-bar {
  margin-top: 14px;
  padding: 10px 14px;
  border-top: 1px dashed var(--card-border);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--chalk-dim);
  min-height: 18px;
}

.niveau-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.niveau-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  background: rgba(227,168,59,0.12);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 3px 10px;
}

.niveau-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chalk-dim);
}

.narration-bar {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 4px;
  background: rgba(227,168,59,0.08);
  border: 1px dashed var(--gold-dim);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gold);
  line-height: 1.5;
}
.narration-bar.danger {
  background: rgba(193,68,59,0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Bet panel ---------- */

.bet-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--chalk-dim);
}

.value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--chalk);
}

.value-xl {
  font-size: 40px;
  color: var(--gold);
  line-height: 1;
}

.sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--chalk-dim);
}

.balance-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.balance-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-reset:hover { border-color: var(--danger); color: var(--danger); }

.chip-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.chip {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--card-border);
  color: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 0;
  border-radius: 4px;
}
.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip.selected { border-color: var(--gold); color: var(--gold); background: rgba(227,168,59,0.08); }

.btn-auto {
  background: var(--card);
  border: 1px solid var(--teal);
  color: var(--teal);
  margin-top: 6px;
  padding: 10px;
}
.btn-auto:hover { background: rgba(62,142,134,0.12); }
.btn-auto.running {
  background: var(--danger);
  border-color: var(--danger);
  color: #2a0503;
}

.bet-input-row {
  display: flex;
  gap: 8px;
}

#montant {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--card-border);
  color: var(--chalk);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 10px;
  border-radius: 4px;
}

button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: var(--gold);
  color: #1a1204;
}

.btn-secondary {
  background: var(--teal);
  color: #06201e;
  flex: 1;
}

.btn-cashout {
  background: var(--danger);
  color: #2a0503;
  flex: 1;
}

.auto-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--chalk-dim);
  margin-top: 2px;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.history-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.net-result {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--chalk-dim);
}
.net-result.positive { color: var(--gold); }
.net-result.negative { color: var(--danger); }

.status-bar.win { color: var(--gold); border-color: var(--gold); }
.status-bar.loss { color: var(--danger); border-color: var(--danger); }

.history-card li {
  font-family: var(--font-mono);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--bg);
}

.history-card li.win { color: var(--gold); }
.history-card li.loss { color: var(--danger); }

.app-footer {
  text-align: center;
  color: var(--chalk-dim);
  font-size: 12px;
  margin-top: 30px;
  opacity: 0.7;
}

/* Thèmes */
.theme-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.theme-chip {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--chalk-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-mono);
}
.theme-chip.selected {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(227,168,59,0.12);
}

body[data-theme="nuit"] {
  --bg: #0c0e14;
  --card: #151922;
  --chalk: #e8ecf5;
  --gold: #7eb6ff;
  --teal: #5ec4b2;
}
body[data-theme="marche"] {
  --bg: #1a1410;
  --card: #241c16;
  --gold: #f0a35a;
  --teal: #c4783a;
}
body[data-theme="plage"] {
  --bg: #0f1c22;
  --card: #162830;
  --gold: #e8c56a;
  --teal: #3aa7c4;
  --chalk: #eef4f6;
}

.lang-switch {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  overflow: hidden;
  margin-right: 6px;
  vertical-align: middle;
}
.lang-chip {
  background: transparent;
  border: none;
  color: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
}
.lang-chip.selected {
  background: var(--gold);
  color: #1a1208;
}
.lang-switch-gate {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
}
.auth-gate-card { position: relative; }
.honeymoon-badge {
  display: inline-block;
  margin: 4px 0 0;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: #1a1208;
  background: linear-gradient(90deg, #f0c040, #e8a020);
  border-radius: 4px;
  font-weight: 700;
}
.honeymoon-badge[hidden] { display: none !important; }
.voie-hint { margin: 0; font-size: 11px; color: var(--chalk-dim); }
.bonus-star {
  fill: var(--gold);
  font-size: 18px;
  font-family: var(--font-display);
  pointer-events: none;
}
.case-rect.bonus-case {
  stroke: var(--teal);
  stroke-width: 3.5;
}
.case-rect.bonus-case.legal {
  stroke: var(--gold);
}
.bonus-icon {
  fill: var(--teal);
  font-size: 20px;
  text-anchor: middle;
  transform-box: fill-box;
  transform-origin: center;
  animation: bonus-glow 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes bonus-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

.gamble-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(8,10,12,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gamble-overlay[hidden] { display: none !important; }
.gamble-modal {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 22px 20px;
  text-align: center;
}
.gamble-modal h2 { margin: 0 0 10px; color: var(--gold); font-family: var(--font-display); font-weight: 400; }
.gamble-lead { font-size: 16px; margin: 0 0 6px; }
.gamble-sub { color: var(--chalk-dim); font-size: 13px; margin: 0 0 16px; }
.gamble-actions { display: flex; gap: 10px; }
.gamble-actions button { flex: 1; min-height: 44px; }
.gamble-actions button:disabled { opacity: 0.55; cursor: wait; }
.gamble-result {
  margin-top: 14px;
  padding: 14px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  animation: gamble-pop 0.35s ease;
}
.gamble-result.win {
  background: rgba(62, 142, 134, 0.22);
  border-color: var(--teal);
}
.gamble-result.loss {
  background: rgba(193, 68, 59, 0.22);
  border-color: var(--danger);
}
.gamble-result.pending {
  background: rgba(227, 168, 59, 0.12);
  border-color: var(--gold);
}
.gamble-result-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
}
.gamble-result.win .gamble-result-title { color: var(--teal); }
.gamble-result.loss .gamble-result-title { color: var(--danger); }
.gamble-result.pending .gamble-result-title { color: var(--gold); }
.gamble-result-amount {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
}
@keyframes gamble-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- HUD mobile (solde + live au-dessus du plateau) ---------- */

.mobile-hud { display: none; }
.mobile-wallet-actions { display: none; }
.label-short { display: none; }

@media (max-width: 860px) {
  .app {
    padding: 4px 0 70px;
    max-width: 100%;
  }

  .app-header {
    margin-bottom: 4px;
    padding: 0 8px;
  }
  .brand h1 { font-size: 18px; margin: 0; }
  .brand-icon { width: 22px; height: 22px; }
  .btn-gear { width: 26px; height: 26px; font-size: 13px; }
  .btn-help {
    padding: 7px 11px;
    font-size: 12px;
    animation: help-pulse 1.8s ease-in-out infinite;
  }
  .btn-help-icon { width: 18px; height: 18px; font-size: 12px; }
  .brand-sub,
  .player-hello { display: none; }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .desktop-only-card { display: none !important; }

  /* Textes longs → versions courtes */
  .label-full { display: none !important; }
  .label-short { display: inline !important; }

  .mobile-hud {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 4px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--card-border);
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  .mobile-hud-solde {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }
  .mobile-hud-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--chalk-dim);
  }
  .mobile-hud-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--chalk);
  }
  .mobile-hud-live {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
  }
  .mobile-hud-live .niveau-badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  .mobile-hud-mult {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
  }
  .mobile-hud-gain {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--chalk-dim);
  }
  .mobile-hud-info {
    margin: 0;
    font-size: 9px;
    line-height: 1.3;
    color: var(--chalk-dim);
  }

  .board-panel {
    padding: 4px 0;
    order: 0;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  /* Plateau prioritaire : scroll sur le wrap, la boule reste calée sur le SVG */
  .board-wrap {
    width: 100%;
    max-width: 100%;
    max-height: 62vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: block;
    -webkit-overflow-scrolling: touch;
  }
  .board-stage {
    width: 100%;
    max-width: 100%;
  }
  #board-svg {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    max-height: none !important;
    display: block;
    margin: 0;
  }
  .pion {
    width: 26px;
    height: 26px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.55), 0 0 0 3px rgba(227, 168, 59, 0.45);
  }
  .case-rect.active {
    stroke-width: 4.5;
    fill: rgba(227, 168, 59, 0.48);
  }

  .status-bar {
    font-size: 10px;
    padding: 4px 6px;
    margin-top: 4px;
    line-height: 1.3;
  }
  .narration-bar {
    font-size: 10px;
    padding: 4px 6px;
    margin-top: 3px;
  }

  .bet-panel {
    gap: 5px;
    order: 1;
  }

  .card {
    padding: 6px 8px;
    gap: 4px;
  }

  .mobile-wallet-actions {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
  }
  .mobile-wallet-actions .btn-ghost {
    flex: 1;
    font-size: 10px;
    padding: 3px 6px;
  }

  .label { font-size: 9px; letter-spacing: 0.4px; margin: 0; }
  .value { font-size: 14px; }
  .value-xl { font-size: 18px; }

  .bet-input-row { gap: 4px; }
  #montant {
    font-size: 13px;
    padding: 5px 8px;
    min-height: 0;
  }
  .btn-primary {
    padding: 5px 10px;
    font-size: 12px;
  }

  .chip-row { gap: 3px; margin-top: 0; }
  .chip {
    font-size: 10px;
    padding: 3px 0;
  }

  .auto-toggle {
    font-size: 10px;
    gap: 5px;
    line-height: 1.2;
    margin-top: 0;
  }
  .auto-toggle input { width: 14px; height: 14px; }

  .btn-auto {
    padding: 5px 8px;
    font-size: 11px;
    margin-top: 0;
  }
  .auto-pas-row {
    gap: 3px;
    margin-top: 0;
  }
  .hint-text { display: none !important; }

  /* Barre bas : pleine largeur écran, boutons 50/50 */
  .action-row {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    z-index: 60;
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(20, 23, 26, 0.98);
    border-top: 1px solid var(--card-border);
    backdrop-filter: blur(6px);
  }
  .action-row .btn-secondary,
  .action-row .btn-cashout {
    flex: 1 1 50%;
    width: 50%;
    min-width: 0;
    margin: 0;
    border-radius: 0;
    padding: 14px 10px;
    font-size: 14px;
    font-weight: 700;
  }
  .action-row .btn-secondary {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  /* Bloc mise : même largeur que le plateau (bord à bord) */
  .bet-panel {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .bet-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 0;
    margin: 0;
    padding: 8px 10px;
  }
  .bet-input-row {
    width: 100%;
  }
  .bet-input-row #montant {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
  .bet-input-row .btn-primary {
    flex: 0 0 auto;
  }
  .chip-row {
    width: 100%;
  }
  .btn-auto {
    width: 100%;
    box-sizing: border-box;
  }
  .mobile-wallet-actions {
    width: 100%;
  }

  .history-card {
    margin: 0 0 4px;
    padding: 6px 10px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    width: 100%;
    box-sizing: border-box;
  }
  .history-card .label { font-size: 9px; }
  .history-card ul { max-height: 64px; }
  .history-card li { font-size: 10px; padding: 3px 5px; }
  .net-result { font-size: 10px; }

  .app-footer {
    margin-top: 8px;
    font-size: 9px;
    padding: 0 10px 2px;
  }
}

@media (max-width: 400px) {
  .board-wrap {
    max-height: 58vh;
  }
  .mobile-hud-mult { font-size: 15px; }
}
