/* Chess Styles */

/* ==================== Board Layout ==================== */
.board-wrapper {
    position: relative;
    padding-left: 20px;
    padding-bottom: 20px;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(85vw, 480px);
    height: min(85vw, 480px);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 60px rgba(74, 222, 128, 0.1);
}

/* ==================== Cells ==================== */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(8vw, 48px);
    line-height: 1;
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.cell.light {
    background-color: #f0d9b5;
}

.cell.dark {
    background-color: #b58863;
}

/* ==================== Piece Colors ==================== */
.cell.white-piece {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.cell.black-piece {
    color: #1a1a2e;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

/* ==================== Interactive States ==================== */
.cell.selected {
    background-color: #7fa5d0 !important;
    box-shadow: inset 0 0 0 2px #5b8cc4;
}

.cell.legal-move::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
}

.cell.legal-capture {
    background-image: radial-gradient(transparent 55%, rgba(0, 0, 0, 0.25) 55%);
}

.cell.last-move {
    background-color: rgba(255, 255, 100, 0.45) !important;
}

.cell.last-move.light {
    background-color: #f5f682 !important;
}

.cell.last-move.dark {
    background-color: #baca44 !important;
}

.cell.check {
    background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0.6) 0%, rgba(255, 0, 0, 0.3) 40%, transparent 70%) !important;
}

.cell:hover:not(.selected) {
    filter: brightness(1.1);
}

/* ==================== Board Labels ==================== */
.row-labels {
    position: absolute;
    left: 0;
    top: 0;
    height: min(85vw, 480px);
    display: flex;
    flex-direction: column;
    width: 18px;
}

.row-labels span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.col-labels {
    position: absolute;
    bottom: 0;
    left: 20px;
    width: min(85vw, 480px);
    display: flex;
    height: 18px;
}

.col-labels span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

/* ==================== Captured Pieces ==================== */
.captured-bar {
    min-height: 28px;
    flex-wrap: wrap;
}

.captured-piece {
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
}

/* ==================== Move List ==================== */
.move-list {
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.move-list::-webkit-scrollbar {
    width: 4px;
}

.move-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

.move-row {
    display: flex;
    gap: 4px;
    padding: 2px 4px;
    border-radius: 4px;
}

.move-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.move-num {
    color: #64748b;
    min-width: 24px;
}

.move-white {
    color: #e2e8f0;
    min-width: 50px;
}

.move-black {
    color: #94a3b8;
    min-width: 50px;
}

/* ==================== Mode & Difficulty Buttons ==================== */
.mode-btn,
.diff-btn {
    color: #94a3b8;
}

.mode-btn.active,
.diff-btn.active {
    background: #22c55e;
    color: white;
}

.mode-btn:not(.active):hover,
.diff-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==================== Promotion Dialog ==================== */
.promo-btn {
    width: 60px;
    height: 60px;
    font-size: 40px;
    background: #334155;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.promo-btn:hover {
    background: #475569;
    border-color: #22c55e;
    transform: scale(1.1);
}

/* ==================== Modal ==================== */
.modal-content {
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== Panels ==================== */
.panel {
    position: fixed;
    inset: 0;
    z-index: 40;
    transition: opacity 0.3s;
}

.panel-hidden {
    pointer-events: none;
    opacity: 0;
}

.panel-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.panel-content {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: #1e293b;
    padding: 24px;
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.panel-close {
    font-size: 28px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #94a3b8;
    transition: all 0.2s;
}

.panel-close:hover {
    background: #334155;
    color: white;
}

.stat-card {
    background: #334155;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: monospace;
}

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* ==================== Responsive ==================== */
@media (max-width: 480px) {
    .chess-board {
        width: min(92vw, 400px);
        height: min(92vw, 400px);
    }

    .col-labels {
        width: min(92vw, 400px);
    }

    .row-labels {
        height: min(92vw, 400px);
    }

    .cell {
        font-size: min(10vw, 42px);
    }
}