/* ARENA Minigame Room — stage and game palettes */
.mg-page {
  --mg-shell: #131321;
  --mg-shell-raised: #1c1d30;
  --mg-shell-line: #34364c;
  --mg-shell-text: #f5f2fd;
  --mg-shell-muted: #b6b2ca;
  --mg-ladder-color: #ffad58;
  --mg-dice-color: #72f5ff;
  --mg-rps-color: #ff8cdb;
  --mg-slip-color: #d5c3ff;
  max-width: 1600px;
  padding: 18px clamp(14px, 3vw, 48px) 48px;
}
.mg-page [hidden] { display: none !important; }

/* ---------- Staggered Card Entrance ---------- */
@keyframes mg-fade-up {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
.mg-hero { animation: mg-fade-up .48s cubic-bezier(.22, 1, .36, 1) both; }
.mg-tabs { animation: mg-fade-up .48s .06s cubic-bezier(.22, 1, .36, 1) both; }
.mg-game { animation: mg-fade-up .52s .12s cubic-bezier(.22, 1, .36, 1) both; }
.mg-slip { animation: mg-fade-up .52s .18s cubic-bezier(.22, 1, .36, 1) both; }
.mg-history { animation: mg-fade-up .52s .24s cubic-bezier(.22, 1, .36, 1) both; }
.mg-bets { animation: mg-fade-up .52s .30s cubic-bezier(.22, 1, .36, 1) both; }

/* ---------- Room heading ---------- */
.mg-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 110px;
  padding: 14px clamp(18px, 2.4vw, 36px);
  border: 1px solid var(--mg-shell-line);
  border-radius: 18px;
  background: linear-gradient(106deg, #171423 28%, #211b39 59%, #42284a);
}
.mg-hero::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0 0 0 auto;
  width: min(62%, 710px);
  background: url("../img/dragons/card_mini.webp") 58% 60% / cover no-repeat;
  mask-image: linear-gradient(90deg, transparent, #000 57%);
  opacity: .78;
  animation: mg-hero-breathe 9s ease-in-out infinite;
}
.mg-hero-ambient {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 42%, #13121e20 68%, #21142a52);
}
@keyframes mg-hero-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
.mg-hero .crumb { margin-bottom: 0; color: var(--mg-shell-muted); font-size: 11px; }
.mg-hero .crumb a { color: var(--mg-shell-muted); }
.mg-hero .crumb a:hover { color: var(--mg-shell-text); }
.mg-hero-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 14px; }
.mg-hero h1 {
  color: var(--mg-shell-text);
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 860;
  line-height: 1.04;
  letter-spacing: -.06em;
  text-shadow: 0 2px 12px #0b0915;
}
.mg-lounge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid #91f9c954;
  border-radius: 5px;
  background: #102922;
  color: #9cf7ce;
  font-size: 10px;
  font-weight: 780;
  letter-spacing: .1em;
}
.mg-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: mg-dot-pulse 1.9s ease-in-out infinite;
}
.mg-hero-sub { color: var(--mg-shell-muted); font-size: 12px; }

/* ---------- Game switcher and layout ---------- */
.mg-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-block: 12px;
}
.mg-tabs a {
  --mg-tab: var(--mg-slip-color);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 6px 12px;
  border: 1px solid var(--mg-shell-line);
  border-radius: 12px;
  background: var(--mg-shell);
  color: var(--mg-shell-muted);
  font-size: 15px;
  font-weight: 760;
  transition: border-color var(--transition), background-color var(--transition), color var(--transition);
}
.mg-tabs a[data-mg-game="ladder"] { --mg-tab: var(--mg-ladder-color); }
.mg-tabs a[data-mg-game="dice"] { --mg-tab: var(--mg-dice-color); }
.mg-tabs a[data-mg-game="rps"] { --mg-tab: var(--mg-rps-color); }
.mg-tabs i {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--mg-tab) 13%, transparent);
  color: var(--mg-tab);
  font-size: 14px;
}
.mg-tabs a:hover,
.mg-tabs a[aria-current] {
  border-color: color-mix(in srgb, var(--mg-tab) 58%, var(--mg-shell-line));
  background: color-mix(in srgb, var(--mg-tab) 13%, var(--mg-shell));
  color: var(--mg-shell-text);
}
.mg-tabs a[aria-current]::after {
  content: "";
  position: absolute;
  inset: auto 37% -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--mg-tab);
  box-shadow: 0 0 12px var(--mg-tab);
}
.mg-tabs .mg-mobile-slip { display: none; }

.mg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 23vw, 334px);
  grid-template-areas: "game slip" "history slip" "bets bets";
  align-items: start;
  gap: 14px;
}
@media (min-width: 980px) {
  .mg-page {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }
  .mg-hero { min-height: 102px; }
  .mg-tabs { margin-block: 0; }
  .mg-tabs a { min-height: 62px; }
  .mg-grid { grid-column: 1 / -1; }
}
.mg-game {
  /* The existing board effects share this palette within the game panel. */
  --mg-primary: var(--mg-ladder-color);
  --mg-secondary: #ff7775;
  --mg-highlight: #ffedcb;
  --mg-shadow: #1a0e18;
  --mg-surface: #29151f;
  --mg-raised: #472127;
  --mg-deep: #c7482f;
  --mg-ink: #2c1118;
  --mg-cast: url("../img/dragons/card_mini.webp");
  --mg-cast-filter: saturate(1.34) sepia(.17);
  --gold: var(--mg-primary);
  --gold-deep: var(--mg-deep);
  --gold-line: color-mix(in srgb, var(--mg-primary) 43%, var(--mg-shadow));
  --gold-soft: color-mix(in srgb, var(--mg-primary) 16%, transparent);
  --gold-glow: color-mix(in srgb, var(--mg-primary) 48%, transparent);
  --champagne: var(--mg-highlight);
  --mint: var(--mg-secondary);
  --mint-soft: color-mix(in srgb, var(--mg-secondary) 15%, transparent);
  --shade: var(--mg-shadow);
  --bg: var(--mg-shadow);
  --bg-soft: var(--mg-surface);
  --surface: var(--mg-surface);
  --surface-raised: var(--mg-raised);
  --surface-hover: color-mix(in srgb, var(--mg-raised) 85%, var(--mg-primary));
  --border: color-mix(in srgb, var(--mg-primary) 27%, var(--mg-surface));
  --border-soft: color-mix(in srgb, var(--mg-primary) 17%, var(--mg-surface));
  --grove: var(--mg-raised);
  --text: #fff6fc;
  --text-dim: color-mix(in srgb, var(--mg-highlight) 82%, var(--mg-surface));
  --text-mute: color-mix(in srgb, var(--mg-highlight) 74%, var(--mg-surface));
  --ink: var(--mg-ink);
  --foil-bright: linear-gradient(145deg, var(--mg-highlight), var(--mg-primary) 56%, var(--mg-secondary));
  grid-area: game;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--gold-line);
  border-radius: 18px;
  background: var(--shade);
  box-shadow: 0 22px 45px #05040b66;
}
.mg-game[data-game="dice"] {
  --mg-primary: var(--mg-dice-color);
  --mg-secondary: #ab93ff;
  --mg-highlight: #e3fbff;
  --mg-shadow: #0e1328;
  --mg-surface: #151b37;
  --mg-raised: #20295a;
  --mg-deep: #3067be;
  --mg-ink: #071729;
  --mg-cast: url("../img/dragons/card_live.webp");
  --mg-cast-filter: saturate(1.35) hue-rotate(6deg);
}
.mg-game[data-game="rps"] {
  --mg-primary: var(--mg-rps-color);
  --mg-secondary: #fbe485;
  --mg-highlight: #ffedf9;
  --mg-shadow: #1b102a;
  --mg-surface: #291639;
  --mg-raised: #482459;
  --mg-deep: #a343a5;
  --mg-ink: #2b102d;
  --mg-cast: url("../img/dragons/card_casino.webp");
  --mg-cast-filter: saturate(1.32) hue-rotate(8deg);
  --mg-cast-position: 52% 39%;
}

/* ---------- Round Header & Countdown Ring ---------- */
.mg-round-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 12px clamp(16px, 2.4vw, 32px);
  background: linear-gradient(115deg, var(--mg-raised), var(--mg-shadow) 74%);
}
.mg-round-number {
  color: var(--gold);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}
.mg-round-head h2 {
  color: var(--champagne);
  font-size: clamp(30px, 3.55vw, 53px);
  font-weight: 880;
  line-height: 1.04;
  letter-spacing: -.065em;
}
.mg-round-clock {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  gap: 6px 12px;
}
.mg-phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  background: var(--bg-soft);
  font-size: 12px;
  font-weight: 740;
  transition: color .25s ease, border-color .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.mg-phase::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
[data-phase="open"] .mg-phase {
  color: var(--mint);
  border-color: color-mix(in srgb, var(--mint) 42%, var(--border));
  background: var(--mint-soft);
}
[data-phase="open"] .mg-phase::before { animation: mg-dot-pulse 1.8s ease-in-out infinite; }
[data-phase="locked"] .mg-phase {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 12%, var(--bg-soft));
}
[data-phase="suspense"] .mg-phase,
[data-phase="result"] .mg-phase {
  color: var(--gold);
  border-color: var(--gold-line);
  background: var(--gold-soft);
}
[data-phase="suspense"] .mg-phase::before { animation: mg-dot-pulse .6s ease-in-out infinite; }

.mg-clock-meter {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 3px 10px 3px 5px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--shade) 88%, var(--surface));
  box-shadow: inset 0 1px 4px color-mix(in srgb, var(--shade) 90%, transparent);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.mg-clock-ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
}
.mg-clock-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.mg-clock-track {
  fill: none;
  stroke: var(--border-soft);
  stroke-width: 3.2;
}
.mg-clock-arc {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: calc(113.1 * (1 - var(--remaining, 0)));
  transition: stroke-dashoffset .14s linear, stroke .25s ease;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}
.mg-clock-core {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
  opacity: .85;
}
[data-phase="open"] .mg-clock-arc { stroke: var(--mint); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--mint) 48%, transparent)); }
[data-phase="open"] .mg-clock-core { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
[data-phase="locked"] .mg-clock-ring { animation: mg-ring-spin 2.2s linear infinite; }
[data-phase="locked"] .mg-clock-arc { stroke: var(--warning); stroke-dashoffset: 76; }
[data-phase="locked"] .mg-clock-core { background: var(--warning); }
[data-phase="suspense"] .mg-clock-arc { stroke: var(--gold); }
[data-phase="result"] .mg-clock-arc { stroke: var(--gold); stroke-dashoffset: 0; }

.mg-timer {
  min-width: 5ch;
  color: var(--champagne);
  text-align: end;
  font-size: clamp(23px, 3vw, 35px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  transition: color .25s ease, text-shadow .25s ease;
}

/* Final 30s Amber Tension + Accelerated Pulse */
.mg-game[data-urgent="true"] .mg-phase {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 62%, var(--gold-line));
  background: color-mix(in srgb, var(--warning) 16%, var(--bg-soft));
  animation: mg-urgent-pulse 1.05s ease-in-out infinite;
}
.mg-game[data-urgent="true"] .mg-clock-meter {
  border-color: color-mix(in srgb, var(--warning) 62%, var(--gold-line));
  box-shadow: 0 0 18px color-mix(in srgb, var(--warning) 28%, transparent);
  animation: mg-urgent-pulse 1.05s ease-in-out infinite;
}
.mg-game[data-urgent="true"] .mg-clock-arc {
  stroke: var(--warning);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--warning) 65%, transparent));
}
.mg-game[data-urgent="true"] .mg-clock-core {
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning);
}
.mg-game[data-urgent="true"] .mg-timer {
  color: var(--warning);
  text-shadow: 0 0 14px color-mix(in srgb, var(--warning) 50%, transparent);
}
.mg-game[data-critical="true"] .mg-clock-meter,
.mg-game[data-critical="true"] .mg-phase {
  animation-duration: .58s;
}
@keyframes mg-urgent-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.035); opacity: .86; }
}
@keyframes mg-ring-spin {
  from { transform: rotate(-90deg); }
  to { transform: rotate(270deg); }
}
@keyframes mg-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.72); }
}

/* Progress Bar */
.mg-progress {
  position: relative;
  height: 4px;
  background: var(--mg-raised);
  overflow: hidden;
}
.mg-progress > span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--mint), var(--champagne));
  transform-origin: left;
  transform: scaleX(var(--remaining, 0));
  transition: transform .14s linear, background .25s ease;
  will-change: transform;
}
.mg-game[data-urgent="true"] .mg-progress > span {
  background: linear-gradient(90deg, var(--gold-deep), var(--warning), var(--champagne));
}
.mg-game[data-phase="suspense"] .mg-progress > span,
.mg-game[data-phase="result"] .mg-progress > span {
  background: var(--foil-bright);
}

/* ---------- Full-width game stage ---------- */
.mg-stage {
  --mg-stage-inset: clamp(16px, 2vw, 30px);
  --mg-art-offset: 5%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "art" "caption";
  justify-items: center;
  align-items: center;
  gap: 10px;
  min-height: clamp(426px, 48vh, 540px);
  padding: 24px var(--mg-stage-inset) 20px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse at 76% 35%, color-mix(in srgb, var(--mg-deep) 70%, var(--mg-shadow)), transparent 68%),
    linear-gradient(135deg, var(--mg-raised), var(--mg-shadow) 70%);
}
[data-game="ladder"] .mg-stage {
  --mg-art-offset: 16%;
  grid-template-columns: clamp(105px, 11vw, 152px) minmax(0, 1fr);
  grid-template-areas: "beads art" "beads caption";
  column-gap: clamp(10px, 2vw, 30px);
}
.mg-table-backdrop {
  position: absolute;
  z-index: -3;
  inset: 0 0 0 41%;
  pointer-events: none;
  opacity: .72;
  background: var(--mg-cast) var(--mg-cast-position, 52% 51%) / cover no-repeat;
  filter: var(--mg-cast-filter);
  mask-image: radial-gradient(ellipse 85% 88% at 76% 47%, #000 10%, #000c 42%, transparent 87%);
  transition: opacity .45s ease;
}
[data-phase="suspense"] .mg-table-backdrop { opacity: .82; }
[data-phase="result"] .mg-table-backdrop { opacity: .84; }

.mg-table-frame {
  position: absolute;
  z-index: -2;
  inset: 11px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--mg-primary) 33%, transparent);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: inset 0 0 42px color-mix(in srgb, var(--mg-shadow) 46%, transparent);
}
.mg-table-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, var(--mg-primary) 1px, transparent 1px),
    linear-gradient(var(--mg-primary) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse 75% 90% at 9% 38%, #000, transparent 95%);
  opacity: .16;
}
.mg-table-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--mg-primary), var(--mg-primary)) left top / 34px 2px,
    linear-gradient(var(--mg-primary), var(--mg-primary)) left top / 2px 34px,
    linear-gradient(var(--mg-secondary), var(--mg-secondary)) right bottom / 34px 2px,
    linear-gradient(var(--mg-secondary), var(--mg-secondary)) right bottom / 2px 34px;
  background-repeat: no-repeat;
  opacity: .85;
}
.mg-table-crest {
  position: absolute;
  inset: 50% auto auto 45%;
  width: 156px;
  height: 156px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: .10;
  filter: grayscale(1);
  mask-image: radial-gradient(circle, #000 30%, transparent 72%);
}
.mg-table-crest img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
[data-game="ladder"] .mg-table-crest { left: 50%; }

/* ---------- Ambient Fireflies / Spores (GPU transform + opacity only) ---------- */
.mg-ambient {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.mg-spore {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: var(--sz, 5px);
  height: var(--sz, 5px);
  border-radius: 50%;
  background: radial-gradient(circle, var(--champagne) 0%, var(--gold) 45%, transparent 74%);
  opacity: 0;
  will-change: transform, opacity;
  animation: mg-spore-float var(--dur, 7s) var(--del, 0s) ease-in-out infinite;
}
.mg-spore:nth-child(3n) {
  background: radial-gradient(circle, var(--champagne) 0%, var(--mint) 48%, transparent 76%);
}
.mg-spore:nth-child(1)  { --x: 10%; --y: 82%; --sz: 5px; --dx: 14px;  --dy: -54px; --dur: 7.4s; --del: -1.1s; }
.mg-spore:nth-child(2)  { --x: 21%; --y: 66%; --sz: 4px; --dx: -10px; --dy: -46px; --dur: 6.2s; --del: -3.4s; }
.mg-spore:nth-child(3)  { --x: 32%; --y: 88%; --sz: 6px; --dx: 18px;  --dy: -62px; --dur: 8.8s; --del: -0.5s; }
.mg-spore:nth-child(4)  { --x: 43%; --y: 74%; --sz: 4px; --dx: -14px; --dy: -48px; --dur: 6.9s; --del: -4.2s; }
.mg-spore:nth-child(5)  { --x: 54%; --y: 86%; --sz: 5px; --dx: 12px;  --dy: -58px; --dur: 7.8s; --del: -2.1s; }
.mg-spore:nth-child(6)  { --x: 65%; --y: 72%; --sz: 6px; --dx: -16px; --dy: -52px; --dur: 8.3s; --del: -5.3s; }
.mg-spore:nth-child(7)  { --x: 76%; --y: 84%; --sz: 4px; --dx: 10px;  --dy: -44px; --dur: 6.4s; --del: -1.8s; }
.mg-spore:nth-child(8)  { --x: 87%; --y: 68%; --sz: 5px; --dx: -12px; --dy: -56px; --dur: 7.5s; --del: -3.9s; }
.mg-spore:nth-child(9)  { --x: 16%; --y: 38%; --sz: 4px; --dx: 12px;  --dy: -34px; --dur: 9.2s; --del: -2.7s; }
.mg-spore:nth-child(10) { --x: 37%; --y: 42%; --sz: 5px; --dx: -14px; --dy: -38px; --dur: 8.1s; --del: -6.1s; }
.mg-spore:nth-child(11) { --x: 59%; --y: 35%; --sz: 4px; --dx: 16px;  --dy: -36px; --dur: 7.1s; --del: -0.9s; }
.mg-spore:nth-child(12) { --x: 82%; --y: 44%; --sz: 6px; --dx: -10px; --dy: -42px; --dur: 9.5s; --del: -4.7s; }
.mg-spore:nth-child(13) { --x: 48%; --y: 58%; --sz: 4px; --dx: 9px;   --dy: -46px; --dur: 6.7s; --del: -2.4s; }
.mg-spore:nth-child(14) { --x: 92%; --y: 78%; --sz: 5px; --dx: -15px; --dy: -50px; --dur: 8.0s; --del: -5.8s; }

@keyframes mg-spore-float {
  0%   { opacity: 0;   transform: translate3d(0, 0, 0) scale(.6); }
  22%  { opacity: .66; }
  55%  { opacity: .34; }
  80%  { opacity: .62; }
  100% { opacity: 0;   transform: translate3d(var(--dx, 10px), var(--dy, -48px), 0) scale(1.15); }
}

/* ---------- Stage Art, Caption, Stage Bet Badge ---------- */
.mg-art {
  grid-area: art;
  position: relative;
  z-index: 2;
  display: grid;
  align-self: stretch;
  place-items: center;
  width: 100%;
  min-height: 0;
}
.mg-stage-caption {
  grid-area: caption;
  position: relative;
  z-index: 3;
  min-height: 50px;
  min-width: min(210px, 100%);
  max-width: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--shade) 92%, transparent);
  transition: background-color .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.mg-stage-caption strong {
  display: block;
  color: var(--champagne);
  font-size: clamp(20px, 2.1vw, 30px);
  font-weight: 840;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.mg-stage-caption small {
  color: var(--gold);
  font-size: 12px;
  font-weight: 680;
}
[data-phase="suspense"] .mg-stage-caption {
  background: color-mix(in srgb, var(--shade) 82%, transparent);
  border-color: var(--gold-line);
}
[data-phase="result"] .mg-stage-caption {
  padding: 5px 20px;
  border-color: var(--gold-line);
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold-soft) 160%, var(--surface-raised)), color-mix(in srgb, var(--shade) 88%, transparent));
  box-shadow: 0 4px 18px color-mix(in srgb, var(--shade) 75%, transparent), var(--inset-light);
}
[data-game="dice"][data-result="무"] {
  --gold: #ffc95f;
  --gold-deep: #ba732e;
  --champagne: #fff2ce;
  --gold-soft: #ffc95f29;
  --gold-glow: #ffc95f80;
  --gold-line: #a87a38;
  --foil-bright: linear-gradient(148deg, #fff0b1, #ffcb5a 48%, #c77932);
}
[data-phase="result"][data-result="무"] .mg-stage-caption {
  border-color: var(--gold);
  box-shadow: 0 0 28px var(--gold-glow), inset 0 0 0 1px var(--gold);
}

.mg-stage-bet {
  position: absolute;
  z-index: 4;
  inset: auto 14px 14px auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--shade) 90%, var(--surface));
  font-size: 11px;
  font-weight: 760;
  box-shadow: var(--shadow-soft);
}
.mg-stage-bet::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.mg-stage-bet[data-tone="pending"] {
  border-color: color-mix(in srgb, var(--mint) 48%, var(--border));
  color: var(--mint);
}
.mg-stage-bet[data-tone="pending"]::before { animation: mg-dot-pulse 1.3s ease-in-out infinite; }
.mg-stage-bet[data-tone="won"] {
  border-color: var(--gold);
  color: var(--ink);
  background: var(--foil-bright);
  box-shadow: 0 0 18px var(--gold-glow);
}
.mg-stage-bet[data-tone="lost"] {
  border-color: var(--border);
  color: var(--text-mute);
  background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
}
.mg-stage-bet.mg-shake,
.mg-bet-feedback.mg-shake {
  animation: mg-loss-shake .42s ease-in-out both;
}
@keyframes mg-loss-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  18% { transform: translate3d(-6px, 0, 0); }
  36% { transform: translate3d(5px, 0, 0); }
  54% { transform: translate3d(-4px, 0, 0); }
  72% { transform: translate3d(2px, 0, 0); }
}

/* ==========================================================================
 * 1. LADDER BOARD — Full Casino Ladder + Dragon Orb Runner + Left Bead Plate
 * ========================================================================== */
.mg-beadplate {
  grid-area: beads;
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-self: center;
  gap: 12px;
  width: 100%;
  padding: 15px 9px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 84%, transparent), color-mix(in srgb, var(--shade) 94%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gold) 16%, transparent), var(--shadow-soft);
}
.mg-beadplate-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.mg-beadplate-title {
  color: var(--gold);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: .12em;
}
.mg-beadplate-head small {
  color: var(--text-mute);
  font-size: 10px;
}
.mg-beads {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  grid-auto-rows: 42px;
  gap: 4px;
  place-items: center;
  margin-block: auto;
}
.mg-beads li { display: grid; place-items: center; width: 40px; height: 40px; }
.mg-bead {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 840;
  line-height: 1;
  transition: transform .18s ease, box-shadow .18s ease;
}
.mg-bead-no { font-size: 8.5px; font-weight: 700; opacity: .8; transform: translateY(-.5px); }
.mg-bead[data-val="A"] {
  color: var(--ink);
  background: var(--foil-bright);
  border: 1.5px solid var(--champagne);
  box-shadow: inset 0 1px 1px color-mix(in srgb, var(--champagne) 70%, transparent), 0 2px 8px color-mix(in srgb, var(--gold-glow) 85%, transparent);
}
.mg-bead[data-val="B"] {
  background: radial-gradient(circle at 32% 23%, #ff9f85, #ed5a5e 84%);
  color: var(--ink);
  border: 1.5px solid var(--mint);
  box-shadow: inset 0 1px 1px color-mix(in srgb, var(--mint) 35%, transparent), 0 2px 8px color-mix(in srgb, var(--mint) 25%, transparent);
}
.mg-bead::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1px dashed currentColor;
  opacity: .34;
  pointer-events: none;
}
.mg-bead:hover,
.mg-bead[aria-pressed="true"] {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--gold-soft), 0 0 12px var(--gold-glow);
}
.mg-bead-latest {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 55%, transparent), 0 0 14px var(--gold-glow) !important;
}
.mg-bead-enter {
  animation: mg-bead-slide-in .52s cubic-bezier(.22, 1.25, .36, 1) both;
}
@keyframes mg-bead-slide-in {
  0%   { opacity: 0; transform: translate3d(-16px, -10px, 0) scale(.45); }
  70%  { opacity: 1; transform: translate3d(2px, 0, 0) scale(1.16); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
.mg-bead-empty {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed var(--border-soft);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  opacity: .55;
}

/* Ladder Structure */
.mg-ladder {
  display: grid;
  gap: 9px;
  width: min(520px, calc(100% - var(--mg-art-offset)));
  margin-inline-end: var(--mg-art-offset);
  padding: 0 4px;
}
.mg-ladder-labels {
  position: relative;
  height: 40px;
  width: 100%;
}
.mg-ladder-labels b {
  position: absolute;
  top: 0;
  left: 16.25%;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 58px;
  height: 40px;
  color: var(--gold);
  background: linear-gradient(160deg, var(--surface-raised), var(--bg));
  border: 1.5px solid var(--gold-line);
  border-radius: 9px;
  font-size: 22px;
  font-weight: 840;
  letter-spacing: .02em;
  box-shadow: var(--inset-light), 0 4px 12px color-mix(in srgb, var(--shade) 80%, transparent);
  transition: scale .3s ease, background .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease, opacity .3s ease;
}
.mg-ladder-labels b[data-lane="B"] {
  left: 83.75%;
  border-color: color-mix(in srgb, var(--mint) 48%, var(--gold-line));
  color: var(--mint);
}
.mg-ladder-labels.mg-start b.is-active {
  border-color: var(--champagne);
  box-shadow: 0 0 18px var(--gold-glow), inset 0 0 8px var(--gold-soft);
  scale: 1.08;
}
[data-phase="result"][data-result="A"] .mg-finish b:first-child,
[data-phase="result"][data-result="B"] .mg-finish b:last-child {
  color: var(--ink);
  border-color: var(--champagne);
  background: var(--foil-bright);
  box-shadow: 0 0 26px var(--gold-glow), 0 0 0 3px var(--gold-soft);
  scale: 1.15;
}
[data-phase="result"][data-result="A"] .mg-finish b:last-child,
[data-phase="result"][data-result="B"] .mg-finish b:first-child {
  opacity: .42;
}

.mg-ladder-rails {
  position: relative;
  height: clamp(214px, 20vw, 290px);
  width: 100%;
}
.mg-ladder-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.mg-stop-gold { stop-color: var(--gold); }
.mg-stop-deep { stop-color: var(--gold-deep); }
.mg-stop-champ { stop-color: var(--champagne); }
.mg-stop-mint { stop-color: var(--mint); }
.mg-svg-rail-shadow {
  stroke: var(--shade);
  stroke-width: 11;
  stroke-linecap: round;
  opacity: .72;
}
.mg-svg-rail {
  stroke: url(#mg-rail-grad);
  stroke-width: 7.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--gold-glow) 80%, transparent));
}
.mg-svg-rail-inner {
  stroke: var(--champagne);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: .68;
}
.mg-svg-rung-shadow {
  stroke: var(--shade);
  stroke-width: 8.5;
  stroke-linecap: round;
  opacity: .6;
}
.mg-svg-rung {
  stroke: color-mix(in srgb, var(--mg-primary) 60%, var(--mg-deep));
  stroke-width: 5;
  stroke-linecap: round;
  opacity: .72;
  transition: opacity .22s ease;
}
.mg-svg-rung-hi {
  stroke: var(--champagne);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: .28;
  transition: opacity .22s ease;
}
.mg-ladder.is-revealed .mg-svg-rung { opacity: .96; stroke: var(--gold); }
.mg-ladder.is-revealed .mg-svg-rung-hi { opacity: .55; }
.mg-svg-rung.is-lit {
  stroke: var(--champagne) !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 10px var(--gold));
}
.mg-svg-joint {
  fill: var(--gold);
  stroke: var(--champagne);
  stroke-width: 1.2;
  opacity: .78;
  transition: opacity .25s ease;
}
.mg-ladder.is-revealed .mg-svg-joint { opacity: 1; }
.mg-svg-joint.is-lit { fill: var(--champagne); opacity: 1; }

.mg-ladder-trail {
  fill: none;
  stroke: url(#mg-trail-grad);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  filter: drop-shadow(0 0 10px var(--gold));
  transition: opacity .2s ease;
}
.mg-ladder.is-settled .mg-ladder-trail {
  opacity: 1;
}

/* Compact Mystery Status Capsule during Open/Locked (keeps full ladder structure visible!) */
.mg-ladder-veil {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--shade) 88%, var(--surface));
  box-shadow: var(--shadow-soft), 0 0 16px color-mix(in srgb, var(--shade) 90%, transparent), var(--inset-light);
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 760;
  letter-spacing: .04em;
  white-space: nowrap;
  padding: 5px 12px;
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.mg-ladder-veil span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mg-ladder.is-revealed .mg-ladder-veil {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.86);
}

/* Motion path and coordinate fallback share the same rail and gate waypoints. */
.mg-runner,
.mg-runner-tail {
  position: absolute;
  top: 0;
  left: 0;
  offset-path: var(--runner-path, none);
  offset-position: 0 0;
  offset-anchor: center;
  offset-rotate: 0deg;
  opacity: 0;
  pointer-events: none;
}
.mg-runner {
  width: 34px;
  height: 34px;
  z-index: 4;
}
.mg-runner-core {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--champagne);
  background: radial-gradient(circle at 35% 30%, var(--champagne), var(--gold) 52%, var(--gold-deep) 100%);
  box-shadow: 0 0 0 3px var(--gold-soft), 0 0 20px 6px var(--gold-glow), 0 0 36px var(--gold-soft);
}
.mg-runner img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.mg-runner-tail {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--champagne), var(--gold) 52%, transparent 73%);
  box-shadow: 0 0 12px var(--gold-glow);
  z-index: 3;
}
.mg-runner-tail:nth-of-type(n+3) { width: 15px; height: 15px; }
.mg-runner-tail:nth-of-type(n+5) { width: 10px; height: 10px; }
.mg-runner-core::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--champagne);
  opacity: 0;
}
.mg-ladder.is-running .mg-runner,
.mg-ladder.is-settled .mg-runner {
  opacity: 1;
}
.mg-ladder.is-running .mg-runner-core::after {
  animation: mg-orb-ripple .68s ease-out infinite;
}
.mg-animate[data-phase="result"][data-result="A"] .mg-finish b[data-lane="A"]::after,
.mg-animate[data-phase="result"][data-result="B"] .mg-finish b[data-lane="B"]::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid var(--champagne);
  border-radius: inherit;
  animation: mg-orb-ripple .62s ease-out both;
}
@keyframes mg-orb-ripple {
  0%   { opacity: .85; transform: scale(.85); }
  100% { opacity: 0;   transform: scale(1.65); }
}

/* ==========================================================================
 * 2. DICE BOARD — True CSS 3D Cubes + Parabolic Bounce + Special "무" Burst
 * ========================================================================== */
.mg-dice {
  --die-size: clamp(92px, 9.5vw, 140px);
  --die-half: calc(var(--die-size) / 2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 6vw, 89px);
  width: min(530px, calc(100% - var(--mg-art-offset)));
  min-height: clamp(245px, 24vw, 340px);
  margin-inline-end: var(--mg-art-offset);
  padding: 16px 24px;
  perspective: 920px;
}
/* Luxury Casino Dice Pit Ring */
.mg-dice::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 8px 6px;
  border: 1px solid var(--gold-line);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 53%, #2e46a19c, transparent 64%),
    repeating-radial-gradient(ellipse, #b4eaff20 0 1px, transparent 2px 24px),
    #111936c2;
  box-shadow: inset 0 0 46px #090b25, 0 0 0 6px #6c8aff1c, 0 16px 44px #070a22a8;
  transition: border-color .35s ease, box-shadow .35s ease;
}
.mg-dice::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 18px 17px;
  border: 1px dashed color-mix(in srgb, var(--gold) 32%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.mg-die-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
}
.mg-die-shadow {
  position: absolute;
  bottom: -24px;
  width: calc(var(--die-size) * 1.06);
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--shade) 95%, #000) 15%, transparent 72%);
  opacity: .85;
  will-change: transform, opacity;
  transition: transform .35s ease, opacity .35s ease;
}
.mg-die-bounce {
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
  will-change: transform;
}
.mg-die-tilt {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(-16deg) rotateY(18deg);
}
.mg-die-slot:nth-child(2) .mg-die-tilt {
  transform: rotateX(-14deg) rotateY(-20deg);
}

/* 3D Cube */
.mg-die {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  will-change: transform;
  transition: transform .48s cubic-bezier(.22, 1, .36, 1);
}

/* Idle gentle hover/breathing when open/locked */
[data-phase="open"] .mg-die-bounce,
[data-phase="locked"] .mg-die-bounce {
  animation: mg-die-idle 4.4s ease-in-out infinite;
}
[data-phase="open"] .mg-die-slot:nth-child(2) .mg-die-bounce,
[data-phase="locked"] .mg-die-slot:nth-child(2) .mg-die-bounce {
  animation-delay: -2.1s;
}
@keyframes mg-die-idle {
  0%, 100% { transform: translate3d(0, 0, 0) rotateZ(-2deg); }
  50%      { transform: translate3d(0, -6px, 0) rotateZ(2deg); }
}

/* Keep ground travel, height and cube orientation on separate layers. */
.mg-die-slot {
  --release: -68%;
  --rail-hit: -58%;
  --rail-return: -24%;
  --skid: 8%;
  --drift: -3%;
  --roll-x: 720deg;
  --roll-y: 720deg;
  --yaw: 1;
  --throw-stagger: 0ms;
}
.mg-die-slot:nth-child(2) {
  --release: 53%;
  --rail-hit: 58%;
  --rail-return: 29%;
  --skid: -9%;
  --drift: 3%;
  --roll-x: -720deg;
  --roll-y: 1080deg;
  --yaw: -1;
  --throw-stagger: 70ms;
}
.mg-dice.is-rolling .mg-die-slot,
.mg-dice.is-rolling .mg-die-bounce,
.mg-dice.is-rolling .mg-die-shadow,
.mg-dice.is-rolling .mg-die {
  animation: var(--throw-animation) calc(var(--mg-reveal-duration) - var(--throw-stagger)) linear
    calc(var(--mg-reveal-delay) + var(--throw-stagger)) both;
}
.mg-dice.is-rolling .mg-die-slot   { --throw-animation: mg-die-travel; }
.mg-dice.is-rolling .mg-die-bounce { --throw-animation: mg-die-air; }
.mg-dice.is-rolling .mg-die-shadow { --throw-animation: mg-shadow-bounce; }
.mg-dice.is-rolling .mg-die        { --throw-animation: mg-cube-tumble; }

@keyframes mg-die-travel {
  0%   { transform: translate3d(var(--release), -92%, 0); }
  19%  { transform: translate3d(var(--rail-return), -24%, 0); animation-timing-function: ease-out; }
  37%  { transform: translate3d(var(--rail-hit), 25%, 0); }
  54%  { transform: translate3d(var(--rail-return), 20%, 0); }
  71%  { transform: translate3d(var(--skid), -7%, 0); animation-timing-function: ease-out; }
  86%  { transform: translate3d(var(--drift), 2%, 0); animation-timing-function: cubic-bezier(.16, .78, .33, 1); }
  100% { transform: translate3d(0, 0, 0); }
}
@keyframes mg-die-air {
  0%   { transform: translate3d(0, -154%, 0); animation-timing-function: ease-in; }
  19%  { transform: translate3d(0, 0, 0); animation-timing-function: ease-out; }
  26%  { transform: translate3d(0, -42%, 0); animation-timing-function: ease-in; }
  37%  { transform: translate3d(0, 0, 0); animation-timing-function: ease-out; }
  44%  { transform: translate3d(0, -24%, 0); animation-timing-function: ease-in; }
  54%  { transform: translate3d(0, 0, 0); animation-timing-function: ease-out; }
  61%  { transform: translate3d(0, -11%, 0); animation-timing-function: ease-in; }
  71%  { transform: translate3d(0, 0, 0); animation-timing-function: ease-out; }
  77%  { transform: translate3d(0, -4%, 0); animation-timing-function: ease-in; }
  86%, 100% { transform: translate3d(0, 0, 0); }
}
@keyframes mg-shadow-bounce {
  0%   { opacity: .08; transform: scale(.35); }
  19%, 37%, 54%, 71%, 86%, 100% { opacity: .85; transform: scale(1); }
  26%  { opacity: .32; transform: scale(.57); }
  44%  { opacity: .49; transform: scale(.72); }
  61%  { opacity: .63; transform: scale(.85); }
  77%  { opacity: .75; transform: scale(.94); }
}
@keyframes mg-cube-tumble {
  0%   { transform: rotateX(20deg) rotateY(35deg) rotateZ(calc(-32deg * var(--yaw))); }
  19%  { transform: rotateX(calc(var(--roll-x) * .32)) rotateY(calc(var(--roll-y) * .22)) rotateZ(calc(68deg * var(--yaw))); }
  37%  { transform: rotateX(calc(var(--roll-x) * .61)) rotateY(calc(var(--roll-y) * .51)) rotateZ(calc(124deg * var(--yaw))); }
  54%  { transform: rotateX(calc(var(--rx) + var(--roll-x) * .83)) rotateY(calc(var(--ry) + var(--roll-y) * .79)) rotateZ(calc(75deg * var(--yaw))); }
  71%  { transform: rotateX(calc(var(--rx) + var(--roll-x) - 35deg * var(--yaw))) rotateY(calc(var(--ry) + var(--roll-y) - 26deg)) rotateZ(calc(16deg * var(--yaw))); }
  86%  { transform: rotateX(calc(var(--rx) + var(--roll-x) + 6deg * var(--yaw))) rotateY(calc(var(--ry) + var(--roll-y) - 5deg)) rotateZ(calc(-5deg * var(--yaw))); animation-timing-function: cubic-bezier(.16, .78, .33, 1); }
  100% { transform: rotateX(calc(var(--rx) + var(--roll-x))) rotateY(calc(var(--ry) + var(--roll-y))) rotateZ(0deg); }
}
.mg-dice.is-landed .mg-die {
  transform: rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(0deg);
}
.mg-dice.is-rolling .mg-die,
.mg-dice.is-landed .mg-die { transition: none; }

/* 6 Real 3D Faces — tight chamfered casino edges (zero corner gap!) */
.mg-die-core {
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  background: var(--die-core, #2d62b8);
  transform-style: preserve-3d;
}
.mg-die-core-y { transform: rotateY(90deg); }
.mg-die-core-x { transform: rotateX(90deg); }
.mg-die-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 14%;
  border-radius: 10%;
  border: 1.5px solid var(--die-edge, #a6fbff);
  background: linear-gradient(151deg, var(--die-top, #d1feff), var(--die-mid, #72e5fc) 42%, var(--die-core, #2d62b8) 110%);
  box-shadow:
    inset 0 2px 3px color-mix(in srgb, #fff 68%, transparent),
    inset 0 -3px 6px color-mix(in srgb, var(--gold-deep) 44%, transparent),
    inset 0 0 0 2px color-mix(in srgb, var(--gold-line) 22%, transparent);
  backface-visibility: hidden;
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}
/* The second cube uses amethyst faces with the same readable pip color. */
.mg-die-slot:nth-child(2) {
  --die-top: #f1e6ff;
  --die-mid: #bda3ff;
  --die-core: #6342bc;
  --die-edge: #dfccff;
}
.mg-die-face[data-face="1"] { transform: rotateY(0deg)    translateZ(var(--die-half)); }
.mg-die-face[data-face="6"] { transform: rotateY(180deg)  translateZ(var(--die-half)); }
.mg-die-face[data-face="3"] { transform: rotateY(90deg)   translateZ(var(--die-half)); }
.mg-die-face[data-face="4"] { transform: rotateY(-90deg)  translateZ(var(--die-half)); }
.mg-die-face[data-face="2"] { transform: rotateX(90deg)   translateZ(var(--die-half)); }
.mg-die-face[data-face="5"] { transform: rotateX(-90deg)  translateZ(var(--die-half)); }

.mg-pip {
  width: 66%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, #283260, #0b112b 78%);
  box-shadow: inset 0 1px 2px #000, 0 1px 0 color-mix(in srgb, var(--champagne) 70%, transparent);
}
/* Classic 1-pip larger gold-ringed ace pip */
.mg-die-face[data-face="1"] .mg-pip {
  width: 88%;
  background: radial-gradient(circle at 36% 32%, #543172, #161737 72%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold-line) 55%, transparent), inset 0 1px 2px var(--ink);
}
/* Pip grid coordinates per face */
.mg-pip-tl { grid-area: 1 / 1; }
.mg-pip-tr { grid-area: 1 / 3; }
.mg-pip-ml { grid-area: 2 / 1; }
.mg-pip-mc { grid-area: 2 / 2; }
.mg-pip-mr { grid-area: 2 / 3; }
.mg-pip-bl { grid-area: 3 / 1; }
.mg-pip-br { grid-area: 3 / 3; }

/* Special "무" (5.5x Draw) Molten Golden Dice Ceremony */
.mg-dice.mg-dice-golden::before {
  border-color: var(--gold);
  box-shadow:
    inset 0 0 36px color-mix(in srgb, var(--gold) 22%, transparent),
    0 0 0 8px color-mix(in srgb, var(--gold-soft) 150%, transparent),
    0 0 48px var(--gold-glow);
}
.mg-dice.mg-dice-golden .mg-die-face {
  border-color: var(--champagne);
  background: var(--foil-bright);
  box-shadow:
    inset 0 2px 6px color-mix(in srgb, var(--champagne) 85%, transparent),
    inset 0 -3px 8px color-mix(in srgb, var(--gold-deep) 75%, transparent),
    0 0 22px var(--gold-glow);
}
.mg-dice.mg-dice-golden .mg-die-slot::after {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-glow), transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: mg-gold-aura 1.8s ease-in-out infinite;
}
@keyframes mg-gold-aura {
  0%, 100% { opacity: .65; transform: scale(.96); }
  50%      { opacity: 1;   transform: scale(1.12); }
}

/* ==========================================================================
 * 3. ROCK-PAPER-SCISSORS — "가위! 바위! 보!" Triad Ceremony + Strike-In
 * ========================================================================== */
.mg-rps-arena {
  --mg-beat: calc(var(--mg-reveal-duration, 2520ms) / 3);
  --mg-hand-gap: clamp(16px, 3.4vw, 46px);
  position: relative;
  display: grid;
  grid-template-areas: "chant" "hands";
  justify-items: center;
  align-content: center;
  gap: clamp(16px, 3vw, 32px);
  width: min(632px, calc(100% - var(--mg-art-offset)));
  min-height: 268px;
  margin-inline-end: var(--mg-art-offset);
  padding: 20px 12px;
  border-radius: 30px;
  border: 1px solid #f097e971;
  background:
    radial-gradient(ellipse at 50% 64%, #762c8566, transparent 73%),
    radial-gradient(circle, #df98e651 1px, transparent 1.35px) 0 0 / 15px 15px,
    #21102eec;
  box-shadow: inset 0 0 30px #1b0d2c, 0 0 0 6px #ff8cdb1a, 0 9px 32px #190b2cb0;
}
.mg-rps-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--shade) 88%, var(--surface));
  color: var(--gold);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: .06em;
  min-height: 32px;
  transition: opacity .12s ease;
}
.mg-hands {
  position: relative;
  grid-area: hands;
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-items: center;
  justify-content: center;
  gap: var(--mg-hand-gap);
  padding: 12px 16px;
}
/* Connecting Triad Gold Halo Track */
.mg-hands::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 50% 10% auto;
  height: 2px;
  background: linear-gradient(90deg, #ff82d1, #a2a0ff, #ffe286);
  opacity: .72;
  transform: translateY(-50%);
}
.mg-hand {
  --mg-hand-color: #ffa9df;
  --mg-hand-deep: #b33d87;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: clamp(84px, 10vw, 140px);
  aspect-ratio: 1;
  border: 2px solid var(--mg-hand-color);
  border-radius: 50%;
  color: var(--mg-hand-color);
  background: radial-gradient(circle at 40% 25%, color-mix(in srgb, var(--mg-hand-deep) 75%, #2a103d), #251335 76%);
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--mg-hand-color) 16%, transparent),
    inset 0 2px 12px color-mix(in srgb, var(--mg-hand-color) 24%, transparent),
    0 8px 20px #100a22aa;
  will-change: transform, opacity;
}
.mg-hand[data-hand="바위"] { --mg-hand-color: #a5f7fa; --mg-hand-deep: #267a9d; }
.mg-hand[data-hand="보"] { --mg-hand-color: #ffe08a; --mg-hand-deep: #ad682b; }
.mg-hand i { font-size: clamp(34px, 4.3vw, 61px); line-height: 1; }
.mg-hand-name {
  font-size: 14px;
  font-weight: 780;
  letter-spacing: .04em;
  color: var(--text-dim);
}
.mg-hand-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--mg-hand-color);
  opacity: 0;
  pointer-events: none;
}

/* Subtle poised idle breath */
[data-phase="open"] .mg-hand {
  animation: mg-hand-idle 3.6s ease-in-out infinite;
}
[data-phase="open"] .mg-hand:nth-of-type(2) { animation-delay: -1.2s; }
[data-phase="open"] .mg-hand:nth-of-type(3) { animation-delay: -2.4s; }
@keyframes mg-hand-idle {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -4px, 0); }
}

/* Three whole-hand beats followed by a single center-stage strike. */
.mg-rps-header,
.mg-rps-count { grid-area: chant; }
.mg-rps-header.is-chanting { opacity: 0; }
.mg-rps-count {
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 4;
}
.mg-rps-count span {
  grid-area: 1 / 1;
  opacity: 0;
  white-space: nowrap;
  border: 2px solid #2a1232;
  border-radius: 9px;
  padding: 0 .46em;
  background: var(--foil-bright);
  color: var(--ink);
  box-shadow: 2px 4px 0 #33112f, 0 0 22px var(--gold-glow);
  font-size: clamp(27px, 3.5vw, 47px);
  font-weight: 950;
  line-height: 1.13;
}
.mg-rps-count span:nth-child(2) { --word-delay: var(--mg-beat); }
.mg-rps-count span:nth-child(3) { --word-delay: calc(var(--mg-beat) * 2); }
[data-phase="suspense"] .mg-rps-count span {
  animation: mg-rps-word var(--mg-beat) calc(var(--mg-reveal-delay) + var(--word-delay, 0ms)) both;
}
@keyframes mg-rps-word {
  0%   { opacity: 0; transform: translateY(20px) rotate(-12deg) scale(.44, .76); }
  22%  { opacity: 1; transform: translateY(-15px) rotate(6deg) scale(1.24, .98); }
  51%  { opacity: 1; transform: translateY(-7px) rotate(-3deg) scale(.98, 1.07); }
  76%  { opacity: 1; transform: translateY(0) rotate(2deg) scale(1.04, .94); }
  100% { opacity: 0; transform: translateY(17px) scale(.82, .59); }
}
.mg-hand:nth-of-type(1) {
  grid-area: 1 / 1;
  --center-shift: calc(100% + var(--mg-hand-gap));
  --lean: 12deg;
  --inward: 17%;
}
.mg-hand:nth-of-type(2) {
  grid-area: 1 / 2;
  --hand-delay: 32ms;
}
.mg-hand:nth-of-type(3) {
  grid-area: 1 / 3;
  --center-shift: calc(-100% - var(--mg-hand-gap));
  --lean: -12deg;
  --inward: -17%;
  --hand-delay: 62ms;
}
.mg-hands.is-converge .mg-hand.is-beat {
  animation: mg-hand-beat var(--mg-beat) calc(var(--mg-reveal-delay) + var(--hand-delay, 0ms)) 3 both;
}
.mg-hand.is-beat .mg-hand-ring {
  animation: mg-hand-shock var(--mg-beat) calc(var(--mg-reveal-delay) + var(--hand-delay, 0ms)) 3 both;
}
@keyframes mg-hand-beat {
  0%   { transform: translate3d(0, 4%, 0) scale(1.11, .83); animation-timing-function: cubic-bezier(.19, .8, .28, 1); }
  25%  { transform: translate3d(var(--inward, 0%), -27%, 0) rotate(var(--lean, -7deg)) scale(.9, 1.23); }
  42%  { transform: translate3d(var(--inward, 0%), -25%, 0) rotate(var(--lean, 7deg)) scale(1.04, 1.07); animation-timing-function: ease-in; }
  68%  { transform: translate3d(0, 6%, 0) scale(1.18, .77); animation-timing-function: ease-out; }
  83%  { transform: translate3d(0, -9%, 0) scale(.96, 1.07); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes mg-hand-shock {
  0%, 61% { opacity: 0; transform: scale(.82); }
  70%     { opacity: .92; }
  100%    { opacity: 0; transform: scale(1.49); }
}
[data-phase="result"] .mg-hand:not([data-winner]) {
  opacity: 0;
}
.mg-hand[data-winner] {
  z-index: 4;
  color: var(--ink);
  border-color: var(--champagne);
  background: linear-gradient(145deg, #ffedf9, var(--mg-hand-color) 66%);
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--mg-hand-color) 32%, transparent),
    0 0 34px var(--gold-glow),
    var(--shadow-deep);
  transform: translateX(var(--center-shift, 0%)) scale(1.22);
}
.mg-hand[data-winner] .mg-hand-name { color: var(--ink); font-weight: 850; }
/* ==========================================================================
 * Betting Selection Buttons & Commit-Reveal Proof
 * ========================================================================== */
.mg-selection { padding: 20px clamp(16px, 2.4vw, 32px) 16px; }
.mg-selection-head, .mg-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 2px 8px;
}
.mg-selection-head h3, .mg-section-head h2, .mg-slip .bet-slip-head h2 {
  color: var(--champagne);
  font-size: 19px;
  font-weight: 780;
}
.mg-game-rule, .mg-bets-mode { color: var(--text-mute); font-size: 13px; }

.mg-choices {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 10px;
  margin-block: 12px 10px;
}
.mg-choices button {
  --mg-choice-color: var(--mg-primary);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.4vw, 10px);
  min-height: 62px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--mg-choice-color) 51%, var(--mg-shadow));
  border-radius: 11px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--mg-choice-color) 20%, var(--mg-shadow)), var(--mg-shadow));
  color: var(--text);
  font-size: 17px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--inset-light);
  transition: transform .16s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}
.mg-choices button:nth-child(2) { --mg-choice-color: var(--mg-secondary); }
.mg-choices button[data-mg-choice="무"],
.mg-choices button[data-mg-choice="보"] { --mg-choice-color: #ffe18b; }
.mg-choices button[data-mg-choice="바위"] { --mg-choice-color: #a5f7fa; }
.mg-choices i { color: var(--mg-choice-color); }
.mg-choices b {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mg-choice-color) 16%, var(--shade));
  color: var(--mg-choice-color);
  font-size: 15px;
}
.mg-choices button:hover:not(:disabled) {
  border-color: var(--mg-choice-color);
  background: linear-gradient(145deg, color-mix(in srgb, var(--mg-choice-color) 32%, var(--mg-shadow)), var(--mg-shadow));
  transform: translate3d(0, -1px, 0);
  box-shadow: var(--inset-light), 0 4px 14px color-mix(in srgb, var(--gold-glow) 45%, transparent);
}
.mg-choices button:disabled { cursor: default; opacity: .62; }
.mg-choices button:is([aria-pressed="true"], [data-winner]) {
  opacity: 1;
  border-color: var(--mg-choice-color);
  background: color-mix(in srgb, var(--mg-choice-color) 29%, var(--mg-shadow));
  color: var(--champagne);
  box-shadow: inset 0 1px 0 #fff2, 0 0 18px color-mix(in srgb, var(--mg-choice-color) 25%, transparent);
}
.mg-choices button:is([aria-pressed="true"], [data-winner]) b {
  background: var(--mg-choice-color);
  color: var(--ink);
}

.mg-proof {
  padding: 6px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-soft) 78%, transparent);
  color: var(--text-mute);
  font-size: 11px;
}
.mg-proof summary { width: fit-content; cursor: pointer; font-weight: 640; }
.mg-proof summary i { color: var(--gold); margin-inline-end: 2px; }
.mg-proof summary code { margin-inline-start: 6px; color: var(--text-dim); }
.mg-proof dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; margin-top: 6px; }
.mg-proof dd { overflow-wrap: anywhere; }
.mg-proof dd code { color: var(--text-dim); }
.mg-network:not(:empty) { margin-top: 6px; color: var(--warning); }

/* ==========================================================================
 * Bet Slip — Micro-Bounce, Gold Win Burst, Muted Loss Feedback
 * ========================================================================== */
.mg-slip.bet-slip, .mg-history, .mg-bets {
  --gold: var(--mg-slip-color);
  --gold-line: #6f5c9d;
  --gold-soft: #b692ff25;
  --gold-glow: #b692ff55;
  --champagne: var(--mg-shell-text);
  --text-mute: var(--mg-shell-muted);
  --text-dim: var(--mg-shell-muted);
  --shade: #0d0e1c;
  --bg: var(--mg-shell);
  --bg-soft: var(--mg-shell);
  --surface: var(--mg-shell);
  --surface-raised: var(--mg-shell-raised);
  --surface-hover: #272741;
  --border: var(--mg-shell-line);
  --border-soft: #303044;
  --panel-light: linear-gradient(155deg, #222239, #141425);
  --panel-sheen: linear-gradient(155deg, #202034, #151522);
  --foil-bright: linear-gradient(136deg, #ebdbff, #b7a0ff);
  --ink: #1c1131;
  border: 1px solid var(--mg-shell-line);
  border-radius: 16px;
  background: var(--mg-shell);
}
.mg-slip.bet-slip {
  grid-area: slip;
  position: sticky;
  z-index: auto;
  inset: calc(var(--header-h) + 12px) auto auto;
  width: auto;
  max-height: calc(100dvh - var(--header-h) - 24px);
  scroll-margin-top: calc(var(--header-h) + 12px);
  will-change: transform;
}
.mg-slip.mg-slip-bounce {
  animation: mg-slip-pop .38s cubic-bezier(.22, 1.3, .36, 1) both;
}
@keyframes mg-slip-pop {
  0%   { transform: scale(1); }
  36%  { transform: scale(1.028); box-shadow: var(--shadow-deep), 0 0 24px var(--gold-glow); }
  72%  { transform: scale(.992); }
  100% { transform: scale(1); }
}
.mg-slip .bet-slip-head {
  gap: 10px;
  min-height: 59px;
  padding: 12px 16px;
  background: var(--panel-light);
}
.mg-slip .bet-slip-head h2 { display: flex; align-items: center; gap: 7px; }
.mg-slip .bet-slip-body { padding: 15px; gap: 14px; }
.mg-slip .bet-slip-head h2 i { color: var(--gold); }
.mg-mode {
  padding: 2px 8px;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  color: var(--gold);
  background: var(--gold-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.mg-slip .slip-empty { padding-block: 20px; }
.mg-slip .slip-amount { width: 100%; min-height: 44px; font-size: 16px; }
.mg-slip .sp-remove { width: 34px; height: 34px; }
.mg-slip .quick-btns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mg-slip .quick-btns button { min-height: 42px; transition: border-color var(--transition), transform var(--transition); }
.mg-slip .quick-btns button:active { transform: scale(.96); }
.mg-slip .slip-place {
  min-height: 54px;
  border-color: #d9c5ff;
  background: linear-gradient(135deg, #dec7ff, #b6a5fc);
  color: #19112d;
  font-size: 16px;
  font-weight: 830;
}
.mg-slip .slip-place:disabled {
  cursor: default;
  background: var(--surface-hover);
  color: var(--text-mute);
  box-shadow: none;
  border-color: var(--border);
}
.mg-slip .sp-round-closed { color: var(--warning); }
.mg-slip-note:empty, .mg-bet-feedback:empty { display: none; }
.mg-slip-note { color: var(--warning); font-size: 12px; }
.mg-bet-feedback {
  position: relative;
  overflow: hidden;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  transition: border-color .25s ease, background-color .25s ease;
}
.mg-bet-feedback strong { display: block; color: var(--champagne); font-size: 14px; font-weight: 800; }
.mg-bet-feedback[data-tone="won"] {
  border-color: var(--gold);
  background: linear-gradient(155deg, color-mix(in srgb, var(--gold-soft) 180%, var(--surface-raised)), var(--bg-soft));
  box-shadow: 0 0 22px var(--gold-glow);
}
.mg-bet-feedback[data-tone="won"] strong { color: var(--gold); }
.mg-bet-feedback[data-tone="lost"] {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg) 92%, var(--surface));
}
.mg-bet-feedback[data-tone="lost"] strong { color: var(--text-mute); }
.mg-bet-feedback[data-tone="placed"] {
  border-color: color-mix(in srgb, var(--mint) 60%, var(--gold-line));
  background: color-mix(in srgb, var(--mint-soft) 80%, var(--bg-soft));
}
.mg-bet-feedback.mg-flash { animation: mg-feedback-flash .65s cubic-bezier(.22, 1, .36, 1); }
@keyframes mg-feedback-flash {
  0%   { transform: scale(.96); box-shadow: 0 0 0 0 var(--gold-glow); }
  45%  { transform: scale(1.025); box-shadow: 0 0 24px var(--gold-glow); }
  100% { transform: scale(1); box-shadow: 0 0 12px color-mix(in srgb, var(--gold-glow) 40%, transparent); }
}

/* ==========================================================================
 * Recent Results & My Bets (Status Pills: Pending Dot / Gold / Gray)
 * ========================================================================== */
.mg-history { grid-area: history; }
.mg-bets { grid-area: bets; }
.mg-history, .mg-bets { min-width: 0; padding: 18px 22px; }
.mg-history-empty, .mg-bets-empty { margin-top: 7px; color: var(--text-mute); }

.mg-results {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 5px 2px 6px;
  margin-top: 4px;
  scrollbar-width: thin;
}
.mg-results li { flex: 0 0 auto; min-width: 62px; }
.mg-results button {
  display: grid;
  place-items: center;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  padding: 6px 8px;
  background: linear-gradient(165deg, var(--surface-raised), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-mute);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition), transform var(--transition), background-color var(--transition);
}
.mg-results button b {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding-inline: 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.mg-results button[data-res="A"] b,
.mg-results button[data-res="대"] b { border-color: var(--gold-line); color: var(--gold); }
.mg-results button[data-res="B"] b,
.mg-results button[data-res="소"] b { border-color: color-mix(in srgb, var(--mint) 48%, var(--border)); color: var(--mint); }
.mg-results button[data-res="무"] b {
  border-color: var(--gold);
  background: var(--foil-bright);
  color: var(--ink);
}
.mg-results button:is(:hover, [aria-pressed="true"]) {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translate3d(0, -1px, 0);
}
.mg-results li:first-child button {
  border-color: var(--gold-line);
  box-shadow: 0 0 12px color-mix(in srgb, var(--gold-soft) 130%, transparent);
}
.mg-history-proof { margin-top: 6px; }

/* Bet History Status Badges (확정전 = pulsing dot, 당첨 = gold, 낙첨 = gray) */
.mg-bet-list { margin-top: 6px; }
.mg-bet-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-block: 8px;
  border-top: 1px solid var(--border-soft);
}
.mg-bet-list small { display: block; color: var(--text-mute); margin-top: 1px; }
.mg-bet-list b {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 760;
  white-space: nowrap;
}
.mg-bet-list [data-tone="pending"] {
  border-color: color-mix(in srgb, var(--mint) 46%, var(--border));
  background: var(--mint-soft);
  color: var(--mint);
}
.mg-bet-list [data-tone="pending"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 7px var(--mint);
  animation: mg-dot-pulse 1.35s ease-in-out infinite;
}
.mg-bet-list [data-tone="won"] {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  box-shadow: 0 0 12px color-mix(in srgb, var(--gold-glow) 60%, transparent);
}
.mg-bet-list [data-tone="won"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}
.mg-bet-list [data-tone="lost"] {
  border-color: var(--border-soft);
  background: color-mix(in srgb, var(--bg) 82%, var(--surface));
  color: var(--text-mute);
}

/* ==========================================================================
 * Responsive — Preserves Mobile Bottom Tab Bar & Card Stack Pattern
 * ========================================================================== */
@media (max-width: 768px) {
  body[data-page="minigames"] { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .mg-page { padding: 8px 8px 22px; }
  .mg-hero { min-height: 92px; margin-bottom: 8px; padding: 10px 13px; border-radius: 13px; }
  .mg-hero::before { width: 60%; background-position: 52% 55%; }
  .mg-hero-sub { font-size: 11px; }
  .mg-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "game" "history" "slip" "bets";
    gap: 10px;
  }
  .mg-slip.bet-slip { position: relative; inset: auto; max-height: none; overflow: visible; }
  .mg-tabs {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-height: 64px;
    margin: 0;
    padding: 5px max(8px, env(safe-area-inset-right, 0px)) calc(5px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--mg-shell-line);
    background: #12121e;
    box-shadow: 0 -6px 24px #070711aa;
    animation: none;
  }
  .mg-tabs a, .mg-tabs .mg-mobile-slip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 52px;
    padding: 3px 2px;
    border-color: transparent;
    border-radius: 7px;
    font-size: 12px;
    line-height: 1.15;
  }
  .mg-tabs a[aria-current]::after { inset: auto 28% -1px; }
  .mg-tabs i { width: 22px; height: 22px; font-size: 13px; }
  .mg-mobile-count {
    position: absolute;
    top: 2px;
    left: calc(50% + 11px);
    display: grid;
    place-items: center;
    min-width: 15px;
    height: 15px;
    padding-inline: 2px;
    border-radius: 12px;
    background: var(--mg-slip-color);
    color: #1c1131;
    font-size: 10px;
  }
  .mg-game { border-radius: 14px; }
  .mg-round-head { min-height: 77px; padding: 9px 13px; gap: 7px; }
  .mg-round-number { font-size: 12px; }
  .mg-round-head h2 { font-size: 33px; }
  .mg-round-clock { gap: 3px 5px; }
  .mg-clock-meter { gap: 4px; padding-inline: 3px 7px; }
  .mg-clock-ring-wrap { width: 29px; height: 29px; }
  .mg-timer { font-size: 22px; }
  .mg-phase { padding: 3px 7px; font-size: 10.5px; }
  .mg-stage {
    --mg-art-offset: 0%;
    --mg-stage-inset: 12px;
    min-height: clamp(330px, 87vw, 446px);
    padding-block: 14px 12px;
    row-gap: 10px;
  }
  [data-game="ladder"] .mg-stage {
    --mg-art-offset: 0%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "beads" "art" "caption";
    min-height: clamp(371px, 101vw, 478px);
  }
  .mg-stage:has(.mg-stage-bet:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "art art" "caption status";
  }
  [data-game="ladder"] .mg-stage:has(.mg-stage-bet:not([hidden])) {
    grid-template-areas: "beads beads" "art art" "caption status";
  }
  .mg-stage-bet { position: static; grid-area: status; white-space: nowrap; }
  .mg-table-backdrop {
    inset-inline-start: 13%;
    mask-image: radial-gradient(ellipse 90% 75% at 76% 48%, #000 12%, #000b 40%, transparent 87%);
  }
  .mg-table-frame { inset: 6px; }
  .mg-table-crest { left: 50%; }
  .mg-outcome-burst { --burst-x: 50%; }
  .mg-beadplate {
    flex-direction: row;
    align-items: center;
    padding: 6px 8px;
    gap: 8px;
  }
  .mg-beadplate-head {
    flex: none;
    border-bottom: 0;
    border-right: 1px solid var(--border-soft);
    padding: 0 8px 0 0;
    align-items: flex-start;
  }
  .mg-beads {
    display: flex;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    gap: 5px;
    padding: 2px;
    scrollbar-width: none;
  }
  .mg-beads li { flex: none; width: 29px; height: 29px; }
  .mg-bead { width: 27px; height: 27px; font-size: 11px; }
  .mg-bead-no { display: none; }
  .mg-bead-empty { width: 22px; height: 22px; }
  .mg-ladder { width: min(500px, 100%); gap: 6px; }
  .mg-ladder-rails { height: clamp(170px, 46vw, 218px); }
  .mg-ladder-labels, .mg-ladder-labels b { height: 33px; }
  .mg-ladder-labels b { width: 44px; font-size: 18px; }
  .mg-dice {
    --die-size: clamp(74px, 23vw, 126px);
    min-height: clamp(204px, 58vw, 290px);
    gap: clamp(30px, 11vw, 54px);
    padding: 14px 20px;
  }
  .mg-rps-arena { min-height: 202px; width: min(560px, 100%); padding-inline: 3px; }
  .mg-rps-arena { --mg-hand-gap: clamp(11px, 4vw, 33px); }
  .mg-hands { padding-inline: 3px; }
  .mg-die-slot { --rail-hit: -28%; --rail-return: -9%; }
  .mg-die-slot:nth-child(2) { --rail-hit: 28%; --rail-return: 10%; }
  .mg-hand { width: clamp(68px, 22vw, 114px); gap: 3px; }
  .mg-hand-name { font-size: 11px; }
  .mg-stage-caption { min-height: 46px; }
  .mg-selection { padding: 12px 11px 10px; }
  .mg-selection-head h3, .mg-section-head h2, .mg-slip .bet-slip-head h2 { font-size: 17px; }
  .mg-game-rule, .mg-bets-mode { font-size: 11px; }
  .mg-choices { gap: 6px; margin-top: 9px; }
  .mg-choices button { min-height: 54px; padding-inline: 4px; font-size: 14px; }
  .mg-choices b { font-size: 13px; padding-inline: 5px; }
}

@media (max-width: 360px) {
  .mg-round-head h2 { font-size: 28px; }
  .mg-round-clock { flex-direction: column; align-items: end; }
  .mg-choices button { gap: 3px; font-size: 13px; }
  .mg-choices b { font-size: 12px; }
}

/* ==========================================================================
 * Reduced Motion — Full Static Fallback
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .mg-page *, .mg-page *::before, .mg-page *::after {
    animation: none !important;
    transition-duration: .01ms !important;
  }
  .mg-ambient, .mg-outcome-burst, video.mg-perf { display: none !important; }
  .mg-rps-header.is-chanting { opacity: 1; }
  .mg-hero, .mg-tabs, .mg-game, .mg-slip, .mg-history, .mg-bets { opacity: 1; transform: none; }
}

/* Result cinema */
.mg-round-clock { position: relative; padding-inline-end: 43px; }
.mg-sfx {
  position: absolute;
  inset-inline-end: 0;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--gold-line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--champagne);
  cursor: pointer;
}
.mg-sfx:hover { background: var(--surface-hover); }
.mg-sfx[aria-pressed="false"] { color: var(--text-mute); }

.mg-media,
.mg-cinema-tableau {
  position: relative;
  grid-area: art;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  pointer-events: none;
}
.mg-media {
  z-index: 0;
  overflow: hidden;
  border-radius: 12px;
}
.mg-perf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .5;
}
.mg-perf-cut {
  z-index: 1;
  object-fit: contain;
  background: #08050f;
  opacity: 0;
  transition: opacity 250ms ease-in-out;
}
.mg-perf-cut.is-current { opacity: 1; }
[data-game="dice"][data-phase="suspense"] .mg-perf-ambient {
  animation: mg-throw-zoom 1200ms calc(var(--mg-reveal-delay) + var(--mg-reveal-duration) - 1200ms) ease-in both;
}
[data-game="dice"][data-phase="result"].is-cinema-active .mg-perf-ambient { transform: scale(1.12); }
[data-game="dice"] .mg-perf-ambient { transition: transform .28s ease-out; }
@keyframes mg-throw-zoom {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}
[data-game="ladder"].is-cinema-active .mg-ladder {
  filter: drop-shadow(0 2px 3px #130710);
}
.mg-stage:has(.mg-perf-cut.is-current) .mg-ladder-svg { opacity: .57; }
.is-cinema-active:is([data-game="dice"], [data-game="rps"]) .mg-table-backdrop { opacity: .36; }

.mg-game.is-cinema-punching,
.mg-game.is-cinema-shaking {
  animation: mg-fade-up .52s .12s cubic-bezier(.22, 1, .36, 1) both,
    var(--mg-cinema-punch, none),
    var(--mg-cinema-shake, none);
}
.mg-game.is-cinema-punching { --mg-cinema-punch: mg-cinema-punch 400ms cubic-bezier(.2, .73, .26, 1); }
.mg-game.is-cinema-shaking { --mg-cinema-shake: mg-cinema-shake 300ms ease-out; }
@keyframes mg-cinema-punch {
  0%, 100% { scale: 1; }
  29% { scale: 1.03; }
}
@keyframes mg-cinema-shake {
  0%, 100% { translate: 0 0; }
  15% { translate: -6px 2px; }
  32% { translate: 6px -3px; }
  48% { translate: -4px 2px; }
  65% { translate: 3px -1px; }
  82% { translate: -1px 1px; }
}

.mg-cinema {
  position: absolute;
  z-index: 7;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.mg-cinema-grade,
.mg-cinema-flash,
.mg-cinema-impact,
.mg-outcome-burst {
  position: absolute;
  inset: 0;
}
.mg-cinema-grade {
  opacity: 0;
  box-shadow: inset 0 4px 44px 10px #080411bd, inset 0 -10px 25px #08041099;
  background: radial-gradient(ellipse at 51% 43%, transparent 43%, #0b06155e);
  transition: opacity 250ms ease;
}
.is-cinema-active .mg-cinema-grade { opacity: .65; }
.mg-cinema.is-opening .mg-cinema-grade { animation: mg-cinema-vignette 600ms ease-out; }
@keyframes mg-cinema-vignette {
  0% { opacity: 0; }
  28% { opacity: 1; }
  100% { opacity: .65; }
}
.mg-cinema-flash {
  opacity: 0;
  background: radial-gradient(ellipse at 50% 49%, #fff 18%, #fff8f4ee 40%, #f5dcffa1 78%, transparent);
}
.mg-cinema.is-opening .mg-cinema-flash { animation: mg-cinema-flash 120ms linear; }
@keyframes mg-cinema-flash {
  0%, 100% { opacity: 0; }
  18% { opacity: .85; }
}
[data-game="rps"] .mg-cinema.is-impacting .mg-cinema-flash {
  animation: mg-slam-flash 135ms linear;
}
@keyframes mg-slam-flash {
  0%, 100% { opacity: 0; }
  16% { opacity: .78; }
}

.mg-burst-ring,
.mg-spark {
  position: absolute;
  left: var(--burst-x, 50%);
  top: var(--burst-y, 58%);
  opacity: 0;
}
[data-game="ladder"] .mg-cinema { --burst-x: 53%; }
[data-game="rps"] .mg-cinema { --burst-y: 62%; }
.mg-burst-ring {
  --ring-end: 4;
  width: clamp(62px, 9vw, 146px);
  aspect-ratio: 2.1;
  border: 2px solid var(--champagne);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--gold-glow), inset 0 0 11px var(--gold-glow);
  translate: -50% -50%;
}
.mg-burst-ring + .mg-burst-ring {
  --ring-end: 3;
  --ring-delay: 65ms;
  border-color: var(--gold);
  border-width: 1px;
}
[data-game="rps"] .mg-burst-ring + .mg-burst-ring {
  border: 5px solid #d1bcc8;
  filter: blur(4px);
}
.mg-cinema.is-impacting .mg-burst-ring {
  animation: mg-burst-ring-expand .65s var(--ring-delay, 0ms) cubic-bezier(.16, .7, .35, 1);
}
[data-game="ladder"] .mg-cinema-impact { display: none; }
@keyframes mg-burst-ring-expand {
  0% { opacity: .88; scale: .5; }
  100% { opacity: 0; scale: var(--ring-end); }
}
.mg-spark {
  width: var(--size);
  height: var(--size);
  animation: mg-spark-fly .94s var(--lag) cubic-bezier(.14, .71, .37, 1) both;
}
.mg-spark-gold {
  border-radius: 2px;
  background: linear-gradient(125deg, #fff9dc 8%, #ffd67d 41%, #df8226 88%);
  box-shadow: 0 0 8px #ffb044c9;
}
.mg-spark-gold:nth-child(3n) { height: calc(var(--size) * 2.1); }
.mg-spark-dust {
  border-radius: 50%;
  background: radial-gradient(circle, #e0d8e0b8, #78737c6e 57%, transparent 78%);
  animation-duration: .57s;
}
@keyframes mg-spark-fly {
  0% { opacity: 0; transform: rotate(var(--ang)) translateX(10px) scale(.55) rotate(35deg); }
  16% { opacity: 1; }
  62% { opacity: .67; }
  100% { opacity: 0; transform: rotate(var(--ang)) translateX(var(--dist)) scale(.12) rotate(220deg); }
}

.mg-cinema-tableau {
  z-index: 3;
  opacity: 0;
  transition: opacity 250ms ease;
}
.is-cinema-active .mg-cinema-tableau { opacity: 1; }
.mg-cinema-dice {
  position: absolute;
  inset: 47% auto auto 50%;
  translate: -50% -50%;
  width: min(44%, 460px);
  display: flex;
  justify-content: space-between;
  container-type: inline-size;
}
.mg-cinema-dice::before,
.mg-cinema-tableau:has(.mg-claw)::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: -50% -36%;
  background: radial-gradient(ellipse at 50% 52%, #827dff76, #3967bb20 46%, transparent 70%);
}
[data-result="무"] .mg-cinema-dice::before {
  background: radial-gradient(ellipse at 50% 52%, #ffc65383, #c6863026 45%, transparent 70%);
}
.mg-cinema-die {
  --die-size: 43cqw;
  --die-half: calc(var(--die-size) / 2);
  --tilt: 13deg;
  --die-top: #eaffff;
  --die-mid: #7deaf6;
  --die-core: #2254a7;
  --die-edge: #c6ffff;
  position: relative;
  width: var(--die-size);
  aspect-ratio: 1;
  perspective: 920px;
}
.mg-cinema-die + .mg-cinema-die {
  --tilt: -15deg;
  --die-top: #faecff;
  --die-mid: #b99bff;
  --die-core: #6241b4;
  --die-edge: #eed4ff;
  --die-lag: 24ms;
}
[data-result="무"] .mg-cinema-die {
  --die-top: #fff8c5;
  --die-mid: #ffd165;
  --die-core: #a95518;
  --die-edge: #ffefac;
}
.mg-cinema-die-shadow {
  position: absolute;
  inset: 90% -26% -21%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #060411e0, transparent 68%);
}
.mg-cinema-die-drop,
.mg-cinema-cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}
.mg-cinema-die-drop { transform-origin: 50% 97%; }
.mg-cinema-cube {
  transform: rotateX(-13deg) rotateY(var(--tilt)) rotateX(var(--rx)) rotateY(var(--ry));
}
.mg-cinema-cube .mg-die-face {
  display: block;
  padding: 0;
  border-radius: 8%;
  border-color: var(--die-edge);
  background:
    radial-gradient(ellipse at 23% 13%, #fff9 0%, #fff0 63%),
    linear-gradient(150deg, var(--die-top) 4%, var(--die-mid) 52%, var(--die-core));
  box-shadow: inset 0 1px 2px #fff, inset 0 -4px 9px #17223c55, inset 0 0 0 4px #f5fbff38;
}
.mg-cinema-cube .mg-die-face svg { display: block; width: 100%; height: 100%; }
.mg-cinema-cube circle {
  fill: #11234e;
  stroke: #f9f5ffad;
  stroke-width: 1.3;
  filter: drop-shadow(0 1px 1px #21233bcc);
}
[data-result="무"] .mg-cinema-cube circle { fill: #502a23; stroke: #fff1b3bc; }
.is-cinema-active[data-game="dice"] .mg-dice { opacity: .19; }
.mg-dice { transition: opacity 250ms ease; }
.is-animated .mg-cinema-die-drop { animation: mg-cinema-fall 500ms var(--die-lag, 0ms) both; }
.is-animated .mg-cinema-cube { animation: mg-cinema-spin 420ms var(--die-lag, 0ms) cubic-bezier(.2, .68, .3, 1) both; }
@keyframes mg-cinema-fall {
  0% { opacity: 0; transform: translateY(-191%) scale(.83, 1.2); animation-timing-function: cubic-bezier(.42, 0, .8, .52); }
  15% { opacity: 1; }
  59% { transform: translateY(0) scale(.94, 1.06); }
  63% { transform: translateY(0) scale(1.17, .78); animation-timing-function: ease-out; }
  76% { transform: translateY(-25%) scale(.95, 1.06); animation-timing-function: ease-in; }
  85% { transform: translateY(0) scale(1.08, .94); animation-timing-function: ease-out; }
  92% { transform: translateY(-8%) scale(.99, 1.01); animation-timing-function: ease-in; }
  97% { transform: translateY(0) scale(1.03, .98); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes mg-cinema-spin {
  from { transform: rotateX(-24deg) rotateY(var(--tilt)) rotateX(calc(var(--rx) - 210deg)) rotateY(calc(var(--ry) + 140deg)) rotateZ(-34deg); }
  to { transform: rotateX(-13deg) rotateY(var(--tilt)) rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(0deg); }
}

.mg-cinema-tableau:has(.mg-claw)::before {
  inset: 0 8%;
  background: radial-gradient(ellipse at 52% 55%, #ad389976, #5623624d 39%, transparent 72%);
}
.mg-claw {
  position: absolute;
  top: 51%;
  left: 50%;
  translate: -50% -50%;
  width: min(83%, 480px);
  height: min(88%, 340px);
  overflow: visible;
  filter: drop-shadow(0 0 3px #ffc6f3) drop-shadow(0 0 19px #ff4bd28f) drop-shadow(3px 13px 7px #100518d9);
}
.mg-claw-hide {
  fill: url("#mg-claw-hide");
  stroke: url("#mg-claw-rim");
  stroke-width: 3.3px;
}
.mg-claw-light { fill: url("#mg-claw-velvet"); stroke: none; }
.mg-claw-scales { fill: url("#mg-claw-scales"); stroke: none; opacity: .88; }
.mg-claw-membrane { fill: #e663c84a; stroke: #f995db72; stroke-width: 1.4px; }
.mg-claw-talons {
  fill: url("#mg-claw-nail");
  stroke: #31153c;
  stroke-width: 2.1px;
  stroke-linejoin: round;
}
.mg-claw-plates { fill: url("#mg-claw-plate"); stroke: #f8adf28b; stroke-width: 1.15px; }
.mg-claw-creases, .mg-claw-gleam {
  fill: none;
  stroke: #260e42c4;
  stroke-width: 2.7px;
  stroke-linecap: round;
}
.mg-claw-gleam { stroke: #ffd0f0b8; stroke-width: 1.45px; }
.is-animated .mg-claw { animation: mg-claw-slam 455ms both; }
.mg-claw:has([data-claw="가위"]) { --claw-angle: -12deg; }
@keyframes mg-claw-slam {
  0% { opacity: 0; transform: translateY(-16%) scale(3) rotate(var(--claw-angle, 12deg)); animation-timing-function: cubic-bezier(.42, .03, .76, .62); }
  17% { opacity: 1; }
  67% { transform: scale(1) rotate(0deg); }
  74% { transform: scale(1.08, .94); animation-timing-function: ease-out; }
  88% { transform: scale(.99, 1.025); }
  100% { transform: scale(1); }
}
.is-cinema-active .mg-rps-arena {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border-color: transparent;
  background: none;
  box-shadow: none;
}
.is-cinema-active[data-game="rps"] .mg-art { z-index: 4; }
.is-cinema-active .mg-rps-header {
  position: absolute;
  grid-area: auto;
  z-index: 1;
  inset: 3px auto auto 50%;
  translate: -50% 0;
  width: max-content;
  white-space: nowrap;
}
.is-cinema-active .mg-hands {
  position: absolute;
  grid-area: auto;
  z-index: 4;
  inset: 49% auto auto 2%;
  translate: 0 -50%;
  grid-template-columns: auto;
  gap: 10px;
  padding: 0;
}
.is-cinema-active .mg-hands::before,
.is-cinema-active .mg-hand:not([data-player]) { display: none; }
.mg-game.is-cinema-active .mg-hand[data-player] {
  grid-area: auto;
  width: clamp(43px, 6vw, 80px);
  gap: 2px;
  color: var(--mg-hand-color);
  background: radial-gradient(circle at 40% 25%, var(--mg-hand-deep), #251335 76%);
  opacity: 1;
  transform: none;
  animation: none;
}
.is-cinema-active .mg-hand[data-player] i { font-size: clamp(17px, 2.8vw, 33px); }
.is-cinema-active .mg-hand[data-player] .mg-hand-name { color: var(--text-dim); font-size: clamp(9px, 1vw, 12px); }
.mg-game.is-cinema-active .mg-hand[data-player-win] {
  border-color: #ffdc90;
  box-shadow: 0 0 0 3px #ffdc9044, 0 0 21px #ffbd6080;
}
.is-cinema-active .mg-hand[data-player] .mg-hand-ring { animation: none; }

@media (max-width: 640px) {
  .mg-round-clock { padding-inline-end: 34px; }
  .mg-sfx { width: 29px; height: 29px; font-size: 12px; }
  .mg-cinema-die { perspective: 630px; }
  .mg-claw { width: 89%; height: 79%; }
  .mg-cinema-grade { box-shadow: inset 0 4px 22px 3px #080411a9; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-media::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--mg-ambient-poster) center / cover no-repeat;
    opacity: .5;
  }
  .mg-cinema-tableau, .mg-cinema-grade, .mg-perf-poster, .mg-dice { transition-duration: 200ms !important; }
  .mg-cinema-flash, .mg-cinema-impact { display: none; }
}
