/* --- THEME DEFINITIONS --- */
:root {
    /* DEFAULT THEME (Red / Amber) */
    --bg-dark: #0f0f0f;
    --text-main: #dcdde1;
    --text-muted: #718093;
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-border: rgba(255, 255, 255, 0.08);

    --primary: #e84118;   /* Crimson */
    --secondary: #fbc531; /* Gold */
    --tile-active: rgba(232, 65, 24, 0.12);

    --win-color: #00ff80;
    --win-bg: rgba(0, 255, 144, 0.12);
}

body.theme-acid {
    --primary: #9c88ff;
    --secondary: #44bd32;
    --tile-active: rgba(156, 136, 255, 0.12);
    --win-color: #2bff00;
    --win-bg: rgba(30, 255, 0, 0.12);
}

body.theme-vaporwave {
    --primary: #ef57ff;
    --secondary: #00d2ff;
    --tile-active: rgba(239, 87, 255, 0.12);
    --win-color: #00dbff;
    --win-bg: rgba(0, 219, 255, 0.12);
}

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* REDUCED TOP PADDING */
    padding: 15px 20px 40px 20px;
    padding-top: 0 !important;
    transition: background-color 0.5s ease;
}

/* --- AMBIENT LIGHTS (Restored & Moving) --- */
.ambient-light {
    position: fixed;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    opacity: 0.05; /* Subtle to prevent eye strain */
    top: -20%;
    left: -10%;
    filter: blur(100px);
    z-index: -1;
    animation: float-light 20s infinite alternate ease-in-out;
    pointer-events: none;
}

.ambient-light:nth-child(2) {
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: auto;
    bottom: -20%;
    right: -10%;
    left: auto;
    animation-delay: -7s;
}

@keyframes float-light {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10vw, 10vh) scale(1.2); }
}


/* --- FIXED UI ELEMENTS (Burger & Login) --- */
#nav-bar {
    position: fixed;
    /* CHANGE: Move a bit closer to the edge (from 25px to 15px) */
    top: 15px;
    left: 20px;
    z-index: 1000;
}

#nav-bar img {
    width: 32px;
    height: auto;
    cursor: pointer;
    filter: brightness(0) invert(1);
    transition: transform 0.2s ease;
}

#nav-bar img:hover { transform: scale(1.1); }

#log-in {
    position: fixed;
    /* CHANGE: Move a bit closer to the edge (from 25px to 15px) */
    top: 15px;
    right: 20px;
    z-index: 1000;
}
#nav-bar, #log-in {
    position: fixed;
    top: 15px; /* Keep them exactly 15px from the top edge */
}
#btnLogIn {
    color: #bf00ff; /* Fixed Neon Purple as requested */
    border: 1px solid #bf00ff;
    background: rgba(191, 0, 255, 0.05);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: purple-pulse 3s infinite ease-in-out;
    width: auto;         /* Prevents it from taking up a fixed width */
    padding: 8px 16px;   /* Smaller horizontal padding (left/right) */
    min-width: 90px;     /* Optional: ensures it doesn't get too tiny with short text */
}

#btnLogIn:hover {
    color: #fff;
    background: rgba(191, 0, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(191, 0, 255, 0.6);
}

/* --- LEFT SIDE MENU --- */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: rgba(11, 11, 11, 0.98);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--primary); /* Updates with theme! */
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    padding: 40px 25px;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 50px;
}

.menu-header h3 {
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.close-btn {
    font-size: 2.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

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

.menu-items { list-style: none; }

.menu-items li {
    padding: 18px 0;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-items li:hover {
    color: var(--primary);
    padding-left: 15px;
    background: rgba(255, 255, 255, 0.02);
}

.menu-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 1999;
}

.menu-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* --- HEADER & SPLASH --- */
header {
    text-align: center;
    /* CHANGE: This was the biggest gap. Reduce from 80px to 10px */
    padding-top: 0;
    margin-top: 0 !important;
    margin-bottom: 20px;
    width: 100%;
}

.header-main {
    position: relative;
    display: inline-block;
    /* CHANGE: Ensure no extra margin is pushing it down */
    margin-top: 0;
}
h1 {
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 6px;
    margin-top: 0 !important;
    line-height: 1;
    /* Dynamic Shifting Gradient */
    background: linear-gradient(
            90deg,
            var(--primary),
            #fff,
            var(--secondary),
            #00dbff,
            var(--primary)
    );
    background-size: 300% auto; /* Large size to allow "movement" */

    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;

    /* Slower, smoother color shift */
    animation: title-flow 8s linear infinite;
    filter: drop-shadow(0 0 10px var(--primary));
    line-height: 1.2;
}

@keyframes title-flow {
    0% { background-position: 0% center; }
    100% { background-position: 300% center; }
}
.splash-text {
    position: absolute;
    top: 70%;
    left: 90%;
    transform: translate(-35px, 0) rotate(-20deg);
    color: #ffff00;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: bold;
    text-shadow: 2px 2px 0 #3f3f00;
    z-index: 100;
    white-space: nowrap;
    animation: minecraft-pulse 1s infinite alternate ease-in-out;
}

/* --- BINGO GRID --- */
.bingo-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr); /* FORCES all rows to be same height */
    gap: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 15px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 600px; /* Slightly wider to accommodate more text */
    aspect-ratio: 1 / 1; /* Board stays a perfect square */
    margin: auto;
}

.bingo-board.rainbow-mode {
    border: 4px solid transparent;
    background: linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
    linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8f00ff) border-box;
    background-size: 300% 300%;
    animation: rainbow-border 3s linear infinite, board-glow 2s infinite alternate;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
}


@keyframes rainbow-border {
    0% { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

@keyframes board-glow {
    from { box-shadow: 0 0 20px rgba(255, 255, 255, 0.1); }
    to { box-shadow: 0 0 60px rgba(255, 255, 255, 0.4); }
}

#bingo-bingo-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(0,0,0,0.95) 100%);
    z-index: 10000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px);
    cursor: pointer;
}

.ultimate-win-text {
    font-size: clamp(3rem, 18vw, 9rem);
    font-weight: 900;
    /* Animated Rainbow Text */
    background: linear-gradient(to right, #ef5350, #f48fb1, #7e57c2, #2196f3, #26c6da, #43a047, #eeff41, #f9a825, #ff5722);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% auto;
    animation: shine 2s linear infinite;
    text-transform: uppercase;
    letter-spacing: -5px;
    filter: drop-shadow(0 0 30px rgba(255,255,255,0.5));
}

.ultimate-subtext {
    color: #fff;
    font-family: monospace;
    letter-spacing: 5px;
    margin-top: 20px;
    animation: flash 0.5s infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.tile {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    /* Strict sizing */
    aspect-ratio: 1 / 1;
    width: 100%;
    height: 100%;
    padding: 6px;

    /* Text Handling for ~66 characters */
    font-size: clamp(0.55rem, 1.4vw, 0.85rem);
    line-height: 1.1;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;

    /* Prevent text overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    overflow: hidden;
}
.tile.marked {
    background-color: var(--tile-active);
    border-color: var(--primary);
    color: #fff;

    /* Neon Glow Effect */
    text-shadow: 0 0 8px var(--primary);
}
/* Win Visuals */
.tile.won {
    background-color: var(--win-bg) !important;
    border-color: var(--win-color) !important;
    color: #fff !important;
    text-shadow: 0 0 10px var(--win-color);
    animation: chill-pulse 4s infinite ease-in-out !important;
    z-index: 10;
}

@keyframes chill-pulse {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
}



/* --- CONTROLS --- */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
}

.btn-reset { color: #ff4757; border: 2px solid #ff4757; }
.btn-reset:hover { background: #ff4757; color: #000; }

.btn-donate { color: #fbc531; border: 2px solid #fbc531; }
.btn-donate:hover { background: #fbc531; color: #000; }

button {
    background: transparent;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 12px 40px;
    border-radius: 50px;
    cursor: pointer;
    transition: 0.3s;
    width: 220px;
}

/* --- ANIMATIONS --- */
@keyframes purple-pulse {
    0%, 100% { border-color: rgba(191, 0, 255, 1); box-shadow: 0 0 5px rgba(191, 0, 255, 0.2); }
    50% { border-color: rgba(191, 0, 255, 0.4); box-shadow: 0 0 15px rgba(191, 0, 255, 0.1); }
}

@keyframes minecraft-pulse {
    from { transform: translate(-35px, 0) rotate(-20deg) scale(1); }
    to { transform: translate(-35px, 0) rotate(-20deg) scale(1.1); }
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 40px) scale(1.05); }
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    header {
        padding-top: 80px;
    }

    #nav-bar, #log-in {
        top: 15px;
    }

    #nav-bar {
        left: 15px;
    }

    #log-in {
        right: 15px;
    }

    .side-menu {
        width: 80%;
    }

    .bingo-board {
        gap: 5px;
    }

    .splash-text {
        position: absolute;
        top: 80%;
        left: 65%;
        transform: translate(-35px, 0) rotate(-20deg);
        color: #ffff00;
        font-size: clamp(1rem, 2.5vw, 1.5rem);
        font-weight: bold;
        text-shadow: 2px 2px 0 #3f3f00;
        z-index: 100;
        white-space: nowrap;
        animation: minecraft-pulse 1s infinite alternate ease-in-out;
    }
}

.container {
    /* ... existing styles ... */
    /* Remove any top margin or gap from the main wrapper */
    margin-top: 0 !important;
    padding-top: 0 !important;
    gap: 1rem; /* Reduced gap between header and board */
}



/* --- THEME SELECTOR CSS (NEW) --- */
.theme-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

.theme-selector {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    display: flex;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.theme-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s;
}

.theme-dot:hover { transform: scale(1.2); }
.theme-dot.default { background: linear-gradient(45deg, #e84118, #fbc531); }
.theme-dot.acid { background: linear-gradient(45deg, #9c88ff, #44bd32); }
.theme-dot.vaporwave { background: linear-gradient(45deg, #ef57ff, #00d2ff); }

/* --- WIN OVERLAY (Fixed Center) --- */
#win-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.win-text {
    font-size: clamp(3rem, 15vw, 6rem);
    color: var(--win-color);
    text-shadow: 0 0 30px var(--win-color);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 10px;
}