/* ==============================================
   Queens Styles (Mobile & Desktop Optimized)
============================================== */

/* Game Container - The Grid */
.game-container {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    
    /* Responsive Sizing Magic:
       1. width: min(92vw, 75vh) -> ensures it fits within width of mobile (92vw) 
          AND height of desktop (75vh) while staying square.
       2. aspect-ratio: 1/1 -> Forces it to be a perfect square.
    */
    
    width: min(92vw, calc(100vh - 280px)); 
    height: min(92vw, calc(100vh - 280px));
    
    /* Responsive margin: 20px on desktop, reducing to ~5px on smaller widths */
    margin: clamp(5px, 2vw, 20px) auto;

    background-color: #161b22;
    border: 4px solid #30363d;
    position: relative;
    user-select: none;
}

.cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 4vw, 1.5rem); /* Responsive font size */
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    line-height: 1;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1); 
    transition: background-color 0.1s;
    color: #1f2937; 
    text-shadow: none;
}

.cell:hover {
    filter: brightness(0.95);
}

/* Pastel Region Colors */
.region-0 { background-color: #FFB3BA; } /* Red */
.region-1 { background-color: #FFDFBA; } /* Orange */
.region-2 { background-color: #FFFFBA; } /* Yellow */
.region-3 { background-color: #BAFFC9; } /* Green */
.region-4 { background-color: #BAE1FF; } /* Blue */
.region-5 { background-color: #E6B3FF; } /* Purple */
.region-6 { background-color: #FFB3E6; } /* Pink */
.region-7 { background-color: #E0F2F1; } /* Teal */

/* Thick Borders for Regions */
.border-top-thick { border-top: 3px solid #333 !important; }
.border-bottom-thick { border-bottom: 3px solid #333 !important; }
.border-left-thick { border-left: 3px solid #333 !important; }
.border-right-thick { border-right: 3px solid #333 !important; }

/* State Styling */
.cell.is-x {
    color: #6b7280;
    font-weight: bold;
    /* Adjust size relative to cell */
    font-size: 180%; 
}
.cell.is-queen {
    color: #000000;
    padding: 0;
    margin: 0;
    font-size: 180%;
}

/* Feedback */
.cell.error {
    background-color: #ef4444 !important;
    color: white !important;
    animation: shake 0.3s ease-in-out;
}

.cell.win {
    background-color: #22c55e !important;
    color: white !important;
}

/* Buttons */
.pixel-btn {
    font-family: 'Press Start 2P', cursive;
    background-color: #21262d;
    color: #c9d1d9;
    border: 4px solid #30363d;
    padding: 10px 15px;
    font-size: 12px; /* Slightly smaller for mobile safety */
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    text-shadow: 1px 1px #000;
    white-space: nowrap;
}
.pixel-btn:hover {
    background-color: #30363d;
    transform: scale(1.05);
    color: #58a6ff;
}
.pixel-btn:active {
    transform: scale(0.95);
}
.pixel-btn.primary {
    border-color: #238636;
    color: #3fb950;
}
.pixel-btn.primary:hover {
    background-color: #238636;
    color: #fff;
}

/* Modal & Utility */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}
.hidden { display: none !important; }

.modal-content {
    background-color: #161b22;
    border: 4px solid #58a6ff;
    padding: 20px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.2);
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes penalty-flash {
    0%, 100% { color: #8b949e; }
    50% { color: #ef4444; transform: scale(1.1); }
}
.timer-penalty {
    animation: penalty-flash 0.5s ease-in-out;
}