:root {
  --w: 430px;
  --design-h: 468px;
  --s: 1;
  --table-h: 58vh;          /* set in px by applyScale() */
  --ink: #070a1c;
  --navy: #0b1030;
  --gold: #f2b63a;
  --gold-hi: #ffe7a1;
  --gold-deep: #b8791c;
  --dragon: #3ea2ff;
  --dragon-hi: #9fd6ff;
  --tiger: #ff7a1f;
  --tiger-hi: #ffc07a;
  --tie: #27d07f;
  --tie-hi: #9cf5c6;
  --font-title: "Cinzel", "Times New Roman", serif;
  --font-num: "Rubik", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: transparent;
  color: #fff;
  font-family: var(--font-num);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
img { -webkit-user-drag: none; }
.hidden { display: none !important; }

.phone-shell {
  position: fixed;
  left: 50%;
  top: 0;
  width: min(100vw, var(--w));
  height: 100vh;
  height: 100dvh;
  transform: translateX(-50%);
  overflow: hidden;
  background: transparent;
}
.phone-shell.closed .table-panel,
.phone-shell.closed .toast-root { display: none; }

/* transparent: the live stream sits behind this area */
.live-stage {
  position: absolute;
  inset: 0 0 var(--table-h) 0;
  pointer-events: none;
}

/* ── TABLE ─────────────────────────────────────────────────── */
/*
 * No hard top edge: the arena art fades in from transparent, so the table
 * melts into the stream. Below the arena the panel is deep navy → plum.
 */
.table-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--table-h) + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg,
      rgba(8, 11, 34, 0) 0%,
      rgba(8, 11, 34, 0) 22%,
      rgba(8, 11, 34, 0.92) 40%,
      #0a0c26 52%,
      #160b24 100%);
  z-index: 5;
  overflow: hidden;
}
.table-inner {
  position: absolute;
  top: max(0px, (var(--table-h) - var(--design-h) * var(--s)) / 2);
  left: 50%;
  width: 390px;
  height: var(--design-h);
  transform: translateX(-50%) scale(var(--s));
  transform-origin: top center;
}

.arena {
  position: absolute;
  top: 0;
  left: -45px;
  width: 480px;
  height: 262px;
  background: url("assets/art/arena.webp") center top / 100% 100% no-repeat;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%),
                      linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%),
              linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-composite: intersect;
  pointer-events: none;
}

/* ── HEROES (idle) ─────────────────────────────────────────── */
.hero {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  will-change: transform;
  transition: filter 400ms ease, opacity 400ms ease;
}
.hero-dragon {
  left: -46px;            /* head + front claw (right edge of the art) must end before the Dragon card at x=108; the tail slides off-screen instead */
  top: 60px;
  width: 156px;           /* 148 tall, same as the tiger: top y=60, bottom y≈208 */
  transform-origin: 40% 80%;
  filter: drop-shadow(0 0 10px rgba(62, 162, 255, 0.55));
  animation: dragon-idle 4.2s ease-in-out infinite;
}
.hero-tiger {
  right: -10px;
  top: 60px;
  height: 148px;          /* bottom at y≈208, level with the dragon */
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 10px rgba(255, 122, 31, 0.5));
  animation: tiger-idle 3.4s ease-in-out infinite;
}
.hero.lose { filter: grayscale(0.85) brightness(0.55); }
.hero.win.hero-dragon { animation: dragon-idle 4.2s ease-in-out infinite, hero-pulse-d 0.9s ease-in-out infinite; }
.hero.win.hero-tiger  { animation: tiger-idle 3.4s ease-in-out infinite, hero-pulse-t 0.9s ease-in-out infinite; }

.fx-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 390px;
  height: var(--design-h);
  pointer-events: none;
  z-index: 2;
}
.fx-canvas.top { z-index: 9; }

/* ── TOP BAR ───────────────────────────────────────────────── */
.table-topbar {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}
.topbar-side { display: flex; gap: 6px; }
.logo {
  position: absolute;
  left: 50%;
  top: -7px;
  width: 168px;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}
.round-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 32%, #3a2a5e, #1b1236 62%, #0e0a20) padding-box;
  border: 1.5px solid rgba(242, 182, 58, 0.75);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 231, 161, 0.35);
  transition: transform 120ms ease;
}
.round-btn:active { transform: scale(0.9); }
.round-btn svg { width: 15px; height: 15px; fill: var(--gold-hi); }
.round-btn .ln { fill: none; stroke: var(--gold-hi); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn svg { width: 17px; height: 17px; }
.sound-btn .ln { stroke-width: 2; }
.sound-btn .snd-slash { display: none; }
.sound-btn.muted { border-color: rgba(160, 160, 175, 0.6); }
.sound-btn.muted svg { fill: #9a9aab; }
.sound-btn.muted .ln { stroke: #9a9aab; }
.sound-btn.muted .snd-waves { display: none; }
.sound-btn.muted .snd-slash { display: inline; }

/* ── DUEL: cards + timer / VS ──────────────────────────────── */
.duel { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.card-slot {
  position: absolute;
  top: 64px;
  width: 58px;
  height: 81px;
}
#slotDragon { left: 112px; }
#slotTiger { left: 220px; }
.card-slot::before {            /* glowing socket under the card */
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 9px;
  border: 1.5px dashed rgba(255, 231, 161, 0.35);
  background: rgba(5, 8, 25, 0.35);
}
.slot-tag {
  position: absolute;
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-title);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  background: rgba(5, 8, 25, 0.75);
}
.slot-tag.dragon { color: var(--dragon-hi); border: 1px solid rgba(62, 162, 255, 0.6); }
.slot-tag.tiger { color: var(--tiger-hi); border: 1px solid rgba(255, 122, 31, 0.6); }

.card {
  position: absolute;
  inset: 0;
  perspective: 500px;
  opacity: 0;
}
.card.dealt { opacity: 1; }
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 520ms cubic-bezier(0.3, 0.7, 0.3, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-back, .card-front {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}
.card-back { background: url("assets/art/card-back.webp") center / 100% 100% no-repeat; }
.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #fffdf6, #f3ead2);
  border: 1.5px solid #d9b45a;
  color: #1a1a2a;
  overflow: hidden;
}
.card-front.red { color: #d7263d; }
.card-front .c-rank {
  position: absolute;
  left: 4px;
  top: 2px;
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}
.card-front .c-suit-s {
  position: absolute;
  left: 5px;
  top: 20px;
  font-size: 11px;
  line-height: 1;
}
.card-front .c-suit {
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-size: 30px;
  line-height: 1;
}
.card.win .card-front { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px 4px rgba(255, 210, 90, 0.85); }
.card.win { animation: card-win 900ms ease-in-out infinite; }
.card.lose .card-front { filter: brightness(0.6) saturate(0.6); }

.center-slot {
  position: absolute;
  left: 170px;
  top: 78px;
  width: 50px;
  height: 50px;
}
.timer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #2b2050, #0d0a22 75%);
  box-shadow: 0 0 0 1.5px rgba(242, 182, 58, 0.8), 0 3px 10px rgba(0, 0, 0, 0.6);
  transition: opacity 200ms ease;
}
.timer-ring { position: absolute; inset: 2px; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 4.5; }
.ring-track { stroke: rgba(255, 255, 255, 0.08); }
.ring-fill {
  stroke: var(--gold);
  stroke-linecap: round;
  transition: stroke-dashoffset 250ms linear, stroke 200ms;
}
.timer.urgent .ring-fill { stroke: #ff4d5e; }
.timer-value {
  position: relative;
  font-size: 19px;
  font-weight: 800;
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.timer.urgent .timer-value { color: #ff8a95; animation: beat 1s ease infinite; }
.vs-small {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  transform: translate(-50%, -50%);
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(255, 200, 80, 0.6));
  transition: opacity 200ms ease;
}
.phone-shell:not([data-phase="betting"]) .timer { opacity: 0; }
.phone-shell[data-phase="revealing"] .vs-small,
.phone-shell[data-phase="result"] .vs-small { opacity: 1; animation: vs-glow 1.6s ease-in-out infinite; }

.round-pill {
  position: absolute;
  left: 50%;
  top: 166px;
  transform: translateX(-50%);
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(5, 8, 25, 0.72);
  border: 1px solid rgba(242, 182, 58, 0.45);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--gold-hi);
  white-space: nowrap;
  z-index: 4;
}

/* ── ROAD (last results) ───────────────────────────────────── */
.road {
  position: absolute;
  top: 189px;
  left: 108px;            /* same span as the two cards (x 108 – 282) */
  right: 108px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;   /* beads spread edge to edge, no empty gap */
  gap: 2px;
  padding: 0 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(5, 8, 25, 0.85), rgba(15, 10, 35, 0.85));
  border: 1px solid rgba(242, 182, 58, 0.3);
  overflow: hidden;
  z-index: 4;
}
.bead {
  flex: none;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  box-shadow: inset 0 -2px 2px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}
.bead.d { background: radial-gradient(circle at 40% 35%, #6cc0ff, #1565d8); }
.bead.t { background: radial-gradient(circle at 40% 35%, #ffb066, #e0500f); }
.bead.x { background: radial-gradient(circle at 40% 35%, #6ff0ad, #129a58); }
.road .bead:last-child { box-shadow: 0 0 0 1.5px var(--gold-hi), 0 0 6px rgba(255, 220, 120, 0.8); }
.road .bead.new { animation: pop-in 420ms cubic-bezier(0.3, 1.6, 0.5, 1); }

/* ── BET ZONES ─────────────────────────────────────────────── */
.zones {
  position: absolute;
  top: 217px;
  left: 8px;
  right: 8px;
  height: 166px;
  display: grid;
  grid-template-columns: 1fr 84px 1fr;
  gap: 5px;
  z-index: 4;
}
.zone {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: visible;
  text-align: center;
  transition: transform 120ms ease, filter 300ms ease;
}
.zone::after {                 /* win glow ring */
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 15px;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 0 2px var(--gold-hi), 0 0 22px 6px rgba(255, 205, 90, 0.75), inset 0 0 22px rgba(255, 220, 130, 0.6);
}
.zone-dragon { background: url("assets/art/zone-dragon.webp") center / 100% 100% no-repeat; }
.zone-tiger { background: url("assets/art/zone-tiger.webp") center / 100% 100% no-repeat; }
/* the tie art is landscape; keep its gold corners crisp and draw the middle in CSS */
.zone-tie {
  background:
    radial-gradient(ellipse at 50% 28%, rgba(120, 255, 190, 0.3), transparent 62%),
    linear-gradient(180deg, #13854f, #086039 60%, #04432a);
  box-shadow: inset 0 0 0 2px #04331f, inset 0 0 14px rgba(0, 0, 0, 0.45);
}
.zone-tie::before {            /* gold frame + corner ornaments, sliced from the art */
  content: "";
  position: absolute;
  inset: 0;
  border: 16px solid transparent;
  border-image: url("assets/art/zone-tie.webp") 64 / 16px stretch;
  pointer-events: none;
}
.zone:active { transform: scale(0.97); }
.zone.flash { animation: zone-flash 320ms ease; }

.zone-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 15px;
  font-family: var(--font-title);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 10px rgba(255, 255, 255, 0.25);
}
.zone-dragon .zone-title { color: #dff1ff; text-shadow: 0 2px 0 #0a2c6b, 0 0 12px rgba(80, 170, 255, 0.9); }
.zone-tiger .zone-title { color: #fff1e0; text-shadow: 0 2px 0 #6b210a, 0 0 12px rgba(255, 130, 40, 0.9); }
.zone-tie .zone-title { top: 15px; font-size: 18px; color: #eafff3; text-shadow: 0 2px 0 #0a4a2a, 0 0 12px rgba(70, 230, 150, 0.9); }
.zone-odds {
  position: absolute;
  left: 50%;
  top: 38px;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-weight: 800;
  color: var(--gold-hi);
  white-space: nowrap;
}
.zone-tie .zone-odds { top: 38px; padding: 1px 6px; font-size: 10.5px; }
.zone-pot {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  min-width: 72%;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 231, 161, 0.3);
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  z-index: 7;
}
.zone-pot b { color: var(--gold-hi); }
.zone-tie .zone-pot { bottom: 12px; min-width: 0; padding: 2px 6px; font-size: 9.5px; }
.yin {
  position: absolute;
  left: 50%;
  top: 58px;
  width: 44px;
  height: 44px;
  transform: translateX(-50%);
  border-radius: 50%;
  opacity: 0.22;
  background:
    radial-gradient(circle at 50% 25%, #04432a 0 12%, transparent 13%),
    radial-gradient(circle at 50% 75%, #c8ffe2 0 12%, transparent 13%),
    radial-gradient(circle at 50% 25%, #c8ffe2 0 25%, transparent 25.5%),
    radial-gradient(circle at 50% 75%, #04432a 0 25%, transparent 25.5%),
    linear-gradient(90deg, #c8ffe2 50%, #04432a 50%);
  box-shadow: 0 0 0 1.5px #c8ffe2;
}
.zone-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  padding: 3px 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffe9a6, #f2b63a 55%, #b8791c);
  color: #3a1d00;
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
}
.zone.win::after { opacity: 1; animation: glow-pulse 900ms ease-in-out infinite; }
.zone.win .zone-badge { opacity: 1; transform: translate(-50%, -50%) scale(1); transition: transform 380ms cubic-bezier(0.3, 1.7, 0.5, 1), opacity 200ms; }
.zone.lose { filter: brightness(0.45) saturate(0.6); }
.phone-shell:not([data-phase="betting"]) .zone { cursor: default; }
.phone-shell:not([data-phase="betting"]) .zone:active { transform: none; }

/* ── CHIPS (car-game style pills) ──────────────────────────── */
.chip-row {
  position: absolute;
  top: 391px;
  left: 10px;
  right: 10px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 4;
}
.repeat-btn {
  flex: none;
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1.5px solid rgba(242, 182, 58, 0.7);
  background: linear-gradient(180deg, #2b2050, #120c2a);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.repeat-btn svg { width: 16px; height: 16px; }
.repeat-btn .ln { fill: none; stroke: var(--gold-hi); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.repeat-btn:disabled { opacity: 0.4; }
.chip-bar {
  flex: 1;
  display: flex;
  gap: 5px;
}
.chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.95);
  background: linear-gradient(180deg, #2fd8c4, #14a898);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.chip-coin {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: url("assets/ui/coin.png") center / contain no-repeat;
}
.chip:active { transform: translateY(1px) scale(0.95); }
.chip.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
  background: linear-gradient(180deg, #4f8dff, #1a56d8);
  box-shadow: 0 0 0 1px rgba(120, 170, 255, 0.6), 0 0 14px rgba(79, 141, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}
.chip.poor { opacity: 0.45; filter: saturate(0.4); }
.phone-shell:not([data-phase="betting"]) .chip-row { opacity: 0.55; }

.wallet-row {
  position: absolute;
  top: 432px;
  left: 10px;
  right: 10px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
}
.balance-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px 0 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.4));
  border: 1px solid rgba(242, 182, 58, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
}
.balance-pill.bump { animation: bump 260ms ease; }
.coin-icon { width: 22px; height: 22px; object-fit: contain; }
.my-bet {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}
.my-bet b { margin-left: 4px; font-size: 14px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }

/* ── FLYING CHIPS ──────────────────────────────────────────── */
.fly-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.disc {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 6.5px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
  --c1: #4f9dff;
  --c2: #1550c0;
  background:
    radial-gradient(circle, var(--c2) 0 46%, transparent 47%),
    repeating-conic-gradient(#fff 0 15deg, var(--c1) 15deg 45deg),
    var(--c1);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 3px rgba(0, 0, 0, 0.5);
}
.disc[data-v="1000"] { --c1: #30d07e; --c2: #0f8a4d; }
.disc[data-v="10000"] { --c1: #ff5a5a; --c2: #b31d2c; }
.disc[data-v="100000"] { --c1: #c27bff; --c2: #6a24c0; }
.disc.mine { box-shadow: 0 0 0 1.2px var(--gold-hi), 0 2px 3px rgba(0, 0, 0, 0.5); }
.coin-fly {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  background: url("assets/ui/coin.png") center / contain no-repeat;
}

/* ── BIG MOMENTS ───────────────────────────────────────────── */
/* no z-index on the wrapper: it must not isolate its children, or the win
   video's mix-blend-mode: screen would blend with nothing and its black
   background would show. The children carry the z-index instead. */
.stage-fx { position: absolute; inset: 0; pointer-events: none; }
.stage-fx > * { position: absolute; opacity: 0; z-index: 8; will-change: transform, opacity; }
.fx-scrim {
  inset: -60px -80px;
  background: radial-gradient(ellipse at 50% 40%, rgba(8, 6, 26, 0.55), rgba(3, 2, 12, 0.9) 75%);
}
/* darker for the win clip: the screen blend lets bright things behind show through */
.fx-scrim.deep { background: radial-gradient(ellipse at 50% 40%, rgba(4, 3, 14, 0.9), rgba(2, 1, 8, 0.97) 70%); }
.fx-flash {
  inset: -40px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.95), rgba(255, 230, 170, 0.5) 25%, transparent 60%);
  mix-blend-mode: screen;
}
.fx-flash.blue { background: radial-gradient(circle at 50% 40%, rgba(230, 245, 255, 0.95), rgba(60, 160, 255, 0.55) 30%, transparent 65%); }
.fx-flash.orange { background: radial-gradient(circle at 50% 40%, rgba(255, 245, 225, 0.95), rgba(255, 120, 30, 0.55) 30%, transparent 65%); }
.fx-flash.green { background: radial-gradient(circle at 50% 40%, rgba(240, 255, 245, 0.95), rgba(40, 210, 130, 0.5) 30%, transparent 65%); }
/* same height, on a diagonal: dragon high-left (head above the VS), tiger low-right (face below the VS) */
.fx-dragon { left: -40px; top: 18px; height: 240px; filter: drop-shadow(0 0 16px rgba(62, 162, 255, 0.8)); }
.fx-tiger { left: 222px; top: 206px; height: 240px; filter: drop-shadow(0 0 16px rgba(255, 122, 31, 0.8)); }
.fx-vs { left: 120px; top: 120px; width: 150px; filter: drop-shadow(0 0 14px rgba(255, 210, 90, 0.9)); }   /* centre (195,165) */
/* win clip: transparent WebM, or (Apple) black MP4 + screen blend (.blend) */
.fx-video {
  left: -35px;
  top: 40px;
  width: 460px;
  height: 253px;            /* clip is 16:8.8 (800x440 / 960x528) */
  pointer-events: none;
}
video.fx-video.blend { mix-blend-mode: screen; }
.fx-win {
  left: -25px;
  top: 52px;
  width: 440px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 98%);
  mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 98%);
}
/* the dragon win art is a clean, near-square cutout: smaller, centred, no bottom fade; ends just above the title (y≈316) */
.fx-win-dragon {
  left: 45px;
  top: 30px;
  width: 300px;
  -webkit-mask-image: none;
  mask-image: none;
  filter: drop-shadow(0 0 18px rgba(62, 162, 255, 0.55));
}
.fx-title {
  left: 0;
  right: 0;
  top: 316px;
  text-align: center;
  font-family: var(--font-title);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  -webkit-text-stroke: 1px rgba(40, 20, 0, 0.6);
  background: linear-gradient(180deg, #fff6d0 10%, #ffd36a 50%, #c47d12 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(255, 200, 80, 0.7));
}
.fx-title.dragon { background-image: linear-gradient(180deg, #ffffff 10%, #9fd6ff 45%, #2f7fe0 90%); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(62, 162, 255, 0.9)); }
.fx-title.tiger { background-image: linear-gradient(180deg, #fffaf0 10%, #ffc07a 45%, #e35a10 90%); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(255, 122, 31, 0.9)); }
.fx-title.tie { background-image: linear-gradient(180deg, #ffffff 10%, #9cf5c6 45%, #129a58 90%); filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(39, 208, 127, 0.9)); }
.table-inner.shake { animation: shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ── RIBBON / WIN POP ──────────────────────────────────────── */
.ribbon {
  position: absolute;
  left: 50%;
  top: 176px;
  transform: translateX(-50%);
  padding: 6px 26px;
  white-space: nowrap;
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #3a1d00;
  background: linear-gradient(180deg, #fff0b8, #f2b63a 55%, #c4831f);
  clip-path: polygon(0 50%, 8% 0, 92% 0, 100% 50%, 92% 100%, 8% 100%);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
  z-index: 10;
  animation: ribbon-in 380ms cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.ribbon.out { animation: ribbon-out 240ms ease forwards; }
.win-pop {
  position: absolute;
  left: 50%;
  top: 262px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px 8px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(40, 20, 70, 0.95), rgba(10, 6, 30, 0.95));
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 24px rgba(255, 200, 80, 0.55), 0 6px 14px rgba(0, 0, 0, 0.6);
  z-index: 11;
  animation: pop-in 480ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.win-pop img { width: 30px; height: 30px; }
.win-amount {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold-hi);
  text-shadow: 0 0 10px rgba(255, 200, 80, 0.8);
  font-variant-numeric: tabular-nums;
}

/* ── MODALS ────────────────────────────────────────────────── */
/* covers only the game table — the live-stream area above stays untouched */
.modal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--table-h) + env(safe-area-inset-bottom));
  display: grid;
  place-items: end center;
  padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.modal-card {
  position: relative;
  width: 100%;
  max-height: calc(var(--table-h) - 10px);
  overflow: auto;
  padding: 16px 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #1d1440, #0b0a22);
  border: 1.5px solid rgba(242, 182, 58, 0.65);
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  line-height: 1.45;
  animation: sheet-up 260ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 900;
  color: var(--gold-hi);
  text-align: center;
}
.modal-card h3 { margin: 14px 0 6px; font-size: 13px; color: var(--gold-hi); }
.modal-card h3 small { color: rgba(255, 255, 255, 0.55); font-weight: 500; }
.modal-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(242, 182, 58, 0.6);
  background: rgba(0, 0, 0, 0.4);
}
.modal-close svg { width: 14px; height: 14px; }
.modal-close .ln { fill: none; stroke: var(--gold-hi); stroke-width: 2.4; stroke-linecap: round; }
.how-list { margin: 0; padding-left: 18px; color: rgba(255, 255, 255, 0.88); }
.how-list li + li { margin-top: 6px; }
.c-dragon { color: var(--dragon-hi); }
.c-tiger { color: var(--tiger-hi); }
.c-tie { color: var(--tie-hi); }
.pay-table { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-table div {
  display: grid;
  justify-items: center;
  padding: 7px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
}
.pay-table b { font-size: 17px; color: var(--gold-hi); }
.rank-line { margin: 12px 0 0; text-align: center; font-size: 11.5px; color: rgba(255, 255, 255, 0.65); }
.trend-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.trend-stats div {
  padding: 6px 4px;
  border-radius: 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
}
.trend-stats b { display: block; font-size: 17px; }
.bead-plate {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(6, 18px);
  grid-auto-columns: 18px;
  gap: 3px;
  justify-content: start;
  padding: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  overflow-x: auto;
}
.bead-plate .bead { width: 18px; height: 18px; font-size: 9px; }
.trend-note { margin: 8px 0 0; font-size: 11px; color: rgba(255, 255, 255, 0.5); text-align: center; }

/* ── TOASTS ────────────────────────────────────────────────── */
.toast-root {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--table-h) + 8px);
  display: grid;
  gap: 6px;
  pointer-events: none;
  z-index: 30;
}
.toast {
  justify-self: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(242, 182, 58, 0.45);
  font-size: 12px;
  font-weight: 700;
  animation: toast 2s ease forwards;
}

/* ── KEYFRAMES ─────────────────────────────────────────────── */
@keyframes dragon-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-1.5deg); }
}
@keyframes tiger-idle {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.025, 1.035); }
}
@keyframes hero-pulse-d {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(62, 162, 255, 0.6)) brightness(1); }
  50% { filter: drop-shadow(0 0 22px rgba(120, 200, 255, 1)) brightness(1.2); }
}
@keyframes hero-pulse-t {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 122, 31, 0.6)) brightness(1); }
  50% { filter: drop-shadow(0 0 22px rgba(255, 170, 60, 1)) brightness(1.2); }
}
@keyframes card-win {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
@keyframes vs-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.5)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 220, 120, 1)); }
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
@keyframes zone-flash {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.45); }
  100% { filter: brightness(1); }
}
@keyframes shake {
  10%, 90% { transform: translateX(calc(-50% - 1px)) scale(var(--s)); }
  20%, 80% { transform: translateX(calc(-50% + 3px)) scale(var(--s)); }
  30%, 50%, 70% { transform: translateX(calc(-50% - 5px)) scale(var(--s)); }
  40%, 60% { transform: translateX(calc(-50% + 5px)) scale(var(--s)); }
}
@keyframes ribbon-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.5); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes ribbon-out {
  to { opacity: 0; transform: translateX(-50%) scale(0.9); }
}
@keyframes pop-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.4); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
.road .bead.new { animation-name: bead-in; }
@keyframes bead-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast {
  0% { opacity: 0; transform: translateY(8px); }
  12%, 82% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.22); }
}
@keyframes bump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-dragon, .hero-tiger, .card.win, .zone.win::after, .vs-small { animation: none !important; }
}
