/* ER-Poker SPA — dark theme, minimal layout. */

:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev-2: #1f2630;
  --border: #2a313c;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-2: #f78166;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --suit-red: #ff6b6b;
  --suit-black: #cbd5e1;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- hero banner --- */

.hero {
  text-align: center;
  padding: 28px 20px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.hero-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.hero-tagline {
  margin: 0 0 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
}

.hero-intro {
  margin: 0 auto;
  max-width: 680px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* --- topbar / tabs --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-size: 14px;
}

.brand-title { font-size: 18px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.tab:hover { color: var(--text); background: var(--bg-elev-2); }

.tab.active {
  color: var(--text);
  background: var(--bg-elev-2);
  border-color: var(--border);
}

/* --- loading --- */

.loading {
  max-width: 520px;
  margin: 80px auto;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-elev-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

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

.loading-text { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.loading-sub { font-size: 13px; }

/* --- main / panels --- */

main {
  max-width: 980px;
  margin: 24px auto;
  padding: 0 20px 60px;
}

.panel { margin-bottom: 24px; }
.panel h2 { margin: 12px 0 4px; font-size: 22px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.muted { color: var(--text-muted); margin: 4px 0 16px; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

label {
  font-size: 13px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input.hand-input, select.range-select, select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

input.hand-input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

select { width: auto; }

button.primary {
  background: var(--accent);
  color: #04122a;
  font-weight: 600;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  transition: filter 120ms, transform 120ms;
}

button.primary:hover { filter: brightness(1.1); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0;
}

/* --- card-display: chips with suit colors --- */

.card-display {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  min-height: 40px;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chip .rank { font-weight: 600; }
.chip .suit-red { color: var(--suit-red); }
.chip .suit-black { color: var(--suit-black); }

.chip.invalid { border-color: var(--bad); color: var(--bad); }

/* --- results --- */

.result {
  margin-top: 20px;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.equity-bar {
  display: flex;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
  background: var(--bg-elev-2);
}

.equity-bar .hero {
  background: linear-gradient(90deg, var(--accent), #2c8aee);
  display: grid;
  place-items: center;
  color: #04122a;
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
}

.equity-bar .villain {
  background: var(--bg-elev-2);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
}

.equity-bar .tie {
  background: var(--warn);
  display: grid;
  place-items: center;
  color: #1c1408;
  font-size: 12px;
  font-weight: 600;
  min-width: 0;
}

.breakdown {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.breakdown b { color: var(--text); }

.rank-result {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-elev-2);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
}

.rank-result .category {
  color: var(--accent);
  font-weight: 600;
}

.error {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid var(--bad);
  border-radius: 8px;
  color: #ffb3ad;
  font-size: 14px;
}

/* --- best-draw table --- */

table.draws {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

table.draws th, table.draws td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

table.draws th {
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg-elev-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.draws tr.best { background: rgba(88, 166, 255, 0.07); }
table.draws tr.best td:first-child { color: var(--accent); font-weight: 600; }

table.draws .num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* --- footer --- */

.footbar {
  position: sticky;
  bottom: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.footbar .dot { opacity: 0.4; }

/* --- utility --- */

.hidden { display: none !important; }

code {
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* --- Study tab --- */

.study-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.study-meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.study-context {
  background: var(--bg-elev-2);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0 16px;
  font-size: 14px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

.study-context strong {
  color: var(--text);
}

.study-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.action-btn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  transition: filter 120ms, border-color 120ms, background 120ms;
}

.action-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elev);
}

.action-btn.picked {
  background: var(--accent);
  border-color: var(--accent);
  color: #04122a;
  font-weight: 600;
}

.action-btn.correct-reveal {
  border-color: var(--good);
  box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.25) inset;
}

.action-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.study-reveal {
  margin-top: 18px;
  padding: 14px;
  background: var(--bg-elev-2);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

.study-verdict {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.study-verdict.correct { color: var(--good); }
.study-verdict.wrong   { color: var(--bad); }

.study-answer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.study-explanation {
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 14px;
}
