/* ==========================================================================
   ChessMastery - Design System & Stylesheet
   Theme: Luxury Dark Glassmorphism with Emerald & Amber Gold Accents
   Typography: Plus Jakarta Sans & JetBrains Mono
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Color Palette */
  --bg-main: #080c16;
  --bg-sidebar: #0b1120;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(255, 255, 255, 0.03);

  /* Accents */
  --primary: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);

  /* Typography */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Board Colors */
  --sq-light: #e2d6b5;
  --sq-dark: #8b7355;
  --sq-highlight-last: rgba(250, 204, 21, 0.45);
  --sq-highlight-select: rgba(59, 130, 246, 0.5);
  --sq-check: rgba(239, 68, 68, 0.65);

  /* Dimensions */
  --sidebar-w: 270px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px var(--bg-card-border);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  letter-spacing: -0.01em;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.04) 0%, transparent 40%);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: -0.025em;
  font-weight: 700;
}

/* ==========================================================================
   App Layout
   ========================================================================== */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--bg-card-border);
}

.brand-icon {
  font-size: 28px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px var(--accent-gold-glow));
}

.brand-info h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 40%, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 10px 12px 4px;
  font-weight: 700;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active a {
  color: #fff;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border-left: 3px solid var(--primary);
  font-weight: 600;
}

.nav-item a .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.nav-tag {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--bg-card-border);
  background: rgba(0, 0, 0, 0.2);
}

.user-quick-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.progress-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-gold));
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  padding: 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: calc(100vw - var(--sidebar-w));
  overflow-y: auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Headers */
.section-header {
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  margin-bottom: 6px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 15px;
}

/* ==========================================================================
   Dashboard Components
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  padding: 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.05);
}

.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--primary); }
.stat-icon.gold { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.stat-info h4 {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-info .stat-value {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
}

/* Dashboard 2-Column Grid */
.dash-columns {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 28px;
}

.dash-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
}

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.dash-card-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 2-Day Roadmap Cards in Dashboard */
.roadmap-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.roadmap-day-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.roadmap-day-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(16, 185, 129, 0.4);
}

.roadmap-day-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.roadmap-day-card.day2::before {
  background: var(--accent-gold);
}

.day-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 6px;
}

.roadmap-day-card.day2 .day-badge {
  color: var(--accent-gold);
}

.roadmap-day-card h4 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.roadmap-day-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.btn-sm-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.btn-sm-action:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* Quote Card */
.quote-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(16, 185, 129, 0.05));
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 24px;
  position: relative;
}

.quote-icon {
  font-size: 32px;
  color: var(--accent-gold);
  opacity: 0.5;
  margin-bottom: 8px;
}

.quote-text {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 16px;
  line-height: 1.6;
  color: #f1f5f9;
  margin-bottom: 12px;
}

.quote-author {
  font-size: 13px;
  color: var(--accent-gold);
  font-weight: 600;
  text-align: right;
}

/* ==========================================================================
   Crash Course / Lessons View
   ========================================================================== */
.day-selector-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.day-tab {
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.day-tab:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.day-tab.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border-color: var(--primary);
  color: #fff;
}

.day-tab.day2.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.05));
  border-color: var(--accent-gold);
}

.lessons-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 22px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.lesson-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 12px 24px -8px var(--primary-glow);
}

.lesson-card.completed {
  border-color: rgba(16, 185, 129, 0.4);
}

.lesson-card.completed::after {
  content: '✓ Selesai';
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
}

.lesson-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.lesson-number {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
}

.lesson-time {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.lesson-card h3 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.lesson-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.lesson-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.lesson-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* Lesson Detail Modal / Viewer */
.lesson-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lesson-modal {
  background: #0f172a;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.lesson-modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.lesson-modal-header h2 {
  font-size: 22px;
  color: #fff;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close-modal:hover {
  color: #fff;
}

.lesson-modal-body {
  padding: 28px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
}

.lesson-theory {
  font-size: 14px;
  line-height: 1.7;
  color: #cbd5e1;
}

.lesson-theory h3 {
  font-size: 17px;
  color: #fff;
  margin: 18px 0 8px;
}

.lesson-theory ul, .lesson-theory ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.lesson-theory li {
  margin-bottom: 6px;
}

.theory-callout {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  font-size: 13px;
}

.theory-callout.tip {
  background: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--primary);
}

.theory-callout.warning {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--danger);
}

.lesson-interactive-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lesson-puzzle-instruction {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
  margin-bottom: 16px;
  text-align: center;
  color: var(--accent-gold);
  font-weight: 600;
}

.lesson-modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================================
   Play vs Bot View
   ========================================================================== */
.play-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
}

.board-area {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Evaluation Bar */
.eval-bar-wrapper {
  width: 20px;
  height: 480px;
  background: #334155;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bg-card-border);
  position: relative;
}

.eval-bar-white {
  background: #f8fafc;
  width: 100%;
  transition: height 0.3s ease;
}

.eval-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  font-size: 10px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  pointer-events: none;
}

/* Chess Grid & Square Aesthetics */
.chess-board-wrapper {
  background: #2a2016;
  padding: 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 0 2px #4a3824;
}

.chess-grid {
  width: 480px;
  height: 480px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
}

.chess-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sq-light {
  background-color: var(--sq-light);
}

.sq-dark {
  background-color: var(--sq-dark);
}

.sq-selected {
  background-color: var(--sq-highlight-select) !important;
}

.sq-last-move {
  background-color: var(--sq-highlight-last) !important;
}

.sq-in-check {
  background-color: var(--sq-check) !important;
  animation: pulseCheck 1s infinite alternate;
}

@keyframes pulseCheck {
  from { box-shadow: inset 0 0 10px var(--danger); }
  to { box-shadow: inset 0 0 25px var(--danger); }
}

/* Coordinates */
.coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.6;
}

.sq-light .coord { color: var(--sq-dark); }
.sq-dark .coord { color: var(--sq-light); }

.rank-coord {
  top: 2px;
  left: 3px;
}

.file-coord {
  bottom: 2px;
  right: 3px;
}

/* Pieces */
.chess-piece {
  width: 85%;
  height: 85%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s ease;
}

.chess-piece:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.chess-piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Move Markers */
.legal-move-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.6);
  pointer-events: none;
  z-index: 5;
}

.sq-hint-from {
  background-color: rgba(6, 182, 212, 0.45) !important;
  box-shadow: inset 0 0 12px rgba(6, 182, 212, 0.8);
}

.sq-hint-to {
  background-color: rgba(16, 185, 129, 0.5) !important;
  box-shadow: inset 0 0 14px rgba(16, 185, 129, 0.9);
  animation: pulseHint 1.2s infinite alternate;
}

@keyframes pulseHint {
  from { box-shadow: inset 0 0 8px var(--primary); }
  to { box-shadow: inset 0 0 20px var(--primary), 0 0 10px rgba(16, 185, 129, 0.6); }
}

.hint-target-ring {
  position: absolute;
  inset: 6px;
  border: 3px dashed var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  animation: rotateRing 8s linear infinite;
}

@keyframes rotateRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Post-Game Analysis Modal & Key Moments Inspector
   ========================================================================== */
.analysis-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(14px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.analysis-modal {
  background: #0d1322;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  max-width: 1050px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.8);
}

.analysis-modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.analysis-modal-header h2 {
  font-size: 20px;
  color: #fff;
}

.analysis-modal-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.analysis-stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--bg-card-border);
}

.acc-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.acc-stat-box .acc-val {
  font-size: 20px;
  font-weight: 800;
}

.acc-stat-box .acc-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 600;
}

.analysis-modal-body {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  padding: 24px 28px;
  overflow-y: auto;
  flex-grow: 1;
}

.analysis-board-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 360px;
}

#analysis-board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 360px;
}

#analysis-board-container .chess-board-wrapper {
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

#analysis-board-container .chess-grid {
  width: 350px;
  height: 350px;
  max-width: 80vw;
  max-height: 80vw;
}

.analysis-nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--bg-card-border);
}

.btn-step {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-step:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.analysis-moments-side {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.analysis-moments-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  padding-right: 6px;
}

.analysis-moment-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.analysis-moment-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.moment-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.analysis-view-toggle {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-toggle-move {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-move#btn-toggle-played.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: #fca5a5;
}

.btn-toggle-move#btn-toggle-best.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--primary);
  color: #86efac;
}

.analysis-guide-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.guide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.guide-dot.red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.guide-dot.orange { background: #f97316; box-shadow: 0 0 6px #f97316; }
.guide-dot.yellow { background: var(--accent-gold); box-shadow: 0 0 6px var(--accent-gold); }

.moment-split-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}

.moment-played-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 6px 10px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
}

.moment-best-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 10px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
}

.box-label {
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}

.moment-played-box .box-val {
  font-size: 14px;
  font-weight: 800;
  color: #fca5a5;
  font-family: 'JetBrains Mono', monospace;
}

.moment-best-box .box-val {
  font-size: 14px;
  font-weight: 800;
  color: #86efac;
  font-family: 'JetBrains Mono', monospace;
}

.analysis-moment-card.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

/* Analysis Highlight Board Styles */
.sq-played-from {
  background: rgba(239, 68, 68, 0.45) !important;
}

.sq-played-to {
  background: rgba(239, 68, 68, 0.65) !important;
}

.sq-best-from {
  background: rgba(16, 185, 129, 0.45) !important;
}

.sq-best-to {
  background: rgba(16, 185, 129, 0.65) !important;
}

.played-target-ring {
  position: absolute;
  inset: 4px;
  border: 3px solid #ef4444;
  border-radius: 50%;
  pointer-events: none;
  animation: pulseRing 1.5s infinite;
}

.best-target-ring {
  position: absolute;
  inset: 4px;
  border: 3px solid #10b981;
  border-radius: 50%;
  pointer-events: none;
  animation: pulseRing 1.5s infinite;
}

.moment-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
}

.moment-badge.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid var(--danger);
}

.moment-badge.warning {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
  border: 1px solid #f97316;
}

.moment-badge.info {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid var(--accent-gold);
}

.moment-move-num {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.moment-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 6px;
}

.moment-cont-preview {
  font-size: 11.5px;
  font-family: 'JetBrains Mono', monospace;
  color: #86efac;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  word-break: break-all;
}

.moment-cont-preview span {
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  margin-right: 4px;
}

.moment-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-inspect-link {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
}

.analysis-modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
}

/* Coach Card Component */
.coach-card {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(16, 185, 129, 0.06));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coach-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.coach-icon {
  font-size: 18px;
}

.coach-title {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-grow: 1;
}

.btn-coach-hint {
  background: linear-gradient(135deg, #0284c7, #0d9488);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
  white-space: nowrap;
}

.btn-coach-hint:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn-coach-hint:active {
  transform: translateY(1px);
}

.coach-body {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Game Sidebar Controls */
.game-controls-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-card);
}

/* Bot Profile Header */
.bot-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bg-card-border);
}

.bot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.bot-meta h4 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.bot-difficulty-tag {
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 600;
}

/* Difficulty Selector */
.difficulty-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.difficulty-selector label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.difficulty-btn-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.diff-btn {
  padding: 8px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bg-card-border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.diff-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Move History Log */
.move-history-container {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  height: 150px;
  overflow-y: auto;
  padding: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.move-row {
  display: grid;
  grid-template-columns: 35px 1fr 1fr;
  padding: 3px 6px;
  border-radius: 4px;
}

.move-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.move-num {
  color: var(--text-dim);
}

.move-w, .move-b {
  color: var(--text-main);
  cursor: pointer;
}

/* Captured Pieces Box */
.captured-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  font-size: 16px;
}

.captured-label {
  font-size: 11px;
  color: var(--text-dim);
  width: 45px;
}

/* Game Buttons */
.game-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.btn-game-action {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  border: 1px solid var(--bg-card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-game-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.btn-game-action.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* ==========================================================================
   Tactics View
   ========================================================================== */
.tactics-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
}

.tactics-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.puzzle-feedback {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: none;
  animation: fadeIn 0.2s ease;
}

.puzzle-feedback.success {
  display: block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.puzzle-feedback.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* ==========================================================================
   Repertoire & Game Log View
   ========================================================================== */
.repertoire-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

.repertoire-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.repertoire-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.repertoire-header h3 {
  font-size: 18px;
  color: #fff;
}

.eco-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border-radius: 4px;
}

.moves-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--accent-gold);
}

/* ==========================================================================
   Pawn Promotion Modal Backdrop
   ========================================================================== */
.promotion-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promotion-modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--bg-card-border);
  padding: 24px;
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.promotion-modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #fff;
}

.promotion-options {
  display: flex;
  gap: 12px;
}

.promo-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 80px;
}

.promo-btn svg {
  width: 44px;
  height: 44px;
}

.promo-btn span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.promo-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.promo-btn:hover span {
  color: #fff;
}

/* ==========================================================================
   Mobile Header & Bottom Navigation Bar
   ========================================================================== */
.mobile-top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--bg-card-border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  z-index: 90;
}

.brand-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mobile .brand-icon {
  font-size: 22px;
  color: var(--accent-gold);
}

.brand-mobile .brand-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.mobile-streak-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--bg-card-border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item .mobile-nav-icon {
  font-size: 19px;
  margin-bottom: 2px;
  transition: transform 0.2s ease;
}

.mobile-nav-item:active .mobile-nav-icon {
  transform: scale(0.9);
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item.active .mobile-nav-icon {
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

/* ==========================================================================
   Touch Optimization & Square Sizing
   ========================================================================== */
.chess-square {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chess-piece {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .dash-columns, .play-layout, .tactics-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .board-area {
    justify-content: center;
  }
  .chess-grid {
    width: 420px;
    height: 420px;
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 56px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-top-bar {
    display: flex;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .app-container {
    flex-direction: column;
    min-height: auto;
  }

  .sidebar {
    display: none; /* Replaced by bottom nav on mobile */
  }

  .main-content {
    width: 100vw;
    padding: 16px 14px 40px;
    max-width: 100%;
  }

  .section-header {
    margin-bottom: 18px;
  }

  .section-header h2 {
    font-size: 24px;
  }

  .section-header p {
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }

  .stat-info .stat-value {
    font-size: 20px;
  }

  .roadmap-overview {
    grid-template-columns: 1fr;
  }

  /* Responsive Mobile Chess Board */
  .board-area {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  .chess-board-wrapper {
    padding: 6px;
    max-width: 100%;
  }

  .chess-grid {
    width: calc(100vw - 36px);
    height: calc(100vw - 36px);
    max-width: 380px;
    max-height: 380px;
  }

  .eval-bar-wrapper {
    width: 12px;
    height: calc(100vw - 36px);
    max-height: 380px;
  }

  .eval-score-text {
    display: none;
  }

  /* Controls layout */
  .game-controls-panel, .tactics-panel, .dash-card {
    padding: 18px 14px;
  }

  .difficulty-btn-group {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .diff-btn {
    padding: 10px 0;
    font-size: 12px;
  }

  .game-actions-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .btn-game-action {
    padding: 10px 6px;
    font-size: 12px;
  }

  /* Modal on Mobile */
  .lesson-modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }

  .lesson-modal {
    max-height: 94vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .lesson-modal-header {
    padding: 14px 18px;
  }

  .lesson-modal-header h2 {
    font-size: 17px;
  }

  .lesson-modal-body {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }

  .lesson-interactive-panel .chess-grid {
    width: calc(100vw - 64px);
    height: calc(100vw - 64px);
    max-width: 320px;
    max-height: 320px;
  }
}

/* ==========================================================================
   Tactics 100-Puzzle Quick Navigator & Filters
   ========================================================================== */
.tactics-nav-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tactics-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bg-card-border);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  max-width: 260px;
}

.tactics-select option {
  background: #0d1322;
  color: #fff;
}

/* ==========================================================================
   Interactive Repertoire Trainer & Step Timeline
   ========================================================================== */
.rep-timeline-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--bg-card-border);
}

.rep-timeline-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--bg-card-border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.rep-timeline-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.rep-timeline-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--primary);
  color: #86efac;
  font-weight: 700;
}

.rep-timeline-btn .step-num {
  font-size: 10px;
  opacity: 0.7;
}

.rep-commentary-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(6, 182, 212, 0.04));
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

#rep-board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#rep-board-container .chess-grid {
  width: 350px;
  height: 350px;
  max-width: 80vw;
  max-height: 80vw;
}


