/* ==========================================================================
   小瑪俐 (Xiao Ma Li - 高解析度 HD 超清晰 1:1 復刻版)
   - 移除預設模糊濾鏡，保證 100% 視網膜超高畫質、銳利向量圖示
   - 嚴格重現「大77 (40倍)」與「小77 (20倍)」巨細靡遺之對比
   - 機台大幅放大、圖案加大 200%、文字超清晰對比
   ========================================================================== */

:root {
  --cab-bg: #f1f4f8;
  --cab-border: #9aa7b5;
  --cab-shadow: rgba(0, 0, 0, 0.7);
  --deck-black: #08090d;
  --gold-accent: #f59e0b;
  --green-frame: #15803d;
  --led-red: #ff1122;
  --led-glow: rgba(255, 17, 34, 0.95);
  --tile-bg: #ffffff;
  --tile-border: #b8ac95;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(circle at 50% 30%, #1f2735 0%, #0a0c10 100%);
  color: #fff;
  font-family: 'PingFang TC', 'Microsoft JhengHei', 'Segoe UI', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 8px;
  overflow-x: hidden;
  touch-action: manipulation;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* 僅當主動開啟 CRT 濾鏡時才加上掃描線 (預設關閉以保持最高清晰度) */
body.crt-enabled::before {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  z-index: 999;
  pointer-events: none;
}

/* 頂部快捷選單條 (高清晰版) */
.top-menu-bar {
  width: 100%;
  max-width: 860px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  margin-bottom: 12px;
  background: rgba(18, 24, 36, 0.9);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.top-menu-title {
  font-size: 15px;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-menu-btns {
  display: flex;
  gap: 10px;
}

.menu-btn {
  background: #253042;
  color: #e2e8f0;
  border: 1px solid #4a5c78;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
}

.menu-btn:hover {
  background: #3b4d6a;
  color: #fff;
  border-color: #fbbf24;
}

/* ================= 高解析機台總容器 (全面加大至 860px) ================= */
.cabinet-wrapper {
  position: relative;
  display: flex;
  max-width: 860px;
  width: 100%;
}

/* 左側板：揚聲器喇叭網與金屬門鉸鏈 */
.cabinet-left-flange {
  width: 42px;
  background: linear-gradient(90deg, #c7d2de 0%, #e2eaf2 70%, #b8c6d4 100%);
  border-top-left-radius: 20px;
  border-bottom-left-radius: 16px;
  border: 4px solid #8e9cae;
  border-right: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 32px;
  box-shadow: -10px 12px 30px rgba(0,0,0,0.65);
  position: relative;
}

.speaker-grill {
  width: 26px;
  height: 80px;
  background: radial-gradient(circle, #2d3748 2px, transparent 2.5px);
  background-size: 6px 6px;
  border-radius: 13px;
  border: 1.5px solid #64748b;
  box-shadow: inset 0 0 4px #000;
}

.metal-hinge {
  position: absolute;
  width: 12px;
  height: 44px;
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 50%, #475569 100%);
  border: 1.5px solid #334155;
  border-radius: 3px;
  left: 8px;
  box-shadow: 2px 3px 4px rgba(0,0,0,0.5);
}
.hinge-top { top: 80px; }
.hinge-bottom { bottom: 220px; }

/* 正面機台主體 (高質感厚實框體) */
.cabinet-front {
  flex: 1;
  background: linear-gradient(180deg, #ffffff 0%, #ebf1f6 50%, #d8e2eb 100%);
  border: 5px solid #a4b3c2;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 16px;
  box-shadow: 
    0 25px 50px rgba(0,0,0,0.8),
    inset 0 3px 5px #ffffff,
    inset -3px 0 5px rgba(0,0,0,0.15);
  padding: 16px 16px 24px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 鍍鉻六角螺栓 (立體浮雕感) */
.panel-bolt {
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0%, #cbd5e1 45%, #64748b 100%);
  border: 1.5px solid #334155;
  box-shadow: inset 0 0 2px #000, 0 2px 4px rgba(0,0,0,0.5);
  z-index: 30;
}
.panel-bolt::after {
  content: "";
  position: absolute;
  top: 6px; left: 2px;
  width: 9px; height: 2px;
  background: #1e293b;
}
.bolt-top-center { top: 12px; left: 44%; }
.bolt-left-top { top: 12px; left: 16px; }
.bolt-left-mid { top: 38%; left: 16px; }
.bolt-left-bot { top: 58%; left: 16px; }
.bolt-mid-bot { top: 58%; left: 44%; }
.bolt-right-bot { top: 58%; right: 110px; }

/* ================= 上半部：主顯示框 + 右側投幣器 ================= */
.upper-row-layout {
  display: flex;
  gap: 14px;
  width: 100%;
}

/* 主遊戲玻璃框 */
.glass-display-frame {
  flex: 1;
  background: #090b10;
  border: 4px solid #1e2333;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 25px rgba(0,0,0,0.98), 0 4px 8px rgba(0,0,0,0.4);
  position: relative;
}

/* 頂部斜框金屬銘板：BONUS-WIN 與 CREDIT (大幅提高數字字體) */
.top-score-strip {
  display: flex;
  justify-content: space-between;
  padding: 4px 14px;
  margin-bottom: 8px;
  z-index: 10;
}

.score-plaque {
  background: linear-gradient(180deg, #1f0407 0%, #080102 100%);
  border: 3px solid #d97706;
  border-radius: 8px;
  padding: 4px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.5), inset 0 0 8px #000;
  min-width: 125px;
}

.score-plaque-title {
  font-size: 13px;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 2px;
  line-height: 1.2;
}

.plaque-led-num {
  font-family: 'Courier New', Courier, monospace;
  font-size: 34px;
  font-weight: 900;
  color: #ff1122;
  text-shadow: 0 0 5px #ff5566, 0 0 15px #ff0022;
  line-height: 1;
  letter-spacing: 2px;
}

/* ================= 24 格跑馬燈盤面 (全面放大，單格 64px 以上) ================= */
.classic-board-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, minmax(64px, 1fr));
  gap: 4px;
  background: #040508;
  padding: 6px;
  border: 3px solid #232a3a;
  border-radius: 8px;
  position: relative;
}

/* 24 個格子 (超高清晰度、極細描邊、純白無雜質襯底) */
.arcade-tile {
  background: #ffffff;
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 2px;
  box-shadow: inset 0 1px 2px #fff, 0 2px 4px rgba(0,0,0,0.35);
  transition: all 0.08s ease;
  overflow: hidden;
}

/* 內側立體紅色跑馬燈珠 (更醒目、更大顆) */
.tile-inner-bulb {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #50070d;
  border: 1.5px solid #250205;
  box-shadow: inset 0 0 3px #000;
  z-index: 8;
  transition: all 0.08s ease;
}

.bulb-pos-top { bottom: -6px; left: 50%; transform: translateX(-50%); }
.bulb-pos-right { left: -6px; top: 50%; transform: translateY(-50%); }
.bulb-pos-bottom { top: -6px; left: 50%; transform: translateX(-50%); }
.bulb-pos-left { right: -6px; top: 50%; transform: translateY(-50%); }

/* 圖案 SVG 容器 (放大至 46px，超高解析) */
.arcade-tile .tile-svg-content {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

/* 格子底部的清晰倍率徽章 (讓玩家一眼看懂大77與小77等倍數) */
.tile-rate-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  font-weight: 900;
  padding: 0 3px;
  border-radius: 3px;
  line-height: 1.2;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.badge-big {
  background: #b91c1c !important;
  color: #fef08a !important;
  border-color: #f59e0b !important;
  font-weight: 900;
}

.badge-small {
  background: #1e3a8a !important;
  color: #93c5fd !important;
}

/* ONCE MORE 格子特化 (超粗大字體) */
.tile-oncemore {
  background: linear-gradient(180deg, #fff 0%, #fee2e2 100%) !important;
}
.tile-oncemore .oncemore-text {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #dc2626;
  text-align: center;
  line-height: 1.05;
  letter-spacing: 0.5px;
}

/* 跑馬燈點亮激活狀態 (極致強烈金黃耀斑) */
.arcade-tile.active {
  background: radial-gradient(circle, #ffffcc 10%, #ffeb3b 60%, #f59e0b 100%) !important;
  border-color: #ef4444 !important;
  box-shadow: 
    0 0 15px #ffffff,
    0 0 30px #ffea00,
    0 0 45px #f97316,
    inset 0 0 10px #ffffff !important;
  transform: scale(1.1);
  z-index: 20;
}

.arcade-tile.active .tile-inner-bulb {
  background: #ffff55;
  border-color: #fff;
  box-shadow: 0 0 10px #fff, 0 0 20px #ff0022;
}

/* 中獎閃爍 */
.arcade-tile.bonus-strobe {
  animation: tile-strobe 0.25s infinite alternate;
}

@keyframes tile-strobe {
  0% { background: #ff0055; box-shadow: 0 0 20px #ff0055; }
  100% { background: #ffea00; box-shadow: 0 0 30px #ffea00, 0 0 45px #f97316; }
}

/* ================= 盤面中央：鑽戒瑪利歐與吃驚烏龜 (高解析放大) ================= */
.mario-art-center {
  grid-column: 2 / 7;
  grid-row: 2 / 7;
  background: radial-gradient(circle at 50% 40%, #38bdf8 0%, #0284c7 60%, #0369a1 100%);
  border: 3px solid #fbbf24;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.6);
}

/* 頂部標題「小瑪俐」 (超大 3D 泡泡字) */
.mario-logo-text {
  font-size: 30px;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 
    -2.5px -2.5px 0 #fff,
    2.5px -2.5px 0 #fff,
    -2.5px 2.5px 0 #fff,
    2.5px 2.5px 0 #fff,
    0 4px 6px rgba(0,0,0,0.8);
  letter-spacing: 6px;
  z-index: 5;
  margin-top: 2px;
}

/* 角色舞台 (大幅加高至 140px) */
.art-actors-box {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  width: 100%;
  height: 140px;
  z-index: 5;
  position: relative;
}

.actor-koopa {
  width: 105px;
  height: 130px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

.actor-mario-ring {
  width: 125px;
  height: 138px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

/* 中央紅光 7段 比倍數字顯示盒 (放大) */
.center-double-digit-box {
  position: absolute;
  bottom: 8px;
  background: #180204;
  border: 3px solid #dc2626;
  border-radius: 6px;
  padding: 2px 18px;
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.8), inset 0 0 8px #000;
  z-index: 10;
}

.double-digit-num {
  font-family: 'Courier New', Courier, monospace;
  font-size: 34px;
  font-weight: 900;
  color: #ff1122;
  text-shadow: 0 0 5px #ff5566, 0 0 15px #ff0022;
  line-height: 1;
}

/* ================= 螢幕下方 8 色倍率排柱 (超清晰放大) ================= */
.bottom-odds-rack {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-top: 8px;
  background: #000;
  padding: 4px;
  border-radius: 6px;
  border: 2px solid #334155;
}

.odds-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
  border: 1.5px solid #450a0a;
}

/* 頂部倍數標籤 (字體放大至 14px) */
.odds-header-badge {
  width: 100%;
  text-align: center;
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 14px;
  font-weight: 900;
  padding: 2px 0;
  line-height: 1.1;
  background: #7f1d1d;
  color: #fef08a;
  border-bottom: 1.5px solid #991b1b;
}

.odds-icon-area {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 0;
}

/* 紅底 7 段數碼管 (放大至 20px) */
.odds-meter-digit {
  width: 100%;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: 20px;
  font-weight: 900;
  color: #ff1122;
  text-shadow: 0 0 5px #ff4455;
  background: #220306;
  padding: 2px 0;
  border-top: 1.5px solid #450a0a;
}

/* ================= 右側金屬投幣器 (放大版) ================= */
.metal-coin-slot-module {
  width: 96px;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 50%, #94a3b8 100%);
  border: 3px solid #64748b;
  border-radius: 8px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 
    inset 0 1px 2px #fff,
    inset 0 -2px 4px #334155,
    0 5px 12px rgba(0,0,0,0.5);
  cursor: pointer;
  position: relative;
  transition: filter 0.15s;
}

.metal-coin-slot-module:hover { filter: brightness(1.08); }
.metal-coin-slot-module:active { transform: scale(0.98); }

.coin-funnel-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffffff 0%, #cbd5e1 55%, #475569 100%);
  border: 2.5px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.6), inset 0 1px 2px #fff;
}

.coin-inlet-hole {
  width: 26px;
  height: 4.5px;
  background: #000;
  border-radius: 2px;
}

.coin-sticker-blue {
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #7dd3fc;
  margin: 8px 0;
  text-align: center;
  line-height: 1.2;
}

.coin-track-vertical {
  width: 26px;
  height: 55px;
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}

.track-slit { width: 4px; height: 26px; background: #000; }
.track-reject-lever { width: 14px; height: 8px; background: #ea580c; border-radius: 2px; }

.coin-mini-cup {
  width: 54px;
  height: 28px;
  background: linear-gradient(180deg, #1e293b 0%, #475569 100%);
  border: 2px solid #64748b;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #cbd5e1;
  font-weight: bold;
}

/* ================= 下半部：黑色斜面雙組按鍵操作台 (超清晰放大) ================= */
.deck-slanted-base {
  width: 100%;
  background: linear-gradient(180deg, #1e2430 0%, #101318 100%);
  border: 4px solid #374151;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.15), 0 8px 18px rgba(0,0,0,0.8);
  margin-top: 12px;
}

.deck-gold-green-frame {
  border: 2.5px solid var(--green-frame);
  box-shadow: 0 0 0 1.5px #fbbf24, inset 0 0 0 1.5px #fbbf24;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deck-white-key {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 65%, #cbd5e1 100%);
  border: 1.5px solid #94a3b8;
  border-bottom: 4px solid #64748b;
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px 3px;
  color: #0f172a;
  font-weight: 900;
  font-family: inherit;
  transition: all 0.06s ease;
}

.deck-white-key:hover:not(:disabled) { filter: brightness(1.08); }
.deck-white-key:active:not(:disabled), .deck-white-key.pressed {
  transform: translateY(3px);
  border-bottom-width: 1px;
}
.deck-white-key:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.8); }

.deck-upper-keys {
  display: flex;
  justify-content: space-between;
  gap: 7px;
}

.deck-upper-keys .deck-white-key {
  flex: 1;
  font-size: 13px;
  padding: 10px 4px;
}

.key-start-mario {
  flex: 1.4 !important;
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 70%, #15803d 100%) !important;
  color: #fff !important;
  border-color: #86efac !important;
  border-bottom-color: #14532d !important;
  font-size: 15px !important;
}

.key-start-mario.pulse-glow {
  animation: start-pulse-mario 1s infinite alternate;
}

@keyframes start-pulse-mario {
  0% { box-shadow: 0 3px 6px rgba(0,0,0,0.6), 0 0 8px #22c55e; }
  100% { box-shadow: 0 3px 6px rgba(0,0,0,0.6), 0 0 24px #4ade80, 0 0 35px #22c55e; }
}

.deck-lower-bets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.deck-lower-bets .deck-white-key {
  padding: 6px 2px;
}

.deck-white-key.key-active-pressed {
  transform: translateY(3px) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 2px 5px rgba(0,0,0,0.3) !important;
  background: linear-gradient(180deg, #fef08a 0%, #facc15 100%) !important;
  border-color: #d97706 !important;
}

.deck-key-badge {
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: #1e3a8a;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.1;
  margin-bottom: 2px;
  box-shadow: inset 0 1px 0 #fff;
}

.key-active-pressed .deck-key-badge {
  background: #b45309 !important;
  color: #fff !important;
  border-color: #78350f !important;
}

.key-hint {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #ca8a04;
  line-height: 1.2;
  margin-top: 2px;
}

.key-start-mario .key-hint {
  color: #dcfce7 !important;
}

.deck-key-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-key-label { font-size: 11px; line-height: 1.1; color: #1e293b; }
.deck-key-rate { font-size: 10px; font-weight: 900; color: #b91c1c; }

/* ================= 底部大型退幣斗 ================= */
.bottom-coin-hopper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.hopper-frame {
  width: 250px;
  background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 100%);
  border: 3.5px solid #94a3b8;
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.65), inset 0 2px 4px #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.hopper-frame:hover {
  transform: translateY(-2px);
}

.hopper-drop-chute {
  width: 75px;
  height: 24px;
  background: #000;
  border: 2px solid #334155;
  border-radius: 5px;
  margin-bottom: 3px;
}

.hopper-scoop-tray {
  width: 210px;
  height: 44px;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 60%, #cbd5e1 100%);
  border: 3.5px solid #94a3b8;
  border-top: none;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: 0 10px 18px rgba(0,0,0,0.7), inset 0 5px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #64748b;
  letter-spacing: 3px;
}

.coin-drop-anim {
  animation: coin-jiggle 0.4s ease-out;
}

@keyframes coin-jiggle {
  0% { transform: translateY(-5px) scale(0.98); }
  50% { transform: translateY(3px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

.hopper-ticker {
  font-size: 13px;
  font-weight: bold;
  color: #fbbf24;
  text-align: center;
  margin-top: 8px;
  min-height: 20px;
}

/* ================= 說明與設定彈窗 ================= */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

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

.modal-card {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #d97706;
  border-radius: 12px;
  padding: 18px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  color: #e2e8f0;
  box-shadow: 0 20px 40px rgba(0,0,0,0.9), 0 0 25px rgba(217, 119, 6, 0.4);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid #334155;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-head h3 {
  color: #fbbf24;
  font-size: 16px;
  margin: 0;
  font-weight: 900;
}

.modal-close {
  background: #334155;
  border: 1px solid #64748b;
  color: #cbd5e1;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: #ef4444;
  color: #fff;
  border-color: #dc2626;
}

.rule-grid-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.rule-grid-table th, .rule-grid-table td {
  border: 1px solid #334155;
  padding: 6px 8px;
  text-align: left;
}

.rule-grid-table th {
  background: #090d16;
  color: #fbbf24;
  font-weight: 900;
}

.rule-grid-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

.shortcut-pill {
  display: inline-block;
  background: #1e293b;
  color: #fef08a;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 900;
  font-family: monospace;
  border: 1px solid #475569;
}

.badge-mini {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: #fef08a;
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 3px;
  border: 1px solid rgba(254, 240, 138, 0.35);
}

.coin-key-hint {
  display: inline-block;
  font-size: 9px;
  font-weight: bold;
  color: #fef08a;
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 3px;
  border: 1px solid rgba(254, 240, 138, 0.4);
}

/* ================= 平板與中型螢幕適配 (max-width: 820px) ================= */
@media (max-width: 820px) {
  .cabinet-wrapper { max-width: 100%; }
  .classic-board-grid {
    grid-template-rows: repeat(7, minmax(48px, 1fr));
    gap: 3px;
  }
  .arcade-tile .tile-svg-content { width: 34px; height: 34px; }
  .art-actors-box { height: 110px; }
  .actor-koopa { width: 80px; height: 100px; }
  .actor-mario-ring { width: 95px; height: 110px; }
  .mario-logo-text { font-size: 24px; }
  .plaque-led-num { font-size: 28px; }
  .top-menu-title { font-size: 13px; }
  .deck-upper-keys .deck-white-key { font-size: 12px; padding: 8px 2px; }
  .deck-key-label { font-size: 10px; }
}

/* ================= 手機螢幕極致適配 (max-width: 640px) ================= */
@media (max-width: 640px) {
  html, body {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    overflow: hidden !important;
  }

  body {
    padding: 3px 3px 4px 3px;
    padding-top: max(3px, env(safe-area-inset-top));
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    padding-left: max(3px, env(safe-area-inset-left));
    padding-right: max(3px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* 頂部選單條：超緊湊單行，不佔垂直空間 */
  .top-menu-bar {
    max-width: 100%;
    width: 100%;
    padding: 2px 6px;
    margin-bottom: 2px;
    border-radius: 6px;
    gap: 4px;
    min-height: 24px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .top-menu-title {
    font-size: 12px;
    gap: 4px;
    letter-spacing: 0;
    white-space: nowrap;
  }
  .title-sub {
    display: none;
  }
  .top-menu-btns {
    gap: 3px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .menu-btn {
    padding: 2px 5px;
    font-size: 10px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.2;
  }
  .btn-text {
    display: none;
  }
  .badge-mini {
    display: none;
  }

  /* 機台總容器：彈性滿版適配，零滾動條 */
  .cabinet-wrapper {
    flex: 1;
    min-height: 0;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: hidden;
  }
  .cabinet-left-flange {
    display: none !important;
  }
  .cabinet-front {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    border-width: 2px;
    border-radius: 8px;
    padding: 3px 3px 4px 3px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.8);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
  }
  .panel-bolt {
    display: none;
  }

  /* 上半部：垂直排列，自適應拉伸佔滿剩餘高度 */
  .upper-row-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    overflow: hidden;
  }

  /* 主螢幕外框 */
  .glass-display-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 2px;
    border-width: 1.5px;
    border-radius: 6px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
  }

  /* 頂部得分/台數銘板 */
  .top-score-strip {
    padding: 1px 3px;
    margin-bottom: 2px;
    gap: 4px;
    flex-shrink: 0;
  }
  .score-plaque {
    flex: 1;
    min-width: 0;
    padding: 1px 4px;
    border-width: 1.5px;
    border-radius: 4px;
  }
  .score-plaque-title {
    font-size: 8.5px;
    letter-spacing: 0.5px;
    line-height: 1;
  }
  .plaque-led-num {
    font-size: 18px;
    letter-spacing: 1px;
    line-height: 1.1;
  }

  /* 7x7 跑馬燈外環盤面：自適應縱橫比，嚴格隨螢幕高度等比例彈性伸縮 */
  .classic-board-grid {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(7, minmax(0, 1fr));
    gap: 1.5px;
    padding: 1.5px;
    border-width: 1.5px;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .arcade-tile {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0.5px;
    border-width: 1px;
    border-radius: 3px;
    box-sizing: border-box;
  }
  .arcade-tile .tile-svg-content {
    width: 80%;
    height: 80%;
    max-width: 26px;
    max-height: 26px;
  }
  .tile-rate-badge {
    font-size: 7.5px;
    padding: 0 1px;
    bottom: 0px;
    right: 0px;
    line-height: 1;
    border-radius: 1.5px;
  }
  .tile-inner-bulb {
    width: 5px;
    height: 5px;
  }
  .bulb-pos-top { bottom: -2.5px; }
  .bulb-pos-right { left: -2.5px; }
  .bulb-pos-bottom { top: -2.5px; }
  .bulb-pos-left { right: -2.5px; }
  .tile-oncemore .oncemore-text {
    font-size: 8px;
    line-height: 1;
  }

  /* 中央瑪利歐與烏龜舞台 (5x5) */
  .mario-art-center {
    border-width: 1.5px;
    border-radius: 4px;
    padding: 1px;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
  }
  .mario-logo-text {
    font-size: 14px;
    letter-spacing: 1.5px;
    margin-top: 0;
    text-shadow:
      -1px -1px 0 #fff,
      1px -1px 0 #fff,
      -1px 1px 0 #fff,
      1px 1px 0 #fff,
      0 1px 3px rgba(0,0,0,0.8);
  }
  .art-actors-box {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding-bottom: 16px;
  }
  .actor-koopa {
    height: 80%;
    max-height: 58px;
    max-width: 48px;
    width: auto;
  }
  .actor-mario-ring {
    height: 85%;
    max-height: 64px;
    max-width: 55px;
    width: auto;
  }
  .center-double-digit-box {
    bottom: 1px;
    padding: 0 8px;
    border-width: 1.5px;
    border-radius: 3px;
  }
  .double-digit-num {
    font-size: 16px;
    line-height: 1;
  }

  /* 螢幕下方 8 色倍率排柱 */
  .bottom-odds-rack {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 1.5px;
    margin-top: 2px;
    padding: 1px;
    border-width: 1px;
    border-radius: 4px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .odds-column {
    border-radius: 2px;
    border-width: 0.5px;
    min-width: 0;
    overflow: hidden;
  }
  .odds-header-badge {
    font-size: 8.5px;
    padding: 0.5px 0;
    line-height: 1;
  }
  .odds-icon-area {
    width: 100%;
    height: 16px;
    padding: 0;
  }
  .odds-icon-area svg {
    width: 13px;
    height: 13px;
  }
  .odds-meter-digit {
    font-size: 12px;
    padding: 0.5px 0;
    line-height: 1;
  }

  /* 手機專屬：金屬投幣器橫向橫條 (點擊即投幣 +5 單位) */
  .metal-coin-slot-module {
    width: 100%;
    height: 28px;
    min-height: 28px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    gap: 6px;
    border-radius: 6px;
    border-width: 1.5px;
    background: linear-gradient(90deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 1px #fff;
    cursor: pointer;
    margin-top: 2px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .coin-funnel-circle {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-width: 1.5px;
  }
  .coin-inlet-hole {
    width: 12px;
    height: 2px;
  }
  .coin-sticker-blue {
    margin: 0;
    flex: 1;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 4px;
    text-align: center;
    border-radius: 3px;
    line-height: 1.1;
  }
  .coin-key-hint {
    display: none;
  }
  .coin-track-vertical {
    display: none;
  }
  .coin-mini-cup {
    width: auto;
    height: 20px;
    padding: 0 6px;
    font-size: 9.5px;
    flex-shrink: 0;
    border-radius: 3px;
  }

  /* 下半部：操作台 (固定高度，完全呈現在首頁下方，不用往下滑) */
  .deck-slanted-base {
    margin-top: 2px;
    padding: 3px 2px;
    border-width: 2px;
    border-radius: 6px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  .deck-gold-green-frame {
    padding: 2px;
    gap: 3px;
    border-width: 1.5px;
    border-radius: 5px;
    box-sizing: border-box;
  }

  /* 上排 6 個按鍵：2 行 x 3 列，精準高度適配 */
  .deck-upper-keys {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.5px;
    box-sizing: border-box;
  }
  .deck-upper-keys .deck-white-key {
    min-height: 32px;
    max-height: 35px;
    min-width: 0;
    padding: 2px 1px;
    font-size: 10.5px;
    border-radius: 4px;
    flex: initial;
    white-space: normal;
    text-align: center;
    line-height: 1.1;
    word-break: keep-all;
    box-sizing: border-box;
  }
  .deck-upper-keys .key-hint {
    display: none;
  }
  .key-start-mario {
    font-size: 11.5px !important;
    font-weight: 900 !important;
    flex: initial !important;
  }

  /* 下排 8 個押注鍵：維持 8 列與上方倍率管完美 1 對 1 對齊 */
  .deck-lower-bets {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 1.5px;
    box-sizing: border-box;
  }
  .deck-lower-bets .deck-white-key {
    padding: 1.5px 0.5px;
    min-width: 0;
    min-height: 38px;
    max-height: 44px;
    border-radius: 3px;
    overflow: hidden;
    box-sizing: border-box;
  }
  .deck-key-badge {
    font-size: 7px;
    padding: 0 1px;
    margin-bottom: 0.5px;
    line-height: 1;
  }
  .deck-key-icon {
    width: 16px;
    height: 16px;
  }
  .deck-key-icon svg {
    width: 14px;
    height: 14px;
  }
  .deck-key-label {
    font-size: 8px;
    line-height: 1;
    white-space: nowrap;
  }
  .deck-key-rate {
    font-size: 7px;
    line-height: 1;
    white-space: nowrap;
  }

  /* 手機版隱藏實體退幣斗以釋放垂直空間，完全無需向下滑動 */
  .bottom-coin-hopper {
    display: none !important;
  }

  .hopper-ticker {
    font-size: 9.5px;
    margin-top: 1px;
    min-height: 12px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
  }

  /* 彈窗在手機上的體驗優化 */
  .modal-card {
    padding: 12px;
    max-height: 90vh;
  }
  .modal-head h3 {
    font-size: 14px;
  }
  .rule-grid-table {
    font-size: 11px;
  }
  .rule-grid-table th, .rule-grid-table td {
    padding: 4px 6px;
  }
}

/* ================= 窄螢幕超極限適配 (max-width: 360px) ================= */
@media (max-width: 360px) {
  .top-menu-title { font-size: 11px; }
  .menu-btn { padding: 2px 4px; font-size: 9.5px; }
  .deck-upper-keys .deck-white-key { font-size: 10px; padding: 2px 1px; min-height: 30px; }
  .key-start-mario { font-size: 10.5px !important; }
  .deck-lower-bets .deck-white-key { min-height: 34px; max-height: 40px; }
  .deck-key-label { font-size: 7.5px; }
  .deck-key-rate { font-size: 6.5px; }
  .mario-logo-text { font-size: 13px; }
}

/* ================= 手機橫向螢幕適配 (landscape) ================= */
@media (max-height: 520px) and (orientation: landscape) {
  body {
    padding: 4px;
    justify-content: flex-start;
  }
  .top-menu-bar {
    padding: 3px 8px;
    margin-bottom: 4px;
    box-sizing: border-box;
  }
  .title-sub {
    display: none;
  }
  .badge-mini {
    display: none;
  }
  .cabinet-wrapper {
    max-width: 96vw;
  }
  .cabinet-left-flange {
    display: none;
  }
  .cabinet-front {
    padding: 4px;
  }
  .classic-board-grid {
    grid-template-rows: repeat(7, minmax(28px, 1fr));
  }
  .art-actors-box {
    height: 60px;
    padding-bottom: 16px;
  }
  .actor-koopa, .actor-mario-ring {
    max-height: 55px;
  }
  .deck-slanted-base {
    margin-top: 4px;
    padding: 4px;
  }
  .deck-upper-keys .deck-white-key {
    min-height: 34px;
    padding: 3px 1px;
    font-size: 11px;
  }
  .deck-lower-bets .deck-white-key {
    min-height: 44px;
  }
  .bottom-coin-hopper {
    display: none;
  }
}

/* ================= 下注浮動 +1 徽章特效 ================= */
.deck-white-key {
  position: relative;
}

.bet-float-badge {
  position: absolute;
  top: -8px;
  right: 6px;
  font-family: 'Arial Black', Impact, sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #fef08a;
  text-shadow: 0 0 3px #000, 0 0 8px #d97706;
  pointer-events: none;
  animation: bet-float-anim 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 100;
}

@keyframes bet-float-anim {
  0% { transform: translateY(0) scale(0.8); opacity: 1; }
  50% { transform: translateY(-16px) scale(1.2); opacity: 0.95; }
  100% { transform: translateY(-28px) scale(1); opacity: 0; }
}

/* ================= 數碼管跳注高光脈衝 ================= */
.odds-meter-digit.meter-pulse-active {
  animation: meter-glow-pulse 0.28s ease-out;
}

@keyframes meter-glow-pulse {
  0% {
    color: #ffffff;
    text-shadow: 0 0 10px #facc15, 0 0 20px #dc2626;
    background: #450a0a;
  }
  100% {
    color: #ff1122;
    text-shadow: 0 0 5px #ff4455;
    background: #220306;
  }
}

/* ================= 中央舞台大獎慶典星芒 ================= */
.mario-art-center.stage-grand-win {
  animation: stage-win-pulse 1.2s infinite alternate ease-in-out;
}

@keyframes stage-win-pulse {
  0% {
    box-shadow: inset 0 0 15px rgba(234, 179, 8, 0.4), 0 0 25px rgba(234, 179, 8, 0.6);
  }
  100% {
    box-shadow: inset 0 0 35px rgba(250, 204, 21, 0.8), 0 0 55px rgba(220, 38, 38, 0.8);
  }
}

.mario-stage-victory .actor-mario-ring {
  animation: mario-victory-bounce 0.6s infinite alternate ease-in-out;
}

@keyframes mario-victory-bounce {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-6px) rotate(-3deg); }
}

/* ================= PWA 安裝按鈕樣式 ================= */
.menu-btn-install {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%) !important;
  color: #fff !important;
  border-color: #fde68a !important;
  font-weight: 900 !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6) !important;
  animation: install-btn-pulse 2s infinite alternate ease-in-out;
}

@keyframes install-btn-pulse {
  0% { transform: scale(1); box-shadow: 0 0 6px #f59e0b; }
  100% { transform: scale(1.05); box-shadow: 0 0 14px #fbbf24; }
}
