:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #334155;
    --secondary-hover: #475569;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-red: #ef4444;
    --accent-green: #22c55e;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #1e3a8a 0%, transparent 40%),
                      radial-gradient(circle at bottom left, #312e81 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

#app {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
}

.board-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: block;
    width: 100%;
}

/* Make chessground responsive */
.cg-board-wrap {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
    height: auto !important;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-header {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.panel-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.glass h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glass h3::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
}

.highlight-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.sub-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.radio-label:hover {
    background: rgba(255, 255, 255, 0.1);
}

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.radio-label input[type="radio"] {
    margin-top: 0.25rem;
    accent-color: var(--primary);
}

.radio-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.radio-text strong {
    font-weight: 600;
    color: #e2e8f0;
}

.radio-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.button-group {
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background-color: var(--primary);
    color: white;
}

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

.btn.secondary {
    background-color: var(--secondary);
    color: white;
}

.btn.secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
}

#analysis-log {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#analysis-log::-webkit-scrollbar {
    width: 6px;
}
#analysis-log::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 3px;
}

.log-item {
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--primary);
}

.log-item.empty {
    border-left: none;
    background: transparent;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.log-item.mistake {
    border-left-color: var(--accent-red);
}

.log-item.blunder {
    border-left-color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

.log-item strong {
    color: #fff;
}

/* Board Tools */
.board-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}
.btn-flip {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.btn-flip:hover {
    background: rgba(255,255,255,0.2);
}

/* DB Viewer */
.db-viewer {
    margin-top: 1rem;
    width: 100%;
}
.db-viewer table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.db-viewer th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-weight: 600;
}
.db-viewer td {
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.db-viewer tr:hover {
    background: rgba(255,255,255,0.05);
}
.db-bar-container {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
    min-width: 150px;
    background: #333;
}
.db-bar-white { background: #e0e0e0; }
.db-bar-draws { background: #888; }
.db-bar-black { background: #444; }
.db-empty { text-align: center; color: var(--text-muted); padding: 1rem; }
