/* ═══════════════════════════════════════════════════════════
   Chess Move Analyzer — Space Command Design System
   Deep-void aesthetic with glassmorphism + HUD overlays
   ═══════════════════════════════════════════════════════════ */

/* Fonts loaded via <link> in HTML — no @import needed */

/* Reset handled by compat.css — minimal override here */

/* --- Design Tokens --- */
:root {
    /* Surface */
    --void: #00000c;
    --bg-panel: rgba(0, 212, 255, 0.015);
    --bg-panel-hover: rgba(0, 212, 255, 0.035);
    --border-panel: rgba(0, 212, 255, 0.09);
    --border-panel-hover: rgba(0, 212, 255, 0.2);

    /* Board */
    --sq-light: #e8dcc8;
    --sq-dark: #8b6f47;
    --sq-selected: rgba(255, 215, 0, 0.55);
    --sq-legal: rgba(100, 200, 120, 0.45);
    --sq-last-from: rgba(170, 140, 255, 0.35);
    --sq-last-to: rgba(170, 140, 255, 0.50);
    --sq-best-from: rgba(0, 212, 255, 0.40);
    --sq-best-to: rgba(0, 212, 255, 0.60);
    --sq-check: rgba(255, 60, 60, 0.55);

    /* Accent */
    --cyan: #00d4ff;
    --purple: #9333ea;
    --magenta: #ff2d78;
    --green: #00e676;
    --red: #ff5252;
    --cyan-glow: rgba(0, 212, 255, 0.3);
    --purple-glow: rgba(147, 51, 234, 0.3);

    /* Text */
    --text-primary: #dde4ef;
    --text-secondary: #7a8ba4;
    --text-muted: #4a5e78;
    --text-heading: #eef2ff;

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'Share Tech Mono', 'Courier New', monospace;

    /* Sizes */
    --sq-size: min(10vw, 72px);
    --board-size: calc(var(--sq-size) * 8);
    --radius: 6px;
    --radius-sm: 4px;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.15);
    border-radius: 3px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.3);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.15) rgba(0, 0, 0, 0.3);
}

/* --- Focus States --- */
:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.5), 0 0 12px rgba(0, 212, 255, 0.2);
}

/* --- Base --- */
html {
    font-size: 15px;
}

body {
    font-family: var(--font-body);
    background: var(--void);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════
   SPACE BACKGROUND LAYERS
   ═══════════════════════════════════════════════════════════ */

/* Starfield canvas */
#starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* Aurora gradient */
.aurora {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 450px;
    background: linear-gradient(180deg,
            rgba(0, 212, 255, 0.06) 0%,
            rgba(147, 51, 234, 0.04) 40%,
            transparent 100%);
    pointer-events: none;
    z-index: 1;
}

/* Nebula blobs */
.nebula {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 1;
}

.nebula-1 {
    width: 500px;
    height: 500px;
    top: -150px;
    left: -100px;
    background: radial-gradient(circle, rgba(147, 51, 234, 0.12), transparent 70%);
    animation: nebulaDrift 20s ease-in-out infinite;
}

.nebula-2 {
    width: 400px;
    height: 400px;
    bottom: -100px;
    right: -80px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.08), transparent 70%);
    animation: nebulaDrift 25s ease-in-out infinite reverse;
}

.nebula-3 {
    width: 350px;
    height: 350px;
    top: 40%;
    right: 15%;
    background: radial-gradient(circle, rgba(147, 51, 234, 0.06), transparent 70%);
    animation: nebulaDrift 30s ease-in-out infinite;
}

@keyframes nebulaDrift {
    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -20px);
    }
}

/* Grid overlay */
.grid-overlay {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.015) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* Scanlines overlay */
.scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 3px,
            rgba(0, 0, 0, 0.04) 3px,
            rgba(0, 0, 0, 0.04) 4px);
    pointer-events: none;
    z-index: 100;
}

/* Top accent bar — cyan to purple gradient */
.top-bar,
.top-accent-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
    z-index: 101;
}

/* Floating particles */
.particle,
.space-particle {
    position: fixed;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: floatUp linear infinite;
    z-index: 0;
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(100vh);
    }

    10% {
        opacity: 0.5;
    }

    90% {
        opacity: 0.5;
    }

    100% {
        opacity: 0;
        transform: translateY(-10vh);
    }
}

/* ═══════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════ */

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--void);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-orb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
    animation: logoPulse 2s ease-in-out infinite, spin 3s linear infinite;
}

.loading-text {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   NAVIGATION BAR
   ═══════════════════════════════════════════════════════════ */

#app-nav {
    position: fixed;
    top: 2px;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(0, 0, 12, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 212, 255, 0.06);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
}

#app-nav .nav-brand {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-heading);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

#app-nav .nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
    list-style: none;
}

#app-nav .nav-links a {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s, text-shadow 0.2s;
    padding: 6px 8px;
}

#app-nav .nav-links a:hover {
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════ */

#app-header {
    text-align: center;
    padding: 28px 20px 10px;
    position: relative;
    z-index: 10;
    animation: cardIn 0.8s ease-out;
}

#app-header h1 {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 4vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: logoPulse 4s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.15));
}

.subtitle {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.6rem;
    margin-top: 6px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════════════════════ */

#app-main {
    display: flex;
    gap: 28px;
    padding: 18px 20px 40px;
    max-width: 1100px;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

/* ═══════════════════════════════════════════════════════════
   BOARD SECTION
   ═══════════════════════════════════════════════════════════ */

#board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: cardIn 0.8s ease-out 0.1s both;
}

.file-labels {
    display: flex;
    width: var(--board-size);
    justify-content: space-around;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 2px;
    padding: 0 2px;
    user-select: none;
}

#board-wrapper {
    display: flex;
    align-items: stretch;
    gap: 4px;
    position: relative;
}

/* HUD corner brackets on board wrapper */
#board-wrapper::before,
#board-wrapper::after {
    content: '';
    position: absolute;
    pointer-events: none;
    z-index: 2;
}

.hud-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 2;
    pointer-events: none;
}

.hud-corner::before,
.hud-corner::after {
    content: '';
    position: absolute;
    background: var(--cyan);
    opacity: 0.3;
    transition: opacity 0.3s;
}

#board-wrapper:hover .hud-corner::before,
#board-wrapper:hover .hud-corner::after {
    opacity: 0.6;
}

.hud-tl {
    top: -4px;
    left: 18px;
}

.hud-tl::before {
    top: 0;
    left: 0;
    width: 16px;
    height: 1px;
}

.hud-tl::after {
    top: 0;
    left: 0;
    width: 1px;
    height: 16px;
}

.hud-tr {
    top: -4px;
    right: -4px;
}

.hud-tr::before {
    top: 0;
    right: 0;
    width: 16px;
    height: 1px;
}

.hud-tr::after {
    top: 0;
    right: 0;
    width: 1px;
    height: 16px;
}

.hud-bl {
    bottom: -4px;
    left: 18px;
}

.hud-bl::before {
    bottom: 0;
    left: 0;
    width: 16px;
    height: 1px;
}

.hud-bl::after {
    bottom: 0;
    left: 0;
    width: 1px;
    height: 16px;
}

.hud-br {
    bottom: -4px;
    right: -4px;
}

.hud-br::before {
    bottom: 0;
    right: 0;
    width: 16px;
    height: 1px;
}

.hud-br::after {
    bottom: 0;
    right: 0;
    width: 1px;
    height: 16px;
}

.rank-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 400;
    user-select: none;
    padding: 2px 4px 2px 0;
}

/* Chessboard */
#chessboard {
    display: grid;
    grid-template-columns: repeat(8, var(--sq-size));
    grid-template-rows: repeat(8, var(--sq-size));
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow:
        0 0 40px rgba(0, 212, 255, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 212, 255, 0.08);
    transition: box-shadow 0.4s ease;
}

#chessboard:hover {
    box-shadow:
        0 0 60px rgba(0, 212, 255, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 212, 255, 0.15);
}

/* Square base */
.square {
    width: var(--sq-size);
    height: var(--sq-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--sq-size) * 0.72);
    cursor: pointer;
    position: relative;
    transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
    user-select: none;
    -webkit-user-select: none;
}

.square.light {
    background: var(--sq-light);
}

.square.dark {
    background: var(--sq-dark);
}

/* Piece styling */
.square .piece {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.12s ease, filter 0.2s ease;
    pointer-events: none;
    line-height: 1;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.square:hover .piece {
    transform: scale(1.08) translateY(-1px);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25))
        drop-shadow(0 0 8px rgba(0, 212, 255, 0.3));
}

/* Highlight layers */
.square.selected {
    box-shadow: inset 0 0 0 3px rgba(255, 215, 0, 0.8);
    background: var(--sq-selected) !important;
}

.square.legal-target::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: var(--sq-legal);
    pointer-events: none;
}

.square.legal-capture::after {
    content: '';
    position: absolute;
    width: 88%;
    height: 88%;
    border-radius: 50%;
    border: 4px solid var(--sq-legal);
    background: none;
    pointer-events: none;
}

.square.last-from {
    background: var(--sq-last-from) !important;
}

.square.last-to {
    background: var(--sq-last-to) !important;
}

.square.best-from {
    background: var(--sq-best-from) !important;
    animation: bestPulse 1.2s ease-in-out infinite;
}

.square.best-to {
    background: var(--sq-best-to) !important;
    animation: bestPulse 1.2s ease-in-out infinite 0.15s;
}

.square.in-check {
    box-shadow: inset 0 0 0 3px var(--red), inset 0 0 18px rgba(255, 60, 60, 0.3);
}

/* Keyboard navigation focus */
.square.keyboard-focus {
    box-shadow: inset 0 0 0 2px var(--cyan), 0 0 12px rgba(0, 212, 255, 0.3);
    z-index: 2;
}

/* Touch feedback */
.square.touch-active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

@keyframes bestPulse {
    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.25);
    }
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */

#sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 260px;
    min-width: 220px;
    position: relative;
    z-index: 10;
}

/* ═══════════════════════════════════════════════════════════
   PANELS — Glassmorphism with space theme
   ═══════════════════════════════════════════════════════════ */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
    animation: cardIn 0.8s ease-out both;
}

/* Staggered entrance for panels */
#status-panel {
    animation-delay: 0.2s;
}

#controls-panel {
    animation-delay: 0.3s;
}

#history-panel {
    animation-delay: 0.4s;
}

#best-move-panel {
    animation-delay: 0.5s;
}

/* Top border gradient on panels */
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.panel:hover {
    background: var(--bg-panel-hover);
    border-color: var(--border-panel-hover);
    box-shadow:
        0 0 30px rgba(0, 212, 255, 0.06),
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(0, 212, 255, 0.02);
}

.panel:hover::before {
    opacity: 1;
}

.panel-header {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cyan);
    margin-bottom: 12px;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.15);
}

/* ═══════════════════════════════════════════════════════════
   TURN INDICATOR with blinking status dot
   ═══════════════════════════════════════════════════════════ */

#turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

#turn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
    transition: background 0.3s, box-shadow 0.3s;
    position: relative;
    animation: blink 2.5s ease-in-out infinite;
}

#turn-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: pulseRing 2.5s ease-in-out infinite;
}

#turn-dot.black {
    background: #333;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

#turn-dot.black::after {
    border-color: rgba(255, 255, 255, 0.1);
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

@keyframes pulseRing {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.8);
        opacity: 0;
    }
}

#turn-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════
   EVAL BAR — Cyan to Purple gradient fill
   ═══════════════════════════════════════════════════════════ */

#eval-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

#eval-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

#eval-fill {
    height: 100%;
    width: 50%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    transition: width 0.5s ease;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

#eval-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--cyan);
    min-width: 38px;
    text-align: right;
    letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.12s, box-shadow 0.3s, border-color 0.2s;
    min-height: 44px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    color: #fff;
    box-shadow: 0 4px 18px rgba(0, 212, 255, 0.2);
    border: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3), 0 4px 24px rgba(147, 51, 234, 0.25);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(0, 212, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(0, 212, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.08);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    filter: grayscale(0.3);
}

.btn-icon {
    font-size: 1rem;
}

#controls-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Depth control */
#depth-control {
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

#depth-control label {
    display: block;
    margin-bottom: 6px;
    font-weight: 400;
}

#depth-slider {
    width: 100%;
    accent-color: var(--cyan);
    height: 4px;
    cursor: pointer;
}

#depth-value {
    color: var(--cyan);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   GAME MODE TOGGLE
   ═══════════════════════════════════════════════════════════ */

.game-mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.game-mode-toggle label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.3s, background 0.3s, box-shadow 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--cyan);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.5);
}

/* ═══════════════════════════════════════════════════════════
   SOUND BUTTON
   ═══════════════════════════════════════════════════════════ */

.btn-sound {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.12);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sound:hover {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.25);
    color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.1);
}

.btn-sound.muted {
    color: var(--red);
    border-color: rgba(255, 82, 82, 0.15);
}

/* ═══════════════════════════════════════════════════════════
   MOVE HISTORY
   ═══════════════════════════════════════════════════════════ */

#move-list {
    max-height: 200px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

#move-list::-webkit-scrollbar {
    width: 4px;
}

#move-list::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.12);
    border-radius: 2px;
}

.move-row {
    display: flex;
    gap: 6px;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.move-row:nth-child(odd) {
    background: rgba(0, 212, 255, 0.015);
}

.move-row:hover {
    background: rgba(0, 212, 255, 0.06);
}

.move-num {
    color: var(--text-muted);
    min-width: 24px;
    font-size: 0.65rem;
}

.move-white,
.move-black {
    min-width: 55px;
    font-weight: 400;
    color: var(--text-primary);
    cursor: default;
    transition: color 0.15s;
}

.move-white:hover,
.move-black:hover {
    color: var(--cyan);
}

/* ═══════════════════════════════════════════════════════════
   BEST MOVE DISPLAY
   ═══════════════════════════════════════════════════════════ */

#best-move-display {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 1px;
}

#best-move-display .arrow {
    color: var(--cyan);
    font-size: 1.3rem;
    animation: logoPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.4));
}

/* Thinking spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 212, 255, 0.1);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ═══════════════════════════════════════════════════════════
   PROMOTION DIALOG OVERLAY
   ═══════════════════════════════════════════════════════════ */

#promotion-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 12, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cardIn 0.3s ease-out;
}

#promotion-overlay .promotion-dialog {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 0 60px rgba(0, 212, 255, 0.1), 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

#promotion-overlay .promotion-dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), var(--purple), transparent);
}

#promotion-overlay .promotion-title {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cyan);
    margin-bottom: 16px;
}

#promotion-overlay .promotion-pieces {
    display: flex;
    gap: 8px;
    justify-content: center;
}

#promotion-overlay .promotion-piece {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.12);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

#promotion-overlay .promotion-piece:hover {
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--cyan);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */

#app-footer {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1100px;
    padding: 20px 24px;
    margin-top: auto;
    border-top: 1px solid rgba(0, 212, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

#app-footer .footer-text {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

#app-footer .footer-stat {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

#app-footer .footer-stat span {
    color: var(--cyan);
}

/* ═══════════════════════════════════════════════════════════
   SECTION DIVIDER (reusable)
   ═══════════════════════════════════════════════════════════ */

.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
}

.divider-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.5);
}

.divider-label {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.15), transparent);
}

/* ═══════════════════════════════════════════════════════════
   SIGNAL BARS (decoration)
   ═══════════════════════════════════════════════════════════ */

.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}

.signal-bar {
    width: 3px;
    background: var(--cyan);
    border-radius: 1px;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.signal-bar:nth-child(1) {
    height: 4px;
    opacity: 0.8;
}

.signal-bar:nth-child(2) {
    height: 7px;
    opacity: 0.6;
}

.signal-bar:nth-child(3) {
    height: 11px;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoPulse {
    0%,
    100% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 30px rgba(0, 212, 255, 0.35);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════════════════════
   STATUS DOT (for reusable status indicators)
   ═══════════════════════════════════════════════════════════ */

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.6);
    animation: blink 2.5s ease-in-out infinite;
    position: relative;
    flex-shrink: 0;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.3);
    animation: pulseRing 2.5s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 6px rgba(255, 82, 82, 0.6);
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   LOGO ORB (chess-themed)
   ═══════════════════════════════════════════════════════════ */

.logo-orb {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    animation: logoPulse 4s ease-in-out infinite;
    flex-shrink: 0;
    font-size: 1.2rem;
}

/* ═══════════════════════════════════════════════════════════
   UPTIME / PROGRESS BAR (reusable)
   ═══════════════════════════════════════════════════════════ */

.progress-bar {
    width: 60px;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════
   STAT LABELS (mono style)
   ═══════════════════════════════════════════════════════════ */

.stat {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    color: var(--cyan);
}

/* ═══════════════════════════════════════════════════════════
   DETAIL ROWS (mono labels + body values)
   ═══════════════════════════════════════════════════════════ */

.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-label {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 44px;
}

.detail-value {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.detail-value a {
    color: var(--cyan);
    text-decoration: none;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
    transition: all 0.2s;
}

.detail-value a:hover {
    color: #fff;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
}

/* ═══════════════════════════════════════════════════════════
   TOOLTIPS
   ═══════════════════════════════════════════════════════════ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 1px;
    padding: 4px 8px;
    background: rgba(0, 0, 12, 0.9);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 3px;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE: Small Desktops (max-width 1024px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    :root {
        --sq-size: min(9vw, 68px);
    }

    #app-main {
        gap: 20px;
        padding: 14px 16px 32px;
    }

    #sidebar {
        width: 240px;
        min-width: 200px;
    }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE: Tablets / Large Phones (max-width 780px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 780px) {
    :root {
        --sq-size: min(calc((100vw - 60px) / 8), 72px);
    }

    #app-main {
        flex-direction: column;
        align-items: center;
        padding: 12px 16px 32px;
    }

    #sidebar {
        width: 100%;
        max-width: 420px;
    }

    #app-header {
        padding: 20px 16px 8px;
    }

    #app-header h1 {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .subtitle {
        font-size: 0.5rem;
    }

    #app-nav {
        height: 42px;
        padding: 0 16px;
    }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE: Extra Small Phones (max-width 480px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    :root {
        --sq-size: min(calc((100vw - 40px) / 8), 72px);
    }

    html {
        font-size: 14px;
    }

    #app-main {
        gap: 12px;
        padding: 8px 10px 24px;
    }

    #app-header {
        padding: 16px 12px 6px;
    }

    #app-header h1 {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .subtitle {
        font-size: 0.45rem;
        letter-spacing: 2px;
    }

    .panel {
        padding: 12px;
    }

    .panel-header {
        font-size: 0.55rem;
        letter-spacing: 1.5px;
        margin-bottom: 8px;
    }

    #sidebar {
        gap: 10px;
        max-width: 100%;
    }

    .btn {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-height: 44px;
    }

    #move-list {
        max-height: 150px;
        font-size: 0.65rem;
    }

    #app-nav {
        height: 38px;
        padding: 0 12px;
    }

    #app-nav .nav-brand {
        font-size: 0.6rem;
        letter-spacing: 2px;
    }

    #app-footer {
        padding: 14px 12px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .rank-labels {
        font-size: 0.5rem;
        padding: 2px 2px 2px 0;
    }

    .file-labels {
        font-size: 0.5rem;
    }

    /* Ensure all interactive elements are at least 44px for touch */
    .square {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SELECTION & HIGHLIGHT COLORS
   ═══════════════════════════════════════════════════════════ */

::selection {
    background: rgba(0, 212, 255, 0.25);
    color: #fff;
}

::-moz-selection {
    background: rgba(0, 212, 255, 0.25);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════ */

@media print {
    .aurora,
    .nebula,
    .grid-overlay,
    .scanlines,
    .top-bar,
    .top-accent-bar,
    .particle,
    .space-particle,
    #starfield,
    #loading-screen,
    #app-nav,
    .space-nav {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .panel {
        background: #fff;
        border: 1px solid #ddd;
        backdrop-filter: none;
    }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .particle,
.space-particle {
        display: none;
    }
}
