/* ============================================================================
   👑 شاهکار طراحی - استایل سلطنتی کیهان v5.0 👑
   Premium Design System - Cosmic Emperor Edition
   ========================================================================== */

:root {
    /* ===== رنگ‌های اصلی کیهانی ===== */
    --bg-primary: #0a0e1a;
    --bg-secondary: #121a2e;
    --bg-tertiary: #1a2a4a;
    --text-primary: #ffffff;
    --text-secondary: #bfc7d5;
    --text-muted: #7b8698;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    
    /* ===== رنگ‌های پریمیوم ===== */
    --primary: #4f8cff;
    --primary-light: #69e6ff;
    --primary-dark: #2a5cff;
    --secondary: #8b5cf6;
    --secondary-light: #a78bfa;
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.4);
    --gold: #ffd700;
    --gold-glow: rgba(255, 215, 0, 0.5);
    
    /* ===== ابعاد و اندازه‌ها ===== */
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --radius-full: 9999px;
    --header-height: 68px;
    
    /* ===== افکت‌های ویژه ===== */
    --glow-primary: rgba(79, 140, 255, 0.3);
    --glow-secondary: rgba(139, 92, 246, 0.2);
    --shadow-intense: 0 20px 60px rgba(0, 0, 0, 0.8);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.4);
    --gradient-hero: linear-gradient(135deg, #0a0e1a 0%, #1a2a4a 50%, #0a0e1a 100%);
    --glass-effect: rgba(255, 255, 255, 0.03);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== GAME LIST - PREMIUM ===== */
#games-list {
    padding: 4px 0;
}

.games-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.games-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.games-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
}

.games-filter {
    display: flex;
    gap: 4px;
}

.filter-btn {
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Vazirmatn', sans-serif;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

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

.games-search input {
    width: 100%;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.7rem;
    font-family: 'Vazirmatn', sans-serif;
    outline: none;
}

.games-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--glow-primary);
}

.games-search input::placeholder {
    color: var(--text-muted);
}

.games-list-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 380px;
    overflow-y: auto;
    padding: 2px 0;
}

.game-item {
    display: grid;
    grid-template-columns: 32px 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.game-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateX(-2px);
}

.game-item.active {
    border-color: var(--primary);
    background: var(--surface-hover);
    box-shadow: 0 0 20px var(--glow-primary);
}

.game-number {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    text-align: center;
}

.game-info {
    min-width: 0;
    overflow: hidden;
}

.game-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.game-players {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
}

.player-white { color: var(--text-primary); }
.player-black { color: var(--text-secondary); }
.game-vs { color: var(--text-muted); font-size: 0.6rem; font-weight: 400; }

.game-result {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    flex-shrink: 0;
}

.game-result.white-win {
    background: rgba(255,255,255,0.1);
    color: #a8d8ea;
}
.game-result.black-win {
    background: rgba(0,0,0,0.15);
    color: #d4a574;
}
.game-result.draw {
    background: rgba(255,215,0,0.1);
    color: #ffd700;
}
.game-result.unknown {
    background: var(--surface);
    color: var(--text-muted);
}

.game-meta {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 1px;
    font-family: 'Inter', 'Vazirmatn', sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-status {
    font-size: 0.55rem;
    flex-shrink: 0;
}

.status-analyzed {
    color: #4caf50;
    font-weight: 600;
}

.status-pending {
    color: var(--text-muted);
}

.game-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.game-actions .btn {
    padding: 2px 6px;
    font-size: 0.6rem;
}

.game-actions .btn i {
    font-size: 0.55rem;
}

/* ===== GAME INFO HEADER ===== */
.game-info-header {
    padding: 4px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    white-space: nowrap;
}

.game-info-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.game-info-index {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    background: var(--surface);
    padding: 1px 8px;
    border-radius: var(--radius-full);
}

.game-info-players {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.game-info-players .player-w { color: var(--text-primary); }
.game-info-players .player-b { color: var(--text-secondary); }
.game-info-players .vs { color: var(--text-muted); font-size: 0.6rem; }

.game-info-result {
    font-weight: 700;
    font-size: 0.65rem;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
}

.game-info-result.win-white { color: #a8d8ea; background: rgba(255,255,255,0.05); }
.game-info-result.win-black { color: #d4a574; background: rgba(0,0,0,0.05); }
.game-info-result.draw { color: #ffd700; background: rgba(255,215,0,0.05); }

.game-info-meta {
    color: var(--text-muted);
    font-size: 0.6rem;
    font-family: 'Inter', sans-serif;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-item {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 6px 10px;
    }
    
    .game-number {
        text-align: right;
        font-size: 0.55rem;
    }
    
    .game-title {
        font-size: 0.75rem;
    }
    
    .game-actions {
        justify-content: flex-start;
        margin-top: 4px;
    }
    
    .game-info-header {
        padding: 4px 10px;
        font-size: 0.65rem;
        flex-wrap: wrap;
        white-space: normal;
    }
    
    .game-info-content {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .games-header-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .games-filter {
        justify-content: center;
    }
    
    .game-item {
        padding: 4px 8px;
    }
    
    .game-title {
        font-size: 0.7rem;
    }
    
    .game-actions .btn {
        padding: 1px 5px;
        font-size: 0.55rem;
    }
}

/* Annotation styles for board */
.board-annotation {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 14px;
    font-weight: bold;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    z-index: 10;
}

.board-annotation.best {
    color: #81b64c;
}
.board-annotation.great {
    color: #4caf50;
}
.board-annotation.excellent { color: #8bc34a; }
.board-annotation.good { color: #cddc39; }
.board-annotation.inaccuracy { color: #ff9800; }
.board-annotation.mistake { color: #f44336; }
.board-annotation.blunder { color: #d32f2f; background: rgba(211,47,47,0.9); }
.board-annotation.book { color: #2196f3; }
.board-annotation.checkmate { color: #9c27b0; }

/* Move list styles */
.move-list-item {
    display: flex;
    align-items: center;
    padding: 2px 5px;
    margin: 1px 0;
}

.move-annotation {
    margin-left: 5px;
    font-weight: bold;
}

.move-annotation.brilliant { color: #ffd700; }
.move-annotation.great { color: #4caf50; }
.move-annotation.excellent { color: #8bc34a; }
.move-annotation.good { color: #cddc39; }
.move-annotation.inaccuracy { color: #ff9800; }
.move-annotation.mistake { color: #f44336; }
.move-annotation.blunder { color: #d32f2f; }
.move-annotation.book { color: #2196f3; }
.move-annotation.checkmate { color: #9c27b0; }

/* ============================================
   Mobile Menu
   ============================================ */
.mobile-menu {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    position: absolute;
    top: calc(var(--header-height) + 8px);
    right: 12px;
    left: 12px;
    z-index: 99;
    box-shadow: var(--shadow-intense);
    backdrop-filter: blur(20px);
}

.mobile-menu.open {
    display: flex;
}

.mobile-menu .nav-btn {
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: right;
    width: 100%;
    font-family: inherit;
}

.mobile-menu .nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.mobile-menu .nav-btn i {
    margin-left: 10px;
    width: 20px;
}

/* نمایش همبرگر فقط در موبایل */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger:hover span {
    background: var(--primary-light);
}

/* نمایش همبرگر در موبایل و تبلت */
@media (max-width: 820px) {
    .hamburger {
        display: flex;
    }
    .desktop-menu {
        display: none !important;
    }
}

/* استایل دکمه‌های زبان */
.lang-switcher button {
    padding: 4px 12px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.lang-switcher button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 16px rgba(79, 140, 255, 0.3);
}

.lang-switcher button:hover:not(.active) {
    color: var(--text-primary);
}

/* ============================================================
   🎯 ریست و پایه
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ============================================================
   🌌 پس‌زمینه‌ی کیهانی متحرک
   ============================================================ */
body::before {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: -1;
    background: 
        radial-gradient(42% 38% at 18% 12%, rgba(79, 140, 255, 0.15), transparent 62%),
        radial-gradient(46% 42% at 84% 22%, rgba(139, 92, 246, 0.12), transparent 60%),
        radial-gradient(38% 34% at 68% 78%, rgba(105, 230, 255, 0.10), transparent 60%),
        radial-gradient(30% 30% at 42% 82%, rgba(255, 215, 0, 0.05), transparent 50%);
    animation: cosmic-drift 30s ease-in-out infinite alternate;
}

@keyframes cosmic-drift {
    0% { transform: translate(-2%, -1%) scale(1) rotate(0deg); }
    50% { transform: translate(1%, 2%) scale(1.02) rotate(1deg); }
    100% { transform: translate(2%, -1%) scale(1.05) rotate(-1deg); }
}

/* ستاره‌های درخشان */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
    background-size: 200px 100px;
    opacity: 0.3;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.2; }
    100% { opacity: 0.5; }
}

/* Disable expensive background animations on mobile for performance */
@media (max-width: 640px) {
    body::before {
        animation: none;
    }

    body::after {
        animation: none;
        opacity: 0.15;
    }

    body {
        transition: none;
    }
}

/* ============================================================
   🎯 هدر - تاج سلطنتی
   ============================================================ */
.app-header {
    position: sticky;
    top: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
    padding: 0 24px;
    margin: 10px 14px 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border);
    box-shadow: 
        var(--shadow-intense),
        inset 0 1px 0 rgba(255,255,255,0.05);
    transition: all 0.4s var(--ease-spring);
    position: relative;
    overflow: hidden;
}

/* افکت هاله‌ی دور هدر */
.app-header::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: conic-gradient(
        from var(--angle, 0deg),
        transparent,
        var(--glow-primary),
        transparent,
        var(--glow-secondary),
        transparent
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: rotate-border 8s linear infinite;
    opacity: 0.3;
    transition: opacity 0.4s ease;
}

.app-header:hover::before {
    opacity: 0.8;
}

@keyframes rotate-border {
    0% { --angle: 0deg; }
    100% { --angle: 360deg; }
}

@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.brand {
    font-family: 'Orbitron', 'Vazirmatn', sans-serif;
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #ffffff, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px var(--glow-primary);
    position: relative;
}

.brand i {
    -webkit-text-fill-color: var(--primary-light);
    margin-left: 8px;
    animation: brand-sparkle 2s ease-in-out infinite alternate;
}

@keyframes brand-sparkle {
    0% { filter: drop-shadow(0 0 0px rgba(105, 230, 255, 0)); }
    100% { filter: drop-shadow(0 0 20px rgba(105, 230, 255, 0.5)); }
}

.desktop-menu {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.nav-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    position: relative;
}

.nav-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: all 0.3s var(--ease-spring);
    transform: translateX(-50%);
}

.nav-btn:hover::after {
    width: 80%;
}

.nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.nav-btn i { margin-left: 6px; }

.lang-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface);
}

.lang-switcher button {
    padding: 4px 14px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    letter-spacing: 0.05em;
}

.lang-switcher button:hover {
    color: var(--text-primary);
    transform: scale(1.05);
}

.lang-switcher button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 20px var(--glow-primary);
    transform: scale(1.05);
}

/* ============================================================
   📐 لایه‌بندی اصلی
   ============================================================ */
.layout {
    display: grid;
    grid-template-columns: 1fr minmax(320px, 420px);
    gap: 24px;
    max-width: 1520px;
    margin: 24px auto;
    padding: 0 20px;
}

/* ============================================================
   🪟 کارت‌های شیشه‌ای پریمیوم
   ============================================================ */
.glass {
    background: var(--surface);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    transition: all 0.4s var(--ease-spring);
    position: relative;
    overflow: hidden;
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.glass:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: 
        var(--shadow-intense),
        0 0 40px var(--glow-primary);
}

/* ============================================================
   ♟️ منطقه‌ی برد
   ============================================================ */
.board-zone {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.board-wrap {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

#board {
    flex: 1;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border);
    box-shadow: 
        0 16px 48px rgba(0,0,0,0.6),
        inset 0 0 60px rgba(0,0,0,0.2);
    transition: all 0.4s var(--ease-spring);
}

#board:hover {
    border-color: var(--border-strong);
    box-shadow: 
        0 16px 48px rgba(0,0,0,0.6),
        0 0 60px var(--glow-primary);
}

/* ============================================================
   📊 نوار ارزیابی - سه‌بعدی با نور
   ============================================================ */
.eval-bar {
    position: relative;
    width: 28px;
    border-radius: var(--radius-full);
    background: linear-gradient(180deg, #0a0e1a, #1a2a4a);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.eval-bar-white {
    position: absolute;
    bottom: 0;
    inset-inline: 0;
    height: 50%;
    background: linear-gradient(0deg, var(--primary), var(--primary-light));
    transition: height 0.6s var(--ease-out);
    box-shadow: 
        inset 0 0 20px rgba(79, 140, 255, 0.3),
        0 0 20px rgba(79, 140, 255, 0.2);
}

.eval-indicator {
    position: absolute;
    inset-inline: -4px;
    height: 2px;
    background: rgba(255,255,255,0.8);
    box-shadow: 0 0 20px rgba(255,255,255,0.4);
    transition: top 0.6s var(--ease-out);
    z-index: 2;
}

.eval-indicator::after {
    content: '';
    position: absolute;
    inset-inline: -6px;
    top: -4px;
    height: 10px;
    border-radius: var(--radius-full);
    background: radial-gradient(ellipse, rgba(255,255,255,0.3), transparent);
}

/* ============================================================
   🏷️ اسکور پیل
   ============================================================ */
.score-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 24px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    transition: all 0.3s var(--ease-spring);
}

.score-pill:hover {
    border-color: var(--border-strong);
    transform: scale(1.02);
    box-shadow: 0 0 30px var(--glow-primary);
}

.pill-value {
    font-family: 'Chakra Petch', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   🤖 باکس موتور تحلیل
   ============================================================ */
.engine-box {
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all 0.3s var(--ease-spring);
}

.engine-box:hover {
    border-color: var(--border-strong);
    box-shadow: 0 0 30px var(--glow-primary);
}

.engine-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 20px var(--success-glow);
    transition: all 0.3s ease;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.7); opacity: 0.5; }
}

.dot.busy {
    background: var(--warning);
    animation: pulse-dot-busy 0.8s ease-in-out infinite;
}

@keyframes pulse-dot-busy {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px var(--warning-glow); }
    50% { transform: scale(0.6); box-shadow: 0 0 40px var(--warning-glow); }
}

.engine-version {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 2px 12px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--border);
}

.best-line {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}

.bn {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.b-move {
    font-family: 'Chakra Petch', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--glow-primary);
}

.b-score {
    font-family: 'Chakra Petch', monospace;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, rgba(79, 140, 255, 0.15), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(79, 140, 255, 0.2);
    color: var(--primary-light);
    font-size: 0.9rem;
}

.pv-line {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-label {
    color: var(--text-muted);
    margin-right: 8px;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.pv-moves {
    font-family: 'Chakra Petch', monospace;
    color: var(--primary-light);
}

/* ============================================================
   📝 پیشنهادات حرکت - شاهکار
   ============================================================ */
#move-suggestions {
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.3s var(--ease-spring);
}

#move-suggestions:hover {
    border-color: var(--border-strong);
    box-shadow: 0 0 20px var(--glow-primary);
}

.suggestions-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    border: 1px solid transparent;
    position: relative;
}

.suggestion-item:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    transform: translateX(4px);
}

.suggestion-item.best {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.05);
}

.suggestion-item .suggestion-rank {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 24px;
    text-align: center;
}

.suggestion-item.best .suggestion-rank {
    color: var(--success);
}

.suggestion-item .suggestion-move {
    font-family: 'Chakra Petch', monospace;
    font-weight: 700;
    font-size: 0.95rem;
    flex: 1;
    color: var(--text-primary);
}

.suggestion-item .suggestion-score {
    font-family: 'Chakra Petch', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 2px 12px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--border);
}

/* ============================================================
   🎯 آنوتیشن حرکت روی صفحه
   ============================================================ */
.annotation-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: visible;
}

.move-annotation {
    position: absolute;
    font-weight: 900;
    pointer-events: none;
    z-index: 5;
    font-family: 'Chakra Petch', monospace;
    text-shadow: 
        0 0 20px rgba(0,0,0,0.95),
        0 2px 8px rgba(0,0,0,0.9),
        0 0 40px rgba(0,0,0,0.5);
    opacity: 0;
    transform: scale(0.3) rotate(-10deg);
    transition: all 0.4s var(--ease-spring);
    line-height: 1;
    background: rgba(0,0,0,0.5);
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.05);
    font-size: 0.8rem;
}

.move-annotation.show {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* رنگ‌های پریمیوم برای آنوتیشن */
.move-annotation.brilliant {
    color: #69e6ff;
    text-shadow: 0 0 30px rgba(105, 230, 255, 0.3);
    border-color: rgba(105, 230, 255, 0.2);
    background: rgba(105, 230, 255, 0.1);
}
.move-annotation.best {
    color: #81b64c;
    text-shadow: 0 0 30px rgba(129, 182, 76, 0.3);
    border-color: rgba(129, 182, 76, 0.2);
    background: rgba(129, 182, 76, 0.1);
}
.move-annotation.great {
    color: #a78bfa;
    text-shadow: 0 0 30px rgba(167, 139, 250, 0.3);
    border-color: rgba(167, 139, 250, 0.2);
    background: rgba(167, 139, 250, 0.1);
}
.move-annotation.excellent {
    color: #4f8cff;
    text-shadow: 0 0 30px rgba(79, 140, 255, 0.3);
    border-color: rgba(79, 140, 255, 0.2);
    background: rgba(79, 140, 255, 0.1);
}
.move-annotation.good {
    color: #22c55e;
    text-shadow: 0 0 30px rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.2);
    background: rgba(34, 197, 94, 0.1);
}
.move-annotation.inaccuracy {
    color: #f59e0b;
    text-shadow: 0 0 30px rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.1);
}
.move-annotation.mistake {
    color: #ef4444;
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.1);
}
.move-annotation.blunder {
    color: #dc2626;
    text-shadow: 0 0 30px rgba(220, 38, 38, 0.4);
    border-color: rgba(220, 38, 38, 0.3);
    background: rgba(220, 38, 38, 0.15);
    animation: blunder-pulse 0.8s ease-in-out infinite alternate;
}
.move-annotation.checkmate {
    color: #ffd700;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.15);
    animation: checkmate-glow 0.8s ease-in-out infinite alternate;
}

@keyframes blunder-pulse {
    0% { text-shadow: 0 0 20px rgba(220, 38, 38, 0.3); }
    100% { text-shadow: 0 0 50px rgba(220, 38, 38, 0.7); }
}

@keyframes checkmate-glow {
    0% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.3); transform: scale(1); }
    100% { text-shadow: 0 0 60px rgba(255, 215, 0, 0.8); transform: scale(1.05); }
}

/* ============================================================
   🎮 کنترل‌ها - سه‌بعدی با انیمیشن
   ============================================================ */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px 16px;
}

.ctl {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid var(--border);
}

.ctl::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    padding: 2px;
    background: conic-gradient(
        from var(--angle, 0deg),
        transparent,
        var(--primary),
        transparent
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: rotate-border 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ctl:hover::before {
    opacity: 1;
}

.ctl:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 8px 32px rgba(0,0,0,0.4),
        0 0 30px var(--glow-primary);
    border-color: var(--border-strong);
}

.ctl:active {
    transform: scale(0.9);
}

.ctl.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 24px var(--glow-primary);
    border-color: transparent;
}

/* ============================================================
   📊 عمق تحلیل
   ============================================================ */
.depth-box {
    padding: 12px 20px;
}

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

.depth-header label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.depth-presets {
    display: flex;
    gap: 4px;
}

.depth-preset {
    padding: 2px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
}

.depth-preset:hover {
    background: var(--surface-hover);
    color: var(--text-secondary);
    transform: scale(1.05);
}

.depth-preset.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px var(--glow-primary);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--border);
    -webkit-appearance: none;
    outline: none;
    transition: all 0.3s ease;
}

input[type="range"]:hover {
    border-color: var(--border-strong);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    cursor: pointer;
    box-shadow: 0 2px 16px var(--glow-primary);
    transition: all 0.3s var(--ease-spring);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 24px var(--glow-primary);
}

.depth-values {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.depth-values #depth-text {
    font-family: 'Chakra Petch', monospace;
    font-weight: 700;
    color: var(--primary-light);
    font-size: 1rem;
}

/* ============================================================
   📜 تاریخچه حرکت
   ============================================================ */
.moves-box {
    padding: 12px 16px;
}

.moves-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.moves-head span:first-child {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
}

.moves {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
    scroll-behavior: smooth;
}

.moves::-webkit-scrollbar {
    width: 4px;
}

.move-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    position: relative;
}

.move-chip:hover {
    background: var(--surface-hover);
    transform: translateY(-2px) scale(1.02);
    border-color: var(--border-strong);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.move-chip.active {
    background: linear-gradient(135deg, rgba(79, 140, 255, 0.2), rgba(105, 230, 255, 0.1));
    border-color: var(--primary-light);
    box-shadow: 0 0 24px var(--glow-primary);
    transform: scale(1.03);
}

.move-chip .num {
    font-size: 0.55rem;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 18px;
}

.move-chip .san {
    font-family: 'Chakra Petch', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.move-chip .sym {
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
}

.sym.book { color: var(--success); }
.sym.brilliant { color: #26c2a3; }
.sym.great { color: #7fa650; }
.sym.excellent { color: var(--primary-light); }
.sym.good { color: var(--success); }
.sym.best { color: #81b64c; }
.sym.miss { color: #f59e0b; }
.sym.inaccuracy { color: #f3ad61; }
.sym.mistake { color: #ef7b4b; }
.sym.blunder { color: #dc2626; }
.sym.checkmate { color: #ffd700; }

/* ============================================================
   📊 آمار
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
}

.stat-item {
    text-align: center;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.3s var(--ease-spring);
}

.stat-item:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.stat-item .label {
    display: block;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
}

.stat-item .value {
    display: block;
    font-family: 'Chakra Petch', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 4px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   📋 دکمه‌های PGN
   ============================================================ */
.pgn-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
}

.btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px var(--glow-primary);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--glow-primary);
}

/* ============================================================
   🪟 مودال
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: modal-fade 0.3s ease;
}

@keyframes modal-fade {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.modal[hidden] {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 540px;
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-intense);
    animation: modal-slide 0.4s var(--ease-spring);
}

@keyframes modal-slide {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: rotate(90deg) scale(1.1);
}

.pgn-input {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: 'Chakra Petch', monospace;
    font-size: 0.85rem;
    resize: vertical;
    transition: all 0.3s ease;
}

.pgn-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 24px var(--glow-primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   🍞 توست
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    padding: 14px 28px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: var(--shadow-intense);
    font-size: 0.9rem;
    font-weight: 600;
    animation: toast-in 0.4s var(--ease-spring);
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast::before {
    content: '✨';
    font-size: 1.2rem;
}

.toast[hidden] {
    display: none;
}

@keyframes toast-in {
    0% { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.9); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ============================================================
   🔄 حالت تحلیل
   ============================================================ */
.analyzing {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 28px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: var(--shadow-intense);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-light);
    animation: toast-in 0.4s var(--ease-spring);
}

.analyzing[hidden] {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   ⏳ لودر اولیه
   ============================================================ */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    background: var(--bg-primary);
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader .loader-piece {
    font-size: 48px;
    animation: loader-bounce 1s ease-in-out infinite;
    display: inline-block;
    filter: drop-shadow(0 0 30px var(--glow-primary));
}

.preloader .loader-piece:nth-child(1) { animation-delay: 0s; }
.preloader .loader-piece:nth-child(2) { animation-delay: 0.1s; }
.preloader .loader-piece:nth-child(3) { animation-delay: 0.2s; }
.preloader .loader-piece:nth-child(4) { animation-delay: 0.3s; }
.preloader .loader-piece:nth-child(5) { animation-delay: 0.4s; }
.preloader .loader-piece:nth-child(6) { animation-delay: 0.5s; }

@keyframes loader-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-24px) scale(1.1); }
}

.preloader .loader-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    animation: loader-text-pulse 1.5s ease-in-out infinite;
}

@keyframes loader-text-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.preloader .loader-progress {
    width: 200px;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
    margin-top: 10px;
}

.preloader .loader-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--secondary-light));
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 20px var(--glow-primary);
}

/* ============================================================
   📱 اسکرول‌بار سفارشی
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
    box-shadow: 0 0 20px var(--glow-primary);
}

/* ============================================================
   📱 واکنش‌گرایی
   ============================================================ */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
        max-width: 720px;
    }
    
    .desktop-menu {
        display: none;
    }
    
    .hamburger {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        background: transparent;
        border: none;
        cursor: pointer;
        margin-left: auto;
    }
    
    .hamburger span {
        display: block;
        width: 24px;
        height: 2px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: all 0.3s var(--ease-spring);
    }
    
    .hamburger:hover span {
        background: var(--primary-light);
    }
}

@media (max-width: 768px) {
    .layout {
        padding: 0 12px;
        margin: 16px auto;
    }
    
    .app-header {
        padding: 0 16px;
        margin: 8px 8px 0;
        height: 60px;
    }
    
    .brand {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pgn-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls {
        gap: 6px;
        padding: 8px 12px;
    }
    
    .ctl {
        width: 42px;
        height: 42px;
        font-size: 0.95rem;
    }
    
    .eval-bar {
        width: 22px;
    }
    
    .modal-card {
        padding: 20px;
        margin: 12px;
    }
}

@media (max-width: 480px) {
    .layout {
        padding: 0 8px;
        gap: 16px;
    }
    
    .app-header {
        padding: 0 12px;
        margin: 6px 6px 0;
        height: 54px;
        border-radius: var(--radius-md);
    }
    
    .brand {
        font-size: 0.85rem;
    }
    
    .brand i {
        font-size: 0.9rem;
    }
    
    .score-pill {
        padding: 6px 16px;
        font-size: 0.85rem;
    }
    
    .ctl {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    
    .moves {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        max-height: 160px;
    }
    
    .move-chip {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 8px 12px;
    }
    
    .stat-item .value {
        font-size: 1rem;
    }
    
    .pgn-actions {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px 12px;
    }
    
    .btn {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
    
    .engine-box {
        padding: 12px 16px;
    }
    
    .best-line {
        grid-template-columns: 1fr;
        gap: 6px;
        text-align: center;
    }
    
    .b-move {
        font-size: 1.2rem;
    }
    
    .depth-preset {
        font-size: 0.6rem;
        padding: 2px 10px;
    }
}
/* ============================================================
   Saved games list + report modal
   ============================================================ */
#games-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.saved-game {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.saved-game:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.saved-game .sg-name {
    flex: 1;
    font-family: 'Chakra Petch', monospace;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-game .sg-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.saved-game .sg-del:hover {
    color: #ef4444;
}

.report-content {
    max-height: 380px;
    overflow-y: auto;
    padding: 14px;
    margin: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: 'Chakra Petch', monospace;
    font-size: 0.8rem;
    line-height: 1.7;
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
}

/* ============================================================
   📊 ChessReviewEngine - گزارش تحلیل (Review Report)
   ============================================================ */
.report-modal-card {
    max-width: 860px;
    width: 94vw;
}

.review-report {
    white-space: normal;
    direction: ltr;
    text-align: left;
    font-family: 'Chakra Petch', 'Vazirmatn', monospace;
    max-height: 70vh;
    overflow-y: auto;
}

.rv-headers {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 4px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.rv-event {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.rv-result {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-light);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 4px 14px;
    border-radius: var(--radius-full);
}

.rv-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.rv-player {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.rv-player-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.rv-acc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.acc-bar {
    flex: 1;
    height: 10px;
    border-radius: 6px;
    background: var(--border);
    overflow: hidden;
}

.acc-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.acc-value {
    font-family: 'Chakra Petch', monospace;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 58px;
    font-size: 0.95rem;
}

.rv-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.chip-brilliant { color: #26c2a3; border-color: rgba(38, 194, 163, 0.4); }
.chip-best { color: #81b64c; border-color: rgba(129, 182, 76, 0.4); }
.chip-excellent { color: var(--primary-light); border-color: rgba(79, 140, 255, 0.4); }
.chip-great { color: #7fa650; border-color: rgba(127, 166, 80, 0.4); }
.chip-good { color: var(--success); border-color: rgba(34, 197, 94, 0.4); }
.chip-inaccuracy { color: #f3ad61; border-color: rgba(243, 173, 97, 0.4); }
.chip-mistake { color: #ef7b4b; border-color: rgba(239, 123, 75, 0.4); }
.chip-blunder { color: #ef4444; border-color: rgba(239, 68, 68, 0.4); }

.rv-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.rv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.rv-table thead th {
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.rv-table tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.rv-table tbody tr:hover {
    background: var(--surface);
}

.rv-num { color: var(--text-muted); }
.rv-san { font-family: 'Chakra Petch', monospace; font-weight: 700; color: var(--text-primary); }

.rv-cls {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.rv-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Classification colors (chess.com style) */
.rv-theory .rv-dot { background: #ababa8; }
.rv-theory { color: #ababa8; }
.rv-brilliant .rv-dot { background: #26c2a3; }
.rv-brilliant { color: #26c2a3; }
.rv-best .rv-dot { background: #81b64c; }
.rv-best { color: #81b64c; }
.rv-excellent .rv-dot { background: var(--primary-light); }
.rv-excellent { color: var(--primary-light); }
.rv-great .rv-dot { background: #7fa650; }
.rv-great { color: #7fa650; }
.rv-good .rv-dot { background: var(--success); }
.rv-good { color: var(--success); }
.rv-inaccuracy .rv-dot { background: #f3ad61; }
.rv-inaccuracy { color: #f3ad61; }
.rv-mistake .rv-dot { background: #ef7b4b; }
.rv-mistake { color: #ef7b4b; }
.rv-blunder .rv-dot { background: #ef4444; }
.rv-blunder { color: #ef4444; }

.rv-acc, .rv-diff { font-family: 'Chakra Petch', monospace; }
.rv-best { color: var(--primary-light); font-family: 'Chakra Petch', monospace; }

.rv-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Progress bar inside the analyzing overlay */
.analyzing-progress {
    width: 140px;
    height: 4px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
    flex-shrink: 0;
}

.analyzing-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.5s ease;
}

@media (max-width: 640px) {
    .rv-players { grid-template-columns: 1fr; }
    .rv-headers { flex-direction: column; align-items: flex-start; }
    .report-modal-card { width: 96vw; }
}
