:root {
  color-scheme: dark;
  /* "Card-room terminal" palette — warm graphite surfaces (deliberately not
     the stock blue-gray dashboard look), champagne-gold accent (casino, not
     chatbot-blue), deep felt green for the table. Tokens drive everything;
     tweak here, not inline. */
  --bg: #0b0c0e;
  --bg-2: #101214;
  --panel: rgba(20, 22, 25, 0.78);
  --panel-2: rgba(30, 33, 38, 0.85);
  --panel-3: rgba(46, 50, 57, 0.95);
  --inset: #0d0f11;        /* sunken wells: tracks, list rows, histograms */
  --inset-2: #08090b;      /* deepest wells: bar backgrounds */
  --line: rgba(255, 252, 240, 0.07);
  --line-2: rgba(255, 252, 240, 0.14);
  --text: #f5f3ee;
  --text-2: #e4e1d9;
  --muted: #999e9a;
  --muted-2: #6b6f6c;

  /* Primary Theme Accent — champagne gold */
  --accent: #d9a441;
  --accent-2: #c08f2f;
  --accent-3: #a17724;
  /* Reusable accent tints — use these instead of ad-hoc rgba()s so the
     accent stays consistent everywhere (selection, focus, primary, drop). */
  --accent-soft: rgba(217, 164, 65, 0.14);
  --accent-softer: rgba(217, 164, 65, 0.08);
  --accent-line: rgba(217, 164, 65, 0.45);
  --accent-glow: rgba(217, 164, 65, 0.28);
  /* Champagne text tints for accent-adjacent labels. */
  --accent-text: #ead9a8;
  --accent-text-2: #e6cf92;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  /* Table furniture (cards, chips, action controls) uses one bold grotesk. */
  --table-font: "Inter", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

  /* Real poker felt: deep green with a leather-dark rim. */
  --felt: #07241a;        /* deep felt green (edge) */
  --felt-2: #0f3a29;      /* felt green (center glow) */
  --felt-rim: #15100a;    /* espresso leather rim */

  --blue: #3b82f6;
  --red: #ef4444;
  --green: #10b981;
  --orange: #f59e0b;
  --yellow: #fbbf24;

  --good: #10b981;
  --bad: #ef4444;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.85);
  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 11px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv01";
  letter-spacing: -0.005em;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  outline: none;
}

/* Theme the native form widgets gold instead of OS blue. */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
progress {
  accent-color: var(--accent);
}

/* Respect the OS "reduce motion" setting — collapse all transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ───────────────────────── layout ───────────────────────── */

.app-shell {
  display: grid;
  /* Right rail (sim data) scales up on wide screens but clamps on small ones.
     Named areas so narrow windows can restack the rails instead of crushing
     them into unusable slivers. */
  grid-template-areas: "nav main data";
  grid-template-columns: clamp(232px, 19vw, 300px) minmax(0, 1fr) clamp(292px, 28vw, 500px);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar { grid-area: nav; }
.trainer { grid-area: main; }
.rightbar { grid-area: data; }

/* Narrower windows: tighten the rails before anything clips. The felt and
   table furniture have their own breakpoints further down. */
@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: clamp(220px, 22vw, 272px) minmax(0, 1fr) clamp(264px, 27vw, 330px);
  }
  .sidebar,
  .rightbar { padding: 8px; gap: 8px; }
}

.app-shell.home-mode {
  grid-template-areas: "main";
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.home-mode .sidebar,
.app-shell.home-mode .rightbar {
  display: none;
}

.app-shell.home-mode .trainer {
  min-width: 0;
}

.sidebar,
.rightbar {
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--line);
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  box-shadow: 0 3px 12px var(--accent-glow);
  position: relative;
  display: grid;
  place-items: center;
  color: #181206;
  font-size: 16px;
  font-weight: 800;
}
.mark::after {
  content: "♠";
}

.brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-home {
  all: unset;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.brand-home:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  font-family: "JetBrains Mono", monospace;
}

/* ───────────────────────── panels ───────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 200ms;
}
.panel:hover {
  border-color: rgba(255, 252, 240, 0.12);
}

.compact {
  padding-bottom: 8px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

/* Mono micro-headers: poker data reads like a HUD, not a marketing page. */
.panel h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Signature gold tick before every panel header — small, distinctive, cheap. */
.panel h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 9px;
  margin-right: 7px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.9;
}

.icon-button {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  transition: all 150ms;
}
.icon-button:hover {
  background: var(--panel-3);
  border-color: var(--line-2);
}

.button {
  min-height: 31px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #1d2024;
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: -0.01em;
  transition: background 150ms, border-color 150ms, transform 80ms, box-shadow 150ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.button:hover {
  background: #31353c;
  border-color: var(--line-2);
}
.button:active { transform: translateY(1px); }
.button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.button.primary {
  background: linear-gradient(180deg, #e3b254 0%, #c89238 100%);
  color: #181206;
  font-weight: 700;
  border-color: var(--accent-3);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.button.primary:hover {
  background: linear-gradient(180deg, #efc068 0%, #d6a045 100%);
  border-color: var(--accent-2);
}

.input {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0d0f11;
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  transition: all 150ms;
}
.input::placeholder { color: var(--muted-2); }
.input:hover { border-color: var(--line-2); }
.input:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px var(--accent-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  outline: none;
}
.input:focus-visible {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px var(--accent-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* ───────────────────────── packs ───────────────────────── */

.pack-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.pack-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  transition: all 150ms;
}
.pack-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-2);
}
.pack-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.pack-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.pack-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

/* ───────────────────────── session stats ───────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stat-grid div {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 4px 5px;
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
  min-width: 0; /* let tracks shrink so a wide value (e.g. "2/50") can't push the row past the panel */
}

.stat-grid span {
  display: block;
  /* Mono + tabular numerals: poker data should read like a HUD, not prose. */
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(13px, 2.2vw, 17px);
  line-height: 1.1;
  font-weight: 700;
  color: #fff;
  white-space: nowrap; /* keep the value on one line; the small floor + min-width:0 keep it fitting without an ellipsis */
}

.stat-grid label {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: clamp(8px, 1.5vw, 9px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meter {
  height: 5px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 99px;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow) 50%, var(--green));
  transition: width 400ms cubic-bezier(.16,1,.3,1);
}

/* Decision-grade breakdown: one compact 5-tile strip (count over label),
   color-coded by an inset top bar — a fraction of the height of stacked rows. */
.grade-breakdown {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 10px;
}
.grade-row {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 2px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-top-width: 2px;
  min-width: 0;
}
.grade-row label {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 8px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.grade-row span {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.grade-row.grade-best { border-top-color: #10b981; }
.grade-row.grade-best label { color: #34d399; }
.grade-row.grade-correct { border-top-color: rgba(74, 222, 128, 0.7); }
.grade-row.grade-correct label { color: #86efac; }
.grade-row.grade-inaccuracy { border-top-color: rgba(234, 179, 8, 0.8); }
.grade-row.grade-inaccuracy label { color: #facc15; }
.grade-row.grade-wrong { border-top-color: rgba(249, 115, 22, 0.8); }
.grade-row.grade-wrong label { color: #fb923c; }
.grade-row.grade-blunder { border-top-color: rgba(239, 68, 68, 0.85); }
.grade-row.grade-blunder label { color: #f87171; }

.ev-loss-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin-top: 8px;
}
.ev-loss-grid > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}
.ev-loss-grid label {
  font-family: var(--mono);
  font-size: clamp(8px, 1.4vw, 9px);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-loss-grid strong {
  color: #fff;
  font-family: var(--mono);
  font-size: clamp(12px, 2.2vw, 14px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ───────────────────────── trainer / topbar ───────────────────────── */

.trainer {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* Graphite stage with a faint dot grid — quiet texture instead of the
     generic flat-gradient dashboard look. */
  background:
    radial-gradient(rgba(255, 252, 240, 0.02) 1px, transparent 1.5px),
    radial-gradient(ellipse at 50% -10%, #15181c 0%, var(--bg) 62%);
  background-size: 26px 26px, 100% 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 14, 0.65);
  backdrop-filter: blur(12px);
}

/* The title block must be allowed to shrink (min-width:0) so a long spot line or
   hand title truncates instead of pushing the action buttons off the bar. */
.topbar > div:first-child {
  min-width: 0;
  flex: 1;
}

.topbar h2 {
  font-size: clamp(15px, 1.4vw, 19px);
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ───────────────────────── home view ───────────────────────── */

.home-view {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 80px;
}
.home-view.hidden { display: none; }


.button.large {
  min-width: 170px;
  min-height: 52px;
  padding: 0 24px;
  font-size: 15px;
  white-space: nowrap;
}


.qs-tile {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 5px;
}
.qs-value {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}
.qs-tile label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ───────────────────────── table stage ───────────────────────── */

.table-stage {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  padding: 10px 16px;
  min-height: 0;
  gap: 8px;
  /* When the window is too short to fit the felt + decision bar + feedback,
     scroll the stage instead of clipping the bottom controls. Combined with the
     felt's min-height, this keeps the table usable AND every control reachable
     at any window size — no need to maximize to see the feedback. */
  overflow-y: auto;
}
.table-stage.hidden { display: none; }

.action-trail {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.4);
  overflow-x: auto;
  white-space: nowrap;
}

.trail-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: #1e2126;
  color: #e4e1d9;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.trail-pill.street {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}
.trail-pill.hero-action {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-line);
}

/* ───────────────────────── felt / table ───────────────────────── */

.felt {
  position: relative;
  /* Make the felt a query container so the cards, chips and dealer button can be
     sized in container units (cqw) and therefore scale proportionally WITH the
     felt — instead of off the viewport, which let them stay big and overlap the
     board when the window was restored to a smaller size. */
  container-type: inline-size;
  align-self: center;
  justify-self: center;
  width: min(96%, 1020px);
  aspect-ratio: 2.1;
  /* Floor so the table stays usable in a short window; the stage scrolls past it
     rather than crushing the felt to nothing. */
  min-height: 240px;
  border-radius: 50% / 46%;
  background: radial-gradient(ellipse at center, var(--felt-2) 0%, var(--felt) 100%);
  border: 14px solid var(--felt-rim);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.8),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05),
    inset 0 0 80px rgba(0, 0, 0, 0.35);
}

/* Racetrack betting line — the inner ring every real table has. Pure CSS,
   sits under all the table furniture. */
.felt::before {
  content: "";
  position: absolute;
  inset: 7% 9%;
  border: 1.5px solid rgba(255, 252, 240, 0.07);
  border-radius: 50% / 46%;
  pointer-events: none;
}

/* Stream overlay seat blocks (combined name + stack tag). The name and stack
   tags butt together as ONE badge (the strong has no bottom border + top-only
   radius, the small has bottom-only radius), so the column gap lives on the
   cards instead of between every item — a flex gap here would split the badge
   apart. */
.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.seat .cards { margin-bottom: 6px; }

.seat strong {
  min-width: 104px;
  text-align: center;
  border: 1px solid rgba(255, 252, 240, 0.1);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: rgba(13, 14, 17, 0.95);
  color: #fff;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.seat small {
  margin-top: 0;
  min-width: 104px;
  text-align: center;
  padding: 4px 14px;
  border-radius: 0 0 6px 6px;
  background: rgba(26, 29, 34, 0.98);
  color: #fff;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255, 252, 240, 0.1);
}

.villain { top: -36px; left: 50%; transform: translateX(-50%); }
.hero    { bottom: -40px; left: 50%; transform: translateX(-50%); }

.hero strong { border-color: var(--accent-line); }
.hero small { border-color: var(--accent-line); background: rgba(13, 14, 17, 0.98); }

/* ───────────────────────── cards ───────────────────────── */

.cards, .board {
  display: flex;
  gap: clamp(4px, 0.6vw, 8px);
}

/* Card dimensions scale with the FELT (container units) so they shrink in step
   with the table when the app is restored from full screen to a smaller window,
   instead of staying a fixed size and overlapping the board. */
.card {
  position: relative;
  width: clamp(34px, 6.3cqw, 64px);
  height: clamp(48px, 8.9cqw, 90px);
  border-radius: clamp(6px, 1cqw, 10px);
  background: linear-gradient(160deg, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 16px -6px rgba(0, 0, 0, 0.55),
    0 2px 4px rgba(0, 0, 0, 0.35);
  display: grid;
  grid-template-rows: auto 1fr;
  padding: clamp(4px, 0.7cqw, 8px) clamp(5px, 0.9cqw, 10px) clamp(3px, 0.6cqw, 7px);
  font-weight: 800;
  letter-spacing: -0.04em;
  border: 1px solid rgba(15, 23, 42, 0.10);
}

.card .rank {
  font-size: clamp(15px, 3.2cqw, 32px);
  line-height: 0.95;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Corner index: rank top-left, a small suit pip tucked just beneath it, plus a
   larger ghosted suit anchored bottom-right for balance. */
.card .suit {
  font-size: clamp(13px, 2.8cqw, 28px);
  line-height: 1;
  align-self: end;
  justify-self: end;
}

.card.red { color: #dc2626; }

/* 4 color deck — slightly deeper, print-like inks */
.card:not(.filled).suit-d { color: #2563eb; }
.card:not(.filled).suit-c { color: #059669; }
.card:not(.filled).suit-h { color: #dc2626; }
.card:not(.filled).suit-s { color: #0f172a; }
/* Modern four-colour deck: a solid suit-coloured face, a white index in the
   top-left corner, and a faint oversized pip anchored bottom-right. */
.card.filled {
  color: #fff;
  overflow: hidden;
  grid-template-rows: auto auto 1fr;
  border-color: rgba(255, 255, 255, 0.1);
  text-shadow: none;
  box-shadow:
    0 8px 16px -6px rgba(0, 0, 0, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.card.filled .rank {
  font-family: var(--table-font);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card.filled .suit {
  align-self: start;
  justify-self: start;
  margin-top: 0.1em;
  font-size: clamp(11px, 2.3cqw, 23px);
}
.card.filled::after {
  content: attr(data-suit);
  position: absolute;
  right: -7%;
  bottom: -13%;
  font-size: clamp(32px, 6.6cqw, 68px);
  line-height: 1;
  color: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.card.filled.suit-s { background: linear-gradient(180deg, #474d56, #363b43); }
.card.filled.suit-h { background: linear-gradient(180deg, #b73b39, #9a2c2b); }
.card.filled.suit-d { background: linear-gradient(180deg, #3a64c4, #2c4fa8); }
.card.filled.suit-c { background: linear-gradient(180deg, #34955d, #29794a); }

.back-cards span {
  position: relative;
  width: clamp(34px, 6.3cqw, 64px);
  height: clamp(48px, 8.9cqw, 90px);
  border-radius: clamp(6px, 1cqw, 10px);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.06) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #1e3a8a, #172554);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 8px 16px -6px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.board {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Pot label sits in the upper-left of the felt with its chip cluster directly
   beneath it, well clear of the centred board so it has room to breathe when
   the window shrinks. */
.pot {
  position: absolute;
  z-index: 2;
  top: 28%;
  left: 15%;
  transform: none;
  padding: 5px 14px;
  border-radius: 7px;
  background: rgba(13, 14, 17, 0.88);
  border: 1px solid rgba(255, 252, 240, 0.1);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* A small chip cluster sitting just under the pot label to make the settled pot
   feel like real money on the felt. Shown only when the pot is non-zero. */
.pot-chips {
  position: absolute;
  z-index: 2;
  top: 44%;
  left: 15%;
  display: flex;
  align-items: center;
}

.table-action-badge {
  position: absolute;
  z-index: 3;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 252, 240, 0.1);
  color: #fff;
}

.table-action-badge.villain-badge {
  /* Well to the RIGHT of the villain's cards (which sit top-centre), in the open
     felt space beside them, so it never covers the cards, the IP seat tag, or the
     board. Only shown for amount-less actions (CHECK/CALL/FOLD); sized actions
     render as the chip stack instead. */
  top: 14%;
  left: 70%;
  transform: none;
}

.table-action-badge.hero-badge {
  /* Mirror of the villain badge: to the RIGHT of the hero's cards, kept INSIDE
     the felt so it never drops into the action/bet box below the table when the
     window is small. */
  bottom: 22%;
  left: 70%;
  transform: none;
}

.chip-display {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

/* Live wagers sit in the same right-side zone as the action badges (they're the
   sized-bet form of the same indicator), so both forms appear in one consistent
   place and stay clear of the board. */
.chip-display.villain-chips {
  top: 16%;
  left: 64%;
  transform: none;
}

.chip-display.hero-chips {
  bottom: 24%;
  left: 64%;
  transform: none;
}

/* Restored-from-fullscreen / smaller windows: tighten the felt furniture so
   the seat tags, pot and chips don't crowd the shrinking board. */
@media (max-width: 1200px) {
  .table-stage { padding: 16px 20px; }
  .felt { border-width: 12px; }
  .seat strong { min-width: 92px; padding: 6px 12px; font-size: 12px; }
  .seat small { min-width: 92px; padding: 4px 12px; font-size: 11px; }
  .villain { top: -32px; }
  .hero { bottom: -36px; }
  .pot { padding: 6px 14px; font-size: 12px; }
  .chip-display { font-size: 12px; }
  .table-action-badge { font-size: 13px; padding: 6px 12px; }
}

/* ≤980px: three columns no longer fit. Keep the nav rail beside the table and
   move the sim-data rail below, full width; the page scrolls as a whole. */
@media (max-width: 980px) {
  html, body { overflow: auto; height: auto; }
  .app-shell {
    grid-template-areas:
      "nav main"
      "data data";
    grid-template-columns: clamp(208px, 26vw, 256px) minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .app-shell.home-mode {
    grid-template-areas: "main";
    grid-template-columns: minmax(0, 1fr);
  }
  .trainer { min-height: 100vh; }
  .sidebar { overflow: visible; }
  .rightbar {
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .felt { border-width: 10px; }
  .seat strong { min-width: 76px; font-size: 11px; }
  .seat small { min-width: 76px; font-size: 10px; }
  .villain { top: -26px; }
  .hero { bottom: -30px; }
  .pot, .pot-chips { left: 11%; }
}

/* ≤700px: single column — table first, sim data next, nav/session last. The
   trainer caps at one viewport so the felt never towers over the controls. */
@media (max-width: 700px) {
  .app-shell {
    grid-template-areas:
      "main"
      "data"
      "nav";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }
  .trainer { min-height: 96vh; }
  .sidebar { border-right: 0; border-top: 1px solid var(--line); }
  .topbar { flex-wrap: wrap; min-height: 0; }
  .top-actions { width: 100%; }
  .top-actions .button { flex: 1; }
  .table-stage { padding: 8px 10px; }
  /* aspect-ratio × min-height would force the felt wider than the window on
     phone-width screens; switch to an explicit height instead. */
  .felt {
    width: 96%;
    aspect-ratio: auto;
    height: clamp(170px, 52vw, 300px);
    min-height: 0;
    border-width: 8px;
  }
  .decision-bar { grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 8px; }
  .rng { width: 40px; height: 40px; font-size: 14px; }
  .actions { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
  .review-actions { width: 100%; flex-wrap: wrap; }
  .continue-button, #changeMoveBtn { min-width: 0; flex: 1 1 140px; }
  /* Feedback action rows: drop the tag column and shrink the bar so the row
     grid still fits a phone-width window. */
  .fsd-row { grid-template-columns: 16px minmax(0, auto) 1fr 46px 66px; }
  .dialog { width: calc(100vw - 16px); max-width: calc(100vw - 16px); }
  .dialog-body { padding: 14px; }
  .file-row { flex-wrap: wrap; }
}

/* Preflop matrix builder */
.range-builder-body {
  gap: 18px;
  width: 100%;
  max-height: calc(100vh - 72px);
  overflow: auto;
}

.range-builder-body header p {
  margin: 4px 0 0;
  font-size: 13px;
}

.range-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.range-name-row label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.range-name-row .button {
  min-height: 42px;
  white-space: nowrap;
}

.range-builder-layout {
  display: grid;
  grid-template-columns: 260px minmax(440px, 1fr) minmax(420px, 520px);
  gap: 16px;
  min-height: 620px;
}

@media (max-width: 1220px) {
  .range-builder-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .range-builder-detail {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .range-builder-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .range-builder-detail {
    grid-column: auto;
  }
}

.range-builder-side,
.range-builder-detail,
.range-builder-main {
  min-width: 0;
}

.range-builder-panel,
.range-builder-detail,
.range-builder-main {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.24);
  padding: 12px;
}

.range-builder-panel + .range-builder-panel {
  margin-top: 14px;
}

.range-builder-panel h3,
.range-builder-detail h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.range-spot-list {
  display: grid;
  gap: 8px;
}

.spot-editor-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.spot-editor-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.spot-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.range-add-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 8px 0 10px;
}

.range-action-list {
  display: grid;
  gap: 18px;
  overflow-y: auto;
  padding-right: 4px;
}

.range-spot-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.range-spot-item > button:first-child {
  min-width: 0;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.range-spot-item.active > button:first-child {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.range-spot-item strong,
.range-spot-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.range-builder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.range-builder-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.range-help {
  margin: 4px 0 12px;
  font-size: 13px;
}

.range-option-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  padding: 12px 14px;
}

.range-option-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.range-option-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.range-option-head .range-option-swatch {
  flex: 0 0 26px;
}
.range-option-head .range-option-select {
  flex: 1 1 160px;
  min-width: 120px;
}
.range-option-head .range-option-name {
  flex: 1 1 180px;
  min-width: 120px;
}
.range-option-head > button.mini-button {
  flex: 0 0 auto;
}

.range-option-select {
  min-width: 0;
  text-align: left;
  padding: 0;
  color: var(--text);
}

.range-option-select strong,
.range-option-select span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.range-option-select strong {
  font-size: 15px;
  font-weight: 900;
}

.range-option-name {
  min-width: 0;
  height: 40px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.range-paste-box {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
}

.range-option-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.range-option-note {
  color: var(--muted);
  font-size: 12px;
}

.range-option-error {
  color: #ff9a9a;
}

.range-combo-summary {
  font-size: 13px;
  font-weight: 700;
}

.range-editor-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(26px, 1fr));
  gap: 4px;
  margin-bottom: 14px;
}

.range-editor-cell {
  position: relative;
  min-height: 34px;
  border-radius: 6px;
  overflow: hidden;
  background: #1f2937;
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: #fff;
  font-weight: 900;
}

.range-editor-cell.in-range {
  border-color: rgba(255, 255, 255, 0.14);
}

.range-editor-cell.selected {
  outline: 2px solid var(--yellow);
  z-index: 2;
}

.range-editor-cell:hover {
  border-color: var(--line-2);
  transform: translateY(-1px);
}

.range-editor-bars {
  position: absolute;
  inset: 0;
  display: flex;
  opacity: 0.88;
}

.range-editor-bars span {
  min-width: 0;
}

.range-editor-cell label {
  position: relative;
  z-index: 1;
  display: block;
  padding: 6px 4px;
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.range-combo-detail {
  display: grid;
  gap: 12px;
  font-size: 13px;
  margin-top: 12px;
}

.builder-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.3);
}

.builder-detail-head strong {
  color: #fff;
  font-size: 18px;
}

.builder-detail-head span {
  color: var(--muted);
}

.builder-detail-actions {
  display: grid;
  gap: 8px;
}

.builder-strategy-row {
  /* Range-builder rows keep the original single-line 3-column layout (the
     trainer rail's .strategy-row switched to a stacked head+bar layout). */
  grid-template-columns: 72px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.builder-detail-label {
  font-size: 12px;
}

.builder-exact-list {
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.builder-exact-list .builder-exact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}

.builder-exact-list .builder-exact-row:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
}

.builder-exact-list .builder-exact-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.builder-exact-list .builder-exact-row[disabled] {
  opacity: 0.45;
  cursor: default;
}

.builder-exact-list strong {
  color: var(--text-2);
  font-size: 12px;
}

.chip-stack { display: flex; align-items: center; }
.chip-stack .chip { margin-left: clamp(-8px, -0.6cqw, -4px); position: relative; }
.chip-stack .chip:first-child { margin-left: 0; }

/* Casino chip seen from above: six pale edge inserts around a coloured body, a
   raised inner disc, and a darker rim beneath it for thickness. */
.chip {
  --chip: #3f7fe3;
  --chip-2: #24519f;
  --chip-3: #6ea2f2;
  --chip-notch: #f2f3f0;
  width: clamp(20px, 3cqw, 32px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.28), transparent 46%),
    repeating-conic-gradient(from -11deg, var(--chip-notch) 0deg 22deg, var(--chip) 22deg 60deg);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.28),
    0 2px 0 var(--chip-2),
    0 3px 0 rgba(0, 0, 0, 0.45),
    0 5px 6px rgba(0, 0, 0, 0.55);
}
.chip::after {
  content: "";
  position: absolute;
  inset: 21%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, var(--chip-3), var(--chip) 58%, var(--chip-2) 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(0, 0, 0, 0.32);
}
.chip.chip-blue { --chip: #3f7fe3; --chip-2: #24519f; --chip-3: #6ea2f2; }
.chip.chip-red { --chip: #d64848; --chip-2: #8f2626; --chip-3: #ee7272; }
.chip.chip-green, .chip.green { --chip: #2f9b5f; --chip-2: #1c6540; --chip-3: #5fc088; }
.chip.chip-black { --chip: #40464f; --chip-2: #1c1f24; --chip-3: #6a717c; --chip-notch: #d7dbe0; }
.chip.chip-white, .chip.white { --chip: #e9ebee; --chip-2: #a4abb5; --chip-3: #ffffff; --chip-notch: #7d8896; }

/* Scales with the felt (cqw). Sits in the open felt to the RIGHT of the cards so
   it never lands on the board or the upper-left pot, even when minimized. */
.dealer-button {
  position: absolute;
  z-index: 2;
  bottom: 32%;
  left: 60%;
  width: clamp(20px, 3.1cqw, 32px);
  height: clamp(20px, 3.1cqw, 32px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #000;
  font-weight: 800;
  font-size: clamp(10px, 1.4cqw, 14px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* When hero is out of position, the dealer button belongs on the villain
   (top) seat, not the hero (bottom) seat. */
.dealer-button.villain-side {
  bottom: auto;
  top: 32%;
}

/* ───────────────────────── decision bar / actions ───────────────────────── */

.decision-bar {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  max-width: 920px;
  width: 100%;
  margin: 10px auto 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  /* Query container so the action-button text scales with the bar's width and
     never overflows its box when the window is restored small. */
  container-type: inline-size;
  /* Keep the action buttons above the near-transparent feedback panel (a later
     sibling) so a short-window overlap can't intercept their clicks. */
  position: relative;
  z-index: 2;
}

.rng {
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #1d2024;
  color: #fff;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  position: relative;
}
.rng::before {
  content: "RNG";
  position: absolute;
  top: 5px;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}
.rng { padding-top: 11px; }

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
  width: 100%;
}

.action-button {
  position: relative;
  min-height: 46px;
  padding: 10px clamp(6px, 1.4cqw, 16px);
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 700;
  /* Scales with the decision bar (container units) so a long label like
     "RAISE 97 BB (644%)" shrinks to fit instead of spilling out of the button. */
  font-size: clamp(11px, 1.7cqw, 16px);
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 4px;
  transition: all 150ms;
  border: none;
  /* Grid items default to min-width:auto, which refuses to shrink below their
     content and causes the overflow. Allow shrink + clip as a final safety. */
  min-width: 0;
  overflow: hidden;
}

/* PIOSolver default colour scheme */
.action-fold { background: #1e3a8a; border-bottom: 4px solid #1e40af; } /* Blue fold */
.action-check, .action-call { background: #065f46; border-bottom: 4px solid #047857; } /* Green check/call */
.action-bet, .action-raise { background: #991b1b; border-bottom: 4px solid #b91c1c; } /* Red bet/raise */
.action-allin { background: #7f1d1d; border-bottom: 4px solid #991b1b; } /* Deep red all-in */

.action-fold:hover { background: #2563eb; }
.action-check:hover, .action-call:hover { background: #059669; }
.action-bet:hover, .action-raise:hover { background: #dc2626; }
.action-allin:hover { background: #b91c1c; }

.action-button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.action-button:disabled {
  /* Review is when the color mapping matters most. Keep disabled buttons
     clearly inactive without washing all Pio bet-size shades into one red. */
  opacity: 0.72;
  cursor: not-allowed;
}

/* A trailing "(75%)" note reads as a qualifier, not part of the action name. */
.action-note { opacity: 0.9; margin-left: 0.3em; }

.action-button .action-label { min-width: 0; }
.action-button .action-stats { display: inline-flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.action-button .action-freq { font-weight: 700; }
.action-button .action-ev { font-weight: 600; font-size: 0.9em; opacity: 0.85; white-space: nowrap; }

/* ───────────────────────── feedback / review ───────────────────────── */

.feedback {
  min-height: 40px;
  margin-top: 8px;
  /* Match the decision bar's width cap so the review panel reads as one
     column with it — full-bleed width scattered the row columns across the
     whole window and looked broken on wide/restored windows. */
  width: 100%;
  max-width: 920px;
  justify-self: center;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}
/* Simple status prompts (plain text) read better centered on a wide bar. The
   detailed correct/incorrect panel stays left-aligned for scanability. */
.feedback:has(.decision-feedback) {
  justify-content: flex-start;
  text-align: left;
}
.feedback::before {
  content: "";
  flex: 0 0 6px;
  height: 32px;
  border-radius: 99px;
  background: var(--muted-2);
}
.feedback:not(:has(.decision-feedback))::before { display: none; }

.feedback.good {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
  color: #34d399;
}
.feedback.good::before { background: var(--good); }

.feedback.bad {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.05);
  color: #f87171;
}
.feedback.bad::before { background: var(--bad); }

/* Amber "partly correct" — an advanced node that missed SOME steps. Scores as
   a miss, but shouldn't wear the same red as a fully blown node. */
.feedback.warn {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.04);
  color: var(--yellow);
}
.feedback.warn::before { background: var(--yellow); }

.feedback.muted { color: var(--muted); }

.decision-feedback {
  display: grid;
  gap: 6px;
  width: 100%;
}

.decision-main { color: #fff; font-size: 16px; font-weight: 700; }

/* Solver reveal: one aligned row per action (marker | action | tag | mix bar |
   freq | EV) so the mix and EVs compare at a glance, instead of prose pills. */
.feedback-solver-details {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.fsd-row {
  display: grid;
  grid-template-columns: 18px minmax(110px, auto) 1fr minmax(90px, 170px) 52px 76px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12.5px;
  color: var(--text-2);
}
.fsd-marker { text-align: center; font-weight: 800; }
.fsd-action { display: inline-flex; align-items: center; gap: 7px; color: #fff; font-weight: 700; white-space: nowrap; }
.fsd-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.fsd-freq { font-family: var(--table-font); font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.fsd-ev { font-family: var(--table-font); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.fsd-row.chosen { border-color: var(--accent-line); background: var(--accent-softer); }
.fsd-row.chosen.best { border-color: rgba(16, 185, 129, 0.5); background: rgba(16, 185, 129, 0.08); }
.fsd-row.best .fsd-marker, .fsd-row.best .fsd-tag { color: var(--good); }
.fsd-row.chosen:not(.best) .fsd-marker, .fsd-row.chosen:not(.best) .fsd-tag { color: var(--bad); }

.review-actions {
  justify-self: center;
  display: flex;
  gap: 10px;
  margin-top: 12px;
  /* The feedback panel is a later sibling with a near-transparent good/bad
     background; in a short window it can overlap this row and silently eat
     clicks on Continue/Next. Lift the interactive controls above it. */
  position: relative;
  z-index: 3;
}

.continue-button, #changeMoveBtn { min-width: 170px; min-height: 36px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ───────────────────────── right rail / strategy ───────────────────────── */

/* Section headers inside the sim-data rail. Brighter than plain muted text and
   underlined with the signature gold tick so each section reads as its own
   block instead of blending into the bars around it. */
.sim-subtitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Toggle clusters (Combos/% + Full/Range/Norm + zoom) are wider than a
     narrow rail — wrap them onto a second line instead of overflowing. */
  flex-wrap: wrap;
  row-gap: 4px;
  min-width: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 8px 0 9px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.sim-subtitle > span:first-child::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 9px;
  margin-right: 7px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.9;
}
.sim-subtitle > span:last-child {
  color: var(--text-2);
  text-transform: none;
  font-weight: 600;
  font-size: 12px;
}

/* The two frequency panels are boxed cards so each reads as its own unit
   instead of blending into the rail. The combo-level card's header tick is
   blue (vs gold) as an extra "this is MY hand, not the range" cue. */
.strategy-breakdown, .combo-strategy {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
}
.strategy-breakdown .sim-subtitle, .combo-strategy .sim-subtitle { margin-top: 0; }
.sim-subtitle.combo-level > span:first-child::before { background: var(--blue); }
/* Long solver node ids truncate from the front (the tail is the informative
   part); the full id stays available via the title tooltip. */
.sim-subtitle .node-id {
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
}
.range-extras { min-width: 0; }

/* Frequency row: label + % on the head line, full-width bar underneath, so
   long size labels never wrap beside a crushed bar on a narrow rail. */
.strategy-row {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}
.strategy-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.strategy-row strong { color: #fff; }
.strategy-row span:last-child {
  color: var(--text-2);
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 9px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 400ms;
}

.range-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; margin-top: 16px; }

.strategy-grid-169 {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.strategy-cell {
  position: relative;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #1f2937;
  color: #fff;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}
.strategy-cell:hover { transform: scale(1.1); z-index: 10; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.strategy-cell.selected { outline: 2px solid var(--accent); z-index: 11; }
.strategy-cell.filtered-out { opacity: 0.2; }

.strategy-cell-bars {
  position: absolute;
  /* Bottom-anchored fill whose HEIGHT encodes the grid height mode
     (full / range / normalized). Horizontal segments inside still encode the
     action mix (bet sizes / check). */
  left: 0; right: 0; bottom: 0;
  height: var(--bar-height, 100%);
  display: flex;
  pointer-events: none;
  transition: height 0.15s ease;
}
.strategy-cell-bars span {
  min-width: 0;
  /* A hairline preserves the boundary between adjacent Pio shades in the
     compact grid without changing the palette itself. */
  box-shadow: inset 1px 0 rgba(255, 255, 255, 0.14);
}
.strategy-cell-bars span:first-child { box-shadow: none; }
/* The empty area above the fill (the part of the range NOT this hand). */
.strategy-cell { background: #161d27; }

.strategy-cell label {
  position: relative;
  z-index: 1;
  display: block;
  padding: 4px;
  text-shadow: 0 1px 2px #000, 0 0 4px rgba(0, 0, 0, 0.9);
}

/* Exact combo-count (or range-%) badge in the cell's top-right corner. */
.strategy-cell-count {
  position: absolute;
  top: 2px;
  right: 3px;
  z-index: 2;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px #000, 0 0 4px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}
.zoom-dialog-content .strategy-cell-count { top: 4px; right: 5px; font-size: 11px; }

/* ── per-combo hover popover (GTO Wizard style) ── */
.combo-popover {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  max-width: 460px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(12, 18, 30, 0.98);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.7);
  color: #e5e7eb;
  font-size: 12px;
}
.combo-popover.hidden { display: none; }

.combo-popover .cp-head {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.combo-popover .cp-filter {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.combo-popover .cp-table {
  border-collapse: collapse;
  white-space: nowrap;
}
.combo-popover .cp-table th,
.combo-popover .cp-table td {
  padding: 3px 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.combo-popover .cp-table th {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}
.combo-popover .cp-table th .cp-sw {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.combo-popover .cp-cards-h, .combo-popover .cp-cards { text-align: left; }
.combo-popover .cp-mix-h, .combo-popover .cp-mix { width: 96px; }

.combo-popover .cp-cards {
  font-weight: 800;
  letter-spacing: 0.01em;
}
.combo-popover .cp-card { margin-right: 2px; }
.combo-popover .cp-card.red { color: #f87171; }
.combo-popover .cp-card.suit-s { color: #cbd5e1; }
.combo-popover .cp-card.suit-h { color: #f87171; }
.combo-popover .cp-card.suit-d { color: #60a5fa; }
.combo-popover .cp-card.suit-c { color: #34d399; }
.combo-popover .cp-wt {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
}

.combo-popover .cp-bar {
  display: flex;
  height: 12px;
  width: 100%;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}
.combo-popover .cp-bar span { min-width: 0; }

.combo-popover .cp-agg td {
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  color: #fff;
  font-weight: 700;
}
.combo-popover tbody tr:first-child + tr td { padding-top: 6px; }

.range-explorer, .category-explorer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

/* Range-shape (equity/EV distribution morphology) graph */
.range-shape {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.range-shape .sim-subtitle { margin-bottom: 8px; }
.range-shape-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}
.range-shape-metric {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.range-shape-metric:hover:not(:disabled) { color: var(--text-2); }
.range-shape-metric.active {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
}
.range-shape-metric:disabled { opacity: 0.35; cursor: default; }
.range-shape-chart-wrap {
  margin-top: 8px;
  padding: 6px 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
}
.range-shape-chart-wrap.rs-hero {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, var(--accent-softer), transparent);
}
.rs-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.rs-pos {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.range-shape-chart-wrap.rs-hero .rs-pos { color: var(--accent); }
.rs-metric-val { font-size: 10px; font-weight: 600; color: var(--muted); }
.rs-filter-share { font-size: 10px; font-weight: 700; color: #facc15; }
.range-shape-chart {
  width: 100%;
  height: 92px;
  display: block;
}
.range-shape-tick {
  fill: var(--muted-2);
  font-size: 8px;
  font-weight: 600;
  font-family: inherit;
}
.range-shape-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}
.rs-filter-swatch {
  display: inline-block;
  width: 12px;
  height: 10px;
  border-radius: 2px;
  background: #facc15;
}
.range-shape-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.rs-legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; }
.rs-swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.rs-swatch-grad { background: linear-gradient(90deg, hsl(0,68%,52%), hsl(62,68%,52%), hsl(125,68%,52%)); }
.rs-legend-x { margin-left: auto; color: var(--muted-2); font-size: 10px; text-transform: lowercase; letter-spacing: 0.02em; }
.range-shape-loading {
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 12px;
  border-radius: 8px;
  background: var(--panel-2);
}
.range-shape-loading.sm { height: 72px; font-size: 11px; }


.filter-chip {
  display: inline-block;
  margin-right: 8px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--accent-line);
}

.clear-filter {
  margin-left: 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 46px minmax(90px, 1.4fr);
  align-items: center;
  gap: 10px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
}
.category-row:hover, .category-row.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-2);
}
.category-row.active { border-color: var(--accent); color: #fff; }
.category-weight { color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.category-bar {
  height: 10px;
  display: flex;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 90vw;
  /* Never taller than the window — the body scrolls instead of spilling off
     the screen when the window is small. Fixes dialogs (Add Pack, Start, etc.)
     overflowing the viewport on a restored/minimized window. */
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
.dialog > .dialog-body,
.dialog > form.dialog-body {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.dialog.range-dialog {
  width: min(1500px, calc(100vw - 56px));
  max-width: calc(100vw - 56px);
}

.dialog.zoom-dialog {
  /* Scale WITH the window: ~84% of viewport width, clamped so it's never tiny
     nor wider than the screen. This (vs the old min(1040px, …) which pinned to
     ~1040px until the window got small) makes the popup proportionally smaller
     on a restored window and larger fullscreen. Height is capped so it never
     runs off-screen vertically. */
  width: clamp(420px, 84vw, 1500px);
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 64px);
}
.dialog.zoom-dialog .dialog-body { max-height: calc(100vh - 64px); overflow: auto; }
.zoom-dialog-content { display: grid; gap: 16px; min-width: 0; }
/* Enlarge the cloned panels in the zoom view so the popup is actually more
   readable, not just wider. Cells/text grow with the larger dialog. */
.zoom-dialog-content .range-shape-chart { height: 260px; }
.zoom-dialog-content .range-shape-tick { font-size: 5px; }
.zoom-dialog-content .strategy-grid-169 { gap: 4px; }
.zoom-dialog-content .strategy-cell { min-height: 46px; font-size: 13px; }
.zoom-dialog-content .strategy-cell label { padding: 5px 6px; }
.zoom-dialog-content .category-row { padding: 8px 10px; }
.zoom-dialog-content .category-row strong { font-size: 14px; }
.zoom-dialog-content .category-weight { font-size: 13px; }
.zoom-dialog-content .category-bar { height: 13px; }
.zoom-dialog-content .range-explorer,
.zoom-dialog-content .category-explorer { margin-top: 0; padding-top: 0; border-top: 0; }

/* Corner expand control shown in panel subtitles */
.subtitle-right { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.zoom-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.zoom-btn:hover { color: #fff; border-color: var(--accent); background: var(--accent-soft); }

.dialog.preflop-drill-dialog {
  width: min(900px, calc(100vw - 56px));
  max-width: calc(100vw - 56px);
}

.dialog.range-dialog .dialog-body {
  min-width: 0;
}
.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.dialog-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}
.dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.dialog header h2 { margin: 0; font-size: 16px; font-weight: 700; color: #fff; }
.dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0;
}
legend {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 4px;
}
.sample-weight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.sample-weight-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
#startDialogSampleFieldset > .muted {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.4;
}
.file-row { display: flex; gap: 10px; }
.selected-files {
  max-height: 120px;
  overflow-y: auto;
  font-size: 12px;
  font-family: monospace;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.selected-files.bad {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.check-row + .check-row { margin-top: 6px; }
.select-row { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }


.inline-title { align-items: center; }


.library-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 14px;
  min-width: 0;
  overflow-x: auto;
}

.library-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.32);
}

.library-column-head {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.library-column-head h3 {
  margin: 0 0 5px;
  color: #fff;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

.library-column-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.library-head-actions,
.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.library-tree {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}


.mini-button {
  min-width: 60px;
  min-height: 27px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.mini-button:hover {
  border-color: var(--line-2);
  background: rgba(255, 255, 255, 0.1);
}


.mini-button.compact {
  min-width: 44px;
  padding: 0 8px;
}

.mini-button.primary-mini {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.drill-source-panel {
  display: grid;
  gap: 10px;
}


.spot-history {
  display: grid;
  gap: 8px;
}

.spot-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.28);
}

.spot-history-item strong,
.spot-history-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}


/* ---- Advanced Trainer Mode config (pack dialog) -------------------------- */
.advanced-mode-section { margin-top: 12px; }
.adv-config { margin-top: 8px; display: grid; gap: 12px; }

/* Reusable hover/focus "?" help tip — replaces always-visible helper paragraphs.
   Put it next to a label/legend; the explanatory text lives in the tooltip. */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: var(--accent-text);
  font-size: 11px; font-weight: 700; line-height: 1; cursor: help;
  position: relative; vertical-align: middle; user-select: none;
}
.help-tip:hover, .help-tip:focus { background: var(--accent-line); outline: none; }
.help-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 280px; white-space: normal; text-align: left;
  background: #0e1822; color: #e8eef5; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 400; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.12s ease;
}
.help-tip:hover::after, .help-tip:focus::after { opacity: 1; }
/* Tips near the top of the dialog open downward so they aren't clipped. */
.help-tip.tip-below::after { bottom: auto; top: calc(100% + 8px); }
.adv-legend-row { display: flex; align-items: center; }
.adv-bucket-actions { display: flex; gap: 6px; }
.adv-tol-row { display: flex; align-items: center; gap: 6px; }
.adv-tol-row .input { width: 70px; }
.adv-bucket-list { display: grid; gap: 6px; }
.adv-bucket-row { display: flex; align-items: center; gap: 8px; }
.adv-bucket-label { flex: 1 1 auto; min-width: 0; }
.adv-bucket-center { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.adv-bucket-num { width: 72px; flex: 0 0 auto; text-align: center; padding-left: 6px; padding-right: 6px; }
.adv-bucket-suffix { color: var(--muted); }
.adv-bucket-window { flex: 0 0 auto; width: 84px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.adv-bucket-remove { flex: 0 0 auto; }

/* ---- Per-step accuracy readout (session panel) -------------------------- */
.step-accuracy { display: grid; gap: 4px; margin: 8px 0; }
.step-accuracy .step-acc-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.step-accuracy .step-acc-row label { color: var(--muted); }
.step-accuracy .step-acc-row span { font-weight: 600; }
.step-accuracy .step-acc-row small { color: var(--muted); margin-left: 6px; font-weight: 400; }

/* ---- Advanced Trainer Mode staged flow (decision bar) ------------------- */
.action-button.adv-step-button { background: #1d2b3a; border-color: rgba(255,255,255,0.12); color: #e8eef5; }
.action-button.adv-step-button:hover { background: #26384c; }
.action-button.adv-step-button small { display: block; font-size: 11px; opacity: 0.7; margin-top: 2px; font-weight: 400; }
/* Hand-class identify step: up to ~25 buttons, so shrink them to keep the
   wrapped grid readable. */
.action-button.adv-class-button { font-size: 12px; padding: 8px 12px; min-width: 0; }
.rng.adv-dim { opacity: 0.35; transition: opacity 0.2s ease; }

/* Progress / summary strip above the decision bar. Its own opaque panel +
   z-index so it never visually collides with the felt's overflowing hero seat
   in a short window; top margin clears that seat. */
.adv-progress {
  margin: 44px auto 0; max-width: 920px; width: 100%;
  position: relative; z-index: 3;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px;
}
.adv-prog-head {
  font-weight: 700; font-size: 15px; color: var(--accent-text); text-align: center;
  margin-bottom: 8px; letter-spacing: 0.2px;
}
.adv-prog-board { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.adv-prog-board strong { color: #e8eef5; }
.adv-prog-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.adv-prog-chip {
  display: flex; flex-direction: column; gap: 2px; min-width: 96px; flex: 0 1 auto;
  padding: 6px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}
.adv-prog-chip .apc-step { font-size: 11px; color: var(--muted); white-space: nowrap; }
.adv-prog-chip .apc-val { font-size: 14px; font-weight: 700; color: #e8eef5; }
.adv-prog-chip.current { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-glow) inset; }
.adv-prog-chip.current .apc-step { color: var(--accent-text-2); }
.adv-prog-chip.done-ok { border-color: rgba(80,180,110,0.45); background: rgba(80,180,110,0.12); }
.adv-prog-chip.done-ok .apc-step { color: #8fd6a6; }
.adv-prog-chip.done-bad { border-color: rgba(210,90,80,0.45); background: rgba(210,90,80,0.12); }
.adv-prog-chip.done-bad .apc-step { color: #e79b93; }
.adv-prog-chip.pending { opacity: 0.5; }
/* On a missed step: your wrong pick struck-through + dim, the correct answer
   shown in green so later steps can reason off it. */
.adv-prog-chip .apc-wrong { color: #e79b93; text-decoration: line-through; opacity: 0.75; font-weight: 600; }
.adv-prog-chip .apc-answer { color: #8fd6a6; }

/* Compact the strip on narrow/short windows so 4 chips fit one row cleanly. */
@media (max-width: 1100px) {
  .adv-progress { margin-top: 40px; padding: 10px 12px; }
  .adv-prog-head { font-size: 13px; margin-bottom: 6px; }
  .adv-prog-row { gap: 6px; }
  .adv-prog-chip { min-width: 72px; padding: 5px 8px; }
  .adv-prog-chip .apc-step { font-size: 10px; }
  .adv-prog-chip .apc-val { font-size: 12px; }
}

/* Short windows: shrink the felt + its seat overhang so the strip clears the
   table instead of overlapping the OOP seat. The stage already scrolls. */
@media (max-height: 820px) {
  .felt { min-height: 180px; }
  .hero { bottom: -26px; }
  .villain { top: -24px; }
  .adv-progress { margin-top: 30px; }
}

/* Pio / Custom hand-class toggle (Current Sim Data panel) */
.class-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.class-toggle-btn { background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 11px; font-weight: 700; padding: 4px 10px; letter-spacing: 0.3px; }
.class-toggle-btn:hover { color: #e8eef5; }
.class-toggle-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.category-row-readonly { cursor: default; width: 100%; text-align: left; }

/* Disabled buttons (e.g. Save during a sim scan) */
.button:disabled, .button[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Start-dialog: starting-action-sequence input + "Pick from sim" button */
.line-input-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.line-input-row .input { flex: 1 1 auto; min-width: 0; }
.line-input-row .button { flex: 0 0 auto; }

/* Interactive node picker */
.node-picker-path {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--accent-text);
  background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; margin: 8px 0; word-break: break-all;
}
.node-picker-children { display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px; }
.node-picker-child {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 96px; padding: 10px 14px; cursor: pointer;
  background: #1d2b3a; color: #e8eef5; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px; font-size: 14px; font-weight: 700;
}
.node-picker-child:hover { background: #26384c; border-color: var(--accent); }
.node-picker-child small { font-size: 11px; font-weight: 400; color: var(--muted); }
.node-picker-child.is-card { background: #243044; min-width: 56px; }

/* ── Compact, expandable hand History (sidebar) ───────────────────────────── */
.history-list { display: grid; gap: 4px; }
.history-row { border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,0.25); overflow: hidden; }
.history-head {
  width: 100%; display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: transparent; border: 0; color: var(--text); padding: 7px 9px; text-align: left;
}
.history-head:hover { background: rgba(255,255,255,0.04); }
.hist-mark { font-weight: 800; width: 14px; text-align: center; flex: 0 0 auto; }
.hist-mark.good { color: #5ac977; }
.hist-mark.bad { color: #e0564e; }
.hist-mark.pending { color: var(--muted); }
.hist-on { color: var(--muted); font-size: 11px; }
.hist-caret { margin-left: auto; color: var(--muted); font-size: 11px; }
.mini-cards { display: inline-flex; gap: 2px; }
.mini-card {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
  padding: 1px 4px; border-radius: 3px; background: #2a3340; color: #e8eef5; line-height: 1.4;
}
.mini-card.red { color: #ff8a80; }
.mini-card.suit-s { background:#2f3a4a; color:#cdd9e6; }
.mini-card.suit-h { background:#5a2730; color:#ff9aa2; }
.mini-card.suit-d { background:#234a63; color:#7fc8ff; }
.mini-card.suit-c { background:#26492f; color:#86d99a; }
.history-detail { display: none; padding: 0 10px 10px; }
.history-row.open .history-detail { display: block; }
.hist-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; margin-bottom: 8px; }
.hist-act { color: #cdd9e6; }
.hist-act.good { color: #8fd6a6; }
.hist-act.bad { color: #e79b93; }
.hist-run { color: var(--accent-text-2); font-weight: 700; }
.hist-arrow { color: var(--muted); }

/* History pager */
.history-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; }
.history-page-label { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.history-pager .mini-button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Node picker: "Any card" wildcard button (default at runout steps) */
.node-picker-child.node-picker-any {
  min-width: 130px; background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text);
}
.node-picker-child.node-picker-any:hover { background: var(--accent-glow); }

/* Grid height-mode toggle (Full / Range / Normalized) in the grid header */
.grid-height-toggle { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-right: 6px; }
.grid-h-btn {
  background: transparent; color: var(--muted); border: none; cursor: pointer;
  font-size: 11px; font-weight: 700; padding: 2px 7px; letter-spacing: 0.2px;
}
.grid-h-btn:hover { color: #e8eef5; }
.grid-h-btn.active { background: var(--accent-soft); color: var(--accent-text); }

/* ── Session-complete summary (hand-limit finish) ── */
.session-complete-dialog {
  width: 420px;
  background: #14161a;
}
.session-complete-dialog[open] {
  animation: sc-in 220ms ease-out;
}
.session-complete-dialog[open]::backdrop {
  animation: sc-backdrop 220ms ease-out;
}
@keyframes sc-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes sc-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}
.session-complete-dialog .dialog-body { gap: 16px; padding: 22px 22px 18px; }
.session-complete-dialog header { align-items: flex-start; margin-bottom: 0; }
.session-complete-dialog header h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.sc-verdict {
  margin: 0 0 2px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.sc-score-wrap { display: flex; justify-content: center; padding: 4px 0 2px; }
.sc-ring {
  position: relative;
  width: 148px;
  height: 148px;
}
.sc-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.sc-ring-bg {
  fill: none;
  stroke: rgba(255, 252, 240, 0.08);
  stroke-width: 2.6;
}
.sc-ring-fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 400ms ease-out, stroke 200ms ease;
}
.sc-ring.sc-good .sc-ring-fg { stroke: #34d399; }
.sc-ring.sc-ok .sc-ring-fg { stroke: var(--accent); }
.sc-ring.sc-bad .sc-ring-fg { stroke: #f87171; }
.sc-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.sc-ring-label strong {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #fff;
}
.sc-ring-label span {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sc-bars { display: grid; gap: 8px; }
.sc-bar-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}
.sc-bar-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.sc-bar-track {
  height: 7px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.sc-bar-fill {
  height: 100%;
  border-radius: 99px;
  width: 0;
  transition: width 350ms ease-out;
}
.sc-bar-row span {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.sc-bar-row.grade-best .sc-bar-fill { background: #10b981; }
.sc-bar-row.grade-best label { color: #34d399; }
.sc-bar-row.grade-correct .sc-bar-fill { background: #4ade80; }
.sc-bar-row.grade-correct label { color: #86efac; }
.sc-bar-row.grade-inaccuracy .sc-bar-fill { background: #eab308; }
.sc-bar-row.grade-inaccuracy label { color: #facc15; }
.sc-bar-row.grade-wrong .sc-bar-fill { background: #f97316; }
.sc-bar-row.grade-wrong label { color: #fb923c; }
.sc-bar-row.grade-blunder .sc-bar-fill { background: #ef4444; }
.sc-bar-row.grade-blunder label { color: #f87171; }
.sc-ev {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.sc-ev label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sc-ev strong {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.sc-ev.muted { display: none; }
.sc-highlights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sc-highlights:empty { display: none; }
.sc-hi {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-width: 0;
}
.sc-hi .sc-hi-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.sc-hi .sc-hi-cards { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sc-hi .sc-hi-board { opacity: 0.85; }
.sc-hi .sc-hi-meta {
  font-size: 11px;
  color: var(--text-2);
}
.session-complete-dialog footer {
  justify-content: stretch;
  gap: 10px;
  margin-top: 4px;
}
.session-complete-dialog footer .button { flex: 1; min-height: 36px; }

/* Dedicated routine drill selection keeps the schedule visible until needed. */
#routineDialog .routine-picker-panel { display:none; }
.routine-picker { width:min(800px, calc(100vw - 24px)); }
.routine-picker .dialog-body { max-height:85dvh; overflow:auto; }
.routine-picker-filters { display:flex; gap:8px; flex-wrap:wrap; }
.routine-picker-filters [aria-pressed=true] { border-color:var(--gold,#d6a53e); color:var(--gold,#d6a53e); }
.routine-picker .routine-sources { max-height:50dvh; overflow:auto; }
.routine-picker .routine-source-row { display:flex; gap:12px; cursor:pointer; }
.routine-picker .routine-source-row input { width:20px; height:20px; flex-shrink:0; }
.routine-picker footer { position:sticky; bottom:0; background:#101315; padding:12px 0; }
.routine-picker .drill-source-toolbar { flex-wrap:wrap; }
.sim-metadata-fields label { min-width:0; }
@media(max-width:600px) {
 .routine-picker .panel-title { align-items:stretch; flex-direction:column; }
 .routine-picker .drill-source-search { width:100%; min-width:0; }
 .routine-picker footer button { width:100%; white-space:normal; }
}
