:root {
  --bg: #050b08;
  --felt: #0b4a30;
  --felt-2: #08392a;
  --line: rgba(240, 220, 170, 0.55);
  --gold: #e6c068;
  --gold-2: #b8862f;
  --text: #f4eee0;
  --muted: #a9b5ad;
  --red: #b3121f;
  --black: #16171a;
  --green: #0d7a3e;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  font-family: Outfit, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 30% 0%, #12382a 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 100%, #2a1608 0%, transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.4; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Header */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(5, 11, 8, 0.6);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 1.25rem; letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.brand b { color: var(--gold); font-weight: 800; }
.logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: repeating-conic-gradient(var(--red) 0 10deg, var(--black) 10deg 20deg);
  box-shadow: inset 0 0 0 6px #3a1a08, 0 0 0 2px var(--gold);
}
.wallet { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); }
.wallet div { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.wallet small { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; }
.wallet strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
#balance { color: var(--gold); }

.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 9px 14px;
  transition: background 0.15s, border-color 0.15s;
}
.ghost:not(:disabled):hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(230, 192, 104, 0.5); }
#refill, #mute { width: 38px; height: 38px; padding: 0; font-size: 1.1rem; }
#refill.pulse { animation: pulse 1.2s infinite; border-color: var(--gold); }

/* Layout */
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 16px clamp(16px, 3vw, 32px);
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
@media (min-width: 1150px) {
  main { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: center; }
  .stage { height: min(78vh, 760px) !important; }
}

.stage {
  position: relative;
  height: clamp(320px, 52vh, 560px);
  border-radius: 24px;
  background: radial-gradient(closest-side, rgba(230, 192, 104, 0.08), transparent);
  overflow: hidden;
}
#wheel { width: 100%; height: 100%; display: block; touch-action: none; }
.stage.no-webgl::after {
  content: 'Roue 3D indisponible (WebGL désactivé)';
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
}
.hint {
  user-select: none;
  position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 0.75rem; color: var(--muted); opacity: 0.6; pointer-events: none;
}
#zoom { pointer-events: auto; touch-action: manipulation; -webkit-tap-highlight-color: transparent; padding: 8px 0; }
.result {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px 10px 10px;
  border-radius: 999px;
  background: rgba(8, 14, 11, 0.8);
  border: 1px solid rgba(230, 192, 104, 0.35);
  backdrop-filter: blur(10px);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  white-space: nowrap;
}
.result[hidden] { display: none; }
.ball-num {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 800;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.result.red .ball-num { background: var(--red); }
.result.black .ball-num { background: var(--black); }
.result.green .ball-num { background: var(--green); }
.r-name { font-weight: 600; }
.r-net { font-size: 0.9rem; color: var(--muted); }
.r-net.up { color: #6ee7a0; }
.r-net.down { color: #f19a9a; }

/* Panel */
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.history-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.history { display: flex; gap: 5px; flex-wrap: wrap; min-height: 30px; align-items: center; }
.history em { color: var(--muted); font-size: 0.85rem; }
.h {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.h:first-child { outline: 2px solid var(--gold); outline-offset: 1px; }
.h.red { background: var(--red); }
.h.black { background: var(--black); border: 1px solid #333; }
.h.green { background: var(--green); }
.stats { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.stats small { color: var(--muted); font-size: 0.75rem; }
.bar3 { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; }
.bar3 i.red { background: var(--red); }
.bar3 i.black { background: #555; }
.bar3 i.green { background: var(--green); }

/* Table */
.table-scroll { overflow-x: auto; padding: 4px 4px 8px; margin: -4px; }
.table {
  --row: clamp(44px, 5.4vw, 64px);
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr repeat(12, 1fr) 1.2fr;
  grid-template-rows: repeat(3, var(--row)) 46px 46px;
  min-width: 620px;
  padding: 14px;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 30%, var(--felt), var(--felt-2));
  box-shadow: inset 0 0 0 2px rgba(230, 192, 104, 0.35), inset 0 0 60px rgba(0, 0, 0, 0.45), 0 20px 50px rgba(0, 0, 0, 0.4);
  user-select: none;
}
body.spinning .table { pointer-events: none; }
.cell {
  position: relative;
  border: 0;
  margin: 0;
  background: transparent;
  box-shadow: inset 0 0 0 0.5px var(--line);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.12s, filter 0.12s;
}
.cell sup { font-size: 0.6em; }
.cell.num span {
  width: 74%; aspect-ratio: 1; max-height: 80%;
  display: grid; place-items: center; border-radius: 10px;
  font-size: 1.05rem; font-weight: 700;
}
.cell.red span { background: linear-gradient(160deg, #d0202f, var(--red)); }
.cell.black span { background: linear-gradient(160deg, #2a2c31, var(--black)); }
.cell.green { border-radius: 40px 0 0 40px; }
.cell.green span { background: linear-gradient(160deg, #11994e, var(--green)); height: 50%; aspect-ratio: auto; }
.cell:hover, .cell.hl { background: rgba(255, 230, 160, 0.14); }
.cell.win { background: rgba(255, 215, 100, 0.3); }
.cell.win span { animation: pulse 1s infinite; box-shadow: 0 0 0 3px var(--gold), 0 0 24px var(--gold); }
.cell.won, .hot.won { filter: drop-shadow(0 0 10px var(--gold)); }
.cell.out { font-size: 0.85rem; letter-spacing: 0.03em; }
.dia { display: block; width: 28px; height: 18px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.dia.red { background: var(--red); }
.dia.black { background: #000; }

.overlay {
  grid-column: 2 / 14; grid-row: 1 / 4;
  position: relative; pointer-events: none; z-index: 2;
}
.hot {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 0; padding: 0;
  background: transparent;
  border-radius: 7px;
  pointer-events: auto;
}
.hot.v { width: 14px; height: 30px; }
.hot.h { width: 30px; height: 14px; }
.hot.x { width: 16px; height: 16px; border-radius: 50%; }
.hot:hover { background: rgba(255, 220, 130, 0.55); }

/* Chips */
.chip, .chip-btn {
  --c: #f1f1f1; --t: #222;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  color: var(--t);
  background:
    radial-gradient(circle, var(--c) 52%, transparent 53%),
    repeating-conic-gradient(var(--c) 0 22.5deg, #fff 22.5deg 45deg);
  box-shadow: 0 0 0 2px var(--c), 0 3px 8px rgba(0, 0, 0, 0.5);
  font-variant-numeric: tabular-nums;
}
[data-tier="1"] { --c: #c8202e; --t: #fff; }
[data-tier="2"] { --c: #138a4a; --t: #fff; }
[data-tier="3"] { --c: #1b1b1f; --t: #fff; }
[data-tier="4"] { --c: #6a2bbf; --t: #fff; }
.chip {
  font-style: normal;
  position: absolute; left: 50%; top: 50%;
  width: 30px; height: 30px; margin: -15px 0 0 -15px;
  font-size: 0.68rem;
  pointer-events: none;
  z-index: 3;
  animation: drop 0.22s ease-out;
}
.hot .chip { width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 0.6rem; }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.chips { display: flex; gap: 10px; }
.chip-btn { width: 48px; height: 48px; border: 0; font-size: 0.9rem; transition: transform 0.15s; }
.chip-btn:not(:disabled):hover { transform: translateY(-3px); }
.chip-btn.all-in {
  --c: #e6c068; --t: #1e1405;
  width: auto; padding: 0 16px; border-radius: 999px;
  font-size: 0.78rem; letter-spacing: 0.06em;
  background: linear-gradient(180deg, #f6d98c, var(--gold) 50%, var(--gold-2));
}
.chip-btn.on { transform: translateY(-5px) scale(1.08); box-shadow: 0 0 0 2px var(--c), 0 0 0 5px var(--gold), 0 8px 18px rgba(0, 0, 0, 0.5); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.spin {
  border: 0; border-radius: 12px;
  padding: 11px 28px;
  font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: #1e1405;
  background: linear-gradient(180deg, #f6d98c, var(--gold) 50%, var(--gold-2));
  box-shadow: 0 6px 20px rgba(230, 192, 104, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.1s, box-shadow 0.15s;
  min-width: 150px;
}
.spin:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(230, 192, 104, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.spin:not(:disabled):active { transform: translateY(1px); }
body.spinning .spin:disabled { opacity: 0.85; }
.help { margin: 0; color: var(--muted); font-size: 0.78rem; }

footer { text-align: center; color: var(--muted); font-size: 0.75rem; padding: 12px 16px 18px; opacity: 0.7; }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 30px);
  padding: 12px 20px; border-radius: 12px;
  background: #1b2420; border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  font-weight: 600;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: linear-gradient(180deg, #f6d98c, var(--gold)); color: #1e1405; border: 0; }

/* Win celebration */
.win-fx {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(circle, rgba(60, 30, 0, 0.6), rgba(0, 0, 0, 0.88));
  perspective: 900px;
  opacity: 0; transition: opacity 0.15s;
  cursor: pointer; overflow: hidden;
}
.win-fx.show { opacity: 1; animation: strobe 0.4s steps(1) 6; } /* 2.5 Hz max, 2.4 s */
.win-fx.tier-0.show { animation-iteration-count: 3; }
.win-fx[hidden] { display: none; }
.win-fx canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.win-fx::after { /* pulsing gold vignette */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 120px 30px rgba(255, 190, 60, 0.6);
  animation: vignette 0.8s ease-in-out infinite alternate;
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 3; }
.win-fx.show .flash { animation: flash 0.5s ease-out; }
.rays {
  position: absolute; left: 50%; top: 50%;
  width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255, 210, 110, 0.35) 0 7deg, rgba(255, 60, 40, 0.1) 7deg 10deg, transparent 10deg 18deg);
  mask: radial-gradient(circle, #000 0, transparent 50%);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 50%);
  animation: spinrays 5s linear infinite, hue 3s linear infinite;
}
.speed { /* radial speed lines spinning the other way */
  position: absolute; left: 50%; top: 50%;
  width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.5) 0 0.4deg, transparent 0.4deg 6deg);
  mask: radial-gradient(circle, transparent 12%, #000 30%, transparent 60%);
  -webkit-mask: radial-gradient(circle, transparent 12%, #000 30%, transparent 60%);
  animation: spinrays 1.5s linear infinite reverse;
  opacity: 0.55;
}
.tier-2 .rays, .tier-3 .rays { animation-duration: 2.5s; }
.rings i {
  position: absolute; left: 50%; top: 50%;
  width: 40vmin; height: 40vmin; margin: -20vmin 0 0 -20vmin;
  border-radius: 50%; border: 10px solid #ffd76a;
  box-shadow: 0 0 40px #ffb020, inset 0 0 40px #ffb020;
  opacity: 0;
}
.win-fx.show .rings i { animation: ring 1.1s ease-out infinite; }
.win-fx.show .rings i:nth-child(2) { animation-delay: 0.35s; }
.win-fx.show .rings i:nth-child(3) { animation-delay: 0.7s; }
.win-box { position: relative; text-align: center; padding: 0 16px; z-index: 4; }
.win-fx.show .win-box { animation: slam 0.6s cubic-bezier(0.2, 1.8, 0.4, 1) both, tilt 1.6s ease-in-out 0.6s infinite alternate; transform-style: preserve-3d; }
.win-title {
  font-size: clamp(3.6rem, 16vw, 12rem); font-weight: 800; line-height: 0.95;
  letter-spacing: 0.01em; white-space: nowrap;
}
.win-title span {
  display: inline-block;
  background: linear-gradient(180deg, #fffbe6 0%, #ffe08a 30%, #f0a923 55%, #8a4a00 100%);
  background-size: 100% 200%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #5a2a00) drop-shadow(0 0 40px rgba(255, 170, 40, 0.9));
  animation: letter 0.5s cubic-bezier(0.2, 2, 0.4, 1) calc(var(--i) * 0.06s) both, bounce 0.5s ease-in-out calc(0.6s + var(--i) * 0.08s) infinite alternate, shimmer 0.8s linear infinite alternate, glitch 0.45s steps(2) infinite;
}
.tier-3 .win-title span { background-image: linear-gradient(180deg, #fff 0%, #ffe08a 25%, #ff3b2f 60%, #6a0010 100%); }
.win-amount {
  margin-top: 12px;
  font-size: clamp(2.8rem, 10vw, 7rem); font-weight: 800;
  font-variant-numeric: tabular-nums; color: #fff;
  text-shadow: 0 0 30px rgba(255, 210, 110, 1), 0 0 80px rgba(255, 150, 30, 0.8), 0 5px 0 #6b4a10;
}
.win-amount.hit { animation: hit 0.6s cubic-bezier(0.2, 2, 0.4, 1); }
.win-sub { margin-top: 8px; font-size: clamp(1.1rem, 3vw, 1.8rem); font-weight: 800; color: #ffd76a; letter-spacing: 0.2em; text-shadow: 0 0 20px #ff9a1f; }
.win-skip { margin-top: 28px; font-size: 0.8rem; color: var(--muted); opacity: 0.7; }
#balance { display: inline-block; }
body.shake main, body.shake .bar { animation: shake 0.45s linear 2; }
body.shake-hard main, body.shake-hard .bar, body.shake-hard .win-box { animation: shake-hard 0.35s linear 4; }
@keyframes spinrays { to { transform: rotate(360deg); } }
@keyframes slam { from { transform: scale(6) rotate(-8deg); opacity: 0; filter: blur(12px); } 60% { opacity: 1; filter: none; } }
@keyframes tilt { from { transform: rotateY(-22deg) rotateX(10deg) scale(1); } to { transform: rotateY(22deg) rotateX(-6deg) scale(1.08); } }
@keyframes hue { to { filter: hue-rotate(360deg); } }
@keyframes glitch { /* RGB split jitter */
  0% { filter: drop-shadow(-5px 0 0 rgba(255, 0, 60, 0.8)) drop-shadow(5px 0 0 rgba(0, 220, 255, 0.8)) drop-shadow(0 6px 0 #5a2a00); }
  50% { filter: drop-shadow(6px 2px 0 rgba(255, 0, 60, 0.8)) drop-shadow(-6px -2px 0 rgba(0, 220, 255, 0.8)) drop-shadow(0 6px 0 #5a2a00); }
}
.fx3d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.win-fx.has3d .win-title { visibility: hidden; height: 0; }
.win-fx.has3d .win-box { margin-top: 30vh; }
/* The whole page rocks in 3D while the party lasts */
body.partying { overflow-x: hidden; }
body.partying .stage { animation: rock 1.1s ease-in-out infinite alternate; }
body.partying .panel { animation: rock 1.1s ease-in-out -0.55s infinite alternate-reverse; }
@keyframes rock { from { transform: perspective(1400px) rotateY(-9deg) rotateX(6deg) scale(0.97); } to { transform: perspective(1400px) rotateY(9deg) rotateX(-4deg) scale(1.03); } }
/* Hollywood montage */
.cinema { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
.cinema.on { pointer-events: auto; cursor: pointer; }
.cinema .bar-top, .cinema .bar-bottom {
  position: absolute; left: 0; right: 0; height: 13vh; background: #000; z-index: 3;
  transition: transform 0.6s cubic-bezier(0.7, 0, 0.2, 1);
}
.cinema .bar-top { top: 0; transform: translateY(-100%); }
.cinema .bar-bottom { bottom: 0; transform: translateY(100%); display: flex; align-items: center; justify-content: flex-end; padding: 0 24px; }
.cinema.on .bar-top, .cinema.on .bar-bottom { transform: none; }
.bar-bottom span { color: #777; font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase; }
.cinema .grain {
  position: absolute; inset: -50%; z-index: 2; opacity: 0; transition: opacity 0.6s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  animation: grain 0.5s steps(4) infinite;
}
.cinema.on .grain { opacity: 0.35; }
.cinema.on::after { /* heavy vignette + teal/orange grade */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.85)), linear-gradient(180deg, rgba(0, 90, 110, 0.25), rgba(255, 120, 20, 0.18));
}
body.in-cinema .stage { position: fixed; inset: 0; z-index: 110; height: 100dvh !important; border-radius: 0; background: radial-gradient(circle, #10261c, #000); }
body.in-cinema .bar, body.in-cinema .panel, body.in-cinema footer, body.in-cinema .hint, body.in-cinema #result { opacity: 0; transition: opacity 0.5s; }
.cinema .impact { position: absolute; inset: 0; z-index: 2; background: #fff; opacity: 0; pointer-events: none; }
body.hit .cinema .impact { animation: impact 0.16s ease-out; }
.cinema .streaks { /* speed streaks punching out of the centre on each cut */
  position: absolute; inset: -20%; z-index: 2; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.7) 0 0.6deg, transparent 0.6deg 7deg);
  mask: radial-gradient(circle, transparent 18%, #000 40%);
  -webkit-mask: radial-gradient(circle, transparent 18%, #000 40%);
}
body.hit .cinema .streaks { animation: streaks 0.45s ease-out; }
body.hit.in-cinema .stage canvas { animation: punch 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
body.hit-inv.in-cinema .stage canvas { animation: punch 0.45s cubic-bezier(0.2, 1.6, 0.4, 1), invert 0.12s steps(1); }
body.hit .cinema .bar-top, body.hit .cinema .bar-bottom { animation: barslam 0.3s ease-out; }
/* Glass shatter transition */
.shatter { position: fixed; inset: 0; z-index: 130; pointer-events: none; perspective: 900px; }
.shatter i {
  position: absolute; inset: 0; background-size: 100vw 100vh; background-position: 0 0;
  filter: sepia(1) contrast(1.2) brightness(0.9);
  animation: shard 1.3s cubic-bezier(0.3, 0, 0.6, 1) both;
}
@keyframes shard {
  0% { transform: none; filter: sepia(1) contrast(1.2) brightness(1.6); }
  8% { transform: scale(1.02); }
  100% { transform: var(--to); opacity: 0; }
}
/* JoJo layer */
.sfx-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.sfx {
  position: absolute; transform: translate(-50%, -50%) rotate(var(--rot));
  font-family: 'Hiragino Sans', 'Yu Gothic', 'Noto Sans JP', Outfit, sans-serif; font-weight: 900;
  font-size: 5rem; line-height: 1; white-space: nowrap; color: var(--c);
  -webkit-text-stroke: 4px #000; paint-order: stroke fill;
  text-shadow: 6px 6px 0 #000, 0 0 30px var(--c);
  font-style: italic; letter-spacing: -0.02em;
}
.sfx.slam { animation: sfx-slam 0.9s cubic-bezier(0.2, 2.2, 0.4, 1) both; }
.sfx.small { font-size: 2.6rem; }
.sfx.huge { font-size: clamp(4rem, 14vw, 11rem); animation-duration: 1.4s; }
.sfx.menace { animation: menace 2s ease-in-out both; -webkit-text-stroke: 3px #1a0024; text-shadow: 0 0 18px #b33cff, 4px 4px 0 #1a0024; font-style: normal; }
.sfx.ora { animation: ora 0.5s cubic-bezier(0.2, 2.4, 0.4, 1) both; }
@keyframes sfx-slam {
  from { transform: translate(-50%, -50%) rotate(var(--rot)) scale(4); opacity: 0; }
  15% { opacity: 1; }
  30% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1); }
  45% { transform: translate(calc(-50% + 6px), calc(-50% - 4px)) rotate(var(--rot)) scale(1.05); }
  85% { opacity: 1; }
  to { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1.15); opacity: 0; }
}
@keyframes menace {
  from { opacity: 0; transform: translate(-50%, -30%) rotate(var(--rot)) scale(0.6); }
  20%, 80% { opacity: 1; }
  50% { transform: translate(-46%, -60%) rotate(calc(var(--rot) * -1)) scale(1.1); }
  to { opacity: 0; transform: translate(-50%, -90%) rotate(var(--rot)) scale(0.9); }
}
@keyframes ora { from { transform: translate(-50%, -50%) rotate(var(--rot)) scale(3); opacity: 0; } 20% { opacity: 1; } to { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1); opacity: 0.9; } }
/* Palette swap per cut (hue changes, not brightness flashes) */
body.hit.in-cinema .stage { filter: hue-rotate(var(--hue, 0deg)) saturate(2.2) contrast(1.3); }
/* ZA WARUDO: inverting sphere expands then collapses, world stays desaturated */
.cinema .time-stop {
  position: absolute; left: 50%; top: 50%; width: 30vmax; height: 30vmax; margin: -15vmax 0 0 -15vmax;
  border-radius: 50%; z-index: 2; pointer-events: none; opacity: 0;
  backdrop-filter: invert(1) hue-rotate(180deg) saturate(2); -webkit-backdrop-filter: invert(1) hue-rotate(180deg) saturate(2);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.6), 0 0 80px 20px rgba(120, 60, 255, 0.5);
}
body.zw .cinema .time-stop { animation: zw 1.6s cubic-bezier(0.5, 0, 0.3, 1) both; }
body.zw.in-cinema .stage canvas { filter: grayscale(0.7) sepia(0.3) contrast(1.3) hue-rotate(200deg); }
@keyframes zw { 0% { transform: scale(0); opacity: 1; } 55% { transform: scale(5); opacity: 1; } 100% { transform: scale(0); opacity: 1; } }
/* Screentone + diagonal manga panel gutters */
.cinema .halftone {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.55) 30%, transparent 32%) 0 0 / 10px 10px;
  mix-blend-mode: multiply;
}
body.in-cinema .cinema .halftone { opacity: 0.35; }
body.rush .cinema .halftone { opacity: 0.7; }
.cinema .panels i {
  position: absolute; left: -10%; width: 120%; height: 14px; background: #fff; z-index: 2; opacity: 0;
  box-shadow: 0 0 0 4px #000;
}
.cinema .panels i:first-child { top: 38%; transform: rotate(-12deg); }
.cinema .panels i:last-child { top: 62%; transform: rotate(9deg); }
body.panelled .cinema .panels i { animation: gutter 0.5s steps(1) both; }
@keyframes gutter { from { opacity: 1; } to { opacity: 1; } }
/* ORA rush: shaking screen and radial speed lines */
body.rush .cinema .streaks { opacity: 1; animation: spinrays 0.6s linear infinite; }
body.rush.in-cinema .stage canvas { animation: shake-hard 0.2s linear infinite; filter: saturate(2) contrast(1.4); }
/* To Be Continued: sepia freeze frame + arrow */
body.tbc-on.in-cinema .stage canvas { filter: sepia(1) contrast(1.2) brightness(0.9); }
.cinema .tbc {
  position: absolute; left: 4vw; bottom: 16vh; z-index: 4; pointer-events: none;
  transform: translateX(-120%); transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.cinema .tbc span {
  display: inline-block; padding: 14px 70px 14px 26px;
  font-size: clamp(1.2rem, 3vw, 2.2rem); font-weight: 800; font-style: italic; letter-spacing: 0.08em;
  color: #3b2a12; background: #e9d9a8;
  clip-path: polygon(0 0, calc(100% - 46px) 0, 100% 50%, calc(100% - 46px) 100%, 0 100%);
  border-left: 8px solid #3b2a12;
}
body.tbc-on .cinema .tbc { transform: none; }
@keyframes impact { from { opacity: 0.9; } to { opacity: 0; } }
@keyframes streaks { from { opacity: 1; transform: scale(0.6) rotate(0deg); } to { opacity: 0; transform: scale(1.6) rotate(25deg); } }
@keyframes punch {
  from { transform: scale(1.35) rotate(-2deg); filter: drop-shadow(-12px 0 0 rgba(255, 0, 60, 0.85)) drop-shadow(12px 0 0 rgba(0, 220, 255, 0.85)) blur(2px); }
  to { transform: none; filter: none; }
}
@keyframes invert { from { filter: invert(1) hue-rotate(180deg) contrast(1.6); } }
@keyframes barslam { 40% { height: 19vh; } }
@keyframes grain { 25% { transform: translate(-5%, 3%); } 50% { transform: translate(4%, -6%); } 75% { transform: translate(-3%, -2%); } }
/* After the overlay: page keeps glowing for a few seconds */
body.afterglow #balance { animation: rich 0.5s ease-in-out 6 alternate; }
body.afterglow .table { animation: tableglow 0.6s ease-in-out 5 alternate; }
body.afterglow .cell.num span { animation: wave 0.5s ease-in-out calc(var(--d, 0) * 1s) 4 alternate; }
@keyframes rich { to { transform: scale(1.5); color: #fff; text-shadow: 0 0 20px #ffb020, 0 0 50px #ff7a00; } }
@keyframes tableglow { to { box-shadow: inset 0 0 0 4px #ffd76a, 0 0 60px 10px rgba(255, 170, 40, 0.6), 0 20px 50px rgba(0, 0, 0, 0.4); } }
@keyframes wave { to { transform: translateY(-8px) scale(1.12); } }
@keyframes wobble { from { transform: rotate(-2deg) scale(1); } to { transform: rotate(2deg) scale(1.04); } }
@keyframes letter { from { transform: translateY(-120vh) scale(2) rotate(-30deg); } }
@keyframes bounce { to { transform: translateY(-14px) scale(1.06); } }
@keyframes shimmer { from { background-position: 0 0; } to { background-position: 0 100%; } }
@keyframes hit { 40% { transform: scale(1.6); } }
@keyframes flash { from { opacity: 0.95; } to { opacity: 0; } }
@keyframes ring { from { transform: scale(0.2); opacity: 1; } to { transform: scale(5); opacity: 0; } }
@keyframes vignette { to { box-shadow: inset 0 0 200px 60px rgba(255, 120, 30, 0.75); } }
@keyframes strobe { 50% { background: radial-gradient(circle, rgba(140, 60, 0, 0.8), rgba(60, 0, 10, 0.92)); } }
@keyframes shake {
  20% { transform: translate(-10px, 5px); } 40% { transform: translate(9px, -7px); }
  60% { transform: translate(-7px, -4px); } 80% { transform: translate(6px, 7px); }
}
@keyframes shake-hard {
  10% { transform: translate(-22px, 10px) rotate(-1deg); } 30% { transform: translate(20px, -14px) rotate(1deg); }
  50% { transform: translate(-16px, -10px); } 70% { transform: translate(18px, 12px) rotate(-1deg); } 90% { transform: translate(-8px, 6px); }
}
@keyframes pulse { 50% { filter: brightness(1.35); } }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }
@keyframes drop { from { transform: translateY(-10px) scale(1.3); opacity: 0; } }

@media (max-width: 640px) {
  .brand { font-size: 1.05rem; }
  .wallet strong { font-size: 1rem; }
  .chip-btn:not(.all-in) { width: 42px; height: 42px; font-size: 0.8rem; }
  .controls, .actions { width: 100%; }
  .actions .spin { flex: 1; }
  .hint { font-size: 0.68rem; bottom: 4px; }
}
/* Portrait phone: vertical framing for the montage and the party */
@media (orientation: portrait) and (max-width: 700px) {
  .cinema .bar-top, .cinema .bar-bottom { height: 5vh; }
  body.hit .cinema .bar-top, body.hit .cinema .bar-bottom { animation-name: barslam-p; }
  .sfx { font-size: 3.4rem; }
  .sfx.small { font-size: 1.9rem; }
  .sfx.huge { font-size: clamp(3rem, 21vw, 6rem); }
  .cinema .tbc { bottom: 9vh; }
  .win-fx.has3d .win-box { margin-top: 22vh; }
  .win-amount { font-size: clamp(2.6rem, 15vw, 4.5rem); }
}
@keyframes barslam-p { 40% { height: 11vh; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
