/* Global Design Tokens for Chess Mini Games */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --accent-gold: #fbbf24;
    --accent-gold-hover: #f59e0b;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    margin: 0;
    color: var(--accent-gold);
}

.back-btn {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    transition: color var(--transition-speed);
}

.back-btn:hover {
    color: var(--accent-gold);
}

/* Base Game Components */
.game-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: var(--accent-gold);
    color: var(--bg-primary);
    transition: all var(--transition-speed);
}

.game-btn:hover {
    background-color: var(--accent-gold-hover);
    transform: translateY(-2px);
}

.game-btn.secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.board-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.chessboard {
    width: 100%;
    aspect-ratio: 1;
    border: 8px solid var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.hazard-indicator {
    position: absolute;
    top: 8px;
    /* Match board border */
    left: 8px;
    right: 8px;
    bottom: 8px;
    pointer-events: none;
    z-index: 10;
}

@media (max-width: 600px) {
    .container {
        padding: 0.5rem;
    }

    header {
        margin-bottom: 1rem;
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    h1 {
        font-size: 1.5rem;
    }

    .chessboard {
        border-width: 4px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-over-overlay {
    animation: fadeIn 0.3s ease-out;
}

/* Result & Transition Overlays */
.result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 8px;
    text-align: center;
}

.result-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    margin-bottom: 10px;
}

/* Candy Crush Specific Styles */
.candy-piece {
    font-size: 2.8rem;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    will-change: transform, opacity;
}

/* Vibrant Piece Colors */
.piece-gold {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

/* Queen */
.piece-green {
    color: #22c55e;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

/* Pawn */
.piece-blue {
    color: #3b82f6;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

/* Knight */
.piece-purple {
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* Bishop */
.piece-orange {
    color: #f97316;
    text-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

/* Rook */
.piece-teal {
    color: #14b8a6;
    text-shadow: 0 0 10px rgba(20, 184, 166, 0.4);
}

/* King */

/* Elimination Effect */
/* Elimination Effect - Dazzling Flash */
@keyframes pieceFlash {
    0% {
        transform: scale(1);
        filter: brightness(1) white-shadow;
    }

    50% {
        transform: scale(1.3);
        filter: brightness(3) contrast(1.5);
        text-shadow: 0 0 20px #fff;
    }

    100% {
        transform: scale(0);
        opacity: 0;
        filter: brightness(5) blur(5px);
    }
}

.candy-piece.clearing {
    animation: pieceFlash 0.4s forwards;
    pointer-events: none;
}

/* Row/Column Flash Effect */
@keyframes cellFlash {
    0% {
        background-color: rgba(255, 255, 255, 0);
    }

    30% {
        background-color: rgba(255, 255, 255, 0.3);
    }

    100% {
        background-color: rgba(255, 255, 255, 0);
    }
}

.candy-cell.flash {
    animation: cellFlash 0.5s ease-out;
}

@media (max-width: 480px) {
    .candy-piece {
        font-size: 2.1rem;
    }
}