/* Hand-history popup: slide-in drawer with list + detail. */
.hist-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(6, 7, 10, 0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.28s ease;
}
.hist-backdrop.show { opacity: 1; pointer-events: auto; }

.hist-drawer {
  position: fixed; top: 0; right: 0; z-index: 70; height: 100vh; width: min(1320px, 98vw);
  display: flex; flex-direction: column; background: var(--bg-2);
  border-left: 1px solid var(--line); box-shadow: -24px 0 60px rgba(0, 0, 0, 0.55);
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.25, 1);
}
.hist-drawer.show { transform: translateX(0); }

.hist-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.hist-title { font-size: 16px; font-weight: 700; }
.hist-close {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px; font-size: 18px; cursor: pointer; line-height: 1;
}
.hist-close:hover { color: var(--text); filter: brightness(1.2); }

/* per-session summary band */
.hist-summary { display: none; }
.hist-summary.show {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 11px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  background: var(--panel);
}
.hs-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.hs-stat { text-align: center; min-width: 50px; }
.hs-stat b { display: block; font-size: 17px; font-weight: 800; line-height: 1; }
.hs-stat span { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.hs-stat.win b { color: var(--green); }
.hs-stat.lose b { color: var(--red); }
.hs-stat.even b { color: var(--text); }
.hs-grades { display: flex; align-items: center; gap: 5px; }
.hs-bigs { display: flex; gap: 8px; }
.hs-big {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 10px; cursor: pointer; font: inherit; text-align: left;
}
.hs-big:hover { border-color: var(--gold-soft); }
.hs-big-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hs-big-net { font-size: 15px; font-weight: 800; }
.hs-big-net.win { color: var(--green); } .hs-big-net.lose { color: var(--red); }
.hs-big-hand { font-size: 10px; color: var(--muted); }
.hs-resume { margin-left: auto; padding: 9px 14px; }
.hs-leaks { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.hs-leaks-label { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.hist-body { flex: 1; display: flex; min-height: 0; }
/* per-session analytics column (left). Hidden on the generic global popup. */
.hist-charts {
  flex: 0 0 640px; overflow: auto; border-right: 1px solid var(--line);
  padding: 10px; display: flex; flex-direction: column; gap: 12px; background: var(--bg);
}
.hist-charts[hidden] { display: none; }
/* bigger side (y-axis) numbers on the session charts (charts 1, 3, 4) */
.hist-charts .chart-axis-l, .hist-charts .chart-axis-r { font-size: 18px; }
/* chart 1 (street equity) side numbers 20% smaller than the others */
.hist-charts #hist-chart-streets .chart-axis-l,
.hist-charts #hist-chart-streets .chart-axis-r { font-size: 14.4px; }
.hist-list { flex: 0 0 230px; overflow: auto; border-right: 1px solid var(--line); padding: 8px; }
.hist-detail { flex: 1; overflow: auto; padding: 16px 18px; min-width: 0; }

/* list rows — cards stacked on top of the hand info */
.hist-row {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 6px;
  cursor: pointer; background: var(--panel); transition: filter 0.12s ease;
}
.hist-row { position: relative; }
.hist-row:hover { filter: brightness(1.15); }
.hist-row.sel { border-color: var(--gold); }
.hr-del {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  width: 24px; height: 24px; padding: 0; line-height: 1; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); cursor: pointer; opacity: 0.5; transition: opacity 0.12s, color 0.12s;
}
.hist-row:hover .hr-del { opacity: 1; }
.hr-del:hover { color: #ff9aa5; background: var(--panel-2); border-color: #4a2a32; }
.hist-row .confirm-inline { position: absolute; top: 5px; right: 5px; z-index: 3; }
.hr-cards { display: flex; justify-content: center; gap: 3px; }
.hr-cards:empty { display: none; }
.hr-cards .hand-cards { display: inline-flex; gap: 3px; }
.hr-info { width: 100%; min-width: 0; }
.hr-top { display: flex; align-items: center; gap: 7px; }
.hr-hand { font-weight: 700; font-size: 13px; }
.hr-pos { color: var(--muted); font-size: 11px; font-weight: 600; }
.hr-grade { margin-left: auto; font-weight: 800; font-size: 14px; }
.hr-bot { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 11.5px; }
.hr-net { font-weight: 700; }
.hr-net.win { color: var(--green); } .hr-net.lose { color: var(--red); } .hr-net.even { color: var(--muted); }
.hr-sd { color: var(--gold); font-size: 9px; font-weight: 800; border: 1px solid var(--gold-soft); border-radius: 4px; padding: 0 3px; }
.hr-time { margin-left: auto; color: var(--muted); }

/* detail */
.hd-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.hd-title { font-size: 16px; font-weight: 700; }
.hd-meta { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.hd-tags { display: flex; align-items: center; gap: 8px; }
.hd-result { font-weight: 700; font-size: 13px; }
.hd-result.win { color: var(--green); } .hd-result.lose { color: var(--red); } .hd-result.even { color: var(--text); }
.hd-grade { font-weight: 800; font-size: 18px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 2px 10px; }

.hd-label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 7px; }
.hd-board { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hd-board .hand-cards { display: inline-flex; gap: 3px; }
.hd-board .hd-label { margin-bottom: 0; }
.hd-section { margin-bottom: 16px; }

.hd-seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.hd-seat { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--panel); }
.hd-seat.me { border-color: var(--gold-soft); }
.hd-seat.win { border-color: var(--green); }
.hd-seat-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.hd-pos { color: var(--muted); font-weight: 700; font-size: 10px; }
.hd-name { font-weight: 600; }
.hd-wins { margin-left: auto; color: var(--green); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.hd-seat .hand-cards { display: inline-flex; gap: 3px; }
.pcard-svg { display: block; }

/* action breakdown */
.hd-actions { display: flex; flex-direction: column; gap: 10px; }
.hd-street { }
.hd-st-name { color: var(--gold); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.hd-st-rows { display: flex; flex-direction: column; gap: 2px; }
.ar { display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 2px 6px; border-radius: 6px; }
.ar.me { background: rgba(216, 180, 106, 0.08); }
.ar-pos { color: var(--muted); font-size: 10px; font-weight: 700; }
.ar-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-act { color: var(--muted); font-weight: 600; }

/* zebra-striped action rows (skip the hero row so its tint still shows) */
.hd-st-rows .ar:nth-child(even):not(.me) { background: rgba(255, 255, 255, 0.035); }

/* color-coded actions */
.ar-act.fold  { color: var(--muted); }
.ar-act.check { color: var(--blue); }
.ar-act.call  { color: #5fc9c9; }
.ar-act.bet   { color: var(--gold); }
.ar-act.raise { color: var(--red); }
.ar-act.post  { color: var(--muted); }

/* hero (You) in green, villains in red — action rows + players list */
.ar.me .ar-name,
.hd-seat.me .hd-name { color: var(--green); font-weight: 700; }
.ar:not(.me) .ar-name,
.hd-seat:not(.me) .hd-name { color: #ff8088; }

/* coach notes */
.hd-notes { display: flex; flex-direction: column; gap: 6px; }
.hd-note { display: flex; gap: 8px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 8px 10px; background: var(--panel); }
.hd-note.good { border-left-color: var(--green); }
.hd-note.warn { border-left-color: var(--gold); }
.hd-note.bad { border-left-color: var(--red); }
.hd-note-icon { font-weight: 800; }
.hd-note.good .hd-note-icon { color: var(--green); }
.hd-note.warn .hd-note-icon { color: var(--gold); }
.hd-note.bad .hd-note-icon { color: var(--red); }
.hd-note-st { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.hd-note-text { font-size: 12.5px; line-height: 1.35; margin-top: 2px; }

@media (max-width: 720px) {
  .hist-body { flex-direction: column; }
  .hist-charts { flex: 0 0 auto; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--line); }
  .hist-list { flex: 0 0 auto; max-height: 30vh; border-right: none; border-bottom: 1px solid var(--line); }
}

/* phones: full-height bottom sheet */
@media (max-width: 640px) {
  .hist-drawer {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100vw; height: 100dvh;                 /* all the way up */
    border-left: none; border-top: none; border-radius: 0;
    box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.55);
    transform: translateY(100%);
  }
  .hist-drawer.show { transform: translateY(0); }

  /* compact session-stats band (smaller fonts + padding) */
  .hist-summary.show { gap: 8px 10px; padding: 8px 12px; }
  .hs-stats { gap: 8px; }
  .hs-stat { min-width: 40px; }
  .hs-stat b { font-size: 14px; }
  .hs-stat span { font-size: 8px; margin-top: 2px; }
  .hs-grades { gap: 4px; }
  .hs-big { padding: 4px 8px; }
  .hs-big-net { font-size: 13px; }
  .hs-resume { margin-left: 0; padding: 7px 12px; }

  /* hand list: each row = just the 4 hole cards (+ a small corner delete);
     shorter rows AND a shorter list, so the detail below gets more room */
  .hist-list { max-height: 22vh; padding: 6px; }
  .hist-row { padding: 5px 6px; gap: 0; margin-bottom: 5px; }
  .hr-info { display: none; }
  .hr-cards .pcard-svg { width: 30px; height: 42px; }
  .hr-del { opacity: 0.6; }

  /* detail (bottom) gets the freed space */
  .hist-detail { padding: 12px 14px; }
}
