/**
 * Plinko — 物理落珠台樣式
 * 設計風格：VIP 暗黑賭場金屬保險庫風格，Canvas 物理光效，彩虹漸層賠率槽位
 */

: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);
}

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

.plinko-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) {
  .plinko-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;
  }

  .plinko-board-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
  }

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

  .plinko-title-block {
    display: none; /* 手機端隱藏標題文字，釋放 100% 空間給釘盤動畫 */
  }

  .history-strip {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
  }

  .history-pill {
    font-size: 10px;
    padding: 2px 6px;
  }

  .canvas-container {
    flex: 1 1 auto;
    min-height: 180px;
    max-height: 48vh;
    border-radius: 8px;
  }

  .buckets-display {
    margin-top: 4px;
    gap: 2px;
  }

  .bucket-item {
    padding: 3px 0;
    font-size: 8.5px;
    border-radius: 3px;
  }

  .plinko-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);
  }

  .panel-section {
    gap: 4px;
  }

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

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

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

  .btn-step {
    width: 36px;
    height: 34px;
    font-size: 18px;
  }

  .bet-input {
    height: 34px;
    font-size: 14px;
  }

  .chip-row {
    gap: 4px;
  }

  .btn-chip {
    padding: 4px 2px;
    font-size: 11px;
  }

  /* 手機端：風險選擇與排數選擇並排成雙欄，節省整整一行高度！ */
  .mobile-controls-row {
    display: flex;
    gap: 8px;
    width: 100%;
  }

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

  .risk-tabs, .rows-tabs {
    gap: 3px;
  }

  .btn-risk, .btn-row {
    padding: 5px 0;
    font-size: 11px;
    text-align: center;
  }

  .action-btn-wrapper {
    display: flex;
    gap: 6px;
    margin-top: 2px;
  }

  .btn-drop {
    flex: 2;
    padding: 10px 0;
    font-size: 14px;
    border-radius: 8px;
  }

  .btn-auto-drop {
    flex: 1.2;
    padding: 10px 0;
    font-size: 11px;
    border-radius: 8px;
  }

  .fairness-badge {
    display: none; /* 手機端隱藏徽章，避免縱向溢出 */
  }
}

.mobile-controls-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: 13px;
  color: #e0a96d;
  font-weight: 700;
}

.hint-text {
  font-size: 11px;
  color: #888;
}

.rows-badge {
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #ffd32a;
  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);
}

/* 風險切換 (Low / Medium / High) */
.risk-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-risk {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #bdc3c7;
  border-radius: 8px;
  padding: 9px 0;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-risk[data-risk="LOW"].active {
  background: linear-gradient(135deg, #10ac84, #1dd1a1);
  border-color: #1dd1a1;
  color: #032b1f;
  box-shadow: 0 0 12px rgba(29, 209, 161, 0.4);
}

.btn-risk[data-risk="MEDIUM"].active {
  background: linear-gradient(135deg, #d35400, #e67e22);
  border-color: #f39c12;
  color: #fff;
  box-shadow: 0 0 12px rgba(243, 156, 18, 0.4);
}

.btn-risk[data-risk="HIGH"].active {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  border-color: #ff7675;
  color: #fff;
  box-shadow: 0 0 12px rgba(231, 76, 60, 0.5);
}

/* 排數切換 (8, 12, 16) */
.rows-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

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

.btn-row.active {
  background: linear-gradient(135deg, #d4af37, #f39c12);
  border-color: #ffd32a;
  color: #000;
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

/* 核心行動按鈕 */
.action-btn-wrapper {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-drop {
  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;
  background: linear-gradient(135deg, #eb2f06, #ff793f);
  color: #fff;
  box-shadow: 0 6px 20px rgba(235, 47, 6, 0.5);
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.btn-drop:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
  box-shadow: 0 8px 25px rgba(235, 47, 6, 0.7);
}

.btn-drop:active {
  transform: translateY(1px);
}

.btn-auto-drop {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1c40f;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-auto-drop:hover {
  background: rgba(241, 196, 15, 0.15);
  border-color: #f1c40f;
}

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

/* ==================== 右側 Plinko 畫布舞台 ==================== */
.plinko-board-area {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 18px 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: 12px;
}

.plinko-title-block {
  text-align: left;
}

.plinko-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;
}

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

/* 近期倍率歷史標籤 */
.history-strip {
  display: flex;
  gap: 6px;
  overflow-x: hidden;
}

.history-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 12px;
  animation: pillPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes pillPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Canvas 容器 */
.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 460px;
  background: radial-gradient(circle at 50% 30%, #170b05 0%, #060201 100%);
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9);
}

canvas#plinkoCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 底部倍率槽位指示條 */
.buckets-display {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  width: 100%;
  justify-content: center;
}

.bucket-item {
  flex: 1;
  border-radius: 6px;
  padding: 6px 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: #000;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.bucket-item.hit {
  transform: translateY(-4px) scale(1.15);
  filter: brightness(1.35);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.8);
  z-index: 10;
}

/* 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); }
}
