/* Modern Material Dark Theme */
:root {
    --bg-main: #121212;
    --bg-surface: #1e1e1e;
    --bg-card: #252525;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --primary-color: #bb86fc;
    --secondary-color: #03dac6;
    --correct: #4caf50;
    --incorrect: #cf6679;
    --close: #fbc02d;
}

body,
html {
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    padding-top: 20px;
    padding-bottom: 80px;
    /* overflow-x: hidden; REMOVED: This was causing the right-side clipping! */
}

/* Menu Hub Layout */
.menu-container {
    background-color: var(--bg-surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    max-width: 450px;
    width: 90%;
    text-align: center;
}

h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
    color: var(--primary-color);
}

.rules-card {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    text-align: left;
    margin: 20px 0;
    border-left: 4px solid var(--primary-color);
}

.rules-card h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.rules-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.auth-status {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin-bottom: 20px;
}

/* Material Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn {
    background-color: var(--primary-color);
    color: #000;
}

.primary-btn:hover {
    background-color: #a370db;
}

.secondary-btn {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid #444;
}

.secondary-btn:hover {
    background-color: #333;
}

.minimal-btn {
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.minimal-btn:hover {
    color: var(--text-primary);
}


/* Forms & Tables */
.input-field {
    padding: 12px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    border-bottom: 1px solid #444;
    text-align: center;
}

.leaderboard-table th {
    color: var(--primary-color);
    font-weight: 600;
}

/* Suggestions Box Overrides */
#suggestions li {
    padding: 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    color: var(--text-primary);
    list-style-type: none;
    text-align: left;
}

#suggestions li:hover {
    background-color: #333 !important;
}

/* 1. The Main Scrolling Container */
#game-board {
    width: max-content;
    max-width: 95vw;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#game-board::-webkit-scrollbar {
    display: none;
}

/* 2. The Feedback Wrapper */
#feedback {
    width: max-content;
    display: flex;
    flex-direction: column;
}

/* 3. Lock BOTH Header and Rows to the Exact Same Grid */
.header,
.row {
    display: grid;
    grid-template-columns: 155px repeat(7, 85px);
    gap: 6px;
    margin-bottom: 6px;
    width: max-content;
}

/* 4. The Squares */
.cell {
    box-sizing: border-box;
    /* THE MAGIC FIX: Forces borders/padding to face inward */

    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid #2a2a2a;
    border-radius: 4px;
    padding: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    min-height: 85px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

/* 5. The Titles */
.header .cell {
    min-height: 40px;
    background-color: transparent !important;
    border: none;
    border-bottom: 2px solid var(--primary-color);
    border-radius: 0;
    align-items: flex-end;
    padding-bottom: 8px;
}

/* --- Mobile Responsiveness --- */
/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    #game-board {
        align-items: center;
        /* Re-centers the board since it now fits the screen */
        padding-left: 2px;
        padding-right: 2px;
    }

    .header,
    .row {
        /* Math: 85px + (7 * 40px) + (7 gaps * 2px) = 379px Total Width */
        /* This guarantees it fits naturally on 99% of modern smartphones! */
        grid-template-columns: 85px repeat(7, 40px);
        gap: 2px;
    }

    .cell {
        min-height: 50px;
        /* Reduced height to keep them looking like squares */
        font-size: 0.55rem;
        /* Smaller font to fit inside 40px boxes */
        padding: 1px;
        /* Removes internal padding to maximize text space */
        border-width: 1px;

        /* Forces longer words (like "Uncommon") to cleanly break to the next line */
        word-break: break-word;
        line-height: 1.1;
    }

    .header .cell {
        min-height: 30px;
        font-size: 0.55rem;
        padding-bottom: 4px;
    }
}


/* Gameplay Cell Highlighting */
.correct {
    background-color: var(--correct) !important;
    color: #000 !important;
    font-weight: bold;
}

.incorrect {
    background-color: var(--incorrect) !important;
    color: #000 !important;
}

.close {
    background-color: var(--close) !important;
    color: #000 !important;
    font-weight: bold;
}

/* Share Section Styling */
.emoji-row {
    letter-spacing: 3px;
    font-size: 1.1rem;
    margin: 4px 0;
}

/* Toast Notification (Hidden by default) */
.toast {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-card);
    color: var(--primary-color);
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    transition: opacity 0.5s ease;
    z-index: 9999;
}

.toast.show {
    visibility: visible;
    opacity: 1;
}