/* ============================================
   Analysis Page
   ============================================ */

.analysis-page {
  padding: 80px clamp(0.75rem, 2vw, 1.5rem) 0;
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}

body:has(.analysis-page) {
  overflow: hidden;
  height: 100vh;
}

.analysis-layout {
  display: grid;
  grid-template-columns: auto 340px;
  gap: 1.25rem;
  max-width: 1060px;
  margin: 0 auto;
  align-items: start;
}

/* ---- Board column ---- */
.board-column {
  min-width: 0;
}

.board-wrapper {
  display: flex;
  gap: 0;
  align-items: stretch;
}

/* ---- Eval bar ---- */
.eval-bar {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
}

.eval-bar-track {
  flex: 1;
  width: 100%;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.eval-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: #e5e5e5;
  transition: height 0.4s ease;
  border-radius: 0 0 3px 3px;
}

.eval-score {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Board ---- */
.board-container {
  position: relative;
  flex: 1;
  max-width: 620px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  user-select: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
}

.square.light { background: #4a5d4a; }
.square.dark { background: #2d3a2d; }

.square.selected { background: rgba(74, 222, 128, 0.4) !important; }
.square.last-move { background: rgba(74, 222, 128, 0.18) !important; }

.square.legal-target::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.4);
  pointer-events: none;
}

/* legal target on occupied square = ring */
.square.legal-target:has(.piece)::after {
  width: 90%;
  height: 90%;
  background: transparent;
  border: 3px solid rgba(74, 222, 128, 0.45);
}

.square:hover:not(.selected) {
  filter: brightness(1.15);
}

/* pieces */
.piece {
  width: 85%;
  height: 85%;
  pointer-events: none;
  z-index: 1;
  user-select: none;
  -webkit-user-drag: none;
  transition: none;
}

/* Move animation */
.piece.animating {
  position: absolute;
  z-index: 50;
  width: 85%;
  height: 85%;
  transition: transform 0.15s ease;
  pointer-events: none;
}

/* Dragging styles */
.square.dragging-source .piece {
  opacity: 0.3;
}

.square.drag-over {
  background: rgba(74, 222, 128, 0.35) !important;
}

.square[draggable="true"] {
  cursor: grab;
}

.square[draggable="true"]:active {
  cursor: grabbing;
}

/* Custom drag visual */
.drag-visual {
  position: fixed;
  width: 60px;
  height: 60px;
  pointer-events: none;
  z-index: 10000;
  display: none;
  transform: translate(-50%, -50%);
}

/* ---- Promotion overlay ---- */
.promotion-overlay {
  position: absolute;
  z-index: 100;
}

.promotion-choices {
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  overflow: hidden;
}

.promotion-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: none;
  padding: 4px;
  transition: background 0.15s;
}
.promotion-choice:hover {
  background: rgba(74,222,128,0.2);
}
.promotion-choice img {
  width: 85%;
  height: 85%;
  pointer-events: none;
}

/* coordinates */
.coord {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  pointer-events: none;
  opacity: 0.5;
  z-index: 2;
  line-height: 1;
}
.rank-coord {
  top: 2px;
  left: 3px;
}
.file-coord {
  bottom: 2px;
  right: 3px;
}
.square.light .coord { color: #2d3a2d; }
.square.dark .coord { color: #4a5d4a; }

/* game status overlay */
.game-status {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  padding: 0.4rem 1rem;
  background: rgba(0,0,0,0.8);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
}

/* ---- Board controls ---- */
.board-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-left: 34px; /* align with board (eval bar width + gap) */
}

.move-controls {
  display: flex;
  gap: 0;
}

.move-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  padding: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.move-controls button:first-child { border-radius: 4px 0 0 4px; }
.move-controls button:last-child { border-radius: 0 4px 4px 0; }
.move-controls button:not(:first-child) { border-left: none; }
.move-controls button:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.move-controls button svg { flex-shrink: 0; }

.board-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  margin-left: auto;
}

.controls-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.icon-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}
.icon-btn.active {
  color: var(--accent);
}
.icon-btn svg { flex-shrink: 0; }

.turn-indicator {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.turn-indicator.white-turn {
  background: rgba(255,255,255,0.1);
  color: #e5e5e5;
}
.turn-indicator.black-turn {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
}

/* ---- FEN row ---- */
.fen-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
  padding-left: 34px;
}

.fen-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.fen-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  outline: none;
  transition: border-color 0.2s;
}
.fen-input:focus { border-color: var(--accent); }
.fen-input.error {
  border-color: #ef4444;
  animation: shake 0.3s ease;
}

.fen-btn {
  padding: 0.4rem 0.8rem;
  background: var(--accent-dim);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.fen-btn:hover {
  background: rgba(74,222,128,0.15);
  border-color: var(--accent);
}

/* ---- Piece tray ---- */
.piece-tray {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  padding-left: 34px;
}

.tray-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.tray-pieces {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.tray-piece {
  width: 30px;
  height: 30px;
  padding: 3px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: grab;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray-piece:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tray-piece:active {
  cursor: grabbing;
}

.tray-piece img {
  width: 22px;
  height: 22px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.tray-trash {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: default;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.tray-trash.drag-hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

@keyframes shake {
  0%, 100% { translate: 0; }
  25% { translate: -4px 0; }
  75% { translate: 4px 0; }
}

/* ---- Player bars above/below board ---- */
.board-and-players {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.player-bar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 1.6rem;
}

.player-bar.visible {
  display: flex;
}

.player-bar-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.player-bar-icon.white-icon {
  background: #e8e8e8;
  border: 1px solid var(--border);
}

.player-bar-icon.black-icon {
  background: #333;
  border: 1px solid var(--border);
}

.player-bar-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar-rating {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ---- Game info bar ---- */
.game-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  margin-left: 34px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
}

.game-info-text {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.game-link {
  color: var(--accent);
  font-size: 0.75rem;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.game-link:hover { opacity: 0.8; }

/* ============================================
   Right Panel
   ============================================ */
.panel-column {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  position: sticky;
  top: 80px;
}

/* ---- Engine bar ---- */
.engine-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.engine-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.engine-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 0.1rem 0.4rem;
  background: rgba(255,255,255,0.03);
  border-radius: 3px;
}
.engine-status.connected {
  color: var(--accent);
  background: var(--accent-dim);
}

.depth-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ---- Analysis lines ---- */
.analysis-lines {
  border-bottom: 1px solid var(--border);
  min-height: 80px;
}

.analysis-placeholder {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.analysis-line {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  transition: background 0.15s;
  cursor: default;
}
.analysis-line:last-child { border-bottom: none; }
.analysis-line:hover { background: rgba(255,255,255,0.02); }
.analysis-line.best { background: rgba(74,222,128,0.04); }

.line-score {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 42px;
  flex-shrink: 0;
}
.line-score.positive { color: #e5e5e5; }
.line-score.negative { color: var(--text-muted); }

.line-moves {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Tabs ---- */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  padding: 0.55rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.panel-tab:hover { color: var(--text-muted); }
.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Panel content ---- */
.panel-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.panel-content.hidden { display: none; }

/* ---- Move list ---- */
.move-list {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 4px;
  padding: 0.75rem;
  font-size: 0.8rem;
  min-height: 120px;
  align-content: flex-start;
}

.empty-moves {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.move-number {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 2px;
}

.move-entry {
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.move-entry:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.move-entry.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ---- Import tab ---- */
.import-section {
  padding: 0.85rem;
}

.import-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.import-divider {
  height: 1px;
  background: var(--border);
}

.pgn-input {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.pgn-input:focus { border-color: var(--accent); }
.pgn-input.error { border-color: #ef4444; }

.import-btn {
  margin-top: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--accent-dim);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.import-btn:hover {
  background: rgba(74,222,128,0.15);
  border-color: var(--accent);
}

/* platform toggle */
.platform-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.platform-option {
  flex: 1;
  display: flex;
  cursor: pointer;
}

.platform-option input { display: none; }

.platform-option span {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.platform-option input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.search-row {
  display: flex;
  gap: 0.4rem;
}

.username-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  outline: none;
  transition: border-color 0.2s;
}
.username-input:focus { border-color: var(--accent); }

/* ---- Games list ---- */
.games-list {
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.loading {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.error-msg {
  padding: 1rem;
  font-size: 0.78rem;
  color: #ef4444;
  text-align: center;
}

.empty-games {
  padding: 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
}

.game-entry {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.game-entry:last-child { border-bottom: none; }
.game-entry:hover { background: rgba(255,255,255,0.03); }

.game-players {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  margin-bottom: 2px;
}

.game-white { color: var(--text); }
.game-vs { color: var(--text-dim); font-size: 0.65rem; }
.game-black { color: var(--text-muted); }

.game-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.game-result {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
}

.game-opening {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 820px) {
  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .panel-column {
    position: static;
    max-height: none;
  }

  .board-column {
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 500px) {
  .analysis-page { padding-top: 72px; }
  .board-controls { padding-left: 0; }
  .fen-row { padding-left: 0; }
  .piece-tray { padding-left: 0; }
  .game-info { margin-left: 0; }

  .eval-bar { display: none; }
}

/* ---- Full analysis section ---- */
.full-analysis-section {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.full-analysis-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--accent-dim);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  justify-content: center;
}
.full-analysis-btn:hover {
  background: rgba(74,222,128,0.15);
  border-color: var(--accent);
}

.analysis-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
}

/* ---- Post-game panel ---- */
.postgame-panel {
  border-bottom: 1px solid var(--border);
}

.postgame-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.postgame-tab {
  flex: 1;
  padding: 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.postgame-tab:hover { color: var(--text-muted); }
.postgame-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.postgame-content {
  padding: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.postgame-content.hidden { display: none; }

/* Game tab */
.pg-game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.pg-game-field {
  font-size: 0.72rem;
}

.pg-game-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.pg-game-value {
  color: var(--text);
  font-weight: 500;
}
.pg-game-value a { color: var(--accent); }

/* Stats tab */
.pg-stats-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pg-stat-card {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
}

.pg-stat-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.pg-stat-metrics {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.pg-stat-metric { text-align: center; }

.pg-stat-metric-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.pg-stat-metric-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.pg-stat-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pg-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
}
.pg-badge.inaccuracy { background: rgba(234,179,8,0.15); color: #eab308; }
.pg-badge.mistake { background: rgba(249,115,22,0.15); color: #f97316; }
.pg-badge.blunder { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Eval / Time charts */
#eval-chart,
#time-chart {
  width: 100%;
  height: 140px;
  border-radius: 4px;
}

/* ============================================
   Arrow Overlay
   ============================================ */
.arrow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.arrow-overlay .best-move-arrow {
  opacity: 0.7;
}

.arrow-overlay .user-arrow {
  opacity: 0.8;
}

.arrow-overlay .user-highlight {
  opacity: 0.45;
}

/* ============================================
   Depth Slider
   ============================================ */
.depth-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.depth-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.depth-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.depth-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* ============================================
   Opening Name
   ============================================ */
.opening-name {
  padding: 0.3rem 0.85rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  min-height: 1.4em;
  font-style: italic;
}

.opening-name:empty {
  display: none;
}

.opening-eco {
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--accent);
  margin-right: 0.3rem;
  font-weight: 600;
  font-size: 0.68rem;
}

/* ============================================
   FEN Copy Button
   ============================================ */
.fen-copy-btn {
  padding: 0.4rem 0.5rem;
  min-width: unset;
}

/* ============================================
   Move Classification Colors
   ============================================ */
.move-entry.brilliant { color: #22d3ee; }
.move-entry.great { color: #3b82f6; }
.move-entry.good { color: var(--text-muted); }
.move-entry.inaccuracy { color: #eab308; }
.move-entry.mistake { color: #f97316; }
.move-entry.blunder { color: #ef4444; }

.move-entry.brilliant.active,
.move-entry.great.active { background: rgba(59,130,246,0.15); }
.move-entry.inaccuracy.active { background: rgba(234,179,8,0.15); }
.move-entry.mistake.active { background: rgba(249,115,22,0.15); }
.move-entry.blunder.active { background: rgba(239,68,68,0.15); }

/* ============================================
   Move Annotation
   ============================================ */
.move-annotation {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 1px;
}

.move-annotation.brilliant { color: #22d3ee; }
.move-annotation.great { color: #3b82f6; }
.move-annotation.inaccuracy { color: #eab308; }
.move-annotation.mistake { color: #f97316; }
.move-annotation.blunder { color: #ef4444; }

/* ============================================
   Analysis Line Click
   ============================================ */
.analysis-line {
  cursor: pointer;
}

.analysis-line:active {
  background: rgba(74,222,128,0.08) !important;
}

/* ============================================
   Threat Mode Active
   ============================================ */
#threat-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

#sound-btn.muted svg {
  opacity: 0.4;
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.2rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font-body);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ============================================
   Cloud Eval Badge
   ============================================ */
.cloud-eval-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  padding: 1px 5px;
  background: rgba(74,222,128,0.06);
  border-radius: 3px;
  margin-left: 0.3rem;
}

.cloud-eval-badge svg {
  width: 10px;
  height: 10px;
}

/* ============================================
   Right-click highlight square
   ============================================ */
.square.user-highlight-red {
  background: rgba(235, 97, 80, 0.45) !important;
}

.square.user-highlight-green {
  background: rgba(74, 222, 128, 0.35) !important;
}

.square.user-highlight-blue {
  background: rgba(59, 130, 246, 0.35) !important;
}

.square.user-highlight-yellow {
  background: rgba(234, 179, 8, 0.35) !important;
}

/* ============================================
   Board actions responsive wrap
   ============================================ */
.board-actions {
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ============================================
   Touch support
   ============================================ */
@media (pointer: coarse) {
  .square {
    -webkit-touch-callout: none;
  }

  .piece-tray .tray-piece {
    width: 36px;
    height: 36px;
  }

  .action-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
  }

  .move-controls button {
    padding: 0.55rem 0.85rem;
  }
}

/* ============================================
   Famous games
   ============================================ */
.famous-game-entry {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.famous-game-entry:last-child { border-bottom: none; }
.famous-game-entry:hover { background: rgba(255,255,255,0.03); }

.famous-game-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 1px;
}

.famous-game-meta {
  font-size: 0.68rem;
  color: var(--text-dim);
}
