:root {
    --bg-gradient-start: #1e1e2e;
    --bg-gradient-end: #2d2d44;
    --panel-bg: rgba(255, 255, 255, 0.05);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent-color: #bb86fc;
    --button-bg: #3700b3;
    --button-hover: #6200ea;
    --canvas-shadow: 0 10px 30px rgba(0,0,0,0.6);
    --font-stack: 'Roboto', sans-serif;

    --light-square: #f0d9b5;
    --dark-square: #b58863;
}

body {
    margin: 0;
    font-family: var(--font-stack);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 95%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
}

.header {
    text-align: center;
    padding: 20px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h1 {
    margin: 0 0 10px 0;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 1px;
}

.status-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1.2rem;
    font-weight: 300;
}

#turn-indicator {
    font-weight: 500;
}

.game-area {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
}

.board-container {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--canvas-shadow);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    touch-action: none; /* Prevent scrolling on mobile */
}

.sidebar {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    padding: 5px 0;
}

.btn {
    background: var(--button-bg);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(0);
}

.settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.3);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

select:focus {
    border-color: var(--accent-color);
}

.history-panel {
    max-height: 250px; /* Limit height */
    display: flex;
    flex-direction: column;
}

ul#move-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

ul#move-history-list li {
    background: rgba(255,255,255,0.05);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    font-family: monospace;
    font-size: 1rem;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.thinking {
    animation: pulse 1.5s infinite ease-in-out;
    color: var(--accent-color);
    font-weight: bold;
}

@media (max-width: 768px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .sidebar {
        width: 100%;
        max-width: none;
    }

    .board-container {
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    canvas {
        max-width: 100%;
        height: auto; /* Maintain aspect ratio */
    }
}
