:root {
  --blue: #2f86ff;
  --green: #44d65d;
  --gold: #ffc64a;
  --purple: #b455ff;
  --red: #ff464b;
  --black: #d9dbe2;
  --panel-bg: rgba(5, 7, 14, 0.48);
  --panel-bg-strong: rgba(5, 7, 14, 0.68);
  --panel-line: rgba(255, 221, 137, 0.24);
  --panel-glow: rgba(255, 207, 91, 0.1);
  --label-gold: #ffda76;
  --soft-white: #fff5ce;
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  width: 100vw;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.18)),
    url("/assets/img_pc_bg.png?v=pc-bg-1") center / cover no-repeat,
    #05070c;
  color: #fff;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

/* ── Boot loading (center progress) ─────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.14)),
    url("/assets/img-loading.png?v=loading-2") center / cover no-repeat,
    #05070e;
  transition: opacity 320ms ease, visibility 320ms ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  width: min(78%, 420px);
  text-align: center;
  padding: 24px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 221, 137, 0.22);
  background: rgba(5, 7, 14, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(0, 0, 0, 0.55);
}

.loading-title {
  margin: 0 0 4px;
  font-size: clamp(14px, 3.2vw, 20px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--label-gold);
}

.loading-bar-track {
  height: 10px;
  margin-top: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd46e, #ff9a3c);
  box-shadow: 0 0 12px rgba(255, 180, 90, 0.55);
  transition: width 420ms ease-out;
}

.loading-pct {
  margin: 10px 0 0;
  font-size: clamp(12px, 2.4vw, 15px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 245, 206, 0.88);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.game-screen {
  position: absolute;
  left: 50%;
  top: 50%;
  /* Fixed 1080x1920 stage. The whole stage is scaled uniformly by JS. */
  width: 1080px;
  height: 1920px;
  aspect-ratio: 9 / 16;
  max-width: none;
  max-height: none;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--stage-scale, 1));
  transform-origin: center center;
  background:
    radial-gradient(circle at 50% 18%, rgba(118, 219, 255, 0.28), transparent 42%),
    linear-gradient(180deg, #49bdf3 0%, #63d178 54%, #2c7a42 100%);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}

.overlay-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 576px;
  height: 1024px;
  transform: scale(1.875);
  transform-origin: top left;
  pointer-events: none;
}

.overlay-layer {
  z-index: 120;
}

.item-screen-flash {
  position: absolute;
  z-index: 132;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 42%, var(--item-flash-color, rgba(255, 255, 255, 0.35)) 0 18%, transparent 58%),
    linear-gradient(180deg, transparent 0%, var(--item-flash-color, rgba(255, 255, 255, 0.25)) 45%, transparent 100%);
  mix-blend-mode: screen;
}

.item-screen-flash.active {
  animation: itemScreenFlash 620ms ease-out both;
}

@keyframes itemScreenFlash {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
  }
}

.hotspot {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.84);
}

/* ── 상단 메뉴 바 ─────────────────────────────────────────── */
.top-menu-bar {
  right: 5.5%;
  top: 10.5%;
  display: flex;
  flex-direction: column;
  gap: 5%;
  pointer-events: auto;
  z-index: 60;
}

.menu-btn {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: clamp(30px, 6.5vw, 40px);
  height: clamp(30px, 6.5vw, 40px);
  padding: 0;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background: var(--panel-bg-strong);
  box-shadow:
    inset 0 0 10px var(--panel-glow),
    0 4px 10px rgba(0,0,0,0.4);
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(8px, 1.1vw, 9px);
  font-weight: 800;
  letter-spacing: 0.06em;
  transition: color 160ms, box-shadow 160ms, background 160ms;
}

.menu-btn svg {
  width: clamp(16px, 3.2vw, 21px);
  height: clamp(16px, 3.2vw, 21px);
}

.menu-btn:hover,
.menu-btn.active {
  color: var(--label-gold);
  background: rgba(255, 207, 91, 0.14);
  box-shadow:
    inset 0 0 14px rgba(255, 207, 91, 0.18),
    0 0 12px rgba(255, 207, 91, 0.28);
  border-color: rgba(255, 207, 91, 0.5);
}

.mute-btn.muted {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 80, 80, 0.12);
}

/* ── 출목표 (결과 히스토리 인라인 패널) ──────────────────── */
.result-history-panel {
  right: 5.5%;
  top: 36%;
  width: 10%;
  pointer-events: none;
  z-index: 50;
}

.result-history-panel > strong {
  display: block;
  color: var(--label-gold);
  font-size: clamp(8px, 1.1vw, 9px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 4px;
}

.result-history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}

.result-history-item {
  width: clamp(22px, 4.8vw, 30px);
  height: clamp(22px, 4.8vw, 30px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  font-size: clamp(9px, 1.9vw, 12px);
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 0 7px color-mix(in srgb, var(--fighter) 70%, transparent);
  animation: historyPop 0.32s cubic-bezier(0.2, 0.8, 0.3, 1.2) both;
}

.result-history-item.dark-horse-winner {
  outline: 2px solid rgba(255, 214, 92, 0.95);
  box-shadow:
    0 0 10px rgba(255, 214, 92, 0.7),
    0 0 7px color-mix(in srgb, var(--fighter) 70%, transparent);
}

@keyframes historyPop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── 모달 공통 ────────────────────────────────────────────── */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.camera-follow-panel {
  right: 5.4%;
  top: 10.7%;
  width: 10%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}

.camera-follow-panel > strong {
  display: block;
  margin: -11px 0 8px;
  color: var(--label-gold);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
}

.camera-follow-list {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 7px;
}

.camera-follow-btn {
  width: 44px;
  height: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #081018;
  font-size: 11px;
  font-weight: 900;
  background: var(--fighter, #ffffff);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.46),
    0 2px 6px rgba(0, 0, 0, 0.35);
  opacity: 0.74;
  transform: scale(1);
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.camera-follow-btn svg {
  width: 58%;
  height: 58%;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.35));
}

.camera-follow-btn.blue { --fighter: var(--blue); }
.camera-follow-btn.green { --fighter: var(--green); }
.camera-follow-btn.gold { --fighter: var(--gold); }
.camera-follow-btn.purple { --fighter: var(--purple); }
.camera-follow-btn.red { --fighter: var(--red); }
.camera-follow-btn.black { --fighter: var(--black); }

.camera-follow-leader-btn {
  --fighter: #101010;
  width: 44px;
  height: 44px;
  margin: 9px auto 0;
  border-radius: 999px;
  color: #fff4bf;
  font-size: 9px;
  letter-spacing: -0.06em;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.26), transparent 34%),
    linear-gradient(180deg, #31343b, #08090d 62%, #000000);
}

.camera-follow-btn.active {
  opacity: 1;
  transform: scale(1.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 0 0 2px rgba(255, 244, 191, 0.88),
    0 0 14px color-mix(in srgb, var(--fighter) 72%, transparent);
}

.race-mini-map {
  right: 4.4%;
  top: 51.2%;
  width: 18.2%;
  height: 14.7%;
  padding: 7px;
  border: 1px solid rgba(255, 221, 137, 0.22);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 207, 91, 0.06), rgba(0, 0, 0, 0.2)),
    rgba(5, 7, 14, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 16px rgba(0, 0, 0, 0.28);
  z-index: 57;
}

.race-mini-map > strong {
  display: block;
  margin-bottom: 4px;
  color: var(--label-gold);
  font-size: clamp(7px, 1.25vw, 9px);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
}

.race-mini-map-route {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  margin: 5px auto 0;
  background: url("/assets/map/img_map.svg?v=map-1") center / contain no-repeat;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.72));
}

.race-mini-map-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.race-mini-map-path {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 1;
  pointer-events: none;
}

.race-mini-map-path path {
  fill: none;
  stroke: rgba(210, 210, 210, 0.9);
  stroke-width: 3.4;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.82));
}

.race-mini-map-marker {
  position: absolute;
  z-index: 3;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: var(--fighter, #fff);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 0 8px color-mix(in srgb, var(--fighter, #fff) 72%, transparent);
  transform: translate(-50%, -50%);
  transition: left 180ms linear, top 180ms linear, opacity 160ms ease;
}

.race-mini-map-marker.black {
  border-color: rgba(255, 244, 191, 0.82);
}

.race-mini-map-marker.dimmed {
  opacity: 0.42;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  position: relative;
  width: 86%;
  max-height: 82%;
  overflow-y: auto;
  padding: 20px 18px 18px;
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 207, 91, 0.07), transparent 40%),
    rgba(5, 8, 18, 0.96);
  box-shadow:
    inset 0 0 28px rgba(255, 207, 91, 0.07),
    0 24px 48px rgba(0, 0, 0, 0.72);
  color: #fff;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,207,91,0.3) transparent;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: background 160ms, color 160ms;
}

.modal-close:hover {
  background: rgba(255, 80, 80, 0.28);
  color: #fff;
}

.modal-title {
  margin: 0 0 14px;
  color: var(--label-gold);
  font-size: clamp(15px, 3.2vw, 20px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 0 12px rgba(255, 207, 91, 0.4);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── 도움말 모달 ──────────────────────────────────────────── */
.help-section h3 {
  margin: 0 0 6px;
  color: var(--label-gold);
  font-size: clamp(11px, 2.2vw, 13px);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.help-section p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(10px, 2vw, 12px);
  line-height: 1.55;
}

.odds-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.odds-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--fighter) 36%, rgba(255,255,255,0.12));
  border-radius: 8px;
  background: color-mix(in srgb, var(--fighter) 10%, rgba(0,0,0,0.3));
  font-size: clamp(9px, 1.9vw, 11px);
}

.odds-row span { color: rgba(255,255,255,0.85); font-weight: 700; }
.odds-row b    { color: var(--soft-white); font-size: 1.1em; }

.event-help-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 5px;
  font-size: clamp(10px, 2vw, 12px);
}

.event-help-row em {
  flex-shrink: 0;
  font-style: normal;
  font-weight: 800;
  min-width: 90px;
}

.event-help-row span {
  color: rgba(255,255,255,0.75);
  line-height: 1.45;
}

/* ── 히스토리 모달 ────────────────────────────────────────── */
.history-table-wrap {
  font-size: clamp(10px, 2vw, 12px);
}

.history-table-header {
  display: grid;
  grid-template-columns: 50px 1fr 56px 90px;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 207, 91, 0.1);
  color: var(--label-gold);
  font-size: clamp(9px, 1.8vw, 11px);
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.history-table-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,207,91,0.3) transparent;
}

.history-row {
  display: grid;
  grid-template-columns: 50px 1fr 56px 90px;
  gap: 4px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  transition: background 160ms;
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.history-row.dark-horse-win {
  border-color: rgba(255, 214, 92, 0.3);
  background: rgba(255, 207, 91, 0.06);
}

.history-row-round {
  color: rgba(255,255,255,0.45);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

.history-row-winner {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
}

.history-row-odds {
  color: var(--soft-white);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.history-row-dh {
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9em;
}

.history-row-dh.is-winner {
  color: #ffd46e;
  font-weight: 800;
}

.history-row-dh .dh-badge {
  font-size: 0.8em;
  opacity: 0.7;
}

.history-empty {
  padding: 24px;
  text-align: center;
  color: rgba(255,255,255,0.35);
  font-size: clamp(11px, 2.2vw, 13px);
}

/* ── 기존 스타일 유지 ─────────────────────────────────────── */
.jackpot-text {
  left: 8.1%;
  top: 4.35%;
  width: 26.1%;
  padding: 1% 1.35%;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 223, 127, 0.1), transparent 36%),
    var(--panel-bg);
  box-shadow:
    inset 0 0 16px var(--panel-glow),
    0 8px 16px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.jackpot-text span,
.event-text strong,
.round-text span,
.balance-text span {
  display: block;
  color: var(--label-gold);
  font-size: clamp(8px, 1.6vw, 11px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.jackpot-text strong {
  display: block;
  margin-top: 0.9%;
  color: var(--soft-white);
  font-size: clamp(18px, 3.8vw, 26px);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.energy-rank-panel {
  left: 7.9%;
  top: 11.2%;
  width: 24.8%;
  height: 15.4%;
  padding: 1% 1%;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 211, 91, 0.07), rgba(0, 0, 0, 0.12)),
    var(--panel-bg);
  box-shadow:
    inset 0 0 14px rgba(255, 207, 91, 0.07),
    0 8px 16px rgba(0, 0, 0, 0.22);
}

.energy-rank-panel > strong {
  display: block;
  color: var(--label-gold);
  font-size: clamp(7px, 1.25vw, 9px);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
}

.energy-rank-list {
  position: relative;
  height: calc(100% - 12px);
  margin-top: 4px;
}

.energy-rank-row {
  position: absolute;
  left: -4px;
  right: 4px;
  height: 15%;
  min-height: 12px;
  display: grid;
  grid-template-columns: 20px 15px 1fr 34px;
  gap: 3px;
  align-items: center;
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(7px, 1.25vw, 9px);
  font-weight: 800;
  opacity: 1;
  transform: translateY(calc(var(--rank) * 118%));
  transition:
    transform 420ms cubic-bezier(0.2, 0.78, 0.2, 1),
    opacity 240ms ease,
    filter 240ms ease;
}

.energy-rank-row.dimmed {
  opacity: 0.42;
  filter: grayscale(0.8);
}

.energy-rank-position {
  color: var(--label-gold);
  font-size: 0.82em;
  text-align: right;
}

.energy-rank-badge {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 50%;
  background: var(--fighter);
  font-size: 8px;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 0 7px color-mix(in srgb, var(--fighter) 70%, transparent);
}

.energy-rank-bar {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.54);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.energy-rank-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--energy);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--fighter), color-mix(in srgb, var(--fighter) 55%, #ffffff));
  box-shadow: 0 0 8px color-mix(in srgb, var(--fighter) 72%, transparent);
  transition: width 520ms cubic-bezier(0.25, 0.9, 0.22, 1), filter 180ms ease;
}

.energy-rank-row b {
  color: #fff4c4;
  font-size: 0.86em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.energy-rank-row b small {
  display: inline;
  opacity: 0.6;
  font-size: 0.72em;
}

.live-text {
  left: 29%;
  right: auto;
  top: 3.7%;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0.75% 1.25%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: var(--panel-bg);
  font-size: clamp(10px, 2.2vw, 14px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.live-text b {
  color: #ff4747;
  text-shadow: 0 0 6px rgba(255, 52, 52, 0.7);
}

.event-text {
  left: 2%;
  top: 28.4%;
  width: 38%;
  height: 38.8%;
  padding: 0;
  display: block;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: clamp(7px, 1.25vw, 9px);
  font-weight: 700;
  isolation: isolate;
  text-align: left;
}

.event-item-canvas {
  position: absolute;
  z-index: 49;
  left: 1.1%;
  top: 28.4%;
  width: 38%;
  height: 38.8%;
  visibility: hidden;
  pointer-events: none;
}

.event-text::before {
  content: none;
}

.event-text p {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  width: 130px;
  min-height: 126px;
  display: block;
  margin: 0;
  padding: 0;
  border-left: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.05;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transform: none;
}

.event-text p:nth-of-type(1) {
  top: 20px;
}

.event-text p:nth-of-type(2) {
  top: 148px;
}

.event-text p:nth-of-type(3) {
  top: 276px;
}

.event-text > strong {
  position: absolute;
  z-index: 3;
  left: 0;
  width: 130px;
  top: -8px;
  grid-column: 1 / -1;
  text-align: center;
  margin-bottom: 1px;
  font-size: clamp(8px, 1.35vw, 10px);
  text-shadow: 0 1px 3px #000, 0 0 6px rgba(255, 212, 110, 0.42);
}

.event-text p > span {
  position: relative;
  width: 130px;
  min-height: 124px;
  display: block;
  overflow: visible;
  box-sizing: border-box;
  padding: 96px 0 0;
  border: 0;
  background: transparent;
  color: #fff4bf;
  font-size: clamp(8px, 1.2vw, 10px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 1px 3px #000,
    0 0 6px rgba(255, 205, 94, 0.55);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56));
}

.event-text p > span::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 65px;
  width: 91px;
  height: 91px;
  transform: translateX(-50%);
  border-radius: 0;
  background: url("/assets/item/new_item_1.png") center / contain no-repeat;
  animation: none;
}

.event-text p > span::after {
  content: none;
}

.event-text p[data-event-key="heal"] > span::before {
  background-image: url("/assets/item/new_item_1.png");
}

.event-text p[data-event-key="heal"] > span {
  color: #8fff9b;
}

.event-text p[data-event-key="heal"].resolved > span::before {
  background-image: url("/assets/item/new_item_1_d.png");
}

.event-text p[data-event-key="chair"] > span::before {
  background-image: url("/assets/item/new_item_2.png");
}

.event-text p[data-event-key="chair"] > span {
  color: #ff7a6d;
}

.event-text p[data-event-key="chair"].resolved > span::before {
  background-image: url("/assets/item/new_item_2_d.png");
}

.event-text p[data-event-key="weapon"] > span::before {
  background-image: url("/assets/item/new_item_3.png");
}

.event-text p[data-event-key="weapon"] > span {
  color: #42c9ff;
}

.event-text p[data-event-key="weapon"].resolved > span::before {
  background-image: url("/assets/item/new_item_3_d.png");
}

.event-text p[data-event-key="heal"].active > span::before {
  filter:
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56))
    drop-shadow(0 0 14px rgba(120, 255, 122, 0.72));
}

.event-text p[data-event-key="chair"].active > span::before {
  filter:
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56))
    drop-shadow(0 0 14px rgba(255, 42, 36, 0.76));
}

.event-text p[data-event-key="weapon"].active > span::before {
  filter:
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56))
    drop-shadow(0 0 14px rgba(54, 176, 255, 0.78));
}

.event-text p.resolved > span::before {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56));
}

.event-text p time {
  width: auto;
  position: absolute;
  left: 50%;
  top: 112px;
  margin-top: 0;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff4bf;
  text-align: center;
  font-size: clamp(8px, 1.2vw, 10px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

.event-text p.urgent time {
  position: absolute;
  color: #fff1d2;
  text-shadow:
    0 1px 3px #000,
    0 0 8px rgba(255, 59, 36, 0.9);
}

.event-text p.urgent time::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 38, 28, 0.64) 0%, rgba(255, 38, 28, 0.24) 44%, rgba(255, 38, 28, 0) 76%);
  transform: translate(-50%, -50%);
  animation: eventTimeDangerPulse 0.72s ease-in-out infinite;
}

.event-target {
  display: inline-flex;
  position: absolute;
  z-index: 6;
  left: 104px;
  top: 66px;
  visibility: hidden;
  justify-content: center;
  align-items: center;
  gap: 2px;
  width: 58px;
  max-width: 58px;
  min-height: 32px;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff4c5;
  font-style: normal;
  transform: translateX(-50%);
  text-shadow: 0 2px 5px #000;
}

.event-text p.resolved .event-target {
  visibility: visible;
}

.event-target small {
  color: #ffd46e;
  font-size: 0.72em;
  font-weight: 800;
}

.event-target b {
  display: none;
}

.event-target .mini-fighter-badge {
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  border-width: 2px;
  font-size: 18px;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.54),
    0 0 14px currentColor;
}

.mini-fighter-badge {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 0 8px currentColor;
}

.mini-fighter-badge.blue { background: var(--blue); }
.mini-fighter-badge.green { background: var(--green); }
.mini-fighter-badge.gold { background: var(--gold); }
.mini-fighter-badge.purple { background: var(--purple); }
.mini-fighter-badge.red { background: var(--red); }
.mini-fighter-badge.black { background: #4b4f59; }

.event-text p.active {
  color: #dfffbb;
  text-shadow: 0 1px 3px #000, 0 0 4px rgba(168, 255, 122, 0.36);
}

.event-text p.active > span {
  filter:
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.56))
    drop-shadow(0 0 7px rgba(120, 255, 122, 0.34));
}

@keyframes eventTimeDangerPulse {
  0%, 100% {
    opacity: 0.58;
    transform: translate(-50%, -50%) scale(0.92);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }
}

.event-text.spine-items-active p > span::before {
  opacity: 1;
}

.event-text p.resolved {
  color: #ffd46e;
}

.event-text p.resolved time {
  color: rgba(255, 255, 255, 0.55);
}

.round-text {
  right: 7.8%;
  top: 24.2%;
  width: 18.8%;
  padding: 1% 1.1%;
  border: 1px solid rgba(255, 207, 91, 0.45);
  border-radius: 8px;
  background: rgba(5, 6, 12, 0.52);
  box-shadow: inset 0 0 14px rgba(255, 207, 91, 0.08);
  text-align: center;
}

.round-text strong {
  display: block;
  color: #fff;
  font-size: clamp(18px, 3.8vw, 26px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.05em;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}

.camera-transition-overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.camera-transition-overlay.active {
  opacity: 1;
}

.camera-transition-overlay img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.bet-overlay {
  position: absolute;
  z-index: 50;
  left: 2.8%;
  right: 2.8%;
  bottom: 8.9%;
  height: 16.3%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.2%;
  pointer-events: auto;
}

.bet-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--fighter) 36%, rgba(255, 255, 255, 0.18));
  border-radius: 12px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fighter) 14%, transparent), rgba(0, 0, 0, 0.34)),
    rgba(5, 7, 14, 0.38);
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  box-shadow:
    inset 0 0 14px color-mix(in srgb, var(--fighter) 10%, transparent),
    0 8px 14px rgba(0, 0, 0, 0.26);
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.bet-card::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.bet-card b {
  position: absolute;
  z-index: 4;
  left: 4%;
  right: 4%;
  top: 5%;
  display: block;
  font-size: clamp(8px, 1.22vw, 9px);
  font-weight: 800;
  color: #fff5cf;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px #000, 0 0 5px var(--fighter);
}

.bet-avatar {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 52%;
  width: 86%;
  height: 62%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  transform: translate(-50%, -50%);
  filter:
    drop-shadow(0 5px 8px rgba(0, 0, 0, 0.7))
    drop-shadow(0 0 6px color-mix(in srgb, var(--fighter) 30%, transparent));
}

.bet-card strong {
  position: absolute;
  z-index: 4;
  left: 3%;
  right: 3%;
  top: 13%;
  display: block;
  color: var(--soft-white);
  font-size: clamp(12px, 2.4vw, 16px);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.bet-card span {
  position: absolute;
  z-index: 5;
  left: 16%;
  right: 16%;
  bottom: 6%;
  display: inline-block;
  margin: 0;
  padding: 4% 0;
  border: 1px solid color-mix(in srgb, var(--fighter) 54%, #ffffff);
  border-radius: 999px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fighter) 70%, #ffffff), color-mix(in srgb, var(--fighter) 70%, #000));
  font-size: clamp(9px, 1.42vw, 10px);
  font-weight: 800;
  box-shadow: 0 0 10px color-mix(in srgb, var(--fighter) 34%, transparent);
}

.bet-card.selected-bet {
  transform: translateY(-3%);
  outline: 2px solid rgba(255, 238, 155, 0.88);
  box-shadow: 0 0 18px rgba(255, 225, 122, 0.58);
}

.bet-card.dark-horse-card {
  outline: 2px solid rgba(255, 224, 92, 1);
  outline-offset: 2px;
  box-shadow:
    inset 0 0 18px rgba(255, 214, 92, 0.14),
    0 0 0 1px rgba(255, 246, 164, 0.64),
    0 0 18px rgba(255, 214, 92, 0.58);
}

.bet-card.dark-horse-card b,
.bet-card.dark-horse-card strong,
.bet-card.dark-horse-card span,
.bet-card.dark-horse-card .bonus-badge,
.bet-card.dark-horse-card .bet-amount {
  z-index: 12;
}

.bonus-badge {
  position: absolute;
  z-index: 6;
  left: 8%;
  right: 8%;
  top: 24%;
  display: none;
  padding: 2px 0;
  border: 1px solid rgba(255, 224, 113, 0.86);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 224, 113, 0.32), rgba(67, 40, 0, 0.72));
  color: #fff4c5;
  font-size: clamp(7px, 1.45vw, 10px);
  font-style: normal;
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
}

.bet-card.dark-horse-card .bonus-badge {
  display: block;
}

.bet-card.has-bet {
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 20px color-mix(in srgb, var(--fighter) 28%, transparent);
}

.bet-card .bet-chip-stack {
  position: absolute;
  z-index: 7;
  --chip-color: #2458bf;
  --chip-light: #78a5ff;
  --chip-dark: #102d72;
  left: 50%;
  top: 36%;
  width: 36%;
  aspect-ratio: 1;
  display: none;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: center / contain no-repeat;
  filter:
    drop-shadow(0 0 8px var(--chip-color))
    drop-shadow(5px 4px 0 rgba(0, 0, 0, 0.42));
}

.bet-card .bet-chip-stack::before,
.bet-card .bet-chip-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  border: inherit;
  border-radius: inherit;
  background: inherit;
}

.bet-card .bet-chip-stack::before {
  transform: translate(12%, -16%);
}

.bet-card .bet-chip-stack::after {
  transform: translate(-13%, 13%);
}

.bet-card.has-bet .bet-chip-stack {
  display: block;
}

.bet-card .bet-amount {
  position: absolute;
  z-index: 8;
  left: 8%;
  right: 8%;
  top: 48%;
  display: none;
  color: #fff7bd;
  font-size: clamp(9px, 2vw, 13px);
  font-weight: 800;
  text-shadow: 0 1px 3px #000, 0 0 6px color-mix(in srgb, var(--fighter) 45%, transparent);
}

.bet-card.has-bet .bet-amount {
  display: block;
}

.bet-card.disabled {
  cursor: not-allowed;
}

.bet-card.no-more-bet {
  filter: grayscale(0.18) brightness(0.82);
}

.bet-card.win {
  outline: 3px solid rgba(116, 255, 116, 0.95);
  box-shadow: 0 0 26px rgba(116, 255, 116, 0.85);
}

.bet-card.lose {
  filter: grayscale(0.6) brightness(0.75);
}

.result-banner {
  position: absolute;
  z-index: 9999;
  left: 9%;
  right: 9%;
  top: 43%;
  display: none;
  padding: 12px 14px;
  border: 1px solid rgba(255, 222, 130, 0.82);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 207, 91, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(20, 12, 25, 0.88), rgba(5, 7, 12, 0.9));
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 4px #000;
  box-shadow:
    inset 0 0 24px rgba(255, 207, 91, 0.12),
    0 18px 34px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(255, 204, 92, 0.38);
}

.result-banner.show {
  display: block;
}

.result-banner strong {
  display: block;
  color: #ffd46e;
  font-size: clamp(17px, 4.4vw, 27px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-banner span {
  display: block;
  margin-top: 4px;
  font-size: clamp(11px, 2.4vw, 15px);
  font-weight: 700;
}

.balance-stack {
  position: absolute;
  left: 7.2%;
  bottom: 3.55%;
  z-index: 52;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  pointer-events: none;
}

.total-bet-text {
  min-width: 22%;
  padding: 0.55% 1.1%;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: rgba(5, 7, 14, 0.62);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.25);
}

.total-bet-text span {
  display: block;
  font-size: clamp(6px, 1.05vw, 8px);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(255, 245, 206, 0.72);
}

.total-bet-text strong {
  display: block;
  margin-top: 2px;
  color: #b8e4ff;
  font-size: clamp(12px, 2.35vw, 17px);
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.balance-stack .balance-text {
  position: relative;
  left: auto;
  bottom: auto;
  min-width: 22%;
  margin: 0;
  padding: 0.8% 1.2%;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background: var(--panel-bg);
}

.balance-stack .balance-text strong {
  display: block;
  margin-top: 2px;
  color: #ffc95b;
  font-size: clamp(14px, 2.8vw, 19px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.chip-row {
  position: absolute;
  z-index: 50;
  left: 6%;
  right: 4.5%;
  bottom: 3.4%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 2%;
  pointer-events: none;
}

.chip-row .chip-overlay {
  position: relative;
  flex: 1 1 auto;
  left: auto;
  right: auto;
  bottom: auto;
  display: flex;
  justify-content: center;
  gap: 3%;
  pointer-events: auto;
}

.bet-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}

.bet-action-btn {
  min-width: clamp(52px, 11vw, 72px);
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  background: var(--panel-bg-strong);
  color: rgba(255, 245, 206, 0.88);
  font-size: clamp(8px, 1.35vw, 10px);
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow:
    inset 0 0 10px var(--panel-glow),
    0 4px 10px rgba(0, 0, 0, 0.4);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.bet-action-btn:hover {
  color: var(--label-gold);
  border-color: rgba(255, 207, 91, 0.45);
  background: rgba(255, 207, 91, 0.1);
}

.chip-overlay button {
  position: relative;
  width: 16%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: center / contain no-repeat;
  color: #fff;
  font-size: clamp(9px, 2vw, 13px);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 2px 3px #000,
    0 0 5px rgba(0, 0, 0, 0.95);
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.52));
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.chip-overlay button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.chip-overlay button:nth-child(2) { background-image: url("/assets/chip/2.png"); }
.chip-overlay button:nth-child(3) { background-image: url("/assets/chip/3.png"); }
.chip-overlay button:nth-child(4) { background-image: url("/assets/chip/4.png"); }
.chip-overlay button:nth-child(5) { background-image: url("/assets/chip/5.png"); }
.chip-overlay button:nth-child(1) { background-image: url("/assets/chip/1.png"); }

.chip-overlay .selected {
  transform: translateY(-22%) scale(1.14);
  filter:
    drop-shadow(0 5px 7px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 10px rgba(255, 203, 91, 0.8));
}

.chip-row.fight-dimmed .chip-overlay button,
.chip-row.fight-dimmed .bet-action-btn {
  opacity: 0.4;
  transform: none;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.52));
  pointer-events: none;
}

.blue { --fighter: var(--blue); }
.green { --fighter: var(--green); }
.gold { --fighter: var(--gold); }
.purple { --fighter: var(--purple); }
.red { --fighter: var(--red); }
.black { --fighter: var(--black); }

@keyframes dropPulse {
  0%, 100% { scale: 1; filter: brightness(1); }
  50% { scale: 1.08; filter: brightness(1.35); }
}

@keyframes popText {
  0%, 100% { scale: 1; }
  50% { scale: 1.13; }
}

@keyframes stars {
  to { translate: 4px -4px; opacity: 0.65; }
}

@keyframes itemFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7%) rotate(3deg); }
}

/* ── Layout tuning: top HUD, menu rail, baccarat road ───────── */
.jackpot-text {
  left: 5.4%;
  top: 3.6%;
  width: 21.8%;
}

.energy-rank-panel {
  left: 5.4%;
  top: 10.4%;
  width: 21.8%;
}

.jackpot-text span,
.energy-rank-panel > strong {
  font-size: clamp(8px, 1.15vw, 9px);
  letter-spacing: 0.1em;
}

.jackpot-text strong {
  font-size: clamp(17px, 3.35vw, 23px);
}

.energy-rank-row {
  grid-template-columns: 16px 13px 1fr 16px;
  gap: 2px;
  font-size: clamp(8px, 1.05vw, 9px);
}

.energy-rank-position {
  font-size: 0.78em;
}

.energy-rank-badge {
  width: 12px;
  height: 12px;
  font-size: 9px;
}

.energy-rank-bar {
  height: 4px;
}

.energy-rank-row b {
  font-size: 0.78em;
}

.top-menu-bar {
  top: 2.4%;
  right: 4.8%;
  flex-direction: row;
  gap: 6px;
  align-items: center;
}

.menu-btn {
  width: clamp(27px, 5.3vw, 34px);
  padding: 4px 3px 3px;
  border-radius: 9px;
  font-size: clamp(7px, 0.9vw, 8px);
}

.menu-btn svg {
  width: clamp(12px, 2.4vw, 15px);
  height: clamp(12px, 2.4vw, 15px);
}

.live-text {
  left: 29%;
  right: auto;
  top: 2.65%;
  padding: 0.55% 1%;
  font-size: clamp(8px, 1.7vw, 11px);
}

.result-history-panel {
  left: 3.2%;
  right: 3.2%;
  top: 67.65%;
  width: auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 0.75% 1.2%;
  border: 1px solid rgba(255, 221, 137, 0.22);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 207, 91, 0.06), rgba(0, 0, 0, 0.12)),
    rgba(5, 7, 14, 0.54);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.28);
  z-index: 56;
}

.result-history-panel > strong {
  margin: 0;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  color: var(--label-gold);
  font-size: clamp(8px, 1.35vw, 9px);
  letter-spacing: 0.12em;
}

.result-history-list {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(16px, 3.4vw, 21px);
  grid-template-rows: clamp(16px, 3.4vw, 21px);
  gap: 3px;
  justify-content: start;
  align-items: center;
  min-height: clamp(22px, 4.7vw, 30px);
  overflow: visible;
  padding: 2px;
  border-radius: 8px;
  background-image:
    linear-gradient(rgba(255, 221, 137, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 221, 137, 0.09) 1px, transparent 1px);
  background-size: clamp(19px, 3.85vw, 24px) clamp(19px, 3.85vw, 24px);
  background-color: rgba(0, 0, 0, 0.16);
}

.result-history-item {
  width: clamp(16px, 3.4vw, 21px);
  height: clamp(16px, 3.4vw, 21px);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--fighter);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: clamp(8px, 1.55vw, 10px);
  line-height: 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 6px color-mix(in srgb, var(--fighter) 62%, transparent);
}

.result-history-item.dark-horse-winner {
  outline: 2px solid rgba(255, 214, 92, 0.96);
  outline-offset: 1px;
}

.balance-stack {
  left: 5.2%;
  bottom: 3.25%;
}

.balance-stack .balance-text {
  width: 24%;
  min-width: 0;
  padding: 0.75% 1%;
}

.balance-stack .total-bet-text {
  min-width: 0;
  width: 24%;
  padding: 0.5% 1%;
}

.balance-stack .balance-text span,
.balance-stack .total-bet-text span {
  font-size: clamp(6px, 1.15vw, 8px);
  letter-spacing: 0.08em;
}

.balance-stack .balance-text strong {
  font-size: clamp(11px, 2.25vw, 15px);
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.balance-stack .total-bet-text strong {
  font-size: clamp(10px, 2vw, 14px);
}

.chip-row {
  left: 4.8%;
  right: 3.8%;
  bottom: 3.05%;
  gap: 1.5%;
}

.chip-row .chip-overlay {
  gap: 2.5%;
}

/* Mobile readability policy: the 1080x1920 stage is scaled down, so source
   font sizes need a higher floor to remain legible on physical screens. */
@media (max-width: 768px), (pointer: coarse) {
  .jackpot-text span,
  .energy-rank-panel > strong,
  .result-history-panel > strong,
  .balance-stack .balance-text span,
  .balance-stack .total-bet-text span {
    font-size: 12px;
  }

  .jackpot-text strong {
    font-size: 27px;
  }

  .energy-rank-row {
    grid-template-columns: 18px 16px 1fr 22px;
    gap: 3px;
    font-size: 12px;
  }

  .energy-rank-badge {
    width: 15px;
    height: 15px;
    font-size: 11px;
  }

  .energy-rank-bar {
    height: 5px;
  }

  .top-menu-bar {
    gap: 8px;
  }

  .menu-btn {
    width: 42px;
    padding: 6px 4px 5px;
    font-size: 10px;
  }

  .menu-btn svg {
    width: 18px;
    height: 18px;
  }

  .live-text {
    font-size: 13px;
  }

  .event-text,
  .event-text > strong,
  .event-text p > span,
  .event-text p time {
    font-size: 12px;
  }

  .event-target {
    min-height: 18px;
  }

  .event-target .mini-fighter-badge {
    min-width: 17px;
    height: 17px;
    font-size: 12px;
  }

  .result-history-item {
    font-size: 12px;
  }

  .bet-card b {
    font-size: 12px;
  }

  .bet-card strong {
    font-size: 18px;
  }

  .bet-card span,
  .bonus-badge {
    font-size: 12px;
  }

  .balance-stack .balance-text strong {
    font-size: 18px;
  }

  .balance-stack .total-bet-text strong {
    font-size: 16px;
  }

  .chip-overlay button {
    font-size: 16px;
  }

  .bet-action-btn {
    font-size: 11px;
    min-width: 64px;
    padding: 7px 9px;
  }
}

/* ── UX cleanup: prevent HUD/control overlap ─────────────── */
.top-menu-bar {
  top: 2.2%;
  right: 3.8%;
  flex-direction: row;
  gap: 5px;
}

.menu-btn {
  width: 34px;
  min-height: 34px;
  padding: 4px 3px;
}

.live-text {
  left: 31%;
  right: auto;
  top: 2.45%;
  padding: 5px 8px;
  gap: 5px;
}

.jackpot-text {
  left: 4.6%;
  top: 3.2%;
  width: 21%;
}

.energy-rank-panel {
  left: 4.6%;
  top: 10.2%;
  width: 21%;
}

.result-history-panel {
  top: 68.4%;
  left: 3.4%;
  right: 3.4%;
  padding: 5px 7px;
}

.bet-overlay {
  left: 3.2%;
  right: 3.2%;
  bottom: 9.6%;
  height: 15.2%;
  gap: 1%;
}

.bet-card {
  border-radius: 10px;
}

.bet-card b {
  top: 6%;
  font-size: 9px;
}

.bet-card strong {
  top: 15%;
  font-size: 15px;
}

.bet-avatar {
  top: 53%;
  width: 82%;
  height: 58%;
}

.bet-card span {
  left: 14%;
  right: 14%;
  bottom: 7%;
  padding: 5px 0;
  font-size: 9px;
}

.bet-card .bet-chip-stack {
  width: 27%;
}

.bet-card .bet-amount {
  top: 48%;
  font-size: 12px;
}

.balance-stack {
  left: 3.6%;
  bottom: 2.25%;
  width: 25%;
  gap: 4px;
  z-index: 58;
}

.balance-stack .balance-text,
.balance-stack .total-bet-text {
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
}

.balance-stack .balance-text span,
.balance-stack .total-bet-text span {
  font-size: 8px;
}

.balance-stack .balance-text strong,
.balance-stack .total-bet-text strong {
  font-size: 13px;
  line-height: 1.05;
}

.chip-row {
  left: 31%;
  right: 3.6%;
  bottom: 2.2%;
  height: 6.3%;
  align-items: center;
  gap: 2.2%;
  z-index: 58;
}

.chip-row .chip-overlay {
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1.6%;
  height: 100%;
}

.chip-overlay button {
  width: 17.5%;
  max-width: 54px;
  font-size: 12px;
}

.bet-actions {
  height: 100%;
  justify-content: center;
  gap: 7px;
}

.bet-action-btn {
  min-width: 58px;
  padding: 6px 7px;
  font-size: 9px;
  line-height: 1;
}

@media (max-width: 768px), (pointer: coarse) {
  .top-menu-bar {
    right: 3.2%;
    gap: 5px;
  }

  .menu-btn {
    width: 37px;
    min-height: 37px;
    font-size: 9px;
  }

  .live-text {
    left: 30%;
    top: 2.35%;
    font-size: 11px;
  }

  .bet-overlay {
    bottom: 10.1%;
    height: 14.7%;
  }

  .bet-card b {
    font-size: 10px;
  }

  .bet-card strong {
    font-size: 15px;
  }

  .bet-card span,
  .bonus-badge {
    font-size: 9px;
  }

  .balance-stack {
    width: 26%;
    bottom: 2.1%;
  }

  .balance-stack .balance-text span,
  .balance-stack .total-bet-text span {
    font-size: 9px;
  }

  .balance-stack .balance-text strong,
  .balance-stack .total-bet-text strong {
    font-size: 14px;
  }

  .chip-row {
    left: 32%;
    right: 3.2%;
    bottom: 2.05%;
    height: 6.8%;
  }

  .chip-overlay button {
    font-size: 13px;
  }

  .bet-action-btn {
    min-width: 55px;
    padding: 6px 6px;
    font-size: 9px;
  }
}

/* ── Final UX polish: compact wallet, premium bets/rank ───── */
.bet-overlay {
  bottom: 12%;
  height: 13.8%;
  overflow: visible;
}

.bet-card {
  overflow: visible;
  border-color: color-mix(in srgb, var(--fighter) 48%, rgba(255, 255, 255, 0.22));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012) 32%, rgba(0, 0, 0, 0.36)),
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--fighter) 22%, transparent), transparent 56%),
    rgba(7, 9, 18, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -14px 24px rgba(0, 0, 0, 0.22),
    0 8px 16px rgba(0, 0, 0, 0.28);
}

.bet-card::before {
  inset: 4px;
  border-color: color-mix(in srgb, var(--fighter) 18%, rgba(255, 255, 255, 0.1));
}

.bet-card b {
  top: 7%;
  color: #fff7d6;
}

.bet-card strong {
  top: 17%;
  color: #fff0b0;
  text-shadow: 0 2px 3px #000, 0 0 8px color-mix(in srgb, var(--fighter) 36%, transparent);
}

.bet-avatar {
  top: 54%;
  width: 78%;
  height: 56%;
  opacity: 0.96;
}

.bet-card span {
  bottom: 7%;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fighter) 58%, #ffffff), color-mix(in srgb, var(--fighter) 68%, #090909));
  border-color: color-mix(in srgb, var(--fighter) 68%, #ffffff);
}

.bonus-badge {
  left: 50%;
  right: auto;
  top: -18px;
  min-width: 54px;
  padding: 4px 8px;
  transform: translateX(-50%);
  border-color: rgba(255, 226, 112, 0.95);
  background:
    linear-gradient(180deg, rgba(255, 236, 148, 0.96), rgba(255, 160, 44, 0.9));
  color: #271400;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.34);
  box-shadow:
    0 0 0 1px rgba(54, 27, 0, 0.32),
    0 6px 14px rgba(255, 188, 54, 0.38);
}

.bet-card.dark-horse-card {
  outline: 2px solid rgba(255, 224, 92, 1);
  outline-offset: 2px;
  box-shadow:
    inset 0 0 18px rgba(255, 214, 92, 0.14),
    0 0 0 1px rgba(255, 246, 164, 0.64),
    0 0 18px rgba(255, 214, 92, 0.58);
}

.bet-card.dark-horse-card b,
.bet-card.dark-horse-card strong,
.bet-card.dark-horse-card span,
.bet-card.dark-horse-card .bonus-badge,
.bet-card.dark-horse-card .bet-amount {
  z-index: 12;
}

/* ── Compact icon menu and mobile-first modals ─────────────── */
.menu-btn span {
  display: none;
}

.modal-overlay {
  padding: 18px;
  align-items: center;
}

.modal-box {
  width: min(96%, 760px);
  max-height: 88%;
  padding: 24px 20px 20px;
  border-radius: 20px;
}

.modal-title {
  margin-bottom: 16px;
  font-size: clamp(18px, 4vw, 24px);
  line-height: 1.1;
}

.modal-body {
  gap: 16px;
}

.help-section h3 {
  font-size: clamp(14px, 3.2vw, 17px);
}

.help-section p,
.event-help-row,
.history-table-wrap {
  font-size: clamp(15px, 3.2vw, 18px);
  line-height: 1.6;
}

.odds-table {
  grid-template-columns: 1fr;
  gap: 7px;
}

.odds-row {
  padding: 10px 12px;
  font-size: clamp(15px, 3vw, 17px);
}

.event-help-row {
  display: grid;
  grid-template-columns: 138px 1fr;
  gap: 12px;
}

.event-help-row em {
  min-width: 0;
  white-space: nowrap;
}

.history-table-header,
.history-row {
  grid-template-columns: 44px minmax(78px, 1fr) 50px minmax(74px, 1fr);
  gap: 5px;
  padding: 10px 8px;
}

.history-table-body {
  max-height: 58vh;
}

#historyModal .modal-box {
  height: min(88%, 820px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#historyModal .modal-body,
#historyModal .history-table-wrap {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#historyModal .history-table-header {
  flex: 0 0 auto;
}

#historyModal .history-table-body {
  flex: 1;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

@media (max-width: 768px), (pointer: coarse) {
  .modal-overlay {
    padding: 26px;
    align-items: flex-start;
    padding-top: 7%;
  }

  .modal-box {
    width: 96%;
    max-height: 88%;
    padding: 30px 22px 22px;
    border-radius: 22px;
  }

  .modal-close {
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .modal-title {
    font-size: 24px;
  }

  .help-section h3 {
    font-size: 17px;
  }

  .help-section p,
  .event-help-row,
  .history-table-wrap {
    font-size: 17px;
    line-height: 1.6;
  }

  .odds-row {
    padding: 11px 12px;
    font-size: 16px;
  }

  .history-table-header,
  .history-row {
    grid-template-columns: 48px minmax(84px, 1fr) 54px minmax(78px, 1fr);
    padding: 10px 8px;
    font-size: 15px;
  }

  .event-help-row {
    grid-template-columns: 128px 1fr;
    gap: 10px;
  }

  #historyModal .modal-box {
    height: 88%;
  }
}

.balance-stack {
  bottom: 0.95%;
  left: 3.4%;
  width: 21.5%;
  gap: 3px;
  z-index: 48;
}

.balance-stack .balance-text,
.balance-stack .total-bet-text {
  padding: 4px 6px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 207, 91, 0.06), rgba(0, 0, 0, 0.1)),
    rgba(4, 6, 13, 0.66);
}

.balance-stack .balance-text span,
.balance-stack .total-bet-text span {
  font-size: 7px;
  line-height: 1;
}

.balance-stack .balance-text strong,
.balance-stack .total-bet-text strong {
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.08;
}

.chip-row {
  left: 28%;
  right: 3.2%;
  bottom: 0.85%;
  height: 7.5%;
}

.chip-overlay button {
  font-size: 15px;
  -webkit-text-stroke: 1px #050505;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #050505,
    1px -1px 0 #050505,
    -1px 1px 0 #050505,
    1px 1px 0 #050505,
    0 2px 3px #000,
    0 0 5px rgba(0, 0, 0, 0.95);
}

.bet-action-btn {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015)),
    rgba(5, 7, 14, 0.76);
}

.energy-rank-panel {
  border-radius: 12px;
  padding: 7px 7px 8px;
  background:
    linear-gradient(180deg, rgba(255, 207, 91, 0.08), rgba(255, 207, 91, 0.015) 28%, rgba(0, 0, 0, 0.18)),
    rgba(5, 7, 14, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 18px rgba(255, 207, 91, 0.06),
    0 10px 18px rgba(0, 0, 0, 0.28);
}

.energy-rank-panel > strong {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 221, 137, 0.16);
}

.energy-rank-panel > strong::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7dff9b;
  box-shadow: 0 0 8px rgba(125, 255, 155, 0.8);
}

.energy-rank-list {
  height: calc(100% - 18px);
  margin-top: 5px;
}

.energy-rank-row {
  height: 14%;
  grid-template-columns: 18px 16px 1fr 22px;
  gap: 4px;
  padding: 1px 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.energy-rank-position {
  color: rgba(255, 218, 118, 0.9);
}

.energy-rank-badge {
  width: 15px;
  height: 15px;
  border-width: 1.5px;
  font-weight: 900;
}

.energy-rank-bar {
  height: 6px;
  background: rgba(0, 0, 0, 0.62);
}

.energy-rank-bar i {
  background: var(--fighter);
  box-shadow: 0 0 9px color-mix(in srgb, var(--fighter) 82%, transparent);
}

.energy-rank-row b {
  color: #ffffff;
  font-size: 0.82em;
  text-shadow: 0 1px 2px #000;
}

@media (max-width: 768px), (pointer: coarse) {
  .bet-overlay {
    bottom: 12.4%;
    height: 13.2%;
  }

  .bonus-badge {
    top: -17px;
    min-width: 50px;
    font-size: 9px;
    padding: 3px 7px;
  }

  .balance-stack {
    bottom: 0.8%;
    width: 22%;
  }

  .balance-stack .balance-text span,
  .balance-stack .total-bet-text span {
    font-size: 8px;
  }

  .balance-stack .balance-text strong,
  .balance-stack .total-bet-text strong {
    font-size: 12px;
  }

  .chip-row {
    left: 29%;
    bottom: 0.7%;
    height: 7.8%;
  }

  .chip-overlay button {
    font-size: 16px;
    -webkit-text-stroke: 1.1px #050505;
  }

  .energy-rank-row {
    font-size: 11px;
  }
}

/* ── Rebalance after polish: restore bet place spacing/style ─ */
.result-history-panel {
  top: 68.75%;
}

.bet-overlay {
  bottom: 9.4%;
  height: 15.4%;
}

.bet-card {
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--fighter) 36%, rgba(255, 255, 255, 0.18));
  border-radius: 10px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fighter) 14%, transparent), rgba(0, 0, 0, 0.34)),
    rgba(5, 7, 14, 0.38);
  box-shadow:
    inset 0 0 14px color-mix(in srgb, var(--fighter) 10%, transparent),
    0 8px 14px rgba(0, 0, 0, 0.26);
}

.bet-card::before {
  inset: 3px;
  border-color: rgba(255, 255, 255, 0.08);
}

.bet-card b {
  top: 6%;
  color: #fff5cf;
}

.bet-card strong {
  top: 15%;
  color: var(--soft-white);
  text-shadow: 0 1px 3px #000, 0 0 5px var(--fighter);
}

.bet-avatar {
  top: 50.5%;
  width: 82%;
  height: 58%;
  opacity: 1;
}

.bet-card span {
  bottom: 7%;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--fighter) 70%, #ffffff), color-mix(in srgb, var(--fighter) 70%, #000));
  border-color: color-mix(in srgb, var(--fighter) 54%, #ffffff);
}

.bet-card .bet-chip-stack {
  width: 27%;
}

.balance-stack {
  bottom: 1.1%;
}

.chip-row {
  bottom: 1%;
}

@media (max-width: 768px), (pointer: coarse) {
  .result-history-panel {
    top: 69.15%;
  }

  .bet-overlay {
    bottom: 9.8%;
    height: 15%;
  }

  .balance-stack {
    bottom: 0.95%;
  }

  .chip-row {
    bottom: 0.9%;
  }
}

/* Final menu icon-only sizing */
.top-menu-bar {
  gap: 10px;
}

.menu-btn {
  width: 41px;
  height: 41px;
  min-height: 41px;
  padding: 0;
}

.menu-btn svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 768px), (pointer: coarse) {
  .top-menu-bar {
    gap: 10px;
  }

  .menu-btn {
    width: 41px;
    height: 41px;
    min-height: 41px;
  }

  .menu-btn svg {
    width: 22px;
    height: 22px;
  }
}
