:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel2: #1c232d;
  --ink: #e6edf3;
  --muted: #9aa7b4;
  --line: #2a323c;
  --accent: #4f9cf9;
  --good: #3fb950;
  --warn: #f0a43a;
  --bad: #f85149;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .28);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --panel: #fff;
    --panel2: #f0f3f6;
    --ink: #1a1f27;
    --muted: #5a6672;
    --line: #d8dee4;
    --accent: #1f6feb;
    --good: #1a7f37;
    --warn: #9a6700;
    --bad: #cf222e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 7px 20px rgba(0, 0, 0, .07);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select { min-height: 44px; }

.wrap {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 28px 18px 84px;
}

.back {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.back:hover { color: var(--accent); }

header { margin-bottom: 18px; }
h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: -.02em; }
.sub { max-width: 720px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.runtime-status {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.setup,
.task-card,
.scorebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.setup { padding: 20px; }
.setup h2 { margin: 0 0 4px; font-size: 18px; }
.setup-note { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.settings-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  list-style: none;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.quick-difficulty { max-width: 360px; margin-bottom: 14px; }
.settings-disclosure { padding-top: 13px; border-top: 1px solid var(--line); }
.settings-disclosure > summary::-webkit-details-marker { display: none; }
.settings-disclosure > summary small { display: none; color: var(--accent); font-size: 12px; font-weight: 750; }
.settings-content { padding-top: 0; }

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.compact-setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.live-hand-filters { align-items: start; }
.live-hand-filters > .field { width: 100%; align-content: start; }
.question-filter { grid-column: 1 / -1; }
.filter-group {
  min-width: 0;
  margin: 0;
  padding: 9px 11px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
}
.filter-group legend { padding: 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-options { display: flex; flex-wrap: wrap; gap: 7px; }
.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 28%, var(--panel2));
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.check-row:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.check-row:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 58%, var(--line)); }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.field { display: grid; gap: 5px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 700; }

select,
.number-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: var(--panel2);
  color: var(--ink);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 44px 8px 11px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%239aa7b4' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.toggle {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
  cursor: pointer;
}

.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle span { font-size: 14px; font-weight: 650; }

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

.task-count { color: var(--muted); font-size: 12px; }

.primary,
.secondary {
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 750;
  cursor: pointer;
}

.primary { border: 0; background: var(--accent); color: #fff; }
.secondary { border: 1px solid var(--line); background: var(--panel2); color: var(--ink); }
.primary:hover, .secondary:hover { filter: brightness(1.08); }
.primary:focus-visible, .secondary:focus-visible, .choice:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.scorebar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  font-size: 13px;
}

.scorebar b { white-space: nowrap; font-size: 15px; }
.score { color: var(--muted); white-space: nowrap; }
.progress { min-width: 42px; height: 6px; flex: 1; overflow: hidden; background: var(--panel2); }
.progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }

.timer {
  min-width: 50px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.timer.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.timer.urgent { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 65%, var(--line)); }
.scorebar-next {
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.scorebar-next:hover { filter: brightness(1.08); }
.scorebar-next:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.next-short { display: none; }

.task-card { min-height: 280px; padding: 20px; }
.task-meta { margin-bottom: 14px; color: var(--accent); font-size: 14px; font-weight: 850; text-transform: uppercase; letter-spacing: .02em; }
.question { margin: 16px 0 12px; font-size: 20px; line-height: 1.3; letter-spacing: -.01em; }

.scene {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  overflow: hidden;
}

.scene-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.action-list { display: grid; padding: 5px 0; }
.action-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 12px; }
.action-row + .action-row { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.pos { min-width: 38px; color: var(--accent); font: 750 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.action-text { color: var(--ink); font-size: 14px; }

.street-block { padding: 10px 12px; }
.street-block + .street-block { border-top: 1px solid var(--line); }
.street-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.action-sequence { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.action-token {
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 28%, var(--panel2));
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}
.action-token b { margin-right: 4px; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.action-playback {
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 22px;
  text-align: center;
}

.flash-step { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.flash-action { margin-top: 8px; font-size: 25px; line-height: 1.25; font-weight: 800; }
.playback-ready { color: var(--muted); font-size: 14px; }

.mini-table-shell { margin-bottom: 14px; }
.poker-table {
  position: relative;
  width: 100%;
  height: clamp(290px, 42vw, 360px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel2) 75%, var(--bg));
}
.table-felt {
  position: absolute;
  inset: 54px 94px;
  border: 2px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #174d42, #10372f 72%);
  box-shadow: inset 0 0 34px rgba(0, 0, 0, .28);
}
.table-center {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  min-width: 142px;
  transform: translate(-50%, -50%);
  text-align: center;
}
.table-street { color: rgba(255, 255, 255, .7); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.table-pot { margin-top: 2px; color: #fff; font-size: 13px; font-weight: 850; font-variant-numeric: tabular-nums; }
.board-slots { display: flex; justify-content: center; gap: 3px; min-height: 31px; margin-top: 7px; }
.board-card {
  width: 22px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, .22);
  border-radius: 4px;
  color: transparent;
}
.board-card.dealt {
  border-style: solid;
  border-color: rgba(0, 0, 0, .22);
  background: #e9edf1;
  color: #788491;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}
.seat {
  position: absolute;
  z-index: 2;
  width: 116px;
  min-height: 74px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
  transition: opacity .15s, border-color .15s, box-shadow .15s;
}
.seat.hero { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.seat.inactive { opacity: .42; }
.seat.acting { border-color: var(--warn); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 26%, transparent); }
.seat-utg { left: 8px; top: 50%; transform: translateY(-50%); }
.seat-hj { left: 20%; top: 8px; }
.seat-co { right: 20%; top: 8px; }
.seat-btn { right: 8px; top: 50%; transform: translateY(-50%); }
.seat-sb { right: 20%; bottom: 8px; }
.seat-bb { left: 20%; bottom: 8px; }
.seat-head { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 18px; }
.seat-position { color: var(--ink); font: 850 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.seat-role { color: var(--accent); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.dealer-button {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #f2f4f7;
  color: #20262e;
  font-size: 9px;
  font-weight: 900;
}
.hole-cards { display: flex; justify-content: center; gap: 3px; min-height: 28px; margin-top: 3px; }
.hole-card {
  width: 20px;
  height: 27px;
  border: 1px solid rgba(255, 255, 255, .36);
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, #315f91 0 3px, #24486f 3px 6px);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
.seat.hero .hole-card { background: repeating-linear-gradient(135deg, #427ec2 0 3px, #315f91 3px 6px); }
.seat-foot { min-height: 17px; margin-top: 3px; color: var(--muted); font-size: 9.5px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.seat-action { color: var(--warn); font-weight: 800; }
.seat-contribution { color: var(--ink); }
.live-action {
  min-height: 32px;
  display: grid;
  place-items: center;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.live-action strong { color: var(--ink); }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--panel2)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--panel2)); }

.aggressor-form { display: grid; gap: 8px; }
.aggressor-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.aggressor-row > span { color: var(--muted); font-size: 13px; font-weight: 750; }
.aggressor-row small { grid-column: 2; min-height: 16px; color: var(--good); font-size: 11px; }
.aggressor-form .primary { justify-self: end; min-width: 126px; margin-top: 4px; }
.correct-control { border-color: var(--good); }
.wrong-control { border-color: var(--bad); }
.feedback-history { margin-top: 12px; }
.street-divider { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.number-scene {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.number-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.number-label { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.number-value { margin-top: 2px; font-size: 24px; font-weight: 850; font-variant-numeric: tabular-nums; }

.numeric-form { display: flex; gap: 8px; align-items: stretch; }
.input-wrap { position: relative; flex: 1; }
.number-input { min-height: 50px; padding: 9px 74px 9px 13px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.input-suffix { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.numeric-form .primary { min-width: 126px; }

.feedback { display: none; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.feedback.show { display: block; }
.verdict { margin-bottom: 8px; font-weight: 850; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.verdict.warn { color: var(--warn); }
.answer-summary { margin-bottom: 7px; font-weight: 750; }
.explanation { margin: 0; color: var(--muted); font-size: 14px; }
.calculation { margin-top: 10px; padding: 9px 11px; border-left: 3px solid var(--accent); background: var(--panel2); font-size: 14px; }
.result { text-align: center; padding: 6px 0; }
.result h2 { margin: 0 0 4px; font-size: 22px; }
.result-sub { margin: 0 0 18px; color: var(--muted); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.result-stat { padding: 12px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.result-stat b { display: block; font-size: 23px; font-variant-numeric: tabular-nums; }
.result-stat span { color: var(--muted); font-size: 11px; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.error-note { margin-top: 12px; color: var(--muted); font-size: 13px; }
.metric-breakdown { max-width: 520px; margin: 14px auto 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-align: left; }
.metric-row { display: grid; grid-template-columns: minmax(0, 1fr) 60px 72px; gap: 10px; padding: 7px 10px; font-size: 12px; }
.metric-row + .metric-row { border-top: 1px solid var(--line); }
.metric-row b { text-align: center; }
.metric-row span:last-child { color: var(--muted); text-align: right; }
.metric-head { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (max-width: 650px) {
  .wrap { padding: 14px 10px 44px; }
  .back { margin-bottom: 8px; }
  header { margin-bottom: 13px; }
  h1 { font-size: 25px; }
  .setup, .task-card { padding: 14px; }
  .settings-disclosure > summary {
    min-height: 46px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel2);
    font-size: 16px;
  }
  .quick-difficulty { max-width: none; margin-bottom: 12px; }
  .settings-disclosure { padding-top: 12px; }
  .settings-disclosure > summary small { display: inline; }
  .settings-disclosure[open] > summary { margin-bottom: 14px; }
  .settings-disclosure[open] > summary small { visibility: hidden; }
  .settings-content { padding: 0 2px; }
  .setup-grid { grid-template-columns: 1fr; gap: 9px; }
  .question-filter { grid-column: auto; }
  .filter-options { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .filter-group { padding: 7px 10px 9px; }
  .check-row {
    min-height: 34px;
    padding: 3px 2px;
    border: 0;
    background: transparent;
  }
  .check-row:hover,
  .check-row:has(input:checked) { border-color: transparent; }
  .start-row { align-items: stretch; flex-direction: column; gap: 7px; }
  .scorebar { gap: 8px; margin-bottom: 10px; padding: 8px 9px; }
  .score { display: none; }
  .scorebar-next { min-height: 40px; padding-inline: 9px; }
  .next-full { display: none; }
  .next-short { display: inline; }
  .timer { min-width: 46px; }
  .task-meta { font-size: 15px; }
  .question { font-size: 19px; }
  .action-playback { min-height: 130px; padding: 18px 12px; }
  .flash-action { font-size: 23px; }
  .poker-table { height: 282px; }
  .table-felt { inset: 54px 47px; }
  .table-center { min-width: 120px; }
  .seat { width: 88px; min-height: 68px; padding: 5px 4px; }
  .seat-utg { left: 3px; }
  .seat-btn { right: 3px; }
  .seat-hj, .seat-bb { left: 20%; }
  .seat-co, .seat-sb { right: 20%; }
  .seat-hj, .seat-co { top: 5px; }
  .seat-sb, .seat-bb { bottom: 5px; }
  .seat-position { font-size: 11px; }
  .seat-role { font-size: 8px; }
  .hole-cards { min-height: 25px; }
  .hole-card { width: 18px; height: 24px; }
  .seat-foot { font-size: 8.5px; }
  .board-card { width: 18px; height: 25px; }
  .board-slots { min-height: 26px; }
  .street-block { padding: 9px 10px; }
  .action-sequence { gap: 5px; }
  .action-token { padding: 4px 6px; font-size: 11.5px; }
  .numeric-form { flex-direction: column; }
  .numeric-form .primary { width: 100%; }
  .aggressor-form .primary { width: 100%; }
  .result-grid { grid-template-columns: 1fr; }
}
