:root {
  --bg: #0f1420;
  --bg-soft: #161d2e;
  --panel: #1b2338;
  --panel-2: #212b44;
  --border: #2c3752;
  --text: #eef1f8;
  --text-dim: #9aa5bd;
  --accent: #5b9dff;
  --accent-2: #ffb454;
  --good: #34d399;
  --bad: #f87171;
  --tie: #fbbf24;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2745 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon { font-size: 2.4rem; line-height: 1; }
.brand h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; color: var(--text-dim); font-size: 0.95rem; }

.mode-switch {
  display: flex;
  gap: 8px;
  background: var(--panel);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--accent); color: #0b1220; }

/* ---------- Layout ---------- */
main { padding: 24px 32px 48px; }

.mode-panel { display: none; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.mode-panel.active { display: grid; }

@media (max-width: 900px) {
  .mode-panel.active { grid-template-columns: 1fr; }
}

.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 16px;
}

.control-group { display: flex; flex-direction: column; gap: 8px; }
.group-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.72rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.hint { margin: 0; font-size: 0.85rem; color: var(--text-dim); line-height: 1.4; }

.segmented { display: flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 6px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.seg-btn.active { background: var(--accent); color: #0b1220; }

input[type="number"] {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); }
.speed-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-dim); }

.buttons-row { flex-direction: row; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform .05s ease, filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #0b1220; border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 10px; font-size: 0.78rem; align-self: flex-start; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-dim); cursor: pointer; }

.callout {
  background: linear-gradient(180deg, rgba(91,157,255,0.12), rgba(91,157,255,0.03));
  border: 1px solid rgba(91,157,255,0.35);
  border-radius: 10px;
  padding: 12px 14px;
}
.callout strong { color: var(--accent); font-size: 0.85rem; }
.callout p { margin: 6px 0 0; font-size: 0.82rem; color: var(--text-dim); line-height: 1.45; }

/* ---------- Stage / chart ---------- */
.stage { display: flex; flex-direction: column; gap: 20px; }

.chart-card, .stats-card, .card-picker-card, .equity-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.chart-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.chart-header h2 { margin: 0; font-size: 1.05rem; }
.totals { color: var(--text-dim); font-size: 0.9rem; }
.totals strong { color: var(--text); font-variant-numeric: tabular-nums; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 320px;
  padding: 8px 4px 0;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 44px;
  height: 300px;
  position: relative;
}
.bar-track {
  position: relative;
  width: 100%;
  max-width: 64px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bar-theory {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 78%;
  border: 2px dashed rgba(255,180,84,0.85);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-sizing: border-box;
  pointer-events: none;
}
.bar-fill {
  width: 62%;
  background: linear-gradient(180deg, var(--accent), #3f7fd9);
  border-radius: 6px 6px 0 0;
  transition: height 0.12s ease-out;
  min-height: 1px;
}
.bar-value {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.bar-label {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  text-align: center;
}

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stats-table th, .stats-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stats-table td { font-variant-numeric: tabular-nums; }

/* ---------- Poker specifics ---------- */
.mini-cards { display: flex; gap: 6px; flex-wrap: wrap; min-height: 54px; }
.mini-card {
  width: 42px; height: 54px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.mini-card.suit-h, .mini-card.suit-d { color: #d1263a; }
.mini-card.suit-s, .mini-card.suit-c { color: #1a1a1a; }
.mini-card.placeholder { background: var(--bg-soft); border: 1px dashed var(--border); color: var(--text-dim); box-shadow: none; }

.card-picker-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.card-picker-header h2 { margin: 0; font-size: 1.05rem; }
.picker-mode-label { font-size: 0.85rem; color: var(--text-dim); }
.picker-mode-label strong { color: var(--accent-2); }

.deck-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 6px;
}
@media (max-width: 900px) {
  .deck-grid { grid-template-columns: repeat(7, 1fr); }
}
.deck-card {
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
  user-select: none;
}
.deck-card:hover { transform: translateY(-3px); box-shadow: 0 4px 10px rgba(0,0,0,0.35); }
.deck-card.suit-h, .deck-card.suit-d { color: #d1263a; }
.deck-card.used { opacity: 0.25; cursor: not-allowed; transform: none; box-shadow: none; }
.deck-card.selected-hole { outline: 3px solid var(--accent); }
.deck-card.selected-board { outline: 3px solid var(--accent-2); }
.deck-grid.running .deck-card { pointer-events: none; opacity: 0.55; }

.equity-bar-wrap h3 { margin: 0 0 12px; font-size: 1rem; }
.equity-bar { display: flex; width: 100%; height: 44px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); background: var(--bg-soft); }
.equity-seg { display: flex; align-items: center; justify-content: center; transition: width .15s ease-out; font-size: 0.8rem; font-weight: 700; color: #0b1220; white-space: nowrap; overflow: hidden; }
.equity-win { background: var(--good); }
.equity-tie { background: var(--tie); }
.equity-lose { background: var(--bad); }
.equity-seg span { padding: 0 6px; }

.foot { text-align: center; color: var(--text-dim); font-size: 0.8rem; padding: 8px 24px 28px; }
