/* =============================================================================
 * base.css — page theme, typography helpers, modals, toast, clocks, setup.
 * ========================================================================== */
:root {
  --board-border: #141619;
  --gold-accent: #d4af37;
}

body {
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at 50% 0%, #1e2430 0%, #0f1218 75%, #090b0e 100%);
  background-color: #0f1218;
  color: #e2e8f0;
  margin: 0;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

input, textarea { user-select: text; -webkit-user-select: text; }

.font-serif-title { font-family: 'Cinzel', serif; }
.font-mono-code { font-family: 'JetBrains Mono', monospace; }

/* One visibility switch for every modal / overlay (fixes overlays that stayed
   visible because "opacity-0" and "opacity-100" fought each other). */
.is-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

/* Scrollbars */
#move-history-list::-webkit-scrollbar { width: 7px; }
#move-history-list::-webkit-scrollbar-track { background: #14171f; }
#move-history-list::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Clocks */
.clock-white { background: #f3f4f6; color: #111827; border-color: #d1d5db; }
.clock-black { background: #030712; color: #f3f4f6; border-color: #374151; }
.clock-active { box-shadow: 0 0 18px rgba(234, 179, 8, 0.55); border-color: #eab308 !important; }
.clock-low { box-shadow: 0 0 18px rgba(239, 68, 68, 0.7) !important; border-color: #ef4444 !important; color: #fecaca !important; background-color: #450a0a !important; }

/* Setup modal choices */
.setup-choice-active {
  border-color: #f59e0b !important;
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.18) 0%, rgba(17, 24, 39, 0.95) 100%) !important;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.45), 0 8px 20px -4px rgba(0, 0, 0, 0.6);
  color: #fff !important;
}
.setup-section-disabled { opacity: 0.35; pointer-events: none; filter: grayscale(0.6); }

@keyframes aiPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.92); } }
.ai-thinking-dot { animation: aiPulse 1.1s infinite ease-in-out; }

/* Avatars & captured pieces (piece images come from board.css) */
.avatar-piece { width: 30px; height: 30px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.cap-piece { display: inline-block; width: 18px; height: 18px; margin-right: -5px; background-size: contain; background-repeat: no-repeat; }
.cap-gap { display: inline-block; width: 8px; }
.material-adv { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: #94a3b8; margin-left: 9px; }

/* Move history */
.hist-row { display: grid; grid-template-columns: 2.6rem 1fr 1fr; align-items: center; border-radius: 6px; }
.hist-row:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.hist-num { color: #64748b; font-size: 12px; padding-left: 6px; }
.hist-move { padding: 3px 8px; border-radius: 6px; cursor: pointer; color: #e2e8f0; display: flex; align-items: center; gap: 4px; min-height: 26px; }
.hist-move:hover { background: rgba(148, 163, 184, 0.14); }
.hist-move.current { background: rgba(245, 158, 11, 0.22); box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.55); color: #fff; }
.hist-glyph { font-weight: 800; font-size: 12px; }
.cls-brilliant { color: #22d3ee; }
.cls-great { color: #60a5fa; }
.cls-best { color: #4ade80; }
.cls-inaccuracy { color: #facc15; }
.cls-mistake { color: #fb923c; }
.cls-blunder { color: #f87171; }
.cls-book { color: #c4a57a; }
.hist-dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.hist-dot.cls-best { background: #4ade80; }
.hist-dot.cls-book { background: #c4a57a; }

/* Toast */
#toast-notification.show { transform: translateY(0); opacity: 1; }

/* Game summary table */
.summary-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 14px; font-size: 12px; text-align: left; }
.summary-grid .h { color: #94a3b8; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }

/* Right-column tabs */
.tab-btn { flex: 1; padding: 8px 6px; color: #94a3b8; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s, background 0.15s; }
.tab-btn:hover { color: #e2e8f0; background: rgba(148, 163, 184, 0.06); }
.tab-btn.active { color: #fbbf24; border-bottom-color: #f59e0b; background: rgba(245, 158, 11, 0.06); }

/* Small buttons used in the Review / Analysis tabs */
.study-btn { padding: 4px 9px; border-radius: 8px; background: #1f2937; border: 1px solid #374151; color: #e5e7eb; font-size: 11px; font-weight: 700; }
.study-btn:hover:not([disabled]) { background: #273244; border-color: #4b5563; }
.study-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Engine lines */
.study-line { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 5px 8px; border-radius: 8px; background: rgba(15, 23, 42, 0.7); border: 1px solid #1f2937; }
.study-line:hover { border-color: #3b82f6; background: rgba(30, 58, 138, 0.25); }
.study-eval { flex-shrink: 0; min-width: 52px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 6px; }
.study-eval.pos { background: #f1f5f9; color: #0f172a; }
.study-eval.neg { background: #0b0f17; color: #e2e8f0; border: 1px solid #334155; }
.study-pv { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Move tree */
.study-tree { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.9; color: #e2e8f0; word-wrap: break-word; }
.tree-move { cursor: pointer; padding: 1px 3px; border-radius: 4px; }
.tree-move:hover { background: rgba(148, 163, 184, 0.16); }
.tree-move.side { color: #7dd3fc; }
.tree-move.current { background: rgba(245, 158, 11, 0.3); color: #fff; box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.7); }
.tree-num { color: #64748b; margin-right: 2px; }
.tree-var { color: #94a3b8; font-size: 11.5px; }

/* Review */
.review-tip { position: absolute; top: 4px; padding: 2px 7px; border-radius: 6px; background: rgba(2, 6, 23, 0.92); border: 1px solid #334155; color: #e2e8f0; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; pointer-events: none; white-space: nowrap; }
.moment-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border-radius: 8px; background: rgba(15, 23, 42, 0.6); border: 1px solid #1f2937; font-size: 12px; color: #e2e8f0; text-align: left; }
.moment-row:hover { border-color: #f59e0b; }

/* Side-by-side layout: the right column takes the board column's height and
   scrolls inside, instead of growing with long move lists / reviews. */
@media (min-width: 1024px) {
  #right-col { contain: size; min-height: 560px; }
}

/* Clock extras: delay countdown and moves-to-time-control */
.clock-delay { font-size: 11px; font-weight: 700; color: #38bdf8; margin-right: 6px; vertical-align: middle; }
.clock-togo { display: block; font-size: 9px; line-height: 1; font-weight: 600; letter-spacing: 0.04em; opacity: 0.7; margin-top: -2px; }
.tc-input { background: #030712; border: 1px solid #374151; border-radius: 8px; padding: 5px 8px; color: #e5e7eb; font-size: 12px; }
.tc-input:focus { outline: none; border-color: #f59e0b; }
.tree-nag { color: #fbbf24; font-weight: 800; margin-left: 1px; }
.tree-comment { color: #86efac; font-family: 'Inter', sans-serif; font-size: 11.5px; font-style: italic; }
.library-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px; background: rgba(15, 23, 42, 0.6); border: 1px solid #1f2937; }
.library-row:hover { border-color: #374151; }

/* Opening explorer */
.explorer-row { display: grid; grid-template-columns: 58px 1fr auto 52px; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 4px 8px; border-radius: 7px; background: rgba(15, 23, 42, 0.55); border: 1px solid #1f2937; margin-bottom: 3px; }
.explorer-row:hover { border-color: #f59e0b; background: rgba(120, 53, 15, 0.18); }
.ex-san { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: #f8fafc; }
.ex-name { font-size: 11px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-count { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #64748b; }
.ex-eval { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: #93c5fd; text-align: right; }
