:root {
    --bg-main: #121212;
    --bg-panel: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --accent: #4caf50;
    --border: #333333;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    background-image: url('bg-theme.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: 20px auto;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    margin: 0;
    font-weight: 600;
    font-size: 2.5rem;
    background: linear-gradient(90deg, #fff, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-secondary);
    margin-top: 5px;
}

.main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.board-wrapper {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.analysis-panel {
    background: var(--bg-panel);
    padding: 25px;
    border-radius: 10px;
    min-width: 300px;
    flex: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-box h3 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.highlight {
    color: var(--accent);
}

.eval-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.eval-bar {
    height: 10px;
    width: 100%;
    background-color: #333;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.eval-fill {
    height: 100%;
    background-color: var(--text-primary);
    transition: width 0.5s ease-in-out;
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn {
    flex: 1;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    background: #3a3a3a;
    border-color: #555;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(4px, 2vw, 8px);
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-primary);
    box-sizing: border-box;
    flex: 1;
}

.icon-btn .material-icons {
    font-size: clamp(18px, 4.5vw, 24px);
}

.board-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: clamp(4px, 1.5vw, 8px);
    margin-top: 10px;
    width: 100%;
    background-color: var(--bg-panel);
    padding: clamp(6px, 2vw, 10px);
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    box-sizing: border-box;
}

.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    margin-top: 10px;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.pgn-display {
    font-size: 0.9rem;
    color: var(--text-primary);
    background-color: #262421; /* Lichess dark background */
    border-radius: 5px;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#pgn-grid {
    overflow-y: auto;
    max-height: 200px;
    width: 100%;
}

.pgn-row {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    align-items: center;
}

.pgn-row:nth-child(even) {
    background-color: #2a2825;
}

.pgn-num {
    color: #888;
    text-align: right;
    padding-right: 10px;
    background-color: #201e1b;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.pgn-move {
    padding: 4px 8px;
    cursor: pointer;
    color: #ccc;
    transition: background 0.1s;
    user-select: none;
}

.pgn-move:hover {
    background-color: #383531;
}

.pgn-move.active {
    background-color: #2085d0; /* Lichess blue highlight */
    color: white;
    font-weight: 500;
    border-radius: 3px;
}

.pgn-move.variation {
    color: #cda2d8; /* Light purple for variation text */
}

.pgn-move.variation.active {
    background-color: #9c27b0; /* Deep purple highlight for active variation move */
    color: white;
}

.deviation-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background-color: #302e2c;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.deviation-banner .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.pgn-input-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pgn-textarea {
    width: 100%;
    height: 80px;
    background: #2a2a2a;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 10px;
    font-family: monospace;
    resize: vertical;
    box-sizing: border-box;
}

.pgn-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-full {
    width: 100%;
}

.form-input {
    background: #2a2a2a;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 10px;
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 5px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.fetched-games-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

.game-card {
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.game-card:hover {
    background: #333333;
    color: var(--text-primary);
    border-color: var(--accent);
}

.board-player {
    font-weight: 600;
    font-size: 1rem;
    padding: 2px 5px;
    color: var(--text-primary);
    background: #1e1e1e;
    border-radius: 4px;
}

.annotation-square {
    position: absolute;
    width: 12.5%;
    height: 12.5%;
    pointer-events: none;
    z-index: 10;
    container-type: inline-size;
}

.annotation-badge {
    position: absolute;
    top: -12%;
    left: -12%;
    width: 35%;
    height: 35%;
    border-radius: 50%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white;
    font-weight: 900;
    font-size: clamp(10px, 2vw, 16px) !important;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    border: 1px solid white;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.badge-brilliant { background-color: #00bcd4; }
.badge-great { background-color: #2196f3; }
.badge-best { background-color: #4caf50; }
.badge-excellent { background-color: #8bc34a; }
.badge-good { background-color: #8bc34a; }
.badge-book { background-color: #a87ca0; }
.badge-inaccuracy { background-color: #ffc107; color: black; border-color: #333; }
.badge-mistake { background-color: #ff9800; }
.badge-blunder { background-color: #f44336; }
.badge-interrupted { background-color: #9e9e9e; }