* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #fbedd0;
    --panel-bg: #fefaf6;
    --primary: #2c3e50;
    --accent-p1: #c2c2c2; 
    --accent-p2: #c2c2c2; 
    --selected: #732c04;  /* Yellow */
}

/* Essential Utilities */
.hidden { display: none !important; }
.shake { animation: shake 0.3s; }
@keyframes shake { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-5px); } 
    75% { transform: translateX(5px); } 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.main-container {
    width: 100%;
    max-width: 450px;
    text-align: center;
    padding: 20px;
}

.hidden { display: none !important; }

h1 { 
    color: var(--primary); 
    font-size: 2.2rem;
    margin-bottom: 10px; 
}
p.subtitle { 
    color: #7f8c8d; 
    font-size: 1.7rem; 
    margin-bottom: 15px; 
}

/* PANELS */
.panel {
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* CONTROLS */
button {
    border: none; padding: 12px 20px; border-radius: 6px;
    font-size: 1rem; cursor: pointer; transition: transform 0.1s;
    width: 100%; margin-bottom: 10px; font-weight: bold;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.primary-btn { background-color: var(--primary); color: white; }
.secondary-btn { background-color: #95a5a6; color: white; }
.action-btn { background-color: #27ae60; color: white; margin-top: 15px; }

input {
    width: 60%; padding: 12px; border: 2px solid #ddd;
    border-radius: 6px; font-size: 1rem; text-align: center;
    text-transform: uppercase;
}

.join-row { display: flex; gap: 10px; justify-content: center; }
.join-row button { width: 35%; margin-bottom: 0; }
.code-display { font-size: 2.5rem; font-family: monospace; letter-spacing: 5px; margin: 15px 0; color: var(--primary); }

/* GAME BOARD */
.game-header { display: flex; justify-content: space-between; margin-bottom: 2px; align-items: center; }
.player-badge { font-weight: bold; padding: 5px 10px; border-radius: 4px; background: #ddd; }
.turn-badge { font-weight: bold; font-size: 1.2rem; }

.error-text { height: 20px; color: #c0392b; font-weight: bold; font-size: 0.9rem; margin-bottom: 5px; }

.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    aspect-ratio: 1;
}

.cell {
    background-color: #EE9510;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem; font-weight: bold;
    cursor: pointer; user-select: none;
    transition: background 0.2s, transform 0.1s;

    /* FIX: Add a transparent border so the size is pre-calculated */
    border: 4px solid #ba7308; 
    box-sizing: border-box;
}

.cell.selected {
    background-color: #732c04;
    border-color: #732c04; 
    transform: scale(0.95); /* Slight shrink for effect */
}

.cell.played { 
    background-color: transparent;
    border-color: transparent;
    box-shadow: 0 0;
}

/* Animations */
.shake { animation: shake 0.4s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Container: Stacks items vertically and centers them */
.school-credit {
    display: flex;
    flex-direction: column; /* Puts image on top, text below */
    align-items: center;    /* Centers them horizontally */
    justify-content: center;
    margin-bottom: 20px;    /* Space between this section and the H1 title */
    gap: 3px;               /* Space between the image and the text */
    
    /* Text Styling */
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

/* Image: Constraints to keep it looking good */
.school-credit img {
    max-width: 300px;       /* Prevents it from being too huge */
    width: 100%;            /* Responsive width */
    height: auto;           /* Maintains aspect ratio */
    object-fit: contain;    /* Ensures no stretching */
}

/* Link Styling */
.school-credit p {
    color: #732c04;
    text-decoration: none;
    font-weight: bold;
}

.school-credit a:hover {
    text-decoration: underline;
}

h2#text-winner {
    margin-bottom: 10px;
}

.divider {
    margin-bottom: 10px;
}

/* 2. The Footer Explanation */
.project-footer {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 10px;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.footer-link {
    display: inline-block;
    margin-top: 8px;
    color: #2c3e50;
    font-weight: bold;
    text-decoration: underline;
    /* border-bottom: 2px solid #334940; */
}

/* 3. The Game Over Promo */
.promo-box {
    margin-top: 10px;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
}

.promo-box a {
    color: #334940;
    font-weight: bold;
    text-decoration: underline;
}

.loader {
    border: 4px solid #f3f3f3; border-top: 4px solid var(--primary);
    border-radius: 50%; width: 30px; height: 30px;
    animation: spin 1s linear infinite; margin: 10px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
