/* =============================================================================
 * Preflop GTO Flashcard Trainer — dark, mobile-first, solver-style
 * Single source of truth for the action palette is in :root and reused by
 * buttons, the result header, and the range-grid coloring.
 * ========================================================================== */

:root {
  /* surfaces */
  --bg:        #0d1117;
  --panel:     #161b22;
  --panel-2:   #1c2230;
  --border:    #2a3242;
  --text:      #e6edf3;
  --muted:     #8b95a5;

  /* action palette */
  --raise:     #e5484d; /* red    */
  --call:      #2ea043; /* green  */
  --fold:      #3b82f6; /* blue   */

  /* verdicts */
  --correct:     #2ea043;
  --inaccuracy:  #f59e0b;
  --blunder:     #e5484d;

  /* history screen: two-tier inaccuracy split (score>=50 vs <50) + accent.
     --inacc-hi/-lo also drive the heat ramp stops in history-ui.js. */
  --inacc-hi:    #bfce2e;
  --inacc-lo:    #f0962b;
  --accent:      #46a6ff;
  --accent-dim:  #2b5f8a;
  --raised:      #26333d; /* slightly lifted surface for matrix/seg controls */

  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + 10px)
    calc(env(safe-area-inset-bottom) + 8px)
    calc(env(safe-area-inset-left) + 10px);
  gap: 10px;
}

/* ============================ Session region ============================== */
.session {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.selector {
  flex: 1;
  display: flex;
  gap: 6px;
}

.sel-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sel-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.selector select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 600;
  appearance: none;
}

.selector select:disabled {
  color: var(--muted);
  opacity: 0.7;
}

/* Single range-set dropdown in the header — fills the row. */
.rangeset-field { flex: 1; }
.rangeset-field select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  appearance: none;
}

/* Three position selectors as the top row of the front face. */
.card-selector {
  flex: 0 0 auto;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.stat-val { font-size: 18px; font-weight: 700; margin-top: 2px; }
.stat-val.correct    { color: var(--correct); }
.stat-val.inaccuracy { color: var(--inaccuracy); }
.stat-val.blunder    { color: var(--blunder); }
/* Per-hand Elo direction arrow next to the rating. */
.elo-dir { font-size: 12px; font-weight: 700; }
.elo-dir.up   { color: var(--correct); }
.elo-dir.down { color: var(--blunder); }
.elo-dir.flat { color: var(--muted); }

/* ============================ Flashcard ================================== */
.card-area {
  flex: 1 1 auto;
  min-height: 0;
  perspective: 1600px;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.flashcard.flipped { transform: rotateY(180deg); }

/* Hard guard against backface bleed-through: hide whichever face is turned
 * away. `visibility` is delayed to the midpoint of the flip so content doesn't
 * vanish mid-rotation, but at rest only the visible face's children render —
 * this is what actually stops the table seats/chips showing through the back
 * (z-index children can defeat backface-visibility on WebKit). */
.flashcard .front { visibility: visible; transition: visibility 0s 0.25s; }
.flashcard .back  { visibility: hidden;  transition: visibility 0s 0.25s; }
.flashcard.flipped .front { visibility: hidden; }
.flashcard.flipped .back  { visibility: visible; }

.face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Keep each face flat-on at its own depth so its backface is actually culled.
   * Without an explicit transform on the front, child stacking contexts (table
   * seats/chips with z-index) can bleed through to the back on WebKit/Safari. */
  transform: rotateY(0deg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.back { transform: rotateY(180deg); }

/* ---- Front: minimal action rail (folds omitted) ---- */
.rail-zone {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
}
.rc {
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}
.rc small { font-size: 10px; font-weight: 700; color: var(--muted); }
.rc.raised { border-color: var(--raise); } .rc.raised small { color: var(--raise); }
.rc.called { border-color: var(--call); }  .rc.called small { color: var(--call); }
.rc.pending small { font-style: italic; }
/* hero yet to act: white border + white glow */
.rc.hero {
  border-color: #fff;
  background: #1b2433;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22), 0 0 10px rgba(255, 255, 255, 0.4);
}
.rc.hero small { color: #fff; }
/* hero acted earlier: action color border/text, white glow stays */
.rc.hero.raised { border-color: var(--raise); }
.rc.hero.raised small { color: var(--raise); }
.rarrow { color: var(--muted); font-size: 12px; font-weight: 700; }

/* ---- Front: miniature 6-max table, hero bottom-center ----
 * The zone flexes to whatever height remains between the selectors/rail and
 * the action buttons, so the buttons are never clipped; the felt is capped so
 * it doesn't balloon on tall screens. */
.table-zone {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
}
.tablewrap { position: relative; width: 100%; height: 100%; max-height: 310px; }
.felt {
  position: absolute;
  inset: 30px 28px 36px;
  background: radial-gradient(ellipse at 50% 42%, #1c4a33 0%, #143626 65%, #0f2a1e 100%);
  border: 6px solid #233041;
  border-radius: 50%;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.55);
}
.front.mode-max .felt { inset: 26px 26px 32px; }
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 4px 9px;
  min-width: 48px;
  text-align: center;
  z-index: 2;
}
.seat b { font-size: 12px; }
.seat small { font-size: 10px; font-weight: 700; color: var(--muted); }
.seat.folded { opacity: 0.32; }
.seat.raised { border-color: var(--raise); } .seat.raised small { color: var(--raise); }
.seat.called { border-color: var(--call); }  .seat.called small { color: var(--call); }
.seat.pending small { color: var(--muted); font-style: italic; }
/* hero yet to act: white border + white glow */
.seat.hero {
  border-color: #fff;
  background: #1b2433;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25), 0 0 16px rgba(255, 255, 255, 0.45);
}
.seat.hero small { color: #fff; }
/* hero acted earlier (decision back on them): action color, white glow stays */
.seat.hero.raised { border-color: var(--raise); }
.seat.hero.raised small { color: var(--raise); }
.dbtn {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #f5f7fa;
  color: #111;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.betchip {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 9px;
  padding: 2px 7px 2px 4px;
}
.betchip i { width: 11px; height: 11px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.7); }
.betchip.r i { background: var(--raise); }
.betchip.c i { background: var(--call); }
.centerstack {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 1;
}
/* compact cards on the felt */
.hole-cards--felt { gap: 8px; }
.hole-cards--felt .hole-card {
  width: 56px;
  height: 78px;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.hole-cards--felt .card-rank { font-size: 26px; }
.hole-cards--felt .card-suit { font-size: 19px; margin-top: 2px; }
.front.mode-max .hole-cards--felt .hole-card { width: 50px; height: 69px; }
.front.mode-max .hole-cards--felt .card-rank { font-size: 23px; }
.front.mode-max .hole-cards--felt .card-suit { font-size: 17px; }

/* ---- Front: rail-only fallback (big cards) ---- */
.rail-cards {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 20px;
}

/* ---- Front: adaptive mode visibility ---- */
.front .rail-zone { display: flex; }
.front .table-zone { display: flex; }
.front .rail-cards { display: none; }
.front.mode-table .rail-zone { display: none; }
.front.mode-rail .table-zone { display: none; }
.front.mode-rail .rail-cards {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden; /* on very short screens the cards clip, not the buttons */
}
.hole-cards { display: flex; gap: 12px; }
.hole-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f5f7fa;
  color: #0d1117;
  border-radius: 12px;
  width: clamp(66px, 24vw, 100px);
  height: clamp(92px, 34vw, 138px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  line-height: 1;
}
/* Four-color deck on the white card face. */
.hole-card.suit-s { color: #16181d; } /* spade   = black */
.hole-card.suit-h { color: #d61f26; } /* heart   = red */
.hole-card.suit-d { color: #1769d6; } /* diamond = blue */
.hole-card.suit-c { color: #1a8f37; } /* club    = green */
.card-rank { font-size: clamp(34px, 13vw, 56px); font-weight: 800; }
.card-suit { font-size: clamp(26px, 10vw, 44px); margin-top: 3px; }

/* ---- Action buttons: stacked, full-width, fill remaining space.
 * Order top->bottom (set in HTML): Raise, Call, Fold. ---- */
.action-row {
  flex: 0 0 auto;
  margin-top: auto; /* push buttons to the bottom thumb zone */
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.action-btn {
  flex: 0 0 auto;
  width: 100%;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  min-height: 56px;
  letter-spacing: 0.01em;
  transition: transform 0.06s ease, filter 0.06s ease;
}
.action-btn:active { transform: scale(0.96); filter: brightness(1.15); }

.act-fold  { background: var(--fold); }
.act-call  { background: var(--call); }
.act-raise { background: var(--raise); }

/* ---- Back ---- */
.back-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
}

.result-header {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--panel-2);
}
.result-header.correct    { background: rgba(46, 160, 67, 0.18);  color: var(--correct);    border: 1px solid var(--correct); }
.result-header.inaccuracy { background: rgba(245, 158, 11, 0.16); color: var(--inaccuracy); border: 1px solid var(--inaccuracy); }
.result-header.blunder    { background: rgba(229, 72, 77, 0.18);  color: var(--blunder);    border: 1px solid var(--blunder); }

.breakdown { margin-bottom: 14px; }

/* One-liner action rail: the spot's story + dealt hand, header of the back. */
.oneliner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.oneliner i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}
.ol-raise { color: var(--raise); } .ol-raise i { background: var(--raise); }
.ol-call  { color: var(--call); }  .ol-call i  { background: var(--call); }
.ol-hero  { color: #fff; }         .ol-hero i  { background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.7); }
/* hero's own earlier action: white "you" dot, action-colored text */
.ol-heroact { color: var(--raise); }
.ol-heroact i { background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.7); }
.ol-sep { color: var(--border); }
/* hero's dealt hand as mini cards, right of the (you) token */
.ol-hand { display: inline-flex; gap: 3px; margin-left: 2px; }
.ol-hand b {
  background: #f5f7fa;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
}
.ohc-s { color: #16181d; } .ohc-h { color: #d61f26; }
.ohc-d { color: #1769d6; } .ohc-c { color: #1a8f37; }

/* You chose / Best play comparison tiles — directly below the result header. */
.cmp { display: flex; gap: 8px; margin-bottom: 12px; }
.cmp > div {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.cmp b { display: block; font-size: 16px; color: var(--text); margin-top: 2px; }
.cmp .you b  { color: var(--raise); }
.cmp .best b { color: var(--call); }

/* Tap-to-inspect readout above the range grid. */
.inspect {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  text-align: center;
}
.inspect b { color: var(--text); margin: 0 4px; }

/* Stacked horizontal frequency bar: full width = 100%, segments fill shares.
 * Left-to-right order (set in JS): Raise, Call, Fold. */
.freq-bar {
  display: flex;
  width: 100%;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel-2);
  margin-bottom: 10px;
}
.freq-seg { height: 100%; }
.freq-seg.act-fold  { background: var(--fold); }
.freq-seg.act-call  { background: var(--call); }
.freq-seg.act-raise { background: var(--raise); }

/* All four actions + percentages on one line, same order as the bar. */
.freq-labels {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.freq-item {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.freq-item b { font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.dot.act-fold  { background: var(--fold); }
.dot.act-call  { background: var(--call); }
.dot.act-raise { background: var(--raise); }

/* ---- 13x13 range grid ----
 * Region tints (gap/border) help separate the three triangles:
 *   pairs   = diagonal, suited = upper-right, offsuit = lower-left. */
.range-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.25);
  margin-bottom: 6px;
}
.grid-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  line-height: 1;
  overflow: hidden;
  border: 1px solid transparent;
  cursor: pointer; /* tap to inspect this hand's mix */
}

/* Horizontal action fill behind the label (Raise, Call, Fold L->R). */
.gc-fill {
  position: absolute;
  inset: 0;
  display: flex;
}
.gc-seg { height: 100%; }
.gc-seg.act-fold  { background: var(--fold); }
.gc-seg.act-call  { background: var(--call); }
.gc-seg.act-raise { background: var(--raise); }

/* Hand label sits on top of the fill, enlarged to fill the square. */
.gc-hand {
  position: relative;
  z-index: 1;
  font-size: clamp(7px, 2.6vw, 12px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.7);
}

.grid-cell.current {
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #fff, 0 0 8px 2px rgba(255, 255, 255, 0.85);
  z-index: 1;
  transform: scale(1.04);
}

/* The cell whose mix the inspect strip is currently showing (tap target).
 * Blue accent so it reads distinctly from the dealt hand's white .current. */
.grid-cell.inspected {
  border: 2px solid var(--fold);
  box-shadow: 0 0 0 1px var(--fold), 0 0 8px 2px rgba(59, 130, 246, 0.8);
  z-index: 2;
  transform: scale(1.06);
}

/* ---- Next button ---- */
.next-btn {
  flex: 0 0 auto;
  margin: 8px 10px calc(env(safe-area-inset-bottom) + 4px);
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #2f81f7, #1f6feb);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  min-height: 56px;
}
.next-btn:active { filter: brightness(1.12); transform: scale(0.99); }

/* Prevent accidental text selection during rapid tapping. */
.action-btn, .next-btn, .grid-cell, .formation-line, .stat {
  user-select: none;
  -webkit-user-select: none;
}

/* ===========================================================================
 * Multi-view shell: shared top bar, slide-out menu, and the history screen.
 * The trainer view keeps its flex/100dvh layout; the history view scrolls.
 * ======================================================================== */

/* ---- views ------------------------------------------------------------- */
/* Only the active view participates in the .app flex column. The trainer view
 * flexes to fill (its .card-area depends on it); the history view scrolls. */
.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
/* Match the .app gap so the card-area sits below the session header with the
 * same separation it had when the (now-removed) topbar split the .app column. */
#view-trainer.active { gap: 10px; }
#view-history.active { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- menu button (sits inline at the right of the session controls) ---- */
.burger {
  appearance: none; background: none; border: 1px solid var(--border);
  border-radius: 9px; width: 38px; height: 38px; display: grid; place-items: center;
  cursor: pointer; color: var(--text); flex: 0 0 auto;
}
.burger:active { border-color: var(--accent-dim); }
/* Compact variant to match the seg-button height in the history header. */
#burger-history { width: 32px; height: 32px; border-radius: 8px; }
.burger span, .burger span::before, .burger span::after {
  content: ""; display: block; width: 16px; height: 2px;
  background: currentColor; border-radius: 2px; position: relative;
}
.burger span::before { position: absolute; top: -5px; }
.burger span::after  { position: absolute; top: 5px; }

/* ---- slide-out menu ---------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 40;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.menu {
  position: fixed; top: 0; right: 0; height: 100%; width: 248px; max-width: 78vw;
  background: var(--panel); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .2s ease; z-index: 50;
  padding: calc(env(safe-area-inset-top) + 18px) 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.menu.open { transform: translateX(0); }
.menu .mhead {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 6px 10px 10px; font-weight: 600;
}
.menu button {
  appearance: none; text-align: left; background: none; border: 0; color: var(--text);
  font: inherit; padding: 12px; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; gap: 11px; font-size: 15px;
}
.menu button:active { background: var(--panel-2); }
.menu button.active { background: var(--accent-dim); color: #fff; }
.menu button .ic { width: 18px; text-align: center; opacity: .8; }
.menu .danger { color: var(--blunder); margin-top: auto; }
.menu .danger:active { background: rgba(229, 72, 77, .12); }

/* ---- toast ------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 26px);
  transform: translateX(-50%) translateY(20px); background: var(--accent);
  color: #04121f; font-weight: 600; font-size: 14px; padding: 11px 18px;
  border-radius: 11px; opacity: 0; transition: .22s; z-index: 60;
  pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- history: section scaffolding ------------------------------------- */
#view-history { font-variant-numeric: tabular-nums; }
#view-history section { margin-bottom: 22px; }
#view-history section:last-child { margin-bottom: 8px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.sec-h-right { display: flex; align-items: center; gap: 8px; }
.sec-h h2 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.sec-h .hint { font-size: 11px; color: var(--muted); }
.note { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

/* window selector */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button {
  appearance: none; background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; padding: 6px 11px; cursor: pointer;
}
.seg button.on { background: var(--raised); color: var(--text); }
.seg button + button { border-left: 1px solid var(--border); }

/* ---- history: trend chart --------------------------------------------- */
.chart-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 12px 8px; }
.chart-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.chart-meta-lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.chart-meta .big { font-family: monospace; font-size: 26px; font-weight: 600; }
.chart-meta .delta { font-size: 12px; font-family: monospace; }
.delta.up { color: var(--correct); }
.delta.down { color: var(--blunder); }
#view-history svg { display: block; width: 100%; overflow: visible; }

/* ---- history: then-vs-now comparison ---------------------------------- */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp .card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 13px; }
.cmp .lab { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.cmp .score { font-family: monospace; font-size: 30px; font-weight: 600; line-height: 1; }
.cmp .score small { font-size: 14px; color: var(--muted); }
.stackbar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; margin: 11px 0 9px; }
.stackbar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 9px 14px; font-size: 11px; color: var(--muted); margin-top: 11px; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.counts { display: flex; gap: 13px; font-size: 12px; font-family: monospace; margin-top: 2px; }
.counts b { font-weight: 600; }

/* ---- history: accuracy matrix ----------------------------------------- */
/* Sized to fit 6 position columns within the view width without horizontal
 * scroll: fixed layout shares width evenly and cells shrink with the table. */
.matrix-scroll { margin: 0 -2px; padding: 0 2px; }
table.matrix { border-collapse: separate; border-spacing: 2px; width: 100%; table-layout: fixed; }
table.matrix th { font-size: 10px; color: var(--muted); font-weight: 600; text-align: center; padding: 2px 0; }
/* Explicit width fits the widest label ("Cold 4-Bet") without clipping; the
 * remaining width is split evenly across the 6 position columns. */
table.matrix th.row {
  text-align: left; white-space: nowrap; padding-right: 6px; width: 62px;
  color: var(--text); font-weight: 550; font-size: 10px;
}
table.matrix td { padding: 0; }
.cell {
  width: 100%; aspect-ratio: 1.55 / 1; min-height: 26px; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid transparent; position: relative; color: #08120c;
  overflow: hidden;
}
.cell:active { outline: 2px solid #fff; outline-offset: -2px; }
.cell .pct { font-family: monospace; font-size: 13px; font-weight: 600; line-height: 1; }
.cell .n { font-family: monospace; font-size: 9px; opacity: .62; margin-top: 1px; }
.cell.empty { background: var(--panel); cursor: default; border: 1px dashed var(--border); color: var(--muted); }
.cell.empty:active { outline: none; }
.cell.low-n { opacity: .5; }

/* ---- history: drill-down panel ---------------------------------------- */
.drill {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; display: none;
}
.drill.open { display: block; animation: drill-fade .18s; }
@keyframes drill-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.drill .dh { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.drill .dh .title { font-size: 15px; font-weight: 600; }
.drill .dh .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.drill .closex { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 4px; }
.drill .stat-row { display: flex; gap: 14px; font-size: 12px; font-family: monospace; color: var(--muted); flex-wrap: wrap; }
.grid169 { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; margin: 12px 0; }
.hc {
  aspect-ratio: 1 / 1; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; font-family: monospace; font-size: 7.5px; color: #0a0a0a; user-select: none;
}
.hc.nd { background: var(--panel-2); color: var(--muted); }
.gridkey { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); justify-content: center; margin-bottom: 4px; }
.ramp {
  height: 9px; width: 120px; border-radius: 3px;
  background: linear-gradient(90deg, var(--blunder), var(--inacc-lo), var(--inacc-hi), var(--correct));
}
.drill-actions { display: flex; gap: 9px; margin-top: 6px; }
.btn {
  appearance: none; border: 0; border-radius: 10px; font: inherit; font-size: 14px;
  font-weight: 600; padding: 12px 16px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #04121f; flex: 1; }
.btn.primary:active { background: #5fb3ff; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
