body {
    margin: 0;
    padding: 0;
    background: #111;
    color: #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.game-container {
    display: flex;
    gap: 20px;
    align-items: stretch;
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    height: 90vh;
}

.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.board-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #252525;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
}

/* Player Cards */
.player-card {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid transparent;
    transition: 0.3s;
}

.player-card.active {
    background: #333;
    border-left-color: #00f6ff;
    box-shadow: 0 0 10px rgba(0, 246, 255, 0.1);
}

.player-card .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.player-card .info {
    flex: 1;
}

.player-card .name {
    font-weight: bold;
    font-size: 14px;
}

.player-card .sub {
    font-size: 11px;
    color: #888;
}

.player-card .timer {
    font-family: 'Consolas', monospace;
    font-size: 18px;
    background: #000;
    padding: 5px 10px;
    border-radius: 4px;
    color: #00f6ff;
}

.game-info {
    flex: 1;
    background: #222;
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 13px;
    color: #aaa;
}

#status {
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

/* Controls */
.title {
    margin: 0;
    font-size: 18px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 10px;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.btn-level {
    flex: 1;
    background: #333;
    border: 1px solid #444;
    color: #aaa;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.btn-level:hover, .btn-level.active {
    background: #00f6ff;
    color: #000;
    font-weight: bold;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-action {
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: 0.2s;
}

.btn-action.primary {
    background: #00f6ff;
    color: #000;
    box-shadow: 0 0 15px rgba(0, 246, 255, 0.3);
}
.btn-action.primary:hover {
    background: #fff;
    box-shadow: 0 0 20px rgba(0, 246, 255, 0.6);
}

.btn-action.secondary {
    background: #444;
    color: #fff;
}
.btn-action.secondary:hover { background: #555; }

.btn-secondary {
    background: #444;
    color: #fff;
    border: 1px solid #555;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}
.btn-secondary:hover {
    background: #555;
    border-color: #777;
}

.btn-action.undo {
    background: #5c3c0d;
    color: #ffcc00;
}
.btn-action.quit {
    background: #330000;
    color: #ff4444;
    margin-top: auto;
}

.highlight-square {
    box-shadow: inset 0 0 3px 3px yellow;
}

/* Analysis */
.analysis-controls {
    margin-top: 15px;
    background: #2a2a2a;
    padding: 10px;
    border-radius: 8px;
    width: 600px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.eval-box {
    background: #111;
    color: #00f6ff;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    font-family: monospace;
    font-size: 14px;
    border: 1px solid #333;
}
.controls-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}
.graph-container {
    background: #1a1a1a;
    border-radius: 4px;
    padding: 5px;
    margin-bottom: 10px;
    height: 120px; /* Force height */
    position: relative;
    width: 580px; /* Fit inside 600px - padding */
}
canvas#evalGraph {
    width: 100% !important;
    height: 100% !important;
}
.move-feedback {
    min-height: 20px;
    font-size: 13px;
    text-align: center;
    margin-bottom: 5px;
    font-weight: bold;
}
.move-feedback.blunder { color: #ff3333; }
.move-feedback.mistake { color: #ffcc00; }
.move-feedback.good { color: #33ff33; }
.full-width { width: 100%; margin-top: 5px; }
.btn-control {
    background: #444;
    border: none;
    color: #fff;
    width: 40px;
    height: 35px;
    border-radius: 4px;
    cursor: pointer;
}
.btn-control:hover { background: #555; }
.btn-control.exit { background: #550000; color: #ff5555; margin-left: auto; }

/* History */
.history-panel {
    background: #222;
    border-radius: 8px;
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}
.panel-title { font-size: 14px; color: #888; margin: 0 0 10px 0; border-bottom: 1px solid #333; padding-bottom: 5px; }
.history-item {
    font-size: 13px;
    padding: 8px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-item:hover { background: #333; }
.history-item .info-group { display: flex; flex-direction: column; gap: 2px; }
.history-item .result { font-weight: bold; }
.history-item .result.win { color: #00f6ff; }
.history-item .result.loss { color: #ff4444; }
.history-item .result.draw { color: #aaa; }

.btn-delete {
    background: transparent;
    border: none;
    color: #444;
    cursor: pointer;
    padding: 5px;
    transition: 0.2s;
    font-size: 14px;
}
.btn-delete:hover { color: #ff4444; }


#myBoard {
    width: 600px;
    max-width: 100%;
}

@media (max-width: 1000px) {
    body {
        overflow: auto;
        height: auto;
    }
    .game-container {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
    }
    .sidebar {
        width: 100%;
    }
    .board-container {
        padding: 5px;
    }
    #myBoard {
        width: 95vw;
        height: 95vw;
        max-width: 500px;
        max-height: 500px;
    }
    .analysis-controls {
        width: 100%;
    }
    .graph-container {
        width: 100%;
    }
    /* Reorder sidebars on mobile */
    .sidebar.left-panel {
        order: 2;
    }
    .board-container {
        order: 1;
    }
    .sidebar.right-panel {
        order: 3;
    }
    
    .player-card {
        padding: 8px;
    }
    .player-card .timer {
        font-size: 14px;
    }
    .btn-action {
        padding: 15px; /* Larger tap target */
    }
}
