/* fight-ai.css — Đánh với AI board, inspired by xiangqi_afeifly dual-theme design */
/* Theme variables piggy-back on SoftwaresShare's html[data-theme] system */

:root {
  --fa-board-line: #444;
  --fa-river-text: #555;
  --fa-piece-red-bg: #fff;
  --fa-piece-red-text: #000;
  --fa-piece-red-border: #111;
  --fa-piece-black-bg: #111;
  --fa-piece-black-text: #fff;
  --fa-piece-black-border: #111;
  --fa-health-danger-stripe1: var(--color-bg-card);
  --fa-health-danger-stripe2: var(--color-text);
}

html[data-theme="dark"] {
  --fa-board-line: #4a5568;
  --fa-river-text: #718096;
  --fa-piece-red-bg: #e2e8f0;
  --fa-piece-red-text: #0f172a;
  --fa-piece-red-border: #4a5568;
  --fa-piece-black-bg: #1a202c;
  --fa-piece-black-text: #e2e8f0;
  --fa-piece-black-border: #4a5568;
  --fa-health-danger-stripe1: var(--color-bg-card);
  --fa-health-danger-stripe2: var(--color-text);
}

/* Pull the fight-ai section flush against its top edge */
#route-fight-ai {
  padding-top: 0.5rem;
}

/* ── Layout: board column (left) + coach panel (right) ─────────────── */
.fa-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.fa-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding-bottom: 2rem;
  position: relative;
  font-family: inherit;
}

/* ── Header (player info + health bars) ─────────────────────────────── */
.fa-header {
  width: 100%;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin-bottom: 4px;
  box-shadow: var(--shadow-card);
}

.fa-battle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin-bottom: 5px;
}

.fa-player-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fa-player-right .fa-player-meta {
  flex-direction: row-reverse;
}

.fa-player-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  gap: 4px;
}

.fa-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.fa-player-right .fa-player-name {
  text-align: right;
}

.fa-player-score {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.fa-vs-silo {
  flex-shrink: 0;
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.5;
  padding-top: 2px;
}

/* Health bar */
.fa-health-container {
  height: 10px;
  border: 1.5px solid var(--color-text);
  background: var(--color-bg);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.fa-health-fill {
  height: 100%;
  background: var(--color-text);
  float: left;
  transition: width 0.3s ease;
}

.fa-fill-right {
  float: right;
}

.fa-health-danger {
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--fa-health-danger-stripe1),
    var(--fa-health-danger-stripe1) 2px,
    var(--fa-health-danger-stripe2) 2px,
    var(--fa-health-danger-stripe2) 4px
  );
  float: left;
  transition: width 0.3s ease;
}

.fa-health-danger.fa-fill-right {
  float: right;
}

/* Meta row (turn info + undo) */
.fa-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border-top: 1px dashed var(--color-border);
  padding-top: 4px;
  gap: 8px;
}

.fa-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.fa-meta-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fa-turn-info {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  white-space: nowrap;
}

.fa-turn-info.fa-red-turn {
  border-style: dotted;
  border-color: var(--color-text);
}

.fa-turn-info.fa-black-turn {
  border-style: solid;
  border-color: var(--color-text);
}

/* AI thinking indicator */
.fa-thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.fa-thinking-dots {
  display: flex;
  gap: 3px;
}

.fa-thinking-dots span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: fa-dot-bounce 1.2s ease-in-out infinite;
}

.fa-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.fa-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes fa-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Review mode indicator */
.fa-review-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  white-space: nowrap;
}

.fa-review-return {
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--color-accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.fa-review-return:hover {
  text-decoration: underline;
}

.fa-cell.fa-review-dim {
  opacity: 0.75;
}

/* ── Action buttons ──────────────────────────────────────────────────── */
.fa-action-btn {
  padding: 4px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-ui), border-color var(--transition-ui);
  white-space: nowrap;
}

.fa-action-btn:hover {
  background: var(--color-hover-overlay);
  border-color: var(--color-accent);
}

.fa-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fa-btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.fa-btn-primary:hover {
  background: var(--color-accent-soft);
  border-color: var(--color-accent-soft);
}

/* ── Board ───────────────────────────────────────────────────────────── */
.fa-board-wrapper {
  position: relative;
  display: inline-block;
  box-sizing: content-box;
}

.fa-board {
  position: relative;
  background: var(--color-bg-card);
}

.fa-line {
  position: absolute;
  background: var(--fa-board-line);
  pointer-events: none;
  transform-origin: 0 0;
  z-index: 1;
}

.fa-river {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--fa-river-text);
  z-index: 0;
  pointer-events: none;
  left: 0;
  right: 0;
  font-family: 'KaiTi', 'STKaiti', 'SimSun', serif;
}

/* Pieces */
.fa-cell {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  box-sizing: border-box;
  z-index: 10;
  font-family: 'KaiTi', 'STKaiti', 'SimSun', serif;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow 0.15s ease;
}

.fa-cell.fa-red {
  background: var(--fa-piece-red-bg);
  color: var(--fa-piece-red-text);
  border: 2px solid var(--fa-piece-red-border);
}

.fa-cell.fa-black {
  background: var(--fa-piece-black-bg);
  color: var(--fa-piece-black-text);
  border: 2px solid var(--fa-piece-black-border);
}

.fa-cell.fa-red.fa-selected {
  border: 3px solid var(--color-accent);
  outline: 2px solid var(--color-bg);
  outline-offset: -1px;
}

.fa-cell.fa-black.fa-selected {
  border: 3px solid var(--fa-piece-black-text);
  outline: 2px solid var(--fa-piece-black-bg);
  outline-offset: -1px;
}

.fa-cell.fa-empty {
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

.fa-cell.fa-empty:hover {
  background: rgba(128, 128, 128, 0.08);
}

/* ── Bottom bar (level select + new game) ────────────────────────────── */
.fa-bottom-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 0 4px;
  flex-wrap: wrap;
}

.fa-level-select {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  max-width: 200px;
}

.fa-level-select:focus {
  border-color: var(--color-accent);
}

/* ── Result modal ────────────────────────────────────────────────────── */
.fa-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.fa-modal.fa-modal-active {
  display: flex;
}

.fa-modal-inner {
  background: var(--color-bg-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-hover);
}

.fa-modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
}

.fa-modal-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

.fa-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Toast notification ──────────────────────────────────────────────── */
.fa-toast {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  z-index: 2500;
  pointer-events: none;
  max-width: min(90vw, 360px);
  text-align: center;
  box-shadow: var(--shadow-hover);
}

.fa-toast.fa-toast-visible {
  display: block;
}

/* ── AI coach / analysis panel ───────────────────────────────────────── */
.fa-coach-panel {
  width: 100%;
  min-width: 0;
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fa-coach-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.fa-coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.fa-coach-head-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fa-coach-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

.fa-coach-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fa-coach-engine {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* Eval bar */
.fa-eval {
  padding: 12px 14px;
  border-bottom: 1px dashed var(--color-border);
}

.fa-eval-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--fa-piece-black-bg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.fa-eval-fill {
  height: 100%;
  width: 50%;
  background: var(--color-accent);
  transition: width 0.35s ease;
}

.fa-eval-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 7px;
}

.fa-eval-score {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fa-eval-text {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Coach action buttons */
.fa-coach-tools {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.fa-coach-tools .fa-action-btn {
  flex: 1;
  text-align: center;
  padding: 4px 8px;
  min-width: 0;
  font-size: 12px;
}

/* Coach body */
.fa-coach-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 90px;
  max-height: 400px;
  overflow-y: auto;
}

.fa-coach-muted {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.fa-coach-analyzing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.fa-coach-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: fa-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes fa-spin {
  to { transform: rotate(360deg); }
}

.fa-coach-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fa-coach-block + .fa-coach-block {
  border-top: 1px dashed var(--color-border);
  padding-top: 11px;
}

.fa-coach-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.fa-coach-sub {
  opacity: 0.92;
}

.fa-who {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.fa-move-chip {
  font-weight: 700;
  font-size: 13px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2px 9px;
  color: var(--color-text);
  white-space: nowrap;
}

.fa-chip-user { border-color: var(--color-accent); }
.fa-chip-ai { border-style: dashed; }

.fa-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
}

.fa-score-pos { color: #2f8f5b; }
.fa-score-neg { color: #c0392b; }
.fa-score-even { color: var(--color-text-muted); }

.fa-loss {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12px;
  color: #c0392b;
}

.fa-coach-text {
  margin: 0;
  font-size: 12.5px;
  color: var(--color-text);
  line-height: 1.5;
}

/* Coach summary */
.fa-coach-summary {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  font-style: italic;
}

/* PV line */
.fa-pv {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fa-pv-move {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: monospace;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1px 7px;
  color: var(--color-text-muted);
}

/* Reasons bullet list */
.fa-reasons {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.fa-reasons li {
  font-size: 12px;
  color: var(--color-text);
  line-height: 1.5;
  padding: 1px 0 1px 14px;
  position: relative;
}

.fa-reasons li::before {
  content: "·";
  position: absolute;
  left: 3px;
  color: var(--color-accent);
  font-weight: 700;
}

/* Move-quality badges */
.fa-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fa-badge-best { background: rgba(47, 143, 91, 0.16); color: #2f8f5b; }
.fa-badge-excellent { background: rgba(43, 108, 176, 0.16); color: #2b6cb0; }
.fa-badge-good { background: rgba(43, 108, 176, 0.12); color: #2b6cb0; }
.fa-badge-inaccuracy { background: rgba(201, 138, 43, 0.18); color: #b8860b; }
.fa-badge-mistake { background: rgba(192, 57, 43, 0.16); color: #c0392b; }
.fa-badge-blunder { background: rgba(192, 57, 43, 0.22); color: #c0392b; }

/* ── Hint levels (progressive coach) ────────────────────────────────── */
.fa-levels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.fa-level {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-bg);
}

.fa-level summary {
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.fa-level summary::before {
  content: "▸";
  font-size: 10px;
  opacity: 0.55;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.fa-level[open] summary::before {
  transform: rotate(90deg);
}

.fa-level p {
  margin: 0;
  padding: 6px 10px 9px;
  font-size: 12.5px;
  color: var(--color-text);
  line-height: 1.55;
  border-top: 1px dashed var(--color-border);
}

/* ── Lines card (PV stepping animation) ──────────────────────────────── */
.fa-lines-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.fa-lines-board {
  width: 70%;
  max-width: 200px;
  margin: 0 auto;
}

.fa-lines-cap {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  min-height: 16px;
}

.fa-lines-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.fa-var-step {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: inherit;
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.fa-var-step:hover {
  background: var(--color-hover-overlay);
  border-color: var(--color-accent);
}

.fa-lines-pv {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.fa-pv-chip {
  font-size: 11px;
  font-family: monospace;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.12s, color 0.12s;
}

.fa-pv-chip:hover {
  background: var(--color-hover-overlay);
  color: var(--color-text);
}

.fa-pv-chip.fa-pv-on {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* ── Mini-board (SVG-based: lines + pieces scale via viewBox) ────────── */
.fa-mini-board {
  /* The element is now an inline SVG, so we just need display + width.
     The SVG viewBox (908×1008, ratio 9:10) controls the height automatically. */
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.fa-mini-board-nav {
  cursor: pointer;
  outline: 1.5px solid transparent;
  outline-offset: 2px;
  border-radius: 3px;
  transition: outline-color 0.15s;
}

.fa-mini-board-nav:hover {
  outline-color: var(--color-accent);
}

/* ── Move list card ──────────────────────────────────────────────────── */
.fa-moves-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.fa-moves-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.fa-moves-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

.fa-moves-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fa-move-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.fa-mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  background: none;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-ui), border-color var(--transition-ui);
}

.fa-mini-btn:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}

.fa-mini-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.fa-move-list {
  padding: 8px 10px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fa-ml-empty {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

.fa-move-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.fa-move-no {
  font-size: 11px;
  color: var(--color-text-muted);
  width: 22px;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fa-ply {
  flex: 1;
  font-size: 12px;
  font-family: monospace;
  font-weight: 500;
  text-align: center;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.fa-ply:hover {
  background: var(--color-hover-overlay);
  border-color: var(--color-border);
}

.fa-ply.fa-ply-current {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.fa-ply.fa-ply-empty {
  cursor: default;
  opacity: 0.3;
  font-family: inherit;
}

.fa-ply.fa-ply-empty:hover {
  background: none;
  border-color: transparent;
}

/* ── Floating review window ──────────────────────────────────────────── */
.fa-review-window {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 300px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 320px;
  min-height: 240px;
}

.fa-review-window[hidden] {
  display: none;
}

.fa-rw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.fa-rw-head:active {
  cursor: grabbing;
}

.fa-rw-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.fa-rw-tools {
  display: flex;
  gap: 4px;
  align-items: center;
}

.fa-rw-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: inherit;
  padding: 0;
}

.fa-rw-icon:hover {
  background: var(--color-hover-overlay);
  color: var(--color-text);
}

.fa-rw-close:hover {
  border-color: #c0392b;
  color: #c0392b;
}

.fa-rw-hint {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--color-text-muted);
  border-bottom: 1px dashed var(--color-border);
  flex-shrink: 0;
}

.fa-rw-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  cursor: default;
}

.fa-rw-body.fa-panning {
  cursor: grabbing;
}

.fa-rw-viewport {
  min-width: 100%;
  min-height: 100%;
}

.fa-rw-world {
  position: relative;
  transform-origin: 0 0;
}

.fa-rw-edges {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.fa-rw-edge {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 1.5;
}

.fa-rw-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border-radius: 5px;
  overflow: hidden;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-elevated);
  transition: border-color 0.15s;
  /* height is driven by content (mini-board aspect-ratio + caption) */
}

.fa-rw-node:hover {
  border-color: var(--color-accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

.fa-rw-node.fa-rw-current {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb, 59, 130, 246), 0.25);
}

.fa-rw-cap {
  padding: 4px 5px;
  font-size: 10px;
  text-align: center;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
  line-height: 1.3;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fa-rw-label {
  display: block;
  font-weight: 600;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 116px;
}

.fa-rw-red {
  color: #bb0000;
}

.fa-rw-black {
  color: var(--color-text);
}

.fa-rw-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  background: var(--color-border);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 0.5;
}

.fa-rw-resize:hover {
  opacity: 1;
}

.fa-rw-empty {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 8px 0;
}

/* ── Responsive tweaks ───────────────────────────────────────────────── */
@media (max-width: 880px) {
  .fa-layout {
    grid-template-columns: 1fr;
    gap: 14px;
    max-width: 620px;
  }

  .fa-coach-panel {
    position: static;
    max-width: 620px;
    margin: 0 auto;
  }

  .fa-review-window {
    width: min(96vw, 600px);
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 500px) {
  .fa-container {
    padding-bottom: 1.5rem;
  }

  .fa-header {
    padding: 5px 8px;
  }

  .fa-player-meta {
    font-size: 11px;
  }

  .fa-bottom-bar {
    gap: 8px;
  }

  .fa-coach-tools {
    gap: 4px;
    padding: 8px 10px;
  }

  .fa-coach-tools .fa-action-btn {
    font-size: 11px;
    padding: 3px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fa-cell,
  .fa-health-fill,
  .fa-health-danger,
  .fa-eval-fill {
    transition: none;
  }

  .fa-thinking-dots span,
  .fa-coach-spinner {
    animation: none;
    opacity: 0.6;
  }
}
