/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

#app {
  max-width: 700px;
  margin: 0 auto;
  padding: 12px;
}

.screen { }
.hidden { display: none !important; }

h1 { font-size: 18px; margin-bottom: 4px; }
h2 { font-size: 16px; margin-bottom: 8px; }

.subtitle { font-size: 12px; color: #999; margin-bottom: 8px; }

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.app-header .header-text h1 { margin-bottom: 0; }

.back-btn {
  padding: 6px 12px;
  background: #2a2a4a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
}

.back-btn:hover { background: #3a3a5a; }

.settings-btn {
  float: right;
  padding: 4px 10px;
  background: #2a2a4a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #999;
  font-size: 12px;
  cursor: pointer;
}

.settings-btn:hover { color: #fff; }

/* ===== MODE CARDS (Menu) ===== */
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.mode-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.mode-card:hover { background: #3a3a5a; border-color: #4caf50; }

.mode-stat {
  font-size: 12px;
  color: #4caf50;
  background: #1a1a2e;
  padding: 3px 8px;
  border-radius: 10px;
}

/* ===== SETTINGS ROW ===== */
.menu-settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-inline label {
  font-size: 12px;
  color: #999;
  min-width: 60px;
}

/* ===== TOGGLE GROUP ===== */
.toggle-group {
  display: flex;
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 4px;
  overflow: hidden;
}

.toggle-btn {
  padding: 6px 10px;
  background: none;
  border: none;
  color: #999;
  font-size: 12px;
  cursor: pointer;
}

.toggle-btn.active {
  background: #4caf50;
  color: #fff;
  font-weight: 600;
}

.toggle-btn:hover:not(.active) { color: #eee; background: #3a3a5a; }

/* ===== SETTINGS SCREEN ===== */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group > label {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
}

.reference-card {
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 6px;
}

.ref-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #333;
}

.ref-row:last-child { border-bottom: none; }

.ref-label { font-weight: 700; width: 50px; }
.ref-cards { font-size: 13px; color: #999; }

.ref-plus .ref-label { color: #4caf50; }
.ref-zero .ref-label { color: #999; }
.ref-minus .ref-label { color: #f44336; }

.danger-btn {
  padding: 10px;
  background: #3a1a1a;
  border: 1px solid #f44336;
  border-radius: 6px;
  color: #f44336;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn:hover { background: #4a2020; }

/* ===== SCORE BAR ===== */
.score-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.score-item {
  flex: 1;
  background: #2a2a4a;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
}

.score-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #999;
}

.score-value { font-size: 16px; font-weight: 700; }

.correct-score .score-value { color: #4caf50; }
.wrong-score .score-value { color: #f44336; }
.accent-score .score-value { color: #9c27b0; }
.neutral-score .score-value { color: #999; }

/* ===== BADGES ===== */
.streak-badge, .round-badge, .bankroll-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #2a2a4a;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.streak-badge { color: #ffa500; }
.round-badge { color: #999; }
.bankroll-badge { color: #4caf50; }

/* ===== TABLE / FELT ===== */
.table-container {
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
}

.felt {
  position: relative;
  width: 100%;
  min-height: 200px;
  background: #1b5e2f;
  border: 4px solid #5d4037;
  border-radius: 8px;
  padding: 10px;
  overflow: hidden;
}

.table-card-area {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dealer-area {
  text-align: center;
  margin-bottom: 20px;
}

.position-label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.hand-cards {
  display: flex;
  gap: 4px;
  justify-content: center;
  min-height: 70px;
  position: relative;
}

.hand-value-badge {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.hand-value-badge.bust { color: #f44336; }
.hand-value-badge.blackjack { color: #ffa500; }

.players-area {
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
  margin-top: 20px;
}

.player-seat { text-align: center; }
.player-seat .position-label { margin-top: 4px; }

/* ===== PLAYING CARDS (simplified - no 3D flip) ===== */
.playing-card {
  width: 52px;
  height: 72px;
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
  font-family: Georgia, serif;
  border: 1px solid #ccc;
}

.playing-card.face-up { background: #fff; }
.playing-card.face-down { background: #1a3a5c; border: 2px solid #c9a84c; }

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.card-front {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-back {
  position: absolute;
  inset: 0;
  background: #1a3a5c;
  border-radius: 3px;
}

.card-rank { font-size: 16px; font-weight: 800; }
.card-suit-small { font-size: 12px; }
.card-center { font-size: 24px; }

.card-red { color: #d32f2f; }
.card-black { color: #222; }

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top-left { top: 2px; left: 3px; }
.card-corner.bottom-right { bottom: 2px; right: 3px; transform: rotate(180deg); }

/* Show correct face based on state */
.playing-card.face-down .card-front { display: none; }
.playing-card.face-down .card-back { display: block; }
.playing-card.face-up .card-front { display: flex; }
.playing-card.face-up .card-back { display: none; }

/* ===== FLASH DRILL CONTROLS ===== */
.flash-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.count-btn {
  flex: 1;
  padding: 14px 8px;
  font-size: 20px;
  font-weight: 800;
  border: 2px solid #444;
  border-radius: 8px;
  background: #2a2a4a;
  color: #eee;
  cursor: pointer;
  text-align: center;
}

.count-btn:active { transform: scale(0.96); }

.count-minus { border-color: #f44336; color: #f44336; }
.count-minus:hover { background: #3a1a1a; }
.count-zero { border-color: #999; color: #999; }
.count-zero:hover { background: #3a3a5a; }
.count-plus { border-color: #4caf50; color: #4caf50; }
.count-plus:hover { background: #1a3a1a; }

/* ===== SHOE PROGRESS ===== */
.shoe-progress {
  height: 4px;
  background: #2a2a4a;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.shoe-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4caf50, #ffa500, #f44336);
  transition: width 0.3s ease;
}

/* ===== CHALLENGE CONFIG ===== */
.challenge-config {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}

/* ===== BUTTONS ===== */
.primary-btn {
  padding: 10px 20px;
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.primary-btn:hover { background: #45a045; }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-btn {
  padding: 8px 16px;
  background: #2a2a4a;
  border: 1px solid #555;
  border-radius: 6px;
  color: #999;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
}

.secondary-btn:hover { border-color: #4caf50; color: #eee; }

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.overlay-card {
  background: #2a2a4a;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

/* Count input */
.count-input-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.stepper-btn {
  width: 40px;
  height: 40px;
  background: #444;
  border: none;
  border-radius: 6px;
  color: #eee;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.stepper-btn:hover { background: #4caf50; color: #fff; }

.count-input {
  width: 70px;
  height: 44px;
  background: #1a1a2e;
  border: 2px solid #555;
  border-radius: 6px;
  color: #eee;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.count-input::-webkit-outer-spin-button,
.count-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.count-input:focus { border-color: #4caf50; }

/* Results */
.results-grid {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.result-item {
  flex: 1;
  background: #1a1a2e;
  border-radius: 6px;
  padding: 10px 6px;
  text-align: center;
}

.result-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 4px;
}

.result-value {
  font-size: 20px;
  font-weight: 800;
}

.result-value.perfect { color: #4caf50; }
.result-value.close { color: #ffa500; }
.result-value.off { color: #f44336; }

.lifetime-stats {
  background: #1a1a2e;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: #999;
  border-bottom: 1px solid #333;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span:last-child { font-weight: 600; color: #eee; }

/* ===== BETTING CONTROLS ===== */
.count-display {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.count-item {
  flex: 1;
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px;
  text-align: center;
}

.count-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #999;
}

.count-value {
  font-size: 16px;
  font-weight: 700;
}

.betting-controls {
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.chip-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
}

.chip:hover { transform: scale(1.1); }
.chip:active { transform: scale(0.95); }

.chip-5 { background: #d32f2f; }
.chip-10 { background: #1976d2; }
.chip-25 { background: #388e3c; }
.chip-50 { background: #f57c00; }
.chip-100 { background: #333; border-color: #c9a84c; }

.bet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bet-actions .secondary-btn { width: auto; margin: 0; padding: 6px 14px; }
.bet-actions .primary-btn { width: auto; padding: 8px 20px; }

.bet-total {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #ffa500;
}

/* Bet feedback */
.bet-feedback {
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}

.feedback-comparison {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.feedback-item { flex: 1; text-align: center; }

.feedback-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 4px;
}

.feedback-value { font-size: 16px; font-weight: 700; }
.feedback-value.positive { color: #4caf50; }
.feedback-value.negative { color: #f44336; }

.educational-tip {
  font-size: 13px;
  color: #999;
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 8px;
  background: #1a1a2e;
  border-radius: 6px;
  border-left: 3px solid #4caf50;
}

/* ===== BANKROLL CHART ===== */
.bankroll-chart {
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
  min-height: 90px;
}

.bankroll-chart svg { width: 100%; height: 70px; display: block; }

/* ===== SPREAD REFERENCE ===== */
.spread-reference { margin-bottom: 10px; }

.spread-reference summary {
  font-size: 13px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  padding: 6px;
  background: #2a2a4a;
  border: 1px solid #444;
  border-radius: 6px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a4a;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: #eee;
  z-index: 200;
}

.toast.success { border-color: #4caf50; color: #4caf50; }
.toast.error { border-color: #f44336; color: #f44336; }

/* ===== TUTORIAL ===== */
.tutorial-overlay { text-align: center; padding: 16px; }
.tutorial-overlay h3 { font-size: 16px; margin-bottom: 12px; }

.tutorial-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.tutorial-key {
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tutorial-key kbd {
  padding: 2px 6px;
  background: #444;
  border: 1px solid #666;
  border-radius: 3px;
  font-family: monospace;
  font-size: 13px;
}

.tutorial-ref {
  background: #1a1a2e;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #999;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-red-text { color: #f44336; font-weight: 700; }
.card-green-text { color: #4caf50; font-weight: 700; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .playing-card { width: 44px; height: 60px; }
  .card-rank { font-size: 13px; }
  .card-center { font-size: 18px; }
  .count-btn { padding: 12px 6px; font-size: 16px; }
  .chip { width: 38px; height: 38px; font-size: 10px; }
}
