/* ===============================
    GLOBAL SETUP
================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s;
}

body.light-mode {
    background-color: #f1f5f9;
    color: #0f172a;
}

h1 {
    margin: 15px 0;
    color: #38bdf8;
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ===============================
    CONTROLS & BUTTONS
================================= */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 700px;
}

.control-btn {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#startBtn { background: #22c55e; color: white; }
#resetBtn { background: #ef4444; color: white; }
#themeBtn { background: #f59e0b; color: white; }

/* DIFFICULTY BUTTONS (Base Style) */
.diff-btn { 
    background: #ffffff; 
    color: #000; 
    border: 2px solid transparent;
}

/* ACTIVE/SELECTED STATE FIX 
   Isse click kiya gaya button Blue dikhega */
.diff-btn.active {
    background: #38bdf8 !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
    transform: translateY(-2px) scale(1.05);
    border-color: #bae6fd;
}

.control-btn:hover:not(.active) {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* ===============================
    CHESS BOARD (BIGGER SIZE)
================================= */
.chess-board {
    display: grid;
    /* Mobile par thoda bada kiya: 12vw */
    grid-template-columns: repeat(8, 12vw);
    grid-template-rows: repeat(8, 12vw);
    max-width: 550px; 
    max-height: 550px;
    border: 8px solid #1e293b;
    box-shadow: 0 15px 50px rgba(0,0,0,0.7);
    background-color: #1e293b;
}

/* Desktop sizing override: 65px per square */
@media (min-width: 550px) {
    .chess-board {
        grid-template-columns: repeat(8, 65px);
        grid-template-rows: repeat(8, 65px);
    }
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 9.5vw; 
    cursor: pointer;
    user-select: none;
}

@media (min-width: 550px) {
    .square { font-size: 48px; }
}

.white-square { background-color: #f1f5f9; }
.black-square { background-color: #64748b; }

/* PIECES VISIBILITY FIX */
.white-piece { 
    color: #ffffff !important; 
    filter: drop-shadow(0 0 2px #000);
    text-shadow: 0 0 3px #000, 1px 1px 4px rgba(0,0,0,0.4); 
}
.black-piece { 
    color: #000000 !important; 
    filter: drop-shadow(0 0 1px #fff);
    text-shadow: 0 0 2px rgba(255,255,255,0.4);
}

/* HIGHLIGHTS */
.square.selected { background-color: #fbbf24 !important; }
.square.last-move { background-color: rgba(34, 197, 94, 0.4) !important; }

/* OVERLAY */
.game-over-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: flex; justify-content: center;
    align-items: center; z-index: 2000;
}
.winner-card {
    background: white; color: #1e293b; padding: 40px; border-radius: 12px;
    text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    
    width: 90vmin; 
    height: 90vmin;
    max-width: 550px; 
    max-height: 550px;
    
    border: 8px solid #1e293b;
    box-shadow: 0 15px 50px rgba(0,0,0,0.7);
    background-color: #1e293b;
    margin-top: 10px;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 8vmin; 
    cursor: pointer;
    user-select: none;
}

@media (min-width: 600px) {
    .square { font-size: 45px; }
}

@keyframes killShake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    50% { transform: translate(-1px, 2px) rotate(1deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    100% { transform: translate(1px, -2px) rotate(0deg); }
}

.square {
    transition: background-color 0.3s ease;
}
