/**
 * Hi-Lo — 極速高低牌樣式
 */

: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;
  --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 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.game-switcher { display: flex; gap: 6px; overflow-x: auto; }
.switch-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  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: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.switch-tab:hover { background: rgba(212, 175, 55, 0.15); color: #fff; border-color: var(--gold-primary); }
.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: 8px; background: #e74c3c; color: #fff; padding: 1px 4px; border-radius: 6px; font-weight: 800; }

.header-right { display: flex; align-items: center; gap: 10px; }
.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;
}

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

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

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

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

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

  .status-badge {
    font-size: 11px;
    padding: 2px 10px;
  }

  .felt-table {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px 6px;
    gap: 8px;
    border-radius: 12px;
  }

  .poker-card {
    width: 90px;
    height: 126px;
    padding: 6px 8px;
    border-radius: 8px;
  }

  .card-rank { font-size: 16px; }
  .card-suit { font-size: 14px; }
  .card-big-suit { font-size: 34px; }

  .decision-controls {
    gap: 6px;
    width: 100%;
    max-width: 320px;
  }

  .btn-guess {
    padding: 6px 8px;
    border-radius: 8px;
  }

  .guess-dir { font-size: 12px; }
  .guess-mult { font-size: 13px; }
  .guess-chance { font-size: 9px; }

  .btn-skip {
    padding: 6px 6px;
    border-radius: 8px;
  }

  .skip-icon { font-size: 14px; }
  .skip-text { font-size: 9px; }

  .history-ladder-container {
    padding: 2px 0;
    margin-top: 2px;
  }

  .ladder-label {
    display: none;
  }

  .history-card-mini {
    width: 22px;
    height: 30px;
    font-size: 8px;
  }

  .hilo-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-hilo-row {
    display: flex;
    gap: 8px;
    width: 100%;
  }

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

  .mobile-hilo-row .stats-card {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
  }

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

  .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; /* 手機端隱藏籌碼列 */
  }

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

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

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

  .btn-start {
    flex: 1;
    height: 40px;
    font-size: 13px;
    border-radius: 8px;
  }

  .btn-cashout {
    flex: 1;
    height: 40px;
    font-size: 12px;
    border-radius: 8px;
  }

  .fairness-badge {
    display: none;
  }
}

.mobile-hilo-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; }

.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;
  cursor: pointer;
}

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

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

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

.stats-card {
  background: rgba(0, 0, 0, 0.55);
  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; color: #fff; }
.mult-val { color: #ffd32a; }
.stat-divider { width: 1px; height: 28px; background: rgba(255, 255, 255, 0.1); }

.action-btn-wrapper { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.btn-start {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #10ac84, #1dd1a1);
  color: #02291d;
  box-shadow: 0 6px 20px rgba(29, 209, 161, 0.4);
  transition: all 0.2s;
}

.btn-start:hover { filter: brightness(1.1); transform: translateY(-2px); }

.btn-cashout {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #f39c12, #f1c40f);
  color: #2b1800;
  box-shadow: 0 6px 20px rgba(243, 156, 18, 0.5);
  transition: all 0.2s;
}

.btn-cashout:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; filter: none; transform: none; }
.btn-cashout:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-2px); }

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

/* ==================== 右側賭桌舞台 ==================== */
.hilo-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: 14px; }
.hilo-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;
}
.hilo-sub { font-size: 9px; letter-spacing: 2px; color: #e0a96d; font-weight: 800; }

.status-badge {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  color: #bdc3c7;
}

/* 綠毛氈賭桌 */
.felt-table {
  flex: 1;
  min-height: 380px;
  background: radial-gradient(circle at 50% 40%, #0d3826 0%, #061f14 70%, #020d08 100%);
  border: 2px solid rgba(212, 175, 55, 0.4);
  border-radius: 16px;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  position: relative;
}

/* 撲克牌實體卡牌展示 */
.card-stage-container {
  perspective: 800px;
}

.poker-card {
  width: 140px;
  height: 200px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px;
  position: relative;
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.poker-card.deal-anim {
  animation: dealFly 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes dealFly {
  0% { transform: translateY(-50px) scale(0.7) rotate(-15deg); opacity: 0; }
  100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

.poker-card.red { color: #d63031; }
.poker-card.black { color: #2d3436; }

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-rank { font-family: var(--font-sans); font-size: 24px; font-weight: 900; }
.card-suit { font-size: 18px; }

.card-corner.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 54px;
}

/* 決策按鈕列 */
.decision-controls {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 480px;
  justify-content: center;
}

.btn-guess {
  flex: 1;
  height: 60px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.btn-guess:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-higher {
  background: linear-gradient(135deg, #0984e3, #74b9ff);
  color: #fff;
  box-shadow: 0 6px 18px rgba(9, 132, 227, 0.4);
}

.btn-higher:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(9, 132, 227, 0.6); }

.btn-lower {
  background: linear-gradient(135deg, #d63031, #ff7675);
  color: #fff;
  box-shadow: 0 6px 18px rgba(214, 48, 49, 0.4);
}

.btn-lower:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(214, 48, 49, 0.6); }

.guess-dir { font-size: 14px; font-weight: 900; letter-spacing: 0.5px; }
.guess-info { display: flex; gap: 8px; font-size: 11px; font-family: var(--font-mono); }
.guess-mult { font-weight: 900; color: #ffd32a; }
.guess-chance { opacity: 0.9; }

.btn-skip {
  width: 74px;
  height: 60px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #bdc3c7;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 800;
  transition: all 0.2s;
}

.btn-skip:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-skip:hover:not(:disabled) { background: rgba(212, 175, 55, 0.2); border-color: var(--gold-primary); color: #fff; }

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

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

.mini-card {
  background: #fff;
  border-radius: 4px;
  padding: 3px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  gap: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.mini-card.red { color: #d63031; }
.mini-card.black { color: #2d3436; }

/* 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); }
.toast-info { background: #2980b9; color: #fff; }
.toast-success { background: #27ae60; color: #fff; }
.toast-error { background: #c0392b; color: #fff; }
