/* ─── Poker Coach — Mobile-First Dark Theme ─── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --bg-card: #161620;
  --bg-elevated: #1e1e2e;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.15);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.15);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.15);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.15);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.15);
  --border: #2a2a3a;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom) 12px;
}

.hidden { display: none !important; }
.visible { display: flex !important; }

/* ─── Status Bar ─── */
#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 14px;
  color: var(--text-dim);
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.disconnected { background: var(--red); }
.dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Main Advice Area ─── */
#advice-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 8px 0;
  gap: 12px;
}

/* Waiting state */
#waiting-message {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 18px;
}

.emoji-large { font-size: 64px; }

#waiting-message .sub {
  font-size: 14px;
  opacity: 0.6;
}

/* ─── Cards ─── */
#cards-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.cards {
  display: flex;
  gap: 6px;
}

.card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #000;
  font-size: 22px;
  font-weight: 800;
  padding: 6px 8px;
  border-radius: 6px;
  min-width: 42px;
  min-height: 54px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.card.heart, .card.diamond { color: #dc2626; }
.card.club, .card.spade { color: #1a1a2e; }

.card.community {
  font-size: 18px;
  min-width: 36px;
  min-height: 46px;
  padding: 4px 6px;
}

/* ─── Recommendation Badge ─── */
#recommendation-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 28px;
  border-radius: 16px;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  width: 90%;
  text-align: center;
  transition: all 0.3s ease;
}

#recommendation-badge.raise {
  background: var(--green-bg);
  color: var(--green);
  border: 2px solid var(--green);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

#recommendation-badge.call {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 2px solid var(--yellow);
  box-shadow: 0 0 20px rgba(234, 179, 8, 0.2);
}

#recommendation-badge.fold {
  background: var(--red-bg);
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

#recommendation-badge.check {
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 2px solid var(--border);
}

#recommendation-badge.waiting {
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 2px solid var(--border);
  font-size: 20px;
}

#rec-sizing {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.8;
}

/* ─── Reasoning ─── */
#reasoning-text {
  text-align: center;
  font-size: 16px;
  color: var(--text);
  padding: 4px 16px;
  line-height: 1.5;
  max-width: 100%;
}

/* ─── Stats Grid ─── */
#stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  padding: 0 4px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
}

/* ─── Analysis Buttons (Session, Verlauf, Leaks) ─── */
#analysis-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 4px;
  justify-content: center;
}

.btn-analysis {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.btn-analysis:hover,
.btn-analysis:active {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--blue);
}

/* ─── Leak Hint ─── */
#leak-hint {
  width: 100%;
  padding: 8px 12px;
  background: var(--purple-bg);
  border: 1px solid var(--purple);
  border-radius: 8px;
  font-size: 13px;
  color: var(--purple);
  text-align: center;
}

/* ─── Opponent Info ─── */
#opponent-info {
  width: 100%;
  padding: 8px 12px;
  background: var(--blue-bg);
  border: 1px solid var(--blue);
  border-radius: 8px;
  font-size: 13px;
  color: var(--blue);
  text-align: center;
}

/* ─── Action Report Buttons ─── */
#action-report {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 4px;
}

.action-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.action-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.btn-action {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  color: var(--text-dim);
}

.btn-action:active { transform: scale(0.95); }

.btn-action-fold:hover, .btn-action-fold:active {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}

.btn-action-call:hover, .btn-action-call:active {
  background: var(--yellow-bg);
  color: var(--yellow);
  border-color: var(--yellow);
}

.btn-action-raise:hover, .btn-action-raise:active {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}

/* ─── Hand Strength & Game Info ─── */
#hand-strength {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--blue);
}

#game-info {
  display: flex;
  gap: 12px;
  justify-content: center;
  font-size: 13px;
  color: var(--text-dim);
}

#game-info span {
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ─── Processing ─── */
#processing {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Camera Preview ─── */
#camera-container {
  position: fixed;
  bottom: 120px;
  right: 12px;
  width: 120px;
  height: 90px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  z-index: 10;
}

#camera-container.minimized {
  width: 40px;
  height: 40px;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#toggle-camera-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: white;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}

/* ─── Controls ─── */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  align-items: center;
  justify-content: center;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--green);
  color: #000;
  flex: 1;
  min-width: 120px;
}

.btn-primary.active {
  background: var(--red);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

#interval-control {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

#interval-control label {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

#interval-slider {
  flex: 1;
  accent-color: var(--blue);
  height: 4px;
}

/* ─── Overlays ─── */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.overlay-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.btn-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-close:hover {
  color: var(--red);
  border-color: var(--red);
}

.overlay-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Overlay Stat Grid */
.overlay-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.overlay-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.overlay-stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--green);
  margin-bottom: 4px;
}

.overlay-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.overlay-info {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}

.overlay-info p { margin-bottom: 6px; }
.overlay-info p:last-child { margin-bottom: 0; }

.overlay-tip {
  color: var(--yellow) !important;
  font-weight: 600;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
}

.history-hand-num {
  color: var(--blue);
}

.history-rec {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.history-rec.raise { background: var(--green-bg); color: var(--green); }
.history-rec.call { background: var(--yellow-bg); color: var(--yellow); }
.history-rec.fold { background: var(--red-bg); color: var(--red); }
.history-rec.check { background: var(--bg-elevated); color: var(--text-dim); }

.history-cards {
  font-size: 16px;
  font-weight: 800;
}

.history-cards .heart, .history-cards .diamond { color: #dc2626; }
.history-cards .club, .history-cards .spade { color: var(--text); }

.history-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 32px 16px;
  font-size: 15px;
}

/* Leak Summary */
.leak-summary {
  margin-bottom: 16px;
}

.leak-bar-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.leak-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.leak-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.leak-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.leak-bar-fill.tight { background: var(--blue); }
.leak-bar-fill.loose { background: var(--red); }
.leak-bar-fill.passive { background: var(--yellow); }
.leak-bar-fill.aggressive { background: var(--purple); }

.leak-tipp {
  background: var(--bg-card);
  border-left: 3px solid var(--yellow);
  padding: 10px 14px;
  margin-top: 12px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text);
}

.leak-recent-item {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.leak-recent-item .category {
  font-weight: 700;
  margin-right: 8px;
}

.leak-recent-item .category.zu_tight { color: var(--blue); }
.leak-recent-item .category.zu_loose { color: var(--red); }
.leak-recent-item .category.zu_passiv { color: var(--yellow); }
.leak-recent-item .category.zu_aggressiv { color: var(--purple); }

/* ─── Landscape tweaks ─── */
@media (orientation: landscape) {
  #stats-grid { grid-template-columns: repeat(4, 1fr); }
  #recommendation-badge { font-size: 28px; padding: 12px 20px; }
  .stat-value { font-size: 18px; }
}

/* ─── Larger phones ─── */
@media (min-height: 800px) {
  #recommendation-badge { font-size: 40px; }
  .stat-value { font-size: 26px; }
  #reasoning-text { font-size: 18px; }
}

/* Detected bets chips */
.bet-chip {
  background: rgba(255, 193, 7, 0.2);
  border: 1px solid rgba(255, 193, 7, 0.5);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: #ffc107;
  white-space: nowrap;
}

#bb-info {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
}

#detected-bets.hidden { display: none !important; }

