/* ============================================
   Poker Opening Range Trainer — Dark Theme
   ============================================ */

:root {
  --bg-primary:   #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card:      #0f3460;
  --accent:       #e94560;
  --green:        #00b894;
  --blue:         #0984e3;
  --orange:       #e17055;
  --purple:       #6c5ce7;
  --gold:         #fdcb6e;
  --text:         #eee;
  --text-muted:   #aaa;
  --border:       #2d3a5c;
  --radius:       8px;
  --felt:         #1b5e20;
  --felt-light:   #2e7d32;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
header { text-align: center; padding: 1.5rem 1rem 0.5rem; }
header h1 { font-size: 1.6rem; color: var(--gold); letter-spacing: 1px; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ---------- Main ---------- */
main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

/* ---------- Controls ---------- */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.25rem;
}
.control-group { display: flex; flex-direction: column; gap: 0.25rem; }
.control-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
select {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary    { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); }
.btn-raise      { background: var(--green); color: #fff; min-width: 100px; }
.btn-raise:hover:not(:disabled)   { filter: brightness(1.15); }
.btn-3bet       { background: var(--accent); color: #fff; min-width: 100px; }
.btn-3bet:hover:not(:disabled)    { filter: brightness(1.15); }
.btn-4bet       { background: var(--purple); color: #fff; min-width: 100px; }
.btn-4bet:hover:not(:disabled)    { filter: brightness(1.15); }
.btn-call       { background: var(--blue); color: #fff; min-width: 100px; }
.btn-call:hover:not(:disabled)    { filter: brightness(1.15); }
.btn-fold       { background: var(--orange); color: #fff; min-width: 100px; }
.btn-fold:hover:not(:disabled)    { filter: brightness(1.15); }
.btn-secondary  { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------- Poker Table ---------- */
#table-area { margin-bottom: 1.25rem; }

#poker-table {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  aspect-ratio: 1.8 / 1;
}

.felt {
  position: absolute;
  inset: 15%;
  background: radial-gradient(ellipse at center, var(--felt-light), var(--felt));
  border-radius: 50%;
  border: 4px solid #5d4037;
  box-shadow: 0 0 0 8px #3e2723, 0 4px 20px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.felt-label {
  color: rgba(255,255,255,0.15);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  user-select: none;
}

/* Seats */
.seat {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.35s;
  z-index: 2;
  cursor: pointer;
}
.seat:hover {
  filter: brightness(1.3);
}
.seat .seat-label { font-size: 0.75rem; }
.seat .seat-action {
  font-size: 0.55rem;
  margin-top: 1px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-height: 0.7em;
  transition: opacity 0.3s;
}

/* Seat states */
.seat.hero {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(253,203,110,0.15);
  box-shadow: 0 0 12px rgba(253,203,110,0.35);
}
.seat.opener {
  border-color: var(--green);
  color: var(--green);
  background: rgba(0,184,148,0.15);
  box-shadow: 0 0 10px rgba(0,184,148,0.3);
}
.seat.three-bettor {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(233,69,96,0.15);
  box-shadow: 0 0 10px rgba(233,69,96,0.3);
}
.seat.caller {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(9,132,227,0.15);
  box-shadow: 0 0 8px rgba(9,132,227,0.25);
}
.seat.folded {
  opacity: 0.3;
}
.seat.waiting {
  opacity: 0.6;
}
.seat.available {
  border-color: var(--accent);
  background: rgba(214,48,49,0.12);
  box-shadow: 0 0 10px rgba(214,48,49,0.3);
  animation: seatPulse 1.5s ease infinite;
}

/* Seat animation — fade-in when action reaches them */
.seat.acting {
  animation: seatPulse 0.4s ease;
}
@keyframes seatPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* 6 seat positions */
.seat[data-pos="UTG"] { top: 2%;  left: 18%; transform: translate(-50%, 0); }
.seat[data-pos="HJ"]  { top: 2%;  right: 18%; transform: translate(50%, 0); }
.seat[data-pos="CO"]  { top: 42%; right: 0%;  transform: translate(0, -50%); }
.seat[data-pos="BTN"] { bottom: 2%; right: 18%; transform: translate(50%, 0); }
.seat[data-pos="SB"]  { bottom: 2%; left: 18%; transform: translate(-50%, 0); }
.seat[data-pos="BB"]  { top: 42%; left: 0%;   transform: translate(0, -50%); }

/* ---------- Situation Prompt ---------- */
#situation-prompt {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.75rem;
  min-height: 1.5em;
}

/* ---------- Hand Display ---------- */
#hand-area { text-align: center; margin-bottom: 0.75rem; }
#hand-display {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.card {
  width: 90px;
  height: 130px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  background: #fff;
  color: #222;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  user-select: none;
}
.card.red   { color: #c0392b; }
.card.black { color: #222; }

/* ---------- Action Buttons ---------- */
#action-area { text-align: center; margin-bottom: 0.75rem; }
#action-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* ---------- Feedback ---------- */
#feedback {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  min-height: 2.2em;
}
#feedback.correct { background: rgba(0,184,148,0.15); color: var(--green); }
#feedback.wrong   { background: rgba(225,112,85,0.15); color: var(--orange); }

/* ---------- Reveal Grid (shown on wrong answer) ---------- */
#reveal-area {
  margin-bottom: 1.25rem;
  text-align: center;
  animation: revealSlide 0.35s ease;
}
@keyframes revealSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#reveal-header {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
#reveal-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  max-width: 100%;
  margin: 0 auto 0.5rem;
}
#reveal-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
#next-hand-btn {
  margin-top: 0.25rem;
}

/* Highlighted cell (the hand hero was dealt) */
.grid-cell.highlight {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
  box-shadow: 0 0 8px rgba(253,203,110,0.5);
  z-index: 2;
}

/* ---------- Explore Grids ---------- */
#explore-area, #explore-vs-area { margin-bottom: 1.25rem; }

#range-grid, #range-grid-vs {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  max-width: 100%;
  margin: 0 auto 0.75rem;
}

.grid-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 3px;
  cursor: default;
  transition: transform 0.1s;
  user-select: none;
}
.grid-cell:hover { transform: scale(1.12); z-index: 1; }
.grid-cell.raise    { background: var(--green); color: #fff; }
.grid-cell.threeBet { background: var(--accent); color: #fff; }
.grid-cell.call-cell { background: var(--blue); color: #fff; }
.grid-cell.fold     { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); }

#legend, #legend-vs {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 0.35rem; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.raise       { background: var(--green); }
.swatch.threeBet    { background: var(--accent); }
.swatch.call-swatch { background: var(--blue); }
.swatch.fold        { background: var(--bg-secondary); border: 1px solid var(--border); }

/* ---------- Explore prompts & headers ---------- */
.explore-prompt {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.reveal-hdr {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* ---------- Scoreboard ---------- */
#scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.score-item { text-align: center; }
.score-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 0.15rem;
}
.score-value { font-size: 1.4rem; font-weight: 700; }
.score-value.correct { color: var(--green); }
.score-value.wrong   { color: var(--orange); }

/* ---------- Footer ---------- */
footer { text-align: center; padding: 1rem; font-size: 0.8rem; color: var(--text-muted); }
footer kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 0.75rem;
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 540px) {
  header h1 { font-size: 1.25rem; }
  .card { width: 72px; height: 104px; font-size: 1.3rem; }
  .grid-cell { font-size: 0.5rem; }
  #controls { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
  #action-buttons { flex-direction: column; align-items: center; }
  .seat { width: 48px; height: 48px; font-size: 0.6rem; }
  .seat .seat-label { font-size: 0.65rem; }
  .seat .seat-action { font-size: 0.5rem; }
}
