/* Chess Board Styles */
.chess-board {
    max-width: 1080px;
    margin: 0 auto;
    border: 2px solid var(--bs-secondary);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--bs-dark);
}

/* Mobile-First Chess Board */
.chess-board-mobile {
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    overflow: hidden;
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    aspect-ratio: 1;
}

.chess-row {
    display: flex;
    width: 100%;
}

.chess-square {
    width: 12.5%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    touch-action: manipulation;
}

/* Mobile-optimized chess squares */
.chess-board-mobile .chess-square {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    min-height: 40px;
    border: none;
    position: relative;
}

.chess-board-mobile .chess-square:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.chess-square.light {
    background-color: #f0d9b5;
    color: #8b4513;
}

.chess-square.dark {
    background-color: #b58863;
    color: #8b4513;
}

.chess-square:hover {
    filter: brightness(1.1);
}

.chess-square.selected {
    background-color: #7dd3fc !important;
    box-shadow: inset 0 0 0 3px #0ea5e9;
}

.chess-square.possible-move {
    background-color: #fde047 !important;
}

.chess-square.possible-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(34, 197, 94, 0.8);
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { 
        transform: scale(1);
        opacity: 0.8;
    }
    50% { 
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Mobile-specific move indicators */
@media (max-width: 768px) {
    .chess-square.possible-move::after {
        width: 40%;
        height: 40%;
        background: rgba(34, 197, 94, 0.9);
    }
}

.chess-square.last-move {
    background-color: #fbbf24 !important;
}

.chess-square.in-check {
    background-color: #ef4444 !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Chess pieces using Unicode symbols */
.chess-piece {
    font-size: 3.5rem;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Board coordinates */
.board-coordinates {
    position: relative;
    max-width: 1080px;
    margin: 0 auto;
}

.file-label, .rank-label {
    position: absolute;
    font-size: 1rem;
    font-weight: bold;
    color: var(--bs-secondary);
}

.file-label {
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
}

.rank-label {
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    .chess-board {
        max-width: 100%;
        border-radius: 0.5rem;
    }
    
    .chess-board-mobile {
        border-radius: 0.5rem;
        margin: 0;
    }
    
    .chess-square {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }
    
    .chess-piece {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }
}

@media (max-width: 576px) {
    .chess-board-mobile {
        border-radius: 0.25rem;
    }
    
    .chess-square {
        font-size: clamp(1.2rem, 6vw, 1.8rem);
        min-height: 35px;
    }
    
    .chess-piece {
        font-size: clamp(1.2rem, 6vw, 1.8rem);
    }
}

/* Touch-friendly improvements */
@media (pointer: coarse) {
    .chess-square {
        min-height: 44px;
        min-width: 44px;
    }
    
    .chess-square:hover {
        transform: scale(1.05);
        z-index: 10;
    }
    
    .chess-square.selected {
        transform: scale(1.1);
        z-index: 15;
        box-shadow: 0 0 0 3px #0ea5e9, 0 4px 12px rgba(14, 165, 233, 0.4);
    }
}

/* Move history styling */
.move-history {
    font-family: 'Courier New', monospace;
}

.move-history .move {
    display: inline-block;
    padding: 2px 4px;
    margin: 1px;
    border-radius: 3px;
    background: var(--bs-secondary);
    cursor: pointer;
}

.move-history .move:hover {
    background: var(--bs-primary);
}

/* Game status indicators */
.turn-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    background: var(--bs-secondary);
}

.turn-indicator.white-turn {
    border-left: 4px solid #f8f9fa;
}

.turn-indicator.black-turn {
    border-left: 4px solid #212529;
}

/* Loading state */
.board-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--bs-secondary);
}

.board-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mobile Game Box Enhancements */
.player-card {
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.move-history-mobile {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

/* Iframe optimizations */
@media (max-width: 400px) {
    .game-container {
        border-radius: 0;
        border: none;
    }
    
    .compact-header {
        padding: 0.25rem 0.5rem;
    }
    
    .game-title {
        font-size: 1rem;
    }
    
    .main-content {
        padding: 0.25rem;
    }
    
    .game-box {
        margin-bottom: 0.5rem;
        border-radius: 0.5rem;
    }
    
    .game-box-body {
        padding: 0.5rem;
    }
}

/* Very small screens / iframe embedding */
@media (max-width: 320px) {
    .chess-square {
        font-size: clamp(1rem, 5vw, 1.5rem);
        min-height: 30px;
    }
    
    .game-box-header {
        padding: 0.5rem;
    }
    
    .btn-mobile {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        min-height: 40px;
    }
}

/* Promotion modal styling */
.promotion-pieces {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.promotion-piece {
    font-size: 3rem;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.promotion-piece:hover {
    border-color: var(--bs-primary);
    background: var(--bs-secondary);
}
