:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --success: #10b981;
    --error: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Background Blobs */
.background-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.4;
    animation: float 10s infinite alternate ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: #0ea5e9;
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(255,255,255,0.3);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    overflow: hidden;
    max-width: 100%;
}

.upload-section {
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-section:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.upload-section.dragover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease;
}

.upload-section:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.upload-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.image-preview {
    margin-top: 1.5rem;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 24px;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: #fca5a5;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-top: 2rem;
    text-align: center;
    font-weight: 500;
}

.result-section {
    margin-top: 2rem;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.result-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.result-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.result-item.full-width {
    grid-column: 1 / -1;
    min-width: 0;
}

.result-item.focus-item {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.value {
    font-size: 1.25rem;
    font-weight: 500;
}

.value.highlight {
    color: var(--accent-hover);
    font-weight: 700;
}

.value.best-move {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    letter-spacing: 2px;
}

.fen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.fen-header .label {
    margin-bottom: 0;
}

.fen-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fen-container code {
    display: block;
    font-family: monospace;
    font-size: 0.92rem;
    color: #cbd5e1;
    white-space: nowrap;
    min-width: 0;
}

.fen-container::-webkit-scrollbar {
    height: 6px;
}

.fen-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.fen-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.fen-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.copy-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    .glass-panel {
        padding: 1.25rem;
    }

    .result-item {
        padding: 1rem;
    }

    .result-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .value.best-move {
        font-size: 2rem;
    }

    .fen-header {
        margin-bottom: 0.5rem;
    }

    .fen-container {
        padding: 0.75rem;
    }

    .copy-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}
