.chess-section {
    padding: calc(var(--nav-height) + 24px) 24px 40px;
    min-height: 100vh;
    background: var(--bg);
}

.chess-layout {
    display: flex;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
    align-items: flex-start;
}

.board-area {
    flex: 1;
    min-width: 0;
}

.board {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 10.5;
    background: #C49A6C;
    border-radius: 6px;
    border: 6px solid #6B4226;
    box-shadow:
        0 0 0 2px #8B6914,
        0 8px 24px rgba(0,0,0,0.3),
        0 2px 6px rgba(0,0,0,0.15);
    overflow: hidden;
}

.board canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.pieces-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.piece {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #FFF8E7, #E8D5B0);
    border: 2.5px solid #8B7355;
    box-shadow:
        inset 0 0 0 2px rgba(139, 115, 85, 0.3),
        0 3px 6px rgba(0,0,0,0.25),
        0 1px 2px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: all;
    transform: translate(-50%, -50%);
    transition: left 0.2s ease, top 0.2s ease, box-shadow 0.15s, transform 0.15s;
    user-select: none;
    font-family: 'Noto Serif SC', serif, sans-serif;
}

.piece.red {
    color: #B22222;
    border-color: #8B1A1A;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.piece.black {
    color: #1a1a2e;
    border-color: #2C3E50;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.piece.selected {
    box-shadow:
        inset 0 0 0 2px rgba(139, 115, 85, 0.3),
        0 0 0 3px #6c5ce7,
        0 0 16px rgba(108, 92, 231, 0.6),
        0 4px 8px rgba(0,0,0,0.3);
    transform: translate(-50%, -50%) scale(1.08);
    z-index: 2;
}

.piece.last-move {
    box-shadow:
        inset 0 0 0 2px rgba(139, 115, 85, 0.3),
        0 0 0 2px rgba(108, 92, 231, 0.4),
        0 3px 6px rgba(0,0,0,0.25);
}

.move-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(108, 92, 231, 0.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transform: translate(-50%, -50%);
    pointer-events: all;
    cursor: pointer;
    z-index: 1;
    transition: transform 0.15s;
}

.move-dot:hover {
    transform: translate(-50%, -50%) scale(1.3);
}

.move-dot.capture {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 3px solid rgba(178, 34, 34, 0.6);
    box-shadow: 0 0 8px rgba(178, 34, 34, 0.3);
}

/* ========== Info Panel ========== */
.info-panel {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.panel-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.panel-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.lobby-actions .btn {
    width: 100%;
    justify-content: center;
}

.join-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.room-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

.room-input:focus {
    border-color: var(--primary);
}

.join-form .btn {
    padding: 10px 20px;
}

.room-info {
    text-align: center;
    margin-bottom: 16px;
}

.room-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 8px;
}

.room-code {
    font-size: 2rem;
    font-weight: 800;
    font-family: monospace;
    color: var(--primary);
    letter-spacing: 4px;
    padding: 12px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.room-code:hover {
    background: #e8e5ff;
}

.room-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 8px;
}

.status-msg {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    min-height: 20px;
}

.status-msg.error {
    color: #e74c3c;
}

.status-msg.success {
    color: #27ae60;
}

/* ========== Game Info ========== */
.turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.turn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #C0392B;
}

.turn-dot.black {
    background: #2C3E50;
}

.turn-text {
    font-weight: 700;
    font-size: 1rem;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.player-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.red-dot { background: #C0392B; }
.black-dot { background: #2C3E50; }

.captured-pieces {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
}

.move-history {
    margin-bottom: 16px;
}

.history-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 8px;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.8;
    color: var(--text);
}

.history-item {
    padding: 2px 8px;
    border-radius: 4px;
}

.history-item:nth-child(odd) {
    background: var(--bg-soft);
}

.game-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    flex: 1;
    justify-content: center;
}

/* ========== Game Over Overlay ========== */
.game-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

.game-over-msg {
    background: var(--bg-card);
    padding: 32px 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.game-over-msg h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.game-over-msg p {
    color: var(--text-light);
    font-size: 1rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .chess-section {
        padding: calc(var(--nav-height) + 16px) 12px 24px;
    }

    .chess-layout {
        flex-direction: column;
        align-items: center;
    }

    .board-area {
        width: 100%;
        max-width: 420px;
    }

    .info-panel {
        width: 100%;
        max-width: 420px;
    }

    .board {
        border-width: 4px;
    }

    .piece {
        width: 34px;
        height: 34px;
        font-size: 16px;
        border-width: 2px;
    }

    .move-dot {
        width: 14px;
        height: 14px;
    }

    .move-dot.capture {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .board {
        border-width: 3px;
    }

    .piece {
        width: 28px;
        height: 28px;
        font-size: 13px;
        border-width: 1.5px;
    }

    .move-dot {
        width: 10px;
        height: 10px;
    }

    .move-dot.capture {
        width: 26px;
        height: 26px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
