/**
 * Mines — 5x5 鑽石排雷極限博弈樣式
 * 設計風格：VIP 暗黑賭場金屬保險庫風格，3D 透視翻轉卡牌，微發光金剛石與金屬炸彈
 */

:root {
  --bg-dark: #0a0604;
  --bg-card: rgba(22, 13, 8, 0.88);
  --gold-primary: #d4af37;
  --gold-glow: #f39c12;
  --gold-light: #ffd32a;
  --red-accent: #e74c3c;
  --green-win: #2ecc71;
  --cyan-gem: #00d2d3;
  --border-gold: rgba(212, 175, 55, 0.35);
  --font-serif: 'Cinzel', serif;
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: #0b0705;
  background-image: 
    linear-gradient(180deg, rgba(8, 5, 3, 0.85) 0%, rgba(14, 9, 6, 0.88) 50%, rgba(6, 4, 2, 0.95) 100%),
    radial-gradient(circle at 50% 20%, rgba(212, 175, 55, 0.08) 0%, transparent 70%),
    url('/assets/casino_bg.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  font-family: var(--font-sans);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== 頂部全域導航 ==================== */
.app-header {
  height: 58px;
  background: rgba(10, 5, 2, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.game-switcher {
  display: flex;
  gap: 8px;
}

.switch-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #bdc3c7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.25s ease;
}

.switch-tab:hover {
  background: rgba(212, 175, 55, 0.15);
  color: #fff;
  border-color: var(--gold-primary);
  transform: translateY(-1px);
}

.switch-tab.active {
  background: linear-gradient(135deg, #d4af37, #f39c12);
  color: #000;
  border-color: #ffd32a;
  box-shadow: 0 0 15px rgba(243, 156, 18, 0.5);
}

.badge-hot {
  font-size: 9px;
  background: #e74c3c;
  color: #fff;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wallet-pill {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.5);
  padding: 5px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wallet-label {
  font-size: 11px;
  color: #bdc3c7;
}

.wallet-amount {
  font-family: var(--font-mono);
  font-weight: 800;
  color: #ffd32a;
  font-size: 15px;
}

.wallet-currency {
  font-size: 11px;
  color: #e0a96d;
  font-weight: 700;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--gold-primary);
}

/* ==================== 舞台佈局 ==================== */
.mines-stage {
  flex: 1;
  display: flex;
  max-width: 1160px;
  width: 100%;
  margin: 18px auto;
  padding: 0 16px;
  gap: 20px;
  align-items: stretch;
}

.mines-sidebar {
  width: 320px;
  flex: 0 0 320px;
  background: rgba(18, 12, 9, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

@media (max-width: 860px) {
  .mines-stage {
    flex-direction: column;
    margin: 4px auto 0;
    padding: 4px 8px 8px;
    gap: 6px;
    height: calc(100dvh - 56px);
    max-height: calc(100dvh - 56px);
    overflow: hidden;
    box-sizing: border-box;
  }

  .mines-board-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
  }

  .board-top-bar {
    width: 100%;
    margin-bottom: 2px;
  }

  .mines-title-block {
    display: none; /* 手機端隱藏大標題，釋放空間 */
  }

  .grid-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mines-grid {
    width: min(80vw, 40vh);
    max-width: 310px;
    gap: 6px;
    aspect-ratio: 1 / 1;
  }

  .mine-tile {
    border-radius: 8px;
  }

  .tile-icon {
    font-size: 22px;
  }

  .mines-sidebar {
    flex: 0 0 auto;
    width: 100%;
    background: rgba(18, 12, 9, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 12px;
    padding: 8px 10px 10px;
    gap: 6px;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75);
  }

  /* 手機端並排下注與地雷選擇 */
  .mobile-mines-row {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .mobile-mines-row .panel-section {
    flex: 1;
    min-width: 0;
  }

  .panel-section {
    gap: 3px;
  }

  .section-label {
    font-size: 11px;
  }

  .section-label .hint-text {
    font-size: 10px;
  }

  .bet-input-row {
    gap: 4px;
  }

  .btn-step {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .bet-input {
    height: 32px;
    font-size: 13px;
  }

  .chip-row {
    display: none; /* 手機端隱藏冗長籌碼列，改由 +/- 或直接輸入 */
  }

  .mines-quick-select {
    gap: 3px;
  }

  .btn-mine-quick {
    padding: 6px 0;
    font-size: 11px;
  }

  .mines-slider, .slider-bounds {
    display: none; /* 手機端隱藏滑桿，5 個快捷鈕已覆蓋極低至極限 */
  }

  .stats-card {
    padding: 5px 12px;
    gap: 12px;
  }

  .stat-label {
    font-size: 8.5px;
  }

  .stat-val {
    font-size: 14px;
  }

  .btn-main-action {
    padding: 11px 0;
    font-size: 14px;
    border-radius: 8px;
  }

  .fairness-badge {
    display: none;
  }
}

.mobile-mines-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #f1c40f;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.hint-text {
  font-size: 11px;
  color: #bdc3c7;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.mines-badge {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #ff7675;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 800;
}

/* 下注步進列 */
.bet-input-row {
  display: flex;
  gap: 6px;
}

.btn-step {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-step:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-primary);
}

.bet-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  color: #ffd32a;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.bet-input:focus {
  border-color: #ffd32a;
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

/* 快捷籌碼 */
.chip-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.btn-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ccc;
  border-radius: 6px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-chip:hover {
  background: rgba(212, 175, 55, 0.2);
  color: #fff;
  border-color: var(--gold-primary);
}

/* 地雷快選 */
.mines-quick-select {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.btn-mine-quick {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #bdc3c7;
  border-radius: 8px;
  padding: 7px 0;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mine-quick:hover {
  border-color: var(--red-accent);
  color: #fff;
}

.btn-mine-quick.active {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  border-color: #ff7675;
  color: #fff;
  box-shadow: 0 0 12px rgba(231, 76, 60, 0.5);
}

.mines-slider {
  width: 100%;
  accent-color: var(--red-accent);
  cursor: pointer;
}

.slider-bounds {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #777;
}

/* 賠率卡 */
.stats-card {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-label {
  font-size: 11px;
  color: #888;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
}

.mult-val {
  color: #ffd32a;
}

.next-val {
  color: var(--cyan-gem);
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
}

/* 核心行動按鈕 */
.action-btn-wrapper {
  margin-top: auto;
}

.btn-main-action {
  width: 100%;
  height: 52px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  letter-spacing: 0.5px;
}

/* 下注狀態按鈕 (綠金漸層) */
.btn-main-action.btn-bet {
  background: linear-gradient(135deg, #10ac84, #1dd1a1);
  color: #012b1e;
  box-shadow: 0 6px 20px rgba(29, 209, 161, 0.4);
}

.btn-main-action.btn-bet:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(29, 209, 161, 0.6);
  filter: brightness(1.1);
}

/* 提款逃頂狀態按鈕 (閃爍金黃) */
.btn-main-action.btn-cashout {
  background: linear-gradient(135deg, #f39c12, #f1c40f);
  color: #2c1b01;
  box-shadow: 0 6px 22px rgba(243, 156, 18, 0.6);
  animation: cashoutPulse 1.2s infinite alternate;
}

@keyframes cashoutPulse {
  0% { filter: brightness(1); box-shadow: 0 6px 20px rgba(243, 156, 18, 0.5); }
  100% { filter: brightness(1.18); box-shadow: 0 8px 30px rgba(243, 156, 18, 0.9); }
}

.btn-main-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  animation: none !important;
}

.fairness-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  color: #888;
  letter-spacing: 0.5px;
}

/* ==================== 右側 5x5 網格棋盤 ==================== */
.mines-board-area {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.board-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.info-pill {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-green {
  width: 8px;
  height: 8px;
  background: var(--green-win);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green-win);
}

.board-title {
  text-align: center;
}

.mines-h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(180deg, #ffffff, #ffd32a 50%, #d4af37 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mines-sub {
  font-size: 9px;
  letter-spacing: 2px;
  color: #e0a96d;
  font-weight: 800;
}

/* 5x5 矩陣容器 */
.grid-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
}

.mines-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  perspective: 900px;
}

/* 每一格 3D 翻轉保險箱卡牌 */
.mine-tile {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mine-tile:hover:not(.revealed):not(.disabled) {
  transform: translateY(-3px) scale(1.03);
}

.mine-tile.revealed {
  transform: rotateY(180deg);
  cursor: default;
}

/* 卡牌正面 (未翻開的保險庫門) */
.tile-front, .tile-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-front {
  background: linear-gradient(145deg, #2b170e 0%, #150904 55%, #080302 100%);
  border: 1px solid rgba(212, 175, 55, 0.45);
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.2),
    inset 0 -2px 4px rgba(0, 0, 0, 0.8),
    0 4px 10px rgba(0, 0, 0, 0.6);
}

/* 保險箱中心的裝飾紋樣 */
.tile-front::after {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #f39c12 20%, #784212 70%, #1b0a03 100%);
  border: 1px solid rgba(255, 211, 42, 0.5);
  box-shadow: 0 0 8px rgba(243, 156, 18, 0.5);
  transition: all 0.2s;
}

.mine-tile:hover:not(.revealed):not(.disabled) .tile-front::after {
  box-shadow: 0 0 15px rgba(255, 211, 42, 0.9);
  transform: scale(1.15);
}

/* 卡牌背面 (翻開後的結果) */
.tile-back {
  transform: rotateY(180deg);
  background: #0d0603;
  border: 1px solid rgba(212, 175, 55, 0.3);
  font-size: 32px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
}

/* 翻開是鑽石 */
.tile-back.diamond {
  background: radial-gradient(circle, rgba(0, 210, 211, 0.25) 0%, #0d0603 70%);
  border-color: rgba(0, 210, 211, 0.6);
  box-shadow: 0 0 18px rgba(0, 210, 211, 0.4);
}

.diamond-sparkle {
  animation: gemFloat 1.2s ease-in-out infinite alternate;
  display: inline-block;
  filter: drop-shadow(0 0 8px rgba(0, 210, 211, 0.8));
}

@keyframes gemFloat {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.12); }
}

/* 翻開是炸彈 (踩雷爆炸) */
.tile-back.mine {
  background: radial-gradient(circle, rgba(231, 76, 60, 0.4) 0%, #1c0502 70%);
  border-color: #e74c3c;
  box-shadow: 0 0 25px rgba(231, 76, 60, 0.7);
  animation: mineShake 0.4s ease;
}

@keyframes mineShake {
  0%, 100% { transform: rotateY(180deg) translate(0, 0); }
  25% { transform: rotateY(180deg) translate(-4px, 3px); }
  50% { transform: rotateY(180deg) translate(4px, -3px); }
  75% { transform: rotateY(180deg) translate(-3px, -2px); }
}

/* 結算後公開的非主動翻開格子 (半透明顯示) */
.tile-back.revealed-ambient {
  opacity: 0.55;
  filter: grayscale(0.2);
}

/* 提款彈窗 (Cashout Banner) */
.cashout-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  background: rgba(10, 4, 1, 0.96);
  border: 2px solid #ffd32a;
  border-radius: 16px;
  padding: 24px 36px;
  box-shadow: 0 0 40px rgba(243, 156, 18, 0.8);
  text-align: center;
  transition: all 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 50;
}

.cashout-banner.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.banner-title {
  font-size: 15px;
  color: #ffd32a;
  font-weight: 800;
  margin-bottom: 6px;
}

.banner-mult {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 15px rgba(255, 211, 42, 0.9);
}

.banner-win {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--green-win);
  font-weight: 800;
  margin-top: 4px;
}

/* 底部歷史記錄 */
.history-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #888;
}

.history-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.chip-mult {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
}

.chip-mult.win {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green-win);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.chip-mult.bust {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red-accent);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Toast 提示 */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s ease;
}

.toast-info { background: #2980b9; color: #fff; }
.toast-success { background: #27ae60; color: #fff; }
.toast-error { background: #c0392b; color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
