:root {
  --gold: #ffd45d;
  --gold-hot: #fff0a6;
  --gold-deep: #985406;
  --gold-dark: #653200;
  --reel: #640a2f;
  --reel-dark: #2e0416;
  --panel: #7d0d38;
  --panel-dark: #4e061f;
  --green: #20a348;
  --cream: #fff1b8;
  --white: #ffffff;
  --danger: #dc3f34;
  --shadow: rgba(0, 0, 0, 0.62);
  --ease-out-back: cubic-bezier(0.16, 1.18, 0.32, 1);
  --ease-pro: cubic-bezier(0.2, 0.8, 0.16, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #082d1d;
  color: var(--white);
  font-family: "Cinzel", serif;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
}

button:focus-visible {
  outline: 3px solid var(--gold-hot);
  outline-offset: 4px;
}

.machine {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(4, 35, 25, 0), rgba(0, 0, 0, 0.34)),
    url("../assets/bg_forest_magic.png") center / cover no-repeat;
  isolation: isolate;
}

.machine::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.46) 100%),
    linear-gradient(180deg, transparent 68%, rgba(0, 7, 10, 0.94) 100%);
}

.machine.is-locked .slot-shell,
.machine.is-locked .bottom-bar,
.machine.is-locked .quick-actions {
  pointer-events: none;
}

.machine.big-win-shake {
  animation: machineShake 640ms var(--ease-pro);
}

@keyframes machineShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  12% { transform: translate3d(-5px, 2px, 0); }
  24% { transform: translate3d(7px, -2px, 0); }
  36% { transform: translate3d(-8px, 1px, 0); }
  52% { transform: translate3d(6px, 3px, 0); }
  70% { transform: translate3d(-3px, -2px, 0); }
}

.ambient-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff9c4;
  box-shadow: 0 0 14px #fff9c4, 0 0 26px var(--gold);
  opacity: 0;
  animation: sparkle 3s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.2); }
  45% { opacity: 0.92; transform: scale(1); }
}

.slot-shell {
  position: absolute;
  inset: 0 0 12vh 0;
  z-index: 10;
  display: grid;
  place-items: center;
}

/* Reels + bonus HUD: HUD sits directly above the gold frame (avoids overlap
   with the fixed top quick-actions bar on phone). */
.reels-bonus-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 5;
  gap: 0;
  width: max-content;
  max-width: 100%;
}

.slot-frame {
  position: relative;
  width: min(61vw, 790px);
  aspect-ratio: 1.52 / 1;
  min-width: 620px;
  padding: clamp(34px, 4.4vh, 48px) clamp(28px, 2.3vw, 38px) clamp(34px, 4.5vh, 48px);
  filter: none;
  box-shadow: 0 20px 24px rgba(0, 0, 0, 0.58);
  /* Lock the frame on its own GPU layer so spinning reels never cause a
     layout/composite recalculation on the frame itself. */
  transform: translate3d(0, -2.2vh, 0);
  will-change: auto;
  backface-visibility: hidden;
  overflow: hidden;
  isolation: isolate;
  flex: 0 0 auto;
  min-width: 0;
}

.slot-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border: clamp(9px, 1.24vw, 16px) solid var(--gold);
  border-radius: 22px;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(255, 255, 255, 0.26) 10%, transparent 16% 100%),
    linear-gradient(180deg, #fff1a2 0%, #d68a0f 12%, #ffdb68 24%, #8b4b07 52%, #f0b12c 75%, #fff3ad 100%);
  box-shadow:
    inset 0 0 0 3px #6b3703,
    inset 0 0 24px rgba(255, 255, 255, 0.32),
    0 0 0 3px rgba(75, 38, 0, 0.7);
}

.frame-crown {
  position: absolute;
  top: 0.4vh;
  left: 50%;
  z-index: 4;
  display: grid;
  place-items: center;
  width: clamp(78px, 8vw, 110px);
  height: clamp(36px, 5vh, 54px);
  transform: translateX(-50%);
  border: 3px solid var(--gold-dark);
  border-radius: 0 0 22px 22px;
  background: linear-gradient(180deg, #b97710, #ffd45d 55%, #8f4b04);
  color: var(--gold-hot);
  font-size: clamp(22px, 3vw, 40px);
  text-shadow: 0 0 10px #fff, 0 2px 0 #6e3904;
}

.frame-corner {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: clamp(62px, 6vw, 88px);
  height: clamp(62px, 6vw, 88px);
  color: var(--gold);
  font-size: clamp(34px, 5vw, 72px);
  text-shadow: 0 0 8px var(--gold-hot), 2px 2px 0 #743e04;
  pointer-events: none;
}

.corner-top-left { left: -1vw; top: -1.2vh; }
.corner-top-right { right: -1vw; top: -1.2vh; transform: scaleX(-1); }
.corner-bottom-left { left: -1vw; bottom: -1.2vh; transform: scaleY(-1); }
.corner-bottom-right { right: -1vw; bottom: -1.2vh; transform: scale(-1); }

.reels {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Own compositing layer so reel animations don't dirty the parent. */
  transform: translateZ(0);
  will-change: transform;
  border: 3px solid #5a2a00;
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 213, 93, 0.72) 2px, transparent 2px) 0 0 / 20% 100%,
    linear-gradient(180deg, rgba(255, 213, 93, 0.18) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(90deg, #3a0619, var(--reel) 14%, var(--reel) 86%, #3a0619);
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.66),
    inset 0 0 0 2px rgba(255, 240, 163, 0.28);
}

.reel {
  position: relative;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  overflow: hidden;
  border-right: 2px solid rgba(255, 213, 93, 0.68);
  /* Don't pre-promote all reels — only when spinning/stopping. */
  will-change: auto;
}

.reel.is-spinning,
.reel.is-stopping {
  will-change: transform, filter;
}

.reel:last-child {
  border-right: 0;
}

/* During spin: animate on the reel wrapper (not each symbol) to avoid
   creating a new GPU layer per symbol (which was causing the frame to
   visually "breathe" on every frame during heavy repaints). */
.reel.is-spinning {
  animation: reelScrollBlur 100ms linear infinite;
}

/* NO animation on .symbol during spin — symbol-level filter/transform
   creates N GPU layers which destabilise the parent frame geometry. */

.reel.is-stopping {
  animation: reelStopBounce 420ms var(--ease-out-back);
}

@keyframes reelScrollBlur {
  0%   { transform: translateY(-6px); filter: blur(1px); }
  100% { transform: translateY(6px);  filter: blur(1px); }
}

@keyframes reelStopBounce {
  0%   { transform: translateY(-10px); }
  45%  { transform: translateY(5px); }
  72%  { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.08), transparent 62%);
  pointer-events: none;
}

.cell.is-win {
  animation: cellGoldPulse 920ms ease-in-out 3;
}

.cell.is-win .symbol {
  animation: winSymbolPulse 760ms ease-in-out 3;
  filter: drop-shadow(0 0 15px #fff2a5) drop-shadow(0 0 28px var(--gold));
}

/* Cellules contenant un scatter au moment d'un trigger / retrigger.
   Glow violet/argent distinct du highlight de gain payline. */
.cell.is-scatter {
  animation: cellScatterPulse 1.1s ease-in-out 4;
}

.cell.is-scatter .symbol {
  animation: scatterSymbolPulse 760ms ease-in-out 4;
  filter: drop-shadow(0 0 18px #c8a8ff) drop-shadow(0 0 36px #ffd166);
}

@keyframes cellScatterPulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(200, 168, 255, 0); }
  50%      { box-shadow: inset 0 0 42px rgba(200, 168, 255, 0.55), 0 0 22px rgba(255, 209, 102, 0.45); }
}

@keyframes scatterSymbolPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.16) rotate(4deg); }
}

/* ============================================================== */
/* SUSPENSE — phase d'anticipation quand 2 scatters sont visibles  */
/* ============================================================== */

/* Glow persistant sur un scatter qui vient de se poser (avant le 3e).
   Plus saturé que `.is-scatter` (palette flamme), s'auto-amorce. */
.cell.is-scatter-landed {
  position: relative;
  animation: scatterLandedGlow 1100ms ease-in-out infinite;
  z-index: 6;
}

.cell.is-scatter-landed .symbol {
  filter: drop-shadow(0 0 14px #ffb14a) drop-shadow(0 0 28px #ff5f2e);
  animation: scatterLandedSymbol 1100ms ease-in-out infinite;
}

@keyframes scatterLandedGlow {
  0%, 100% { box-shadow: inset 0 0 22px rgba(255, 122, 40, 0.55), 0 0 18px rgba(255, 209, 80, 0.42); }
  50%      { box-shadow: inset 0 0 46px rgba(255, 88, 24, 0.85), 0 0 36px rgba(255, 198, 88, 0.7); }
}

@keyframes scatterLandedSymbol {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.14) rotate(-3deg); }
}

/* ============================================================== */
/* SUSPENSE — feu localisé sur les colonnes en attente             */
/* ------------------------------------------------------------    */
/* Aucun overlay plein écran : tension exclusivement portée par la */
/* ou les colonnes restantes (celles qui pourraient encore poser   */
/* le 3e scatter). Palette ROUGE pour exprimer le danger/excitation. */
/* ============================================================== */

/* Rouleau "en attente" (le 3e scatter peut tomber ici) : enveloppe
   de flammes rouges qui palpitent par dessus, glow interne rouge,
   et léger boost de saturation pour faire ressortir la colonne. */
.reel.is-suspense-flames {
  position: relative;
  box-shadow:
    inset 0 0 24px rgba(255, 60, 24, 0.5),
    inset 0 0 64px rgba(255, 12, 0, 0.35),
    0 0 28px rgba(255, 60, 24, 0.55);
  filter: brightness(1.05) saturate(1.1);
  z-index: 4;
  animation: reelHotPulse 700ms ease-in-out infinite alternate;
}

@keyframes reelHotPulse {
  from { box-shadow: inset 0 0 22px rgba(255, 60, 24, 0.45), inset 0 0 56px rgba(255, 12, 0, 0.3),  0 0 22px rgba(255, 60, 24, 0.45); }
  to   { box-shadow: inset 0 0 38px rgba(255, 88, 24, 0.85), inset 0 0 88px rgba(255, 30, 0, 0.55), 0 0 38px rgba(255, 90, 24, 0.85); }
}

/* Flammes : 4 plumes (haut, bas, et deux latérales pulsées en
   décalé) pour donner l'impression d'un brasier qui dévore la
   colonne sans empêcher de voir les symboles. */
.reel.is-suspense-flames::before,
.reel.is-suspense-flames::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  height: 44%;
  pointer-events: none;
  z-index: 6;
  filter: blur(14px) saturate(1.3);
  opacity: 0.95;
  animation: reelFlames 760ms ease-in-out infinite alternate;
}

.reel.is-suspense-flames::before {
  top: -22%;
  background:
    radial-gradient(ellipse at 50% 90%, rgba(255, 240, 140, 0.95) 0%, rgba(255, 130, 20, 0.85) 28%, rgba(220, 22, 0, 0.55) 60%, transparent 90%);
}

.reel.is-suspense-flames::after {
  bottom: -22%;
  background:
    radial-gradient(ellipse at 50% 10%, rgba(255, 210, 110, 0.9) 0%, rgba(255, 90, 20, 0.8) 30%, rgba(180, 8, 0, 0.55) 60%, transparent 90%);
  animation-delay: 220ms;
}

@keyframes reelFlames {
  0%   { opacity: 0.65; transform: scale(0.92, 0.88) translateY(0); }
  50%  { opacity: 1;    transform: scale(1.08, 1.18) translateY(-6%); }
  100% { opacity: 0.78; transform: scale(0.98, 1.04) translateY(2%); }
}

/* Rouleau "destiné" à porter le 3e scatter (le dernier en suspense) :
   intensifie encore le brasier pour annoncer la zone d'impact. */
.reel.is-suspense-pending {
  box-shadow:
    inset 0 0 36px rgba(255, 90, 30, 0.85),
    inset 0 0 96px rgba(255, 24, 0, 0.55),
    0 0 48px rgba(255, 90, 30, 0.95);
  filter: brightness(1.12) saturate(1.18);
}

/* Flash plein écran à l'apparition du 3e scatter — bref, blanc/or. */
.scatter-flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 248, 200, 0.95), rgba(255, 178, 60, 0.55) 30%, rgba(0, 0, 0, 0) 75%);
  opacity: 0;
}

.scatter-flash-overlay.is-firing {
  animation: scatterFlash 650ms cubic-bezier(.22,.61,.36,1) forwards;
}

@keyframes scatterFlash {
  0%   { opacity: 0; transform: scale(0.6); }
  20%  { opacity: 1; transform: scale(1.0); }
  60%  { opacity: 0.5; transform: scale(1.18); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* Pulse final dramatique sur la cellule du 3e scatter. */
.cell.is-scatter-final {
  animation: scatterFinalCell 720ms cubic-bezier(.22,.61,.36,1) 1;
  z-index: 8;
}

.cell.is-scatter-final .symbol {
  animation: scatterFinalSymbol 720ms cubic-bezier(.22,.61,.36,1) 1;
  filter: drop-shadow(0 0 24px #ffe27a) drop-shadow(0 0 60px #ff7a18);
}

@keyframes scatterFinalCell {
  0%   { box-shadow: inset 0 0 0 rgba(255, 240, 160, 0); transform: scale(1); }
  35%  { box-shadow: inset 0 0 80px rgba(255, 240, 160, 0.95), 0 0 60px rgba(255, 122, 24, 0.85); transform: scale(1.18); }
  100% { box-shadow: inset 0 0 36px rgba(255, 240, 160, 0.4); transform: scale(1.04); }
}

@keyframes scatterFinalSymbol {
  0%   { transform: scale(1) rotate(0deg); }
  35%  { transform: scale(1.45) rotate(-8deg); }
  60%  { transform: scale(1.20) rotate(6deg); }
  100% { transform: scale(1.08) rotate(0deg); }
}

@keyframes cellGoldPulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255, 212, 93, 0); }
  50% { box-shadow: inset 0 0 36px rgba(255, 212, 93, 0.42); }
}

@keyframes winSymbolPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14) rotate(-2deg); }
}

.symbol {
  position: relative;
  z-index: 1;
  width: 80%;
  height: 80%;
  object-fit: contain;
  transform: translateZ(0);
  filter:
    drop-shadow(0 9px 6px rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 2px rgba(255, 228, 127, 0.5));
}

/* Le scatter garde la même taille de boîte que les autres symboles (80%) ;
   on lui ajoute juste un drop-shadow violet/argent distinctif pour qu'on
   l'identifie immédiatement comme symbole spécial. Le PNG est cropé tight
   sur ses pixels opaques (cf. scripts/tighten_scatter.py) donc il remplit
   la cellule comme les autres. */
.cell[data-symbol="scatter"] .symbol {
  filter:
    drop-shadow(0 8px 8px rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 6px rgba(200, 168, 255, 0.55));
}

.cell[data-symbol="Q"] .symbol,
.cell[data-symbol="A"] .symbol,
.cell[data-symbol="J"] .symbol,
.cell[data-symbol="ten"] .symbol {
  width: 76%;
  height: 76%;
}

.cell[data-symbol="beer"] .symbol,
.cell[data-symbol="potion"] .symbol {
  width: 84%;
  height: 84%;
}

.cell.has-fallback-symbol::after {
  content: attr(data-fallback);
  z-index: 2;
  width: 78%;
  min-height: 52%;
  display: grid;
  place-items: center;
  border: 3px solid var(--gold);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff099, #c7770b);
  color: #5c2800;
  font-size: clamp(16px, 2.4vw, 30px);
  font-weight: 900;
  text-align: center;
  text-shadow: 1px 1px 0 white;
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.45);
}

.game-logo {
  position: absolute;
  right: clamp(18px, 5.4vw, 70px);
  top: clamp(70px, 15vh, 125px);
  z-index: 14;
  width: clamp(150px, 20vw, 260px);
  filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.52));
  animation: logoFloat 4.2s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.bonus-panel {
  position: absolute;
  left: clamp(20px, 7vw, 88px);
  z-index: 15;
  width: clamp(122px, 13vw, 166px);
  border: 4px solid var(--gold);
  border-radius: 9px;
  background:
    linear-gradient(145deg, rgba(255, 226, 117, 0.24), transparent 20%),
    linear-gradient(180deg, #8c1641 0%, #5d0627 100%);
  box-shadow:
    inset 0 0 0 2px #774005,
    0 9px 18px var(--shadow),
    0 0 14px rgba(255, 212, 93, 0.45);
  color: var(--cream);
  text-align: center;
}

.bonus-panel::before,
.bonus-panel::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid var(--gold-hot);
  box-shadow: 0 0 8px var(--gold);
  pointer-events: none;
}

.bonus-panel::before {
  left: -8px;
  top: -8px;
  border-right: 0;
  border-bottom: 0;
}

.bonus-panel::after {
  right: -8px;
  bottom: -8px;
  border-left: 0;
  border-top: 0;
}

.buy-panel {
  top: clamp(105px, 18vh, 150px);
  min-height: clamp(110px, 17vh, 136px);
  padding: 14px 8px 12px;
}

.buy-title {
  display: block;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(14px, 1.85vw, 24px);
  line-height: 0.93;
  letter-spacing: 0.5px;
  color: var(--cream);
  text-shadow: 2px 3px 0 #672411, 0 0 12px var(--gold);
}

.buy-price,
.bet-title {
  display: block;
  margin-top: 10px;
  color: #ffe57f;
  font-weight: 900;
  text-shadow: 2px 2px 0 #4a1700;
}

.buy-price {
  font-size: clamp(16px, 2vw, 28px);
}

.bet-panel {
  top: clamp(240px, 43vh, 318px);
  min-height: clamp(100px, 15vh, 126px);
  padding: 11px 8px 10px;
}

.bet-title {
  font-size: clamp(14px, 1.55vw, 22px);
}

.boost-toggle {
  position: relative;
  display: block;
  width: 72%;
  height: 28px;
  margin: 10px auto 5px;
  padding: 0;
  border: 3px solid var(--gold);
  border-radius: 18px;
  background: #c40d2c;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 -1px 2px rgba(255, 255, 255, 0.08),
    0 0 14px rgba(196, 13, 44, 0.55);
  cursor: pointer;
  transition: background 240ms ease, box-shadow 240ms ease;
}

.boost-toggle[aria-pressed="true"] {
  background: #1a9f3f;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 -1px 2px rgba(255, 255, 255, 0.1),
    0 0 18px rgba(74, 255, 116, 0.7);
}

.boost-dot {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #f0f0f0 55%, #c8c8c8);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 0 9px rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(0, 0, 0, 0.18);
  transform: translateY(-50%);
  transition: left 240ms cubic-bezier(.22,.61,.36,1);
}

.boost-toggle[aria-pressed="true"] .boost-dot {
  left: calc(100% - 22px - 3px);
}

.boost-copy {
  color: var(--cream);
  font-size: clamp(8px, 0.82vw, 11px);
  line-height: 1.05;
  text-shadow: 1px 1px 0 #461400;
}

/* Barre du bas — un seul rang horizontal :
   [icônes rapides] [crédit/mise] [turbo hint (flex-grow)] [bet- spin bet+] [AUTO] */
.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 26px);
  height: max(92px, 13vh);
  padding: 1.2vh clamp(14px, 2.2vw, 32px);
  background: linear-gradient(180deg, transparent, rgba(0, 9, 12, 0.78) 30%, rgba(0, 7, 10, 0.95));
}

.meter-group {
  color: #fff1a8;
  font-size: clamp(11px, 1.1vw, 15px);
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 2px 2px 2px #000;
  white-space: nowrap;
}

.meter-line span {
  margin-left: 8px;
  color: var(--white);
}

.turbo-hint {
  flex: 1;
  margin: 0;
  color: var(--white);
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(10px, 1.15vw, 16px);
  line-height: 1.12;
  letter-spacing: 0.6px;
  text-align: center;
  text-shadow: 2px 2px 0 #243131;
}

.control-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1vw, 14px);
}

/* Bloc d'icônes (menu / audio / info) intégré au début de la barre. */
.quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-button,
.round-button,
.spin-button {
  display: grid;
  place-items: center;
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 9px rgba(255, 255, 255, 0.18), 0 5px 11px rgba(0, 0, 0, 0.45);
  color: var(--white);
  font-weight: 900;
  cursor: pointer;
}

.icon-button {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

/* ============================================================== */
/* Audio button (waveform icon)                                   */
/* ============================================================== */
.audio-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 18px;
  height: 18px;
}

.audio-wave {
  display: block;
  width: 3px;
  background: linear-gradient(180deg, #ffe27a, #ff9f43);
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(255, 200, 70, 0.7);
  animation: audioWavePulse 1.4s ease-in-out infinite;
  transform-origin: center;
}

.audio-wave-1 { height: 6px;  animation-delay: 0s;    }
.audio-wave-2 { height: 12px; animation-delay: 0.2s; }
.audio-wave-3 { height: 9px;  animation-delay: 0.4s; }

@keyframes audioWavePulse {
  0%, 100% { transform: scaleY(0.45); }
  50%      { transform: scaleY(1);    }
}

#audioButton.is-muted .audio-icon {
  position: relative;
}

#audioButton.is-muted .audio-wave {
  animation: none;
  background: linear-gradient(180deg, #888, #555);
  box-shadow: none;
  transform: scaleY(0.45);
}

#audioButton.is-muted .audio-icon::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto 0;
  height: 2px;
  background: #ff5c5c;
  box-shadow: 0 0 6px rgba(255, 92, 92, 0.8);
  transform: translateY(-50%) rotate(-28deg);
  pointer-events: none;
}

/* ============================================================== */
/* Audio panel (volume sliders)                                   */
/* ============================================================== */
.audio-card {
  max-width: 480px;
}

.audio-help {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 244, 214, 0.78);
}

.audio-mute-row {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.audio-mute-row .primary-button {
  min-width: 220px;
}

.volume-row {
  display: grid;
  grid-template-columns: 130px 1fr 56px;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 212, 93, 0.14);
}

.volume-row:last-of-type {
  border-bottom: none;
  margin-bottom: 16px;
}

.volume-row label {
  color: var(--cream);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.volume-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe27a 0%, #ff9f43 50%, rgba(255, 255, 255, 0.18) 50%);
  outline: none;
  cursor: pointer;
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7d6 0%, #ffb84a 60%, #b56a14 100%);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.volume-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7d6 0%, #ffb84a 60%, #b56a14 100%);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.volume-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #ffe27a;
  text-align: right;
}

.round-button {
  width: clamp(36px, 4.4vw, 48px);
  height: clamp(36px, 4.4vw, 48px);
  font-size: clamp(22px, 2.7vw, 30px);
}

.spin-stack {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.spin-button {
  width: clamp(64px, 7.2vw, 86px);
  height: clamp(64px, 7.2vw, 86px);
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,0.28), rgba(0,0,0,0.45));
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
}

.spin-button.is-spinning {
  pointer-events: none;
  animation: spinButton 650ms linear infinite;
}

@keyframes spinButton {
  to { transform: rotate(360deg); }
}

.auto-button {
  flex-shrink: 0;
  min-width: clamp(64px, 6.4vw, 88px);
  height: clamp(36px, 4.4vw, 48px);
  padding: 0 clamp(10px, 1.2vw, 16px);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: clamp(14px, 2vw, 22px);
  background: rgba(0, 0, 0, 0.58);
  box-shadow: inset 0 0 9px rgba(255, 255, 255, 0.15), 0 5px 11px rgba(0, 0, 0, 0.45);
  color: white;
  font-size: clamp(13px, 1.25vw, 16px);
  font-weight: 900;
  letter-spacing: 1.2px;
  cursor: pointer;
}

.auto-button.is-on {
  background: #178c38;
  box-shadow: 0 0 12px rgba(74, 255, 116, 0.75);
}

.pressable {
  transition:
    transform 140ms var(--ease-pro),
    filter 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.pressable:hover:not(:disabled) {
  filter: brightness(1.13) saturate(1.08);
  transform: translateY(-2px) scale(1.025);
}

.pressable:active:not(:disabled),
.pressable.is-pressed:not(:disabled) {
  transform: translateY(1px) scale(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  filter: grayscale(0.2);
}

/* =====================================================================
   WIN BANNER — text-only (amount top, WIN bottom)
   ===================================================================== */
.win-banner {
  position: absolute;
  left: 50%;
  top: 80%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-family: "Luckiest Guy", "Cinzel", serif;
  text-align: center;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.72),
    0 8px 18px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1);
}

.win-banner-amount {
  font-size: clamp(46px, 7.4vw, 96px);
  letter-spacing: 0.02em;
  -webkit-text-stroke: 1.6px rgba(0, 0, 0, 0.75);
}

.win-banner.is-pop {
  animation: winBannerPop 520ms var(--ease-out-back);
}

@keyframes winBannerPop {
  0% { transform: translate(-50%, -50%) scale(0.9); filter: brightness(1); }
  55% { transform: translate(-50%, -50%) scale(1.18); filter: brightness(1.12); }
  100% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
}

.win-banner-label {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(14px, 2.1vw, 22px);
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.72),
    0 6px 14px rgba(0, 0, 0, 0.45);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: max(110px, 15vh);
  z-index: 85;
  padding: 10px 18px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-weight: 900;
  text-shadow: 1px 1px 0 #000;
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  display: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop,
.panel-overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(5px);
}

.modal-backdrop.is-open,
.panel-overlay.is-open {
  display: grid;
}

.confirm-card,
.panel-card {
  width: min(92vw, 520px);
  border: 5px solid var(--gold);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 93, 0.26), transparent 42%),
    linear-gradient(180deg, #7e0f3a, #43071f);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), inset 0 0 26px rgba(255, 212, 93, 0.18);
  text-align: center;
  animation: dialogIn 230ms var(--ease-out-back);
}

.confirm-card {
  padding: 26px;
}

.panel-card {
  width: min(94vw, 880px);
  max-height: 86vh;
  overflow: auto;
  padding: 28px;
  margin: 0 auto;
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(18px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.confirm-card h2,
.panel-card h2 {
  margin-bottom: 14px;
  color: #ffe27a;
  font-size: 30px;
  text-shadow: 2px 2px 0 #431500;
}

.confirm-card p {
  margin: 0 auto 22px;
  max-width: 390px;
  color: var(--cream);
  font-size: 18px;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.primary-button,
.secondary-button {
  min-width: 132px;
  padding: 11px 20px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 3px solid var(--gold-hot);
  background: linear-gradient(180deg, #36be5c, #14732f);
  color: #fff;
  text-shadow: 1px 1px 0 #063914;
}

.secondary-button {
  border: 3px solid rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  width: 100%;
  justify-items: stretch;
  align-items: stretch;
}

.math-summary {
  grid-column: 1 / -1;
  padding: 14px 18px;
  border: 1px solid rgba(255, 212, 93, 0.55);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 212, 93, 0.16), rgba(0, 0, 0, 0.28));
  color: var(--cream);
  width: 100%;
}

.math-summary h3 {
  margin: 0 0 8px;
  font-family: var(--font-display, "Cinzel Decorative", serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 14px;
  color: #ffe27a;
}

.math-summary dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
  margin: 0 0 10px;
}

.math-summary dl > div {
  padding: 8px 10px;
  border: 1px solid rgba(255, 212, 93, 0.32);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  text-align: center;
}

.math-summary dt {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 232, 170, 0.85);
}

.math-summary dd {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.math-summary p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(255, 244, 214, 0.86);
}

.asset-card {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 212, 93, 0.45);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--cream);
  font-size: 13px;
  text-align: center;
  width: 100%;
}

/* Fiche dédiée au scatter dans la paytable : encadré violet+or pour bien
   le différencier des symboles payants. */
.asset-card.asset-scatter {
  border-color: #c8a8ff;
  background: linear-gradient(180deg, rgba(60, 30, 90, 0.45) 0%, rgba(20, 10, 5, 0.55) 100%);
  box-shadow:
    0 0 0 1px rgba(255, 212, 93, 0.45),
    0 0 22px rgba(200, 168, 255, 0.35),
    inset 0 0 18px rgba(200, 168, 255, 0.18);
}

.asset-card.asset-scatter strong {
  color: #fff7c2;
  text-shadow: 0 0 10px rgba(200, 168, 255, 0.85);
}

.asset-card.asset-scatter .pay-tiers td {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.asset-card img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.asset-card strong {
  font-family: var(--font-display, "Cinzel Decorative", serif);
  letter-spacing: 0.06em;
  font-size: 13px;
  color: #ffe27a;
}

.pay-tiers {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  table-layout: fixed;
}

.pay-tiers tr + tr th,
.pay-tiers tr + tr td {
  border-top: 1px solid rgba(255, 212, 93, 0.18);
}

.pay-tiers th {
  text-align: left;
  padding: 4px 6px;
  color: rgba(255, 232, 170, 0.78);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.pay-tiers td {
  text-align: right;
  padding: 4px 6px;
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Internal probability labels removed from player-facing UI. */
.pay-prob { display: none; }

/* =====================================================================
   RESPONSIVE — TABLET / SMALL LANDSCAPE
   ---------------------------------------------------------------------
   Up to ~940px wide OR squarish aspect: we keep the machine layout but
   move the BUY/BET side panels down to sit just above the bottom bar so
   the reels keep maximum width.
   ===================================================================== */
@media (max-width: 940px) and (min-width: 721px), (max-aspect-ratio: 4 / 3) and (orientation: landscape) {
  .slot-shell {
    bottom: 18vh;
    align-items: start;
    padding-top: 9vh;
  }

  .slot-frame {
    width: min(94vw, 760px);
    min-width: 0;
    transform: none;
  }

  .game-logo {
    top: 1vh;
    right: 50%;
    width: clamp(142px, 36vw, 230px);
    transform: translateX(50%);
    animation-name: logoFloatMobile;
  }

  @keyframes logoFloatMobile {
    0%, 100% { transform: translateX(50%) translateY(0); }
    50% { transform: translateX(50%) translateY(-6px); }
  }

  .bonus-panel {
    top: auto;
    bottom: max(92px, 13.5vh);
    width: min(42vw, 220px);
    max-width: none;
  }

  .buy-panel { left: 5vw; }
  .bet-panel { left: auto; right: 5vw; }

  .bottom-bar {
    height: max(98px, 14vh);
    padding: 10px 14px;
    gap: 10px;
  }

  .turbo-hint,
  .quick-actions {
    display: none;
  }

  .control-group {
    gap: 8px;
  }

  .asset-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .math-summary dl {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
}

/* =====================================================================
   RESPONSIVE — PHONE PORTRAIT (full restack)
   ---------------------------------------------------------------------
   ≤ 720px portrait OR ≤ 540px any orientation:
   stack vertically — quick actions top-right, logo top-center,
   BUY+BET panels in a row (equal size), reels grow to fill the rest,
   compact 2-row bottom bar.
   ===================================================================== */
@media (max-width: 720px) and (orientation: portrait), (max-width: 540px) {
  /* Center overlays (settings/paytable/confirm) harmoniously on mobile. */
  .panel-overlay,
  .modal-backdrop {
    padding:
      calc(env(safe-area-inset-top, 0px) + 14px)
      0
      calc(env(safe-area-inset-bottom, 0px) + 14px);
  }

  .panel-card,
  .confirm-card {
    width: 92vw;             /* ~90–95% of screen */
    max-width: 560px;
    margin: 0 auto;          /* equal side margins */
    padding: 14px;           /* slightly tighter than desktop */
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 28px);
  }

  .slot-shell {
    inset: 0;
    bottom: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 4px) 8px
             calc(132px + env(safe-area-inset-bottom, 0px)) 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "logo logo"
      "buy bet"
      "frame frame";
    align-items: stretch;
    align-content: stretch;
    justify-items: stretch;
    gap: 6px 8px;
  }

  /* Game logo : in flow, top-center, modest size. */
  .game-logo {
    position: relative;
    grid-area: logo;
    top: auto;
    right: auto;
    width: clamp(96px, 28vw, 138px);
    margin: 0 auto;
    transform: none;
    animation: logoFloatMobile 4.2s ease-in-out infinite;
  }

  @keyframes logoFloatMobile {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
  }

  /* BUY/BET side panels: now in flow, side-by-side, EQUAL size, content
     vertically centered for visual balance. */
  .bonus-panel {
    position: relative;
    grid-area: buy;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: 100%;
    min-height: 84px;
    padding: 6px 6px;
    border-width: 3px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .bet-panel { grid-area: bet; }

  .bonus-panel::before,
  .bonus-panel::after {
    width: 10px;
    height: 10px;
    border-width: 2px;
  }

  .buy-title {
    font-size: clamp(11px, 3vw, 14px);
    line-height: 1;
    margin: 0;
  }

  .buy-price {
    margin: 2px 0 0;
    font-size: clamp(14px, 4vw, 17px);
  }

  .bet-title {
    margin: 0;
    font-size: clamp(11px, 3vw, 14px);
  }

  .boost-toggle {
    width: 84%;
    height: 22px;
    margin: 4px auto 2px;
  }

  .boost-dot {
    width: 16px;
    height: 16px;
  }

  .boost-toggle[aria-pressed="true"] .boost-dot {
    left: calc(100% - 16px - 3px);
  }

  .boost-copy {
    margin: 0;
    font-size: clamp(7px, 2.1vw, 9px);
    line-height: 1.05;
  }

  /* Reels + bonus HUD: fills row 3; HUD sits above the gold frame only. */
  .reels-bonus-wrap {
    grid-area: frame;
    width: 100%;
    min-height: 0;
    max-height: 100%;
    align-self: center;
    justify-self: center;
    justify-content: center;
  }

  /* Reels frame : grows to fill row 3 with squarer cells (5/4 inner ratio,
     ~1.21 outer once we account for padding). Centered vertically so any
     leftover gap balances above/below instead of dumping it all at the
     bottom of the screen. */
  .slot-frame {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    aspect-ratio: 1.21 / 1;
    padding: clamp(14px, 3.4vw, 22px) clamp(10px, 2.6vw, 18px);
    transform: none;
    margin: 0 auto;
    align-self: center;
  }

  .slot-frame::before {
    border-width: clamp(6px, 1.8vw, 10px);
  }

  .frame-crown {
    width: clamp(48px, 13vw, 70px);
    height: clamp(22px, 5vw, 32px);
    font-size: clamp(16px, 4.4vw, 24px);
  }

  .frame-corner {
    width: clamp(36px, 10vw, 52px);
    height: clamp(36px, 10vw, 52px);
    font-size: clamp(22px, 6.4vw, 34px);
  }

  /* Symbols look right at 86% inside more square cells. */
  .symbol {
    width: 86%;
    height: 86%;
  }

  /* Quick actions : pinned to top-right of the screen, compact pill. */
  .quick-actions {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 6px);
    right: calc(env(safe-area-inset-right, 0px) + 8px);
    z-index: 25;
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.55);
    padding: 4px 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(6px);
  }

  /* Bonus HUD must never sit under the fixed quick-actions pill.
     Reserve headroom only during bonus to keep the HUD directly above
     the reels frame without overlap. */
  body.is-bonus-mode .reels-bonus-wrap {
    padding-top: calc(env(safe-area-inset-top, 0px) + 52px);
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 17px;
    line-height: 1;
  }

  /* Bottom bar : compact 2 rows — credit/bet meter on top, controls below.
     Tightened paddings + smaller min-height so it doesn't crowd the reels. */
  .bottom-bar {
    flex-wrap: wrap;
    height: auto;
    min-height: 120px;
    padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
    gap: 4px 10px;
    justify-content: center;
    background: linear-gradient(180deg, transparent, rgba(0, 9, 12, 0.85) 25%, rgba(0, 7, 10, 0.96));
  }

  .turbo-hint {
    display: none;
  }

  .meter-group {
    flex: 1 1 100%;
    display: flex;
    justify-content: center;
    gap: 18px;
    font-size: clamp(11px, 3.2vw, 14px);
    text-align: center;
    order: 1;
  }

  .meter-line {
    white-space: nowrap;
  }

  .meter-line span {
    margin-left: 6px;
  }

  .control-group {
    flex: 0 0 auto;
    gap: 12px;
    order: 2;
  }

  .round-button {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .spin-button {
    width: 72px;
    height: 72px;
    font-size: 38px;
  }

  .auto-button {
    flex: 0 0 auto;
    min-width: 64px;
    height: 44px;
    padding: 0 14px;
    border-radius: 22px;
    font-size: 13px;
    letter-spacing: 1px;
    order: 3;
  }

  /* Modal/paytable cards adapt to small screens. */
  .panel-card {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 28px);
  }

  .confirm-card {
    padding: 14px;
  }

  .confirm-card h2,
  .panel-card h2 {
    font-size: 22px;
  }

  .confirm-card p {
    font-size: 16px;
  }

  .confirm-actions {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    min-width: 0;
    padding: 12px 16px;
    font-size: 15px;
  }

  .asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    justify-items: stretch;
    align-items: stretch;
  }

  .asset-card {
    padding: 8px 6px;
    font-size: 12px;
    width: 100%;
  }

  .asset-card img {
    width: 56px;
    height: 56px;
  }

  .math-summary {
    padding: 10px 12px;
    width: 100%;
  }

  .math-summary dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .math-summary dd {
    font-size: 15px;
  }

  /* Audio panel : compact for narrow screens. */
  .audio-card {
    max-width: 100%;
  }

  .volume-row {
    grid-template-columns: 100px 1fr 44px;
    gap: 8px;
  }

  .volume-row label {
    font-size: 12px;
  }

  /* Win banner: anchored above the fixed bottom-bar so it lives in the
     empty zone beneath the reels frame. The bottom-bar sits in a higher
     stacking context (z:18) than .slot-shell (z:10), so we can't simply
     overlap it; we have to push the banner physically clear of it. */
  .win-banner {
    top: auto;
    bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    max-width: 88vw;
    transform: translate(-50%, 8px) scale(0.85);
  }

  .win-banner.is-pop {
    animation-name: winBannerPopMobile;
  }

  @keyframes winBannerPopMobile {
    0% { transform: translate(-50%, 8px) scale(0.9); filter: brightness(1); }
    55% { transform: translate(-50%, 0) scale(1.18); filter: brightness(1.12); }
    100% { transform: translate(-50%, 0) scale(1); filter: brightness(1); }
  }

  /* Toast pinned just above the bottom bar (which is ~170px tall on phone). */
  .toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 180px);
    font-size: 13px;
    padding: 8px 14px;
  }
}

/* =====================================================================
   RESPONSIVE — VERY NARROW PHONE (≤ 380px wide, e.g. iPhone SE)
   ===================================================================== */
@media (max-width: 380px) {
  .slot-shell {
    padding-left: 6px;
    padding-right: 6px;
    gap: 6px;
  }

  .game-logo {
    width: clamp(100px, 32vw, 150px);
  }

  .buy-title { font-size: 12px; }
  .buy-price { font-size: 14px; }
  .bet-title { font-size: 12px; }
  .boost-copy { display: none; }

  .spin-button { width: 70px; height: 70px; font-size: 38px; }
  .round-button { width: 42px; height: 42px; font-size: 24px; }
  .auto-button { min-width: 60px; height: 42px; padding: 0 10px; font-size: 13px; }
}

/* =====================================================================
   RESPONSIVE — LANDSCAPE PHONE (low height, e.g. 800x360)
   ---------------------------------------------------------------------
   When the viewport is short and wide, we shrink vertical paddings and
   use a more horizontal compaction (reels left, controls right).
   ===================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .slot-shell {
    bottom: 14vh;
    padding-top: 4vh;
  }

  .slot-frame {
    width: min(78vw, 720px);
    aspect-ratio: 1.78 / 1;
    padding: clamp(20px, 3vw, 30px) clamp(16px, 2vw, 24px);
    transform: translateY(-1vh);
  }

  .game-logo {
    top: 4px;
    width: clamp(110px, 14vw, 170px);
  }

  .bonus-panel {
    width: clamp(100px, 12vw, 140px);
  }

  .buy-panel { top: clamp(60px, 12vh, 100px); }
  .bet-panel { top: clamp(180px, 38vh, 240px); }

  .bottom-bar {
    height: max(78px, 12vh);
    gap: 8px;
  }

  .turbo-hint {
    font-size: 10px;
  }

  .spin-button {
    width: clamp(52px, 7vw, 70px);
    height: clamp(52px, 7vw, 70px);
    font-size: clamp(28px, 4.4vw, 40px);
  }

  .round-button {
    width: clamp(34px, 4.4vw, 44px);
    height: clamp(34px, 4.4vw, 44px);
  }
}

/* =====================================================================
   ACCESSIBILITY — touch targets & focus rings on touch devices
   ===================================================================== */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover pop on touch — it triggers a "stuck hover" after tap. */
  .pressable:hover:not(:disabled) {
    filter: none;
    transform: none;
  }

  /* Keep an active feedback so taps still feel reactive. */
  .pressable:active:not(:disabled) {
    transform: scale(0.96);
    filter: brightness(1.1);
  }
}

/* =====================================================================
   BONUS — État, transition, HUD, retrigger, fin de bonus
   ===================================================================== */

/* État global du body pendant le bonus : assombrit l'arrière-plan
   et bloque toutes les interactions extérieures à la grille. */
body.is-bonus-mode .ambient-layer {
  filter: brightness(0.4) saturate(1.15);
  transition: filter 600ms ease;
}

body.is-bonus-mode .machine::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 0%, rgba(2, 12, 7, 0.55) 65%, rgba(2, 12, 7, 0.85) 100%);
  pointer-events: none;
  z-index: 4;
  animation: bonusBackdropFade 600ms ease forwards;
}

@keyframes bonusBackdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Pendant la transition d'entrée, on laisse la grille respirer (zoom doux). */
body.is-bonus-transition .slot-frame,
body.is-bonus-mode .slot-frame {
  box-shadow:
    0 0 0 4px rgba(255, 217, 99, 0.45),
    0 0 60px rgba(255, 217, 99, 0.55),
    0 0 120px rgba(255, 200, 60, 0.35);
  transition: box-shadow 700ms ease;
}

body.is-bonus-transition .slot-frame {
  animation: bonusFrameZoom 1100ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bonusFrameZoom {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}

/* ---- Overlay plein écran : BONUS ACTIVÉ ---- */
.bonus-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 80;
  transition: opacity 350ms ease;
}

.bonus-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.bonus-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center,
              rgba(255, 240, 180, 0.85) 0%,
              rgba(255, 200, 60, 0.45) 25%,
              rgba(255, 200, 60, 0) 60%);
  opacity: 0;
}

.bonus-overlay[aria-hidden="false"] .bonus-flash {
  animation: bonusFlash 1400ms ease-out forwards;
}

@keyframes bonusFlash {
  0%   { opacity: 0; transform: scale(0.4); }
  20%  { opacity: 1; transform: scale(1.1); }
  60%  { opacity: 0.55; transform: scale(1.4); }
  100% { opacity: 0; transform: scale(2.0); }
}

.bonus-headline {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
  text-align: center;
  transform: scale(0.5);
  opacity: 0;
}

.bonus-overlay[aria-hidden="false"] .bonus-headline {
  animation: bonusHeadline 2200ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes bonusHeadline {
  0%   { transform: scale(0.4) rotate(-3deg); opacity: 0; }
  35%  { transform: scale(1.18) rotate(0deg); opacity: 1; }
  55%  { transform: scale(1.0); opacity: 1; }
  85%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1.0); opacity: 0; }
}

.bonus-title {
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-size: clamp(48px, 9vw, 130px);
  letter-spacing: 0.12em;
  color: #ffffff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
    0 6px 18px rgba(0, 0, 0, 0.55);
  -webkit-text-stroke: 1.5px #000;
}

.bonus-subtitle {
  /* Match the always-on WIN style (same font + punchy shadow). */
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(28px, 4.2vw, 64px);
  color: #ffffff;
  letter-spacing: 0.06em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.72),
    0 8px 18px rgba(0, 0, 0, 0.5);
  -webkit-text-stroke: 1.6px rgba(0, 0, 0, 0.75);
}

.bonus-subtitle #bonusInitialSpins {
  display: inline-block;
  color: #ffffff;
  padding: 0 0.15em;
  animation: bonusSpinsPulse 800ms ease-in-out 600ms 2;
}

@keyframes bonusSpinsPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---- Particules dorées ---- */
.bonus-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bonus-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6c2 0%, #ffce4a 55%, rgba(255, 200, 60, 0) 100%);
  box-shadow: 0 0 10px rgba(255, 217, 99, 0.8);
  opacity: 0;
  will-change: transform, opacity;
}

.bonus-particle.is-anim {
  animation: bonusParticle 1800ms ease-out forwards;
}

@keyframes bonusParticle {
  0%   { transform: translate(0, 0) scale(0.4); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -240px)) scale(1.1); opacity: 0; }
}

/* ---- HUD bonus (au-dessus du cadre des rouleaux) ---- */
.bonus-hud {
  position: relative;
  display: flex;
  flex-shrink: 0;
  gap: 14px;
  margin: 0;
  padding: 0;
  max-height: 0;
  border: 0 solid #ffd166;
  border-radius: 14px;
  background: linear-gradient(180deg, #1a3422 0%, #0a1d12 100%);
  box-shadow:
    0 0 22px rgba(255, 217, 99, 0.55),
    inset 0 0 12px rgba(255, 217, 99, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.55);
  font-family: "Cinzel", serif;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff5d0;
  z-index: 16;
  align-self: center;
  width: min(100%, 420px);
  max-width: 100%;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  visibility: hidden;
  transform: scale(0.96);
  transition:
    opacity 360ms ease,
    transform 360ms ease,
    max-height 360ms ease,
    padding 360ms ease,
    margin 360ms ease,
    border-width 80ms ease,
    box-shadow 360ms ease;
}

.bonus-hud[aria-hidden="false"] {
  margin-bottom: 8px;
  padding: 10px 18px;
  max-height: 160px;
  border-width: 2px;
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.bonus-hud-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 70px;
}

.bonus-hud-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255, 245, 208, 0.7);
}

.bonus-hud-value {
  font-size: clamp(16px, 2vw, 22px);
  color: #ffe599;
  text-shadow: 0 0 8px rgba(255, 217, 99, 0.45);
  transition: transform 200ms ease;
}

.bonus-hud-value.is-pulse {
  animation: bonusHudPulse 360ms ease-out;
}

@keyframes bonusHudPulse {
  0%   { transform: scale(1); color: #ffe599; }
  35%  { transform: scale(1.4); color: #fff7c2; }
  100% { transform: scale(1); color: #ffe599; }
}

.bonus-hud-multi .bonus-hud-value {
  color: #ffd166;
}

@media (max-width: 640px) {
  .bonus-hud {
    gap: 8px;
  }
  .bonus-hud[aria-hidden="false"] {
    padding: 6px 10px;
  }
  .bonus-hud-row { min-width: 50px; }
  .bonus-hud-label { font-size: 9px; }
  .bonus-hud-value { font-size: 14px; }
}

/* On portrait phones, when the bonus is running we hide the logo and the
   BUY/BET panels (they can't be interacted with anyway) so the reels area
   can use the space; the bonus HUD stays just above the reel frame. */
@media (max-width: 720px) and (orientation: portrait), (max-width: 540px) {
  body.is-bonus-mode .game-logo,
  body.is-bonus-mode .bonus-panel {
    display: none;
  }
}

/* ---- Gains flottants pendant le bonus ---- */
.float-wins {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}

.float-win {
  position: absolute;
  top: 50%;
  left: 50%;
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-size: clamp(22px, 3.6vw, 44px);
  color: #fff5d0;
  text-shadow:
    0 0 12px rgba(255, 217, 99, 0.95),
    0 0 24px rgba(255, 170, 40, 0.7),
    0 4px 0 rgba(70, 30, 5, 0.7),
    0 8px 16px rgba(0, 0, 0, 0.65);
  -webkit-text-stroke: 1.5px rgba(120, 60, 10, 0.8);
  letter-spacing: 0.04em;
  white-space: nowrap;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  pointer-events: none;
  animation: floatWinFly 1700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes floatWinFly {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  20%  { transform: translate(-50%, -60%) scale(1.15); opacity: 1; }
  60%  { transform: translate(-50%, -110%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(0.85); opacity: 0; }
}

/* ---- Bannière retrigger « EXTRA SPINS » ---- */
.extra-spins-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 42px;
  background: linear-gradient(180deg, rgba(40, 20, 5, 0.92) 0%, rgba(20, 10, 0, 0.92) 100%);
  border: 3px solid #ffd166;
  border-radius: 22px;
  box-shadow:
    0 0 60px rgba(255, 217, 99, 0.85),
    0 0 120px rgba(255, 170, 40, 0.55),
    inset 0 0 22px rgba(255, 217, 99, 0.25);
  pointer-events: none;
  opacity: 0;
  z-index: 12;
}

.extra-spins-banner.is-visible {
  animation: extraSpinsPop 1800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes extraSpinsPop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  85%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; }
}

.extra-title {
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-size: clamp(28px, 4.4vw, 56px);
  letter-spacing: 0.14em;
  color: #ffffff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
    0 4px 12px rgba(0, 0, 0, 0.55);
  -webkit-text-stroke: 1.2px #000;
}

.extra-amount {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(36px, 6vw, 80px);
  color: #ffffff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
    0 5px 14px rgba(0, 0, 0, 0.6);
  -webkit-text-stroke: 1.5px #000;
}

/* ---- Overlay de fin de bonus (totalisation) ---- */
.bonus-end-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 12, 7, 0.78);
  pointer-events: none;
  opacity: 0;
  z-index: 90;
  transition: opacity 380ms ease;
}

.bonus-end-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.bonus-end-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  padding: clamp(22px, 4vw, 44px) clamp(28px, 6vw, 70px);
  background: linear-gradient(180deg, #1a3422 0%, #0a1d12 100%);
  border: 3px solid #ffd166;
  border-radius: 26px;
  box-shadow:
    0 0 80px rgba(255, 217, 99, 0.5),
    0 0 160px rgba(255, 170, 40, 0.35),
    inset 0 0 30px rgba(255, 217, 99, 0.18);
  text-align: center;
  transform: scale(0.6);
  opacity: 0;
}

.bonus-end-overlay[aria-hidden="false"] .bonus-end-card {
  animation: bonusEndCard 580ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes bonusEndCard {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.bonus-end-title {
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-size: clamp(28px, 4.6vw, 60px);
  letter-spacing: 0.12em;
  color: #ffe599;
  text-shadow:
    0 0 14px rgba(255, 217, 99, 0.85),
    0 4px 0 rgba(70, 30, 5, 0.7);
  -webkit-text-stroke: 1.5px rgba(120, 60, 10, 0.8);
}

.bonus-end-label {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 18px);
  color: rgba(255, 245, 208, 0.78);
  letter-spacing: 0.22em;
  margin-top: 0.4em;
}

.bonus-end-amount {
  font-family: "Luckiest Guy", "Cinzel", serif;
  font-size: clamp(46px, 8vw, 110px);
  color: #fff7c2;
  text-shadow:
    0 0 22px rgba(255, 217, 99, 0.95),
    0 0 44px rgba(255, 170, 40, 0.7),
    0 6px 0 rgba(70, 30, 5, 0.7),
    0 14px 30px rgba(0, 0, 0, 0.65);
  -webkit-text-stroke: 2px rgba(120, 60, 10, 0.8);
  margin: 0.1em 0;
}

.bonus-end-stats {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(13px, 1.4vw, 16px);
  letter-spacing: 0.12em;
  color: rgba(255, 245, 208, 0.7);
}

/* Verrouille les contrôles principaux pendant le bonus.
   Le HUD et la grille restent vivants ; tout le reste devient inerte. */
body.is-bonus-locked #spinButton,
body.is-bonus-locked #autoButton,
body.is-bonus-locked #betMinusButton,
body.is-bonus-locked #betPlusButton,
body.is-bonus-locked #buyBonusButton,
body.is-bonus-locked #boostToggle {
  pointer-events: none;
  opacity: 0.5;
  filter: saturate(0.6);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
