:root {
    --bg-main: #edebe9;
    --sidebar-bg: #ffffff;
    --accent: #3692e7;
    --text-primary: #312e2b;
    --text-secondary: #757575;
    --border: #d2d2d2;
    --white-square: #f0d9b5;
    --black-square: #b58863;
    --eval-black: #2b2925;
    --eval-white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 1.5rem;
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
}

.eval-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 24px;
    height: 600px;
    background: var(--eval-black);
    position: relative;
    border: 1px solid #000;
}

#eval-bar {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50%;
    background: var(--eval-white);
    transition: height 0.5s ease-out;
}

.eval-score {
    position: absolute;
    width: 40px;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-primary);
    background: #fff;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: center;
    z-index: 10;
}

.board-container {
    padding: 0;
    border: 4px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#board {
    width: 600px;
    height: 600px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 600px;
}

.status-badge {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.25rem 0;
}

.panel {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.25rem;
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem;
    min-height: 1.25rem;
}

.captured-piece {
    font-size: 1.1rem;
    color: #000;
}

.toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.switch {
    width: 32px;
    height: 18px;
}

.slider:before {
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
}

input:checked + .slider:before {
    transform: translateX(14px);
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.btn-primary, .btn-secondary {
    padding: 0.5rem;
    border-radius: 3px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: background 0.1s;
}

.btn-primary {
    background: #f1f1f1;
    color: var(--text-primary);
}

.btn-primary:hover {
    background: #e5e5e5;
}

.btn-secondary {
    background: #fff;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #f9f9f9;
}

.history-container {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.history-list {
    overflow-y: auto;
    font-size: 0.85rem;
}

.move-row {
    display: grid;
    grid-template-columns: 30px 1fr 1fr;
    padding: 0.35rem 0.75rem;
}

.move-row:nth-child(odd) {
    background: #f6f6f6;
}

.move-num { color: #aaa; }

.modal-overlay {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
    display: none;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}

.promotion-options {
    display: flex;
    gap: 0.5rem;
}

.promo-option {
    font-size: 2rem;
    cursor: pointer;
    padding: 0.25rem;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.1s;
    line-height: 1;
}

.promo-option:hover {
    background: #f0f0f0;
    border-color: var(--accent);
}

.cm-chessboard .square.white { background-color: var(--white-square) !important; }
.cm-chessboard .square.black { background-color: var(--black-square) !important; }
.cm-chessboard .marker-dot { fill: rgba(0,0,0,0.15) !important; }
.cm-chessboard .marker-square { fill: rgba(255, 255, 0, 0.4) !important; }

@media (max-width: 1000px) {
    main {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .eval-wrapper {
        width: 600px;
        height: 12px;
        flex-direction: row;
        margin-bottom: 0.5rem;
    }
}
