:root {
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.42);
  --navy-deep: #0b132b;
  --navy-felt: #16285c;
  --coral-aodai: #dc4628;
  --crimson: #ef4444;
  --ivory: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b18;
  color: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "PingFang SC", sans-serif;
  user-select: none;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 25%, #231915 0%, #070b18 75%);
}

.stage-frame {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 540px;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #121c3d;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.72);
}

@media (max-width: 540px) {
  .stage-frame {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    aspect-ratio: auto;
  }
}

.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Top HUD */
.top-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 15;
  pointer-events: none;
}

.brand-pill,
.hud-actions {
  pointer-events: auto;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 19, 43, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 5px 12px 5px 9px;
  cursor: pointer;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.brand-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-txt strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #fef3c7;
}

.brand-txt small {
  font-size: 10px;
  color: #cbd5e1;
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.icon-pill {
  background: rgba(11, 19, 43, 0.82);
  backdrop-filter: blur(8px);
  color: #fef3c7;
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* Top-Right Live Overhead Macro PIP Window */
.pip-card {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 44px);
  right: 10px;
  width: 39%;
  max-width: 176px;
  background: #101e4a;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.52);
  z-index: 14;
}

.pip-card canvas {
  display: block;
  width: 100%;
  height: auto;
}

.pip-badge {
  position: absolute;
  top: 4px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(7, 11, 24, 0.68);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  color: #fde68a;
  z-index: 2;
}

.pip-rec {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
}

.pip-result-tag {
  background: rgba(8, 14, 34, 0.9);
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fef08a;
  padding: 3px 4px;
  border-top: 1px solid rgba(251, 191, 36, 0.25);
}

/* Countdown Orb */
.countdown-orb {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  left: 10px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(30, 58, 138, 0.94), rgba(11, 19, 43, 0.95));
  border: 2px solid var(--gold);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.48);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 14;
}

.countdown-orb.urgent {
  border-color: #ef4444;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.72);
}

.orb-phase {
  font-size: 8.5px;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.02em;
}

.orb-num {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.05;
  color: #ffffff;
}

/* Minh Châu Speech Bubble */
.dealer-speech {
  position: absolute;
  left: 10px;
  right: 43%;
  top: calc(max(10px, env(safe-area-inset-top)) + 116px);
  background: rgba(11, 19, 43, 0.80);
  backdrop-filter: blur(7px);
  border-left: 3px solid #f97316;
  border-radius: 4px 11px 11px 11px;
  padding: 6px 9px;
  z-index: 13;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.speech-vn {
  font-size: 11.5px;
  font-weight: 600;
  color: #fffbeb;
  line-height: 1.3;
}

.speech-zh {
  margin-top: 2px;
  font-size: 10px;
  color: #cbd5e1;
  line-height: 1.25;
}

.dealer-speech.hide-zh .speech-zh {
  display: none;
}

/* Settle Toast */
.settle-banner {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 58, 138, 0.95));
  border: 1.5px solid var(--gold);
  border-radius: 14px;
  padding: 8px 18px;
  text-align: center;
  z-index: 20;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.settle-banner.hidden {
  display: none;
}

.settle-banner strong {
  display: block;
  font-size: 14px;
  color: #fde047;
}

.settle-banner span {
  font-size: 13px;
  font-weight: 800;
  color: #4ade80;
}

/* Bottom Interactive Deck */
.bottom-deck {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 7px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11, 19, 43, 0.08) 0%, rgba(10, 18, 42, 0.93) 14%, rgba(7, 12, 28, 0.98) 100%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 16;
}

/* Bead Roadmap */
.roadmap-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 27, 61, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.26);
  border-radius: 8px;
  padding: 4px 8px;
}

.rm-title {
  font-size: 10px;
  font-weight: 800;
  color: #fde68a;
}

.rm-beads {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow: hidden;
}

.rm-bead {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rm-bead.chan {
  background: #dc2626;
  color: #fff;
  border: 1px solid #fca5a5;
}

.rm-bead.le {
  background: #2563eb;
  color: #fff;
  border: 1px solid #93c5fd;
}

.rm-stats {
  font-size: 10px;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

/* 10-Zone Betting Grid */
.bet-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bet-row {
  display: grid;
  gap: 4px;
}

.bet-row-2 {
  grid-template-columns: 1fr 1fr;
}

.bet-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.bet-cell {
  position: relative;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(24, 43, 96, 0.92), rgba(15, 27, 64, 0.95));
  border: 1px solid rgba(251, 191, 36, 0.36);
  border-radius: 9px;
  padding: 5px 7px;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bet-cell:active {
  transform: scale(0.97);
}

.bet-cell.win {
  border-color: #fde047;
  background: linear-gradient(180deg, rgba(202, 138, 4, 0.65), rgba(30, 58, 138, 0.95));
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.6);
}

.bet-cell.push {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45);
}

.cell-chan,
.cell-le {
  min-height: 46px;
}

.cell-xiu,
.cell-tai {
  min-height: 41px;
}

.cell-head {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.vn-main {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #fef08a;
}

.cell-chan .vn-main {
  color: #fca5a5;
}

.cell-le .vn-main {
  color: #93c5fd;
}

.zh-sub {
  font-size: 10.5px;
  color: #cbd5e1;
  font-weight: 600;
}

.cell-odds {
  font-size: 10px;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.push-note {
  font-style: normal;
  color: #7dd3fc;
}

.cell-exact {
  min-height: 38px;
  padding: 4px 4px;
}

.cell-wide-exact {
  flex-direction: row;
  justify-content: space-between;
  padding: 4px 9px;
  min-height: 34px;
}

.exact-lbl {
  font-size: 10.5px;
  color: #e2e8f0;
}

.exact-lbl strong {
  color: #fde68a;
}

.disc-icons {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
}

.disc-icons .slash {
  font-size: 10px;
  color: #94a3b8;
  margin: 0 1px;
}

.d {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.d.r {
  background: radial-gradient(circle at 35% 35%, #ff6b6b, #dc2626 70%, #991b1b);
  border: 1px solid #fecaca;
}

.d.w {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e2e8f0 75%, #94a3b8);
  border: 1px solid #cbd5e1;
}

.my-stake {
  position: absolute;
  top: 3px;
  right: 4px;
  background: #f59e0b;
  color: #0f172a;
  font-size: 9.5px;
  font-weight: 900;
  padding: 0 5px;
  border-radius: 999px;
  display: none;
}

.my-stake.visible {
  display: inline-block;
}

/* Chip Tray */
.chip-bar {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chips-scroll {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.72);
  background: radial-gradient(circle at 35% 35%, #2563eb, #1e3a8a);
  color: #fff;
  font-size: 10.5px;
  font-weight: 900;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.chip[data-val="50"] { background: radial-gradient(circle at 35% 35%, #10b981, #065f46); }
.chip[data-val="100"] { background: radial-gradient(circle at 35% 35%, #f59e0b, #92400e); }
.chip[data-val="500"] { background: radial-gradient(circle at 35% 35%, #ec4899, #831843); }
.chip[data-val="1000"] { background: radial-gradient(circle at 35% 35%, #ef4444, #7f1d1d); }
.chip[data-val="5000"] { background: radial-gradient(circle at 35% 35%, #a855f7, #4c1d95); }

.chip.active {
  transform: translateY(-2px) scale(1.07);
  border-style: solid;
  border-color: #fde047;
  box-shadow: 0 0 10px rgba(253, 224, 71, 0.75);
}

.act-btn {
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.btn-clear {
  background: rgba(51, 65, 85, 0.9);
  color: #e2e8f0;
}

.btn-instant {
  background: linear-gradient(180deg, #ea580c, #c2410c);
  border-color: #fdba74;
  color: #fff7ed;
}

/* Wallet & Chat Footer */
.wallet-chat-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wallet-box {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 27, 61, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  padding: 3px 8px;
  flex-shrink: 0;
}

.xu-icon {
  font-size: 14px;
}

.wallet-box strong {
  display: block;
  font-size: 12px;
  color: #fde047;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.wallet-box small {
  display: block;
  font-size: 9px;
  color: #94a3b8;
  max-width: 98px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.moon-btn {
  background: #dc2626;
  color: #fef08a;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.moon-btn.hidden {
  display: none;
}

.chat-form {
  flex: 1;
  display: flex;
  gap: 4px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  padding: 0 8px;
  font-size: 11px;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--gold);
}

.chat-form button {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--gold-soft);
  background: #1e3a8a;
  color: #fef08a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
