/* HUD + betting controls dock */
.hud, .controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  /* Fixed height so the panels never resize between states (active controls vs
     "waiting", wrapped coach text, etc.) — keeps the table from shifting. */
  height: 178px;
  overflow: hidden;
}

/* HUD — flex column so the coach line can fill the leftover height and scroll its
   text internally (the panel keeps its fixed height, so nothing shifts). */
.hud { display: flex; flex-direction: column; }
.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex: 0 0 auto;
}
.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.hud-k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.hud-v { font-size: 17px; font-weight: 700; }
.hud-sub { font-size: 11px; font-weight: 600; color: var(--muted); }
.hud-v.eq-high { color: var(--green); }
.hud-v.eq-mid { color: var(--gold); }
.hud-v.eq-low { color: var(--red); }

.coach-line {
  margin-top: 10px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.35;
  min-height: 40px;
  /* fill the HUD's leftover height so long feedback scrolls here instead of being
     clipped by the fixed-height panel */
  flex: 1 1 auto;
  overflow: hidden;
}
/* the feedback text is the scroll area; the tag + chart chip stay pinned at the top */
#coach-text { flex: 1 1 auto; min-width: 0; overflow-y: auto; }
.coach-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--muted);
  background: #0e1118;
  border: 1px solid var(--line);
  padding: 3px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  align-self: flex-start;
}
.coach-line.good { border-left-color: var(--green); }
.coach-line.good .coach-tag { color: var(--green); }
.coach-line.warn { border-left-color: var(--gold); }
.coach-line.warn .coach-tag { color: var(--gold); }
.coach-line.bad { border-left-color: var(--red); }
.coach-line.bad .coach-tag { color: var(--red); }

/* end-of-hand panel (replaces betting controls) */
.endhand { display: flex; flex-direction: column; gap: 10px; width: 100%; height: 100%; }
.eh-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eh-result { font-size: 16px; font-weight: 700; }
.eh-result.win { color: var(--green); }
.eh-result.lose { color: var(--red); }
.eh-result.even { color: var(--text); }
.eh-grade {
  display: flex; align-items: center; gap: 8px;
  font-size: 22px; font-weight: 800; line-height: 1;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; background: var(--panel-2);
}
.eh-grade .eh-leaks { font-size: 11px; font-weight: 600; color: var(--muted); }
.grade-A { color: var(--green); } .grade-B { color: #9bd66b; }
.grade-C { color: var(--gold); } .grade-D { color: #e8975a; } .grade-F { color: var(--red); }

/* fill the leftover space and scroll, so the Next Hand button + result stay pinned
   at the top and never get clipped when the feedback is long */
.eh-streets { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow: auto; }
.eh-street {
  display: grid; grid-template-columns: 58px 16px 1fr; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 3px 2px;
}
.eh-st-name { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.eh-st-icon { text-align: center; font-weight: 700; }
.eh-street.good .eh-st-icon { color: var(--green); }
.eh-street.warn .eh-st-icon { color: var(--gold); }
.eh-street.bad .eh-st-icon { color: var(--red); }
.eh-st-text { color: var(--text); line-height: 1.3; }
.eh-leak {
  display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700;
  color: #ffb4ba; background: rgba(255, 90, 106, 0.10); border: 1px solid #4a2a32;
  border-radius: 5px; padding: 0 6px; vertical-align: middle; white-space: nowrap;
}

.eh-actions { display: flex; gap: 10px; margin-top: 2px; }
.eh-actions .eh-next { flex: 2; padding: 13px; font-size: 15px; }
.eh-actions .eh-history { flex: 1; padding: 13px; }
.eh-count { font-weight: 600; opacity: 0.8; }

/* clickable starting-hand category chip -> opens the preflop chart */
.hud-chart-chip {
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: var(--panel);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.hud-chart-chip:hover { filter: brightness(1.18); }
.hud-chart-chip:active { transform: translateY(1px); }
.hud-chart-chip .chip-tag {
  color: #0c0c0e;
  background: var(--gold);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 10px;
  margin: 0 2px;
}

/* Controls */
.controls { display: flex; flex-direction: column; gap: 12px; justify-content: center; }
/* dimmed, non-interactive copy shown while it's not your turn — keeps the panel
   the same size so the table doesn't grow/shrink between actions */
.controls.idle { opacity: 0.4; pointer-events: none; }
.ctl-row { display: flex; gap: 10px; }
.ctl-row .btn { flex: 1; padding: 14px 10px; font-size: 16px; }
.btn-fold { background: #2a1d22; border-color: #4a2a32; color: #ff9aa5; }
.btn-check, .btn-call { background: #16263a; border-color: #234260; color: #9cc8ff; }
.btn-raise { background: linear-gradient(180deg, #b5453f 0%, #8e302b 100%); border-color: #7a2924; color: #ffe6e3; }

.sizer { display: flex; flex-direction: column; gap: 10px; }
.preset-row { display: flex; gap: 8px; }
.btn-preset { flex: 1; padding: 8px 6px; font-size: 13px; background: var(--panel-2); }
.btn-allin { color: var(--gold); border-color: var(--gold-soft); }
.slider-row { display: flex; align-items: center; gap: 12px; }
.amt-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px 8px;
}
.amt-text { min-width: 44px; text-align: center; font-weight: 700; font-size: 15px; }
.btn-step { padding: 4px 10px; font-size: 16px; line-height: 1; background: #0e1118; }
.slider { flex: 1; accent-color: var(--gold); height: 6px; }

/* recommended action glow after a Hint (driven from the docked chart-panel aid) */
.ctl-row .btn.recommended {
  box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(212, 175, 55, 0.5);
  filter: brightness(1.08);
}

@media (max-width: 820px) {
  .table-svg { max-height: 48vh; }
  .hud-grid { grid-template-columns: repeat(2, 1fr); }
  /* stacked layout: let panels size to content instead of the fixed height */
  .hud, .controls { height: auto; overflow: visible; }
}

@media (max-width: 640px) {
  /* the coach/HUD is moved out of the dock (placeHud) -> dock holds only betting */
  .dock { display: block; }
  .table-svg { max-height: none; }   /* the vertical table fills the fold, not capped */
  .hud { padding: 10px 11px; }
  /* betting: flush (no card chrome / padding), compact — 3 rows max. Fixed height
     so the end-of-hand "Next hand" panel is the SAME height -> no canvas shift. */
  .controls { padding: 0; background: none; border: none; box-shadow: none; gap: 8px; height: 150px; overflow: hidden; }
  .endhand { height: 100%; gap: 8px; }
  .eh-streets { flex: 1 1 auto; min-height: 0; max-height: none; }  /* fill + scroll within the fixed panel */
  .hud-grid { gap: 6px; }
  .ctl-row { gap: 8px; }
  /* trim button heights so all 3 rows fit the fixed-height panel without cropping
     (explicit min-height overrides the coarse-pointer 42px touch bump) */
  .ctl-row .btn { padding: 11px 8px; font-size: 15px; min-height: 40px; }
  .sizer { gap: 8px; }
  .preset-row { flex-wrap: nowrap; gap: 8px; }   /* ½ / ¾ / Pot on one row */
  .btn-allin { display: none; }                  /* no All-in (use the slider/max) */
  .btn-preset { flex: 1 1 0; min-height: 36px; padding: 6px 6px; }
  .amt-text { min-width: 56px; font-size: 16px; }
  .amt-box { padding: 3px 8px; }
  .btn-step { min-height: 36px; min-width: 44px; }
  .slider { height: 8px; }
}
