:root {
    --neon-blue: #00f3ff;
    --neon-green: #0aff00;
    --neon-red: #ff003c;
    --neon-purple: #bc13fe;
    --bg-dark: #050510;
    --bg-panel: #0a0a1a;
    --grid-line: rgba(0, 243, 255, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    height: 100vh;
    overflow: hidden;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 30px 30px;
    position: relative;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: rgba(0, 243, 255, 0.3);
    box-shadow: 0 0 10px var(--neon-blue);
    animation: scan 4s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes scan {
    0% {
        top: -5%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 105%;
        opacity: 0;
    }
}

.game-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    /* Reduced specific padding */
    background: rgba(10, 10, 26, 0.9);
    border: 1px solid var(--neon-blue);
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    margin-bottom: 10px;
    flex-shrink: 0;
    /* Important: Never shrink the header */
    width: 100%;
}

/* ... LOGO, HUD styles remain same ... */
.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue);
}

.level-badge {
    font-size: 14px;
    background: var(--neon-purple);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
}

.hud {
    display: flex;
    gap: 20px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 15px;
    min-width: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.5);
}

.label {
    font-size: 12px;
    color: #aaa;
    letter-spacing: 1px;
}

#score-display,
#timer-display,
#round-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 700;
}

#timer-display.alert {
    color: var(--neon-red);
    text-shadow: 0 0 10px var(--neon-red);
    animation: pulse 0.5s infinite alternate;
}


/* GAME AREA */
.game-area {
    flex: 1;
    /* Take all remaining vertical space */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed from center to allow scrolling from top */
    overflow-y: auto;
    /* Enable scrolling */
    width: 100%;
    padding: 10px 0;
    min-height: 0;
    /* Crucial for nested flex containers to shrink properly */
}

/* Custom scrollbar for game area */
.game-area::-webkit-scrollbar {
    width: 5px;
}

.game-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.game-area::-webkit-scrollbar-thumb {
    background: var(--neon-blue);
    border-radius: 2px;
}

.category-banner {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    color: var(--neon-blue);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    /* Don't shrink text */
}

.instruction-text {
    margin-bottom: 5px;
    font-size: 16px;
    color: #ddd;
    flex-shrink: 0;
    /* Don't shrink text */
}

.highlight-real {
    color: var(--neon-green);
    font-weight: bold;
    text-shadow: 0 0 10px var(--neon-green);
}

/* IMAGE GRID */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 800px;
    height: 500px;
    /* Fixed height for consistent box sizing */
    margin: 0 auto 10px auto;
}

.image-card {
    position: relative;
    aspect-ratio: 1;
    /* Square boxes for consistency */
    border: 2px solid rgba(0, 243, 255, 0.3);
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #000;
    display: flex;
    width: 100%;
    height: 100%;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    /* Better for portraits/faces */
    transition: transform 0.3s;
}

/* ... existing hover styles ... */
.image-card:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 15px var(--neon-blue);
}

.image-card:hover img {
    transform: scale(1.05);
}

.image-card.selected {
    border-color: var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green), inset 0 0 20px var(--neon-green);
}

.image-card.selected::after {
    content: 'REAL?';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--neon-green);
    color: #000;
    font-weight: bold;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 2px;
}

/* BUTTONS */
.cyber-btn {
    background: transparent;
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 10px 30px;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
    flex-shrink: 0;
    /* Important: Never shrink the button */
    margin-bottom: 5px;
    /* Ensure some bottom spacing */
}

.cyber-btn:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 25px var(--neon-blue);
}

.cyber-btn-small {
    background: var(--neon-blue);
    color: #000;
    border: none;
    padding: 10px 25px;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
}

/* FEEDBACK OVERLAY */
.feedback-overlay {
    position: absolute;
    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: 100;
    backdrop-filter: blur(5px);
}

.hidden {
    display: none;
}

.feedback-content {
    background: rgba(10, 10, 26, 0.95);
    border: 2px solid var(--neon-blue);
    padding: 40px;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.3);
    max-width: 500px;
    width: 90%;
}

.feedback-content h2 {
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    font-size: 30px;
    color: var(--neon-blue);
}

/* UTILS */
.glitch-text {
    position: relative;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
    body {
        overflow: auto;
        /* Enable native scrolling */
        height: auto;
    }

    /* Better Header Control */
    .game-header {
        flex-direction: column;
        align-items: center;
        /* Center everything */
        gap: 5px;
        padding: 8px;
        /* Compact padding */
        margin-bottom: 5px;
    }

    .logo {
        font-size: 18px;
        width: 100%;
        display: flex;
        justify-content: center;
        /* Center logo */
        align-items: center;
        margin-bottom: 5px;
    }

    .level-badge {
        font-size: 12px;
        padding: 1px 5px;
    }

    .hud {
        width: 100%;
        justify-content: center;
        /* Center HUD items */
        gap: 10px;
    }

    .hud-item {
        padding: 4px 10px;
        min-width: 0;
        flex: 0 1 auto;
        /* Let them shrink content based */
    }

    /* FOOTER / CONTROLS FIX */
    .game-container {
        padding: 10px;
        padding-bottom: 30px;
        /* Add safe area at bottom */
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .controls,
    .round-controls {
        width: 100%;
        display: flex;
        justify-content: center;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .cyber-btn {
        width: 90%;
        /* Prevent hitting edges */
        max-width: 300px;
        margin-bottom: 10px;
    }

    /* Disable internal scrolling for game area on mobile */
    .game-area {
        overflow: visible !important;
        height: auto !important;
        flex: none !important;
        display: block;
        width: 100%;
    }
}

@media (max-width: 480px) {

    /* Keep 2 columns on mobile for better visibility of multiple images */
    .image-grid {
        gap: 5px;
        height: auto;
        /* Allow natural height on mobile */
        min-height: 400px;
        /* Ensure minimum size */
    }
}

/* ADVERTISEMENT OVERLAY */
#ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    /* Higher than feedback */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
}

#ad-container {
    width: 90%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    background: #111;
    border: 2px solid var(--neon-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

#ad-video-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(45deg, #050510, #1a1a3a);
    text-align: center;
}

#ad-timer {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    color: var(--neon-blue);
    margin-top: 10px;
}

#ad-message {
    font-size: 20px;
    color: var(--neon-green);
    margin-bottom: 10px;
    text-align: center;
    padding: 0 10px;
}

/* Ad Quiz Styles */
.cyber-input {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--neon-blue);
    color: #fff;
    padding: 10px 15px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    outline: none;
    transition: all 0.3s;
}

.cyber-input:focus {
    border-color: var(--neon-green);
    box-shadow: 0 0 15px var(--neon-green);
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Fade Out Animation */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
