/* Visual Chess - Main Stylesheet */
/* Mobile-first, responsive layout for portrait and landscape */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-panel: #0f3460;
  --text-primary: #e4e4e4;
  --text-secondary: #a0a0a0;
  --accent-blue: #4285f4;
  --accent-green: #34a853;
  --accent-red: #dc3545;
  --accent-yellow: #fbbc04;
  --border-color: #2a2a4a;
  --font-mono: 'Courier New', monospace;
  --font-sans: system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* --- Loading Screen --- */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 1000;
}

.loading-content {
  text-align: center;
  padding: 2rem;
}

.splash-logo {
  width: 160px;
  height: auto;
  margin-bottom: 0.5rem;
}

.loading-content h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: var(--accent-blue);
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin: 0 auto 1rem;
  overflow: hidden;
}

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

#loading-status {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Splash screen branding */
.splash-attribution {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}



.splash-credit {
  position: absolute;
  bottom: 20px;
  right: 20px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.65rem;
  opacity: 0.6;
  line-height: 1.5;
}

.splash-axolotl-icon {
  vertical-align: middle;
  margin-left: 2px;
}

/* Loading bar glitch animation */
@keyframes loading-glitch {
  0%   { width: 100%; transform: translateX(0); }
  30%  { width: 105%; transform: translateX(-1px); }
  60%  { width: 103%; transform: translateX(2px); }
  80%  { width: 105%; transform: translateX(-1px); }
  100% { width: 105%; transform: translateX(0); }
}

.loading-progress.glitch {
  animation: loading-glitch 100ms ease-out forwards;
}

/* --- Main App Layout --- */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Board area: wraps status bar + board container */
#board-area {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

/* Portrait: column layout (board top, panel bottom) */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  #app {
    flex-direction: column;
  }

  #board-area {
    width: 100vw;
    height: min(100vw, 60vh);
  }

  #board-container {
    flex: 1;
    min-height: 0;
  }

  #analysis-panel {
    flex: 1;
    width: 100%;
    min-height: 0;
  }
}

/* Landscape: row layout (board left, panel right) */
@media (orientation: landscape) and (min-aspect-ratio: 1/1) {
  #app {
    flex-direction: row;
  }

  #board-area {
    height: 100vh;
    width: min(100vh, 60vw);
  }

  #board-container {
    flex: 1;
    min-height: 0;
  }

  #analysis-panel {
    flex: 1;
    height: 100%;
    min-width: 0;
  }
}

/* --- Board Container --- */
#board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 4px;
}

#chess-board {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* --- Status Bar --- */
#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-height: 22px;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}

#status-bar:empty {
  min-height: 0;
  padding: 0;
  border: none;
}

/* Inference activity indicator */
.status-inference {
  display: none;
  width: 60px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.status-inference.active {
  display: block;
}

.inference-bar {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent-blue);
  border-radius: 2px;
  animation: inference-slide 2.8s ease-in-out infinite;
}

/* Bar slides fully off both edges: disappears left, reappears right, disappears right, reappears left */
@keyframes inference-slide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(250%); }
  100% { transform: translateX(-100%); }
}

/* Prefetch activity glow */
.status-prefetch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
}

.status-prefetch.slow {
  animation: prefetch-pulse 2.0s ease-in-out infinite;
}

.status-prefetch.moderate {
  animation: prefetch-pulse 1.0s ease-in-out infinite;
}

.status-prefetch.fast {
  animation: prefetch-pulse 0.4s ease-in-out infinite;
}

@keyframes prefetch-pulse {
  0%, 100% { opacity: 0.3; box-shadow: none; }
  50%      { opacity: 1.0; box-shadow: 0 0 6px var(--accent-green); }
}

/* Captured pieces display */
.status-captures {
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 0.9rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.capture-divider {
  color: var(--border-color);
  margin: 0 3px;
  font-size: 0.75rem;
}

/* Cache and performance statistics */
.status-stats {
  color: var(--text-secondary);
  margin-left: auto;
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Build info */
.status-build {
  color: var(--text-secondary);
  font-size: 0.65rem;
  opacity: 0.6;
  margin-left: 0.5em;
  white-space: nowrap;
}

/* Waiting message */
.status-waiting {
  color: var(--accent-blue);
  font-size: 0.7rem;
  font-style: italic;
}

/* ─── Toggle Controls Panel ─── */

#toggle-controls {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.toggle-side-label {
  font-size: 0.65rem;
  font-weight: bold;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  width: 1ch;
  text-align: center;
  flex-shrink: 0;
  user-select: none;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.toggle-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.toggle-pill:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.95);
}

/* Side-identifying: White pills — bright border, subtle light fill */
.toggle-white {
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
}

.toggle-white:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Side-identifying: Black pills — dark fill, contrasting border */
.toggle-black {
  border: 1.5px solid rgba(140, 140, 140, 0.4);
  background: rgba(0, 0, 0, 0.35);
}

.toggle-black:hover {
  background: rgba(0, 0, 0, 0.18);
}

/* Icon states */
.toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.2;
  transition: opacity 0.2s ease, transform 0.15s ease;
  color: var(--text-secondary);
}

.toggle-icon-active {
  opacity: 1;
  color: var(--text-primary);
  transform: scale(1.15);
}

/* Black pills: inverted icon colors for contrast */
.toggle-black .toggle-icon {
  opacity: 0.25;
  color: rgba(160, 160, 160, 0.6);
}

.toggle-black .toggle-icon-active {
  opacity: 1;
  color: rgba(210, 210, 210, 0.95);
}

/* Autoplay countdown progress bar */
.autoplay-countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  pointer-events: none;
}

.autoplay-countdown-bar {
  height: 100%;
  background: var(--accent-blue);
  width: 0%;
  animation: autoplay-fill var(--countdown-duration, 1000ms) linear forwards;
}

.toggle-black .autoplay-countdown-bar {
  background: var(--accent-yellow);
}

@keyframes autoplay-fill {
  from { width: 0%; }
  to { width: 100%; }
}

/* All-aids-disabled warning */
.toggle-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 0 0;
  color: var(--accent-red);
}

.aids-warning-text {
  font-size: 0.7rem;
  font-style: italic;
}

/* Responsive: hide warning text on narrow, keep icon */
@media (max-width: 599px) {
  .aids-warning-text {
    display: none;
  }
}

/* --- Analysis Panel --- */
#analysis-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  overflow: hidden;
}

@media (orientation: portrait) {
  #analysis-panel {
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

/* --- ELO Control --- */
#elo-control {
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#elo-control label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

#elo-value {
  color: var(--accent-green);
  font-weight: bold;
  font-family: var(--font-mono);
  min-width: 3.5ch;
  display: inline-block;
}

#elo-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

#elo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-green);
  border-radius: 50%;
  cursor: pointer;
}

#elo-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent-green);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* --- Panel Sections --- */
.panel-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.section-header {
  padding: 8px 12px;
  background: var(--bg-panel);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.section-header:hover {
  background: #1a4a80;
}

.section-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.section-content.collapsed {
  display: none;
}

/* --- Move History --- */
.move-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 1fr;
  gap: 0 0.5rem;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  align-items: start;
}

.move-number {
  color: var(--text-secondary);
  text-align: right;
  padding-top: 4px;
}

.move-entry {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  min-width: 0;
}

.move-entry-empty {
  cursor: default;
}

.move-entry:hover {
  background: rgba(255, 255, 255, 0.1);
}

.move-entry.current {
  background: rgba(66, 133, 244, 0.3);
}

.move-entry-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.move-entry.current .move-san {
  font-weight: bold;
}

/* cpLoss-based SAN color classes (applied directly on .move-san) */
.move-san.san-blue { color: var(--accent-blue); }
.move-san.san-green { color: var(--accent-green); }
.move-san.san-neutral { color: var(--text-primary); }
.move-san.san-red { color: var(--accent-red); }

/* Verbose move explanation — primary content, multi-line */
.move-explanation {
  font-size: 0.78rem;
  font-family: var(--font-sans);
  line-height: 1.4;
  margin-top: 2px;
  white-space: normal;
  word-wrap: break-word;
  font-style: italic;
}

.move-explanation.score-blue { color: var(--accent-blue); }
.move-explanation.score-green { color: var(--accent-green); }
.move-explanation.score-white { color: var(--text-primary); opacity: 0.85; }
.move-explanation.score-red { color: var(--accent-red); }

.meta-toggle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  cursor: pointer;
  position: absolute;
  top: 4px;
  right: 4px;
}

.move-metadata {
  position: relative;
  margin-top: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Full-width metadata expansion below paired row */
.move-metadata-expanded {
  margin: 2px 0;
}

.meta-eval {
  color: var(--accent-blue);
  font-weight: bold;
  margin-bottom: 4px;
}

.meta-insight {
  color: var(--text-secondary);
}

/* --- Milestone Rows --- */
.milestone-row {
  width: 100%;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  font-style: italic;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin: 2px 0;
  box-sizing: border-box;
}

/* --- PV Descriptions --- */
.insight-pv {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
  cursor: help;
}

.insight-pv-raw {
  font-family: var(--font-mono);
  font-style: normal;
  opacity: 0.7;
}

.milestone-info {
  background: rgba(66, 133, 244, 0.12);
  color: var(--accent-blue);
}

.milestone-warning {
  background: rgba(251, 188, 4, 0.12);
  color: var(--accent-yellow);
}

.milestone-critical {
  background: rgba(220, 53, 69, 0.15);
  color: var(--accent-red);
}

/* --- Hold-to-Revert Progress --- */
.hold-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-blue);
  border-radius: 0 0 4px 4px;
  width: 0%;
  transition: none;
  pointer-events: none;
}

.hold-progress.animating {
  width: 100%;
  transition: width 1000ms linear;
}

/* --- Player Mindset --- */
#player-mindset {
  padding: 4px 0 8px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-secondary);
}

#move-history-content {
  overflow-y: auto;
}

.mindset-white, .mindset-black {
  padding: 2px 0;
}

.mindset-white strong { color: #f0f0f0; }
.mindset-black strong { color: #888; }

/* --- Branch Indicators --- */
.branch-indicator {
  padding: 4px 8px;
  font-size: 0.75rem;
  color: var(--accent-yellow);
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.branch-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.branch-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

/* --- Future Moves --- */
.future-move-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.future-move-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.move-rank {
  color: var(--text-secondary);
  min-width: 2.5ch;
  text-align: right;
}

.move-notation {
  min-width: 5ch;
}

.move-eval {
  color: var(--text-secondary);
  min-width: 5ch;
  text-align: right;
}

.future-move-entry.best-move .move-notation { color: var(--accent-blue); font-weight: bold; }
.future-move-entry.good-move .move-notation { color: var(--accent-green); }
.future-move-entry.ok-move .move-notation { color: var(--text-primary); }
.future-move-entry.bad-move .move-notation { color: var(--accent-red); }

.elo-best-tag {
  background: var(--accent-green);
  color: #000;
  font-size: 0.65rem;
  padding: 0 4px;
  border-radius: 2px;
  font-weight: bold;
}

.insight-toggle {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
}

.future-move-insight {
  width: 100%;
  padding: 6px 8px;
  margin-top: 4px;
  background: var(--bg-panel);
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Move Annotation Summaries --- */
.move-annotation-summary {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  line-height: 1.3;
  margin-top: 2px;
  opacity: 0.85;
}

/* Insight sub-elements in expanded detail sections */
.insight-themes {
  color: var(--accent-blue);
  font-size: 0.75rem;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.insight-details {
  color: var(--text-primary);
  margin-bottom: 4px;
}

.insight-squares {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.no-moves {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
}

/* --- Promotion Overlay --- */
#promotion-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.promotion-choices {
  display: flex;
  gap: 8px;
  background: var(--bg-panel);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.promotion-btn {
  width: 60px;
  height: 60px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promotion-btn:hover {
  border-color: var(--accent-blue);
  background: rgba(66, 133, 244, 0.2);
}

/* --- Update Notification --- */
#update-notification {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--accent-blue);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 200;
  font-size: 0.85rem;
}

#update-notification button {
  background: var(--accent-blue);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#dismiss-update-btn {
  background: transparent !important;
  color: var(--text-secondary) !important;
}

/* --- Inference Analysis UI --- */

/* Color-coded one-liners */
.inference-oneliner {
  display: block;
  font-size: 0.7rem;
  font-family: var(--font-sans);
  line-height: 1.3;
  margin-top: 2px;
  font-style: italic;
}

.inference-oneliner.score-blue { color: var(--accent-blue); }
.inference-oneliner.score-green { color: var(--accent-green); }
.inference-oneliner.score-white { color: var(--text-primary); }
.inference-oneliner.score-red { color: var(--accent-red); }

/* Expanded analysis section */
.inference-expanded {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 3px;
  border-left: 2px solid var(--border-color);
}

/* Concept labels */
.inference-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.concept-label {
  background: rgba(66, 133, 244, 0.15);
  color: var(--accent-blue);
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: capitalize;
  cursor: help;
}

/* GREEN vs BLUE comparison */
.inference-comparison {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 4px 0;
  padding: 4px 8px;
  background: rgba(66, 133, 244, 0.08);
  border-radius: 3px;
}

.clickable-blue-move {
  color: var(--accent-blue);
  cursor: pointer;
  font-weight: bold;
  text-decoration: underline;
}

.clickable-blue-move:hover {
  color: #6ba3ff;
}

.comparison-move {
  font-family: var(--font-mono);
}

/* Confidence indicator */
.inference-confidence {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 4px;
  opacity: 0.7;
}

/* Source indicator */
.inference-source {
  font-size: 0.6rem;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-top: 2px;
}

/* Mindset inference enrichments */
.mindset-inference {
  font-size: 0.75rem;
  color: var(--accent-blue);
  padding: 2px 0;
  opacity: 0.9;
  font-style: italic;
}

/* --- Scrollbar Styling --- */
.section-content::-webkit-scrollbar {
  width: 4px;
}

.section-content::-webkit-scrollbar-track {
  background: transparent;
}

.section-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* --- Tactical Badge Styles --- */
.tactical-badge {
  pointer-events: none;
  /* CSS transition on CSS transform property (set via style.transform in JS).
     SVG attribute transforms don't animate with CSS transitions in Chrome PWA. */
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
  transform-origin: 0 0;
}

.badge-group {
  pointer-events: none;
}

/* Fan-out: badges get pointer-events when expanded (positions set by JS) */
.badge-group.badges-expanded .tactical-badge {
  pointer-events: auto;
}

/* --- Halo Hover & Preview States --- */
.halo-path {
  transition: opacity 0.15s ease, filter 0.15s ease;
}

/* Dimmed state: when a move preview is active, all non-selected halos dim */
.halo-dimmed {
  opacity: 0.08 !important;
  filter: none !important;
}

/* Halo hover/selected glow: explicit color set via inline style in JS.
   CSS currentColor on SVG paths is unreliable in Chrome PWA. */
.halo-hover {
  opacity: 0.9 !important;
  /* filter is set inline by board-renderer.ts with explicit color */
}

.halo-selected {
  opacity: 1.0 !important;
  /* filter is set inline by board-renderer.ts with explicit color */
}

/* Emphasis for pieces affected by a previewed move */
.piece-affected {
  filter: drop-shadow(0 0 4px rgba(255, 200, 50, 0.8)) brightness(1.15);
}

/* --- Badge Transition Animations --- */

/* Vanishing badge: opacity-only pulse, no transform to avoid position glitching */
.badge-vanishing {
  pointer-events: none !important;
  animation: badge-vanish-pulse 2s ease-in-out forwards;
}

@keyframes badge-vanish-pulse {
  0%   { opacity: 0.7; }
  25%  { opacity: 0; }
  50%  { opacity: 0.4; }
  75%  { opacity: 0; }
  100% { opacity: 0; }
}

/* New badge glow: opacity-only pulse, safe for Chrome PWA compositor */
.badge-new-glow {
  animation: badge-glow 1.5s ease-in-out infinite;
}

@keyframes badge-glow {
  0%   { opacity: 0.7; }
  50%  { opacity: 1.0; }
  100% { opacity: 0.7; }
}

/* --- Fire Effect Animations (Losing Exchanges) --- */

/* Standard fire glow: slow opacity pulse under endangered pieces */
.fire-glow {
  animation: fire-glow-pulse 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes fire-glow-pulse {
  0%   { opacity: 0.3; }
  50%  { opacity: 0.5; }
  100% { opacity: 0.3; }
}

/* Newly-entered losing exchange: faster, more prominent opacity-only pulse */
.fire-new {
  animation: fire-new-pulse 1s ease-in-out infinite;
}

@keyframes fire-new-pulse {
  0%   { opacity: 0.4; }
  50%  { opacity: 0.7; }
  100% { opacity: 0.4; }
}

/* --- WebGPU Consent Dialog --- */

.webgpu-consent-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.webgpu-consent-dialog {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  color: #e0e0e0;
  font-family: inherit;
}

.webgpu-consent-dialog h3 {
  margin: 0 0 12px 0;
  color: #7cb3ff;
  font-size: 18px;
}

.webgpu-consent-dialog p {
  margin: 0 0 16px 0;
  font-size: 13px;
  line-height: 1.5;
  color: #aaa;
}

.webgpu-model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.webgpu-model-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.webgpu-model-item:hover {
  border-color: #555;
}

.webgpu-model-item.recommended {
  border-color: #7cb3ff;
}

.webgpu-model-item input[type="radio"] {
  margin-top: 3px;
}

.webgpu-model-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.webgpu-model-info strong {
  color: #e0e0e0;
  font-size: 13px;
}

.webgpu-model-info span {
  color: #888;
}

.webgpu-model-desc {
  color: #666 !important;
  font-style: italic;
}

.webgpu-consent-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.webgpu-btn-cancel {
  padding: 8px 16px;
  border: 1px solid #555;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 13px;
}

.webgpu-btn-cancel:hover {
  background: #222;
}

.webgpu-btn-download {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: #2d6bc4;
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
}

.webgpu-btn-download:hover {
  background: #3a7de0;
}

/* --- WebGPU Progress Bar --- */

.webgpu-progress-bar {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  height: 28px;
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 14px;
  overflow: hidden;
  z-index: 10000;
}

.webgpu-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2d6bc4, #7cb3ff);
  border-radius: 14px;
  width: 0%;
  transition: width 0.3s ease;
}

.webgpu-progress-label {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #e0e0e0;
  pointer-events: none;
}

/* --- Halo inference tooltip --- */
.halo-tooltip {
  position: absolute;
  z-index: 50;
  max-width: 220px;
  padding: 6px 10px;
  background: rgba(20, 20, 28, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  pointer-events: none;
  animation: tooltip-fade-in 0.15s ease-out;
}

/* Engine-data tooltip phase (before inference arrives) */
.tooltip-engine-data {
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.tooltip-engine-eval {
  font-weight: 700;
  font-size: 0.8rem;
}

.tooltip-engine-pv {
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.9;
  font-family: var(--font-mono);
}

.tooltip-quality-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Transition from engine data to inference content */
.tooltip-transition {
  animation: tooltip-content-fade 0.2s ease-out;
}

@keyframes tooltip-content-fade {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

.tooltip-oneliner {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.tooltip-score-blue   { color: #5b9aff; }
.tooltip-score-green  { color: #4ade80; }
.tooltip-score-white  { color: #e0e0e0; }
.tooltip-score-red    { color: #f87171; }

.tooltip-concepts {
  margin-top: 3px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

@keyframes tooltip-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Predictive PV Arrows (high visibility) --- */
.pv-arrow {
  opacity: 0.7;
  animation: arrow-glow calc(var(--arrow-count, 3) * 800ms) ease-in-out infinite;
  animation-delay: calc(var(--arrow-index, 0) * 800ms);
}

.pv-arrow-shaft {
  stroke-width: 7;
  stroke-linecap: round;
}

.pv-arrow-head {
  stroke: none;
}

.arrow-white-move .pv-arrow-shaft { stroke: rgba(210, 220, 255, 0.95); }
.arrow-white-move .pv-arrow-head  { fill: rgba(210, 220, 255, 0.95); }
.arrow-black-move .pv-arrow-shaft { stroke: rgba(255, 190, 110, 0.95); }
.arrow-black-move .pv-arrow-head  { fill: rgba(255, 190, 110, 0.95); }

.pv-arrow-number-bg {
  fill: rgba(20, 20, 28, 0.9);
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1;
}

.pv-arrow-number {
  fill: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}

@keyframes arrow-glow {
  0%, 100% { opacity: 0.55; filter: brightness(1); }
  50%      { opacity: 0.95; filter: brightness(1.4); }
}

/* --- UCI cross-reference links in panel --- */
.uci-ref {
  color: #5b9aff;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}
.uci-ref:hover {
  color: #7db4ff;
  text-decoration-style: solid;
}

/* --- Smooth transitions --- */
@media (prefers-reduced-motion: no-preference) {
  #app {
    transition: flex-direction 0.3s ease;
  }

  .section-content {
    transition: max-height 0.3s ease;
  }
}
