:root {
    --monad-purple: #836ef9;
    --monad-dark: #050508;
}

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    background-color: var(--monad-dark);
    font-family: 'Courier New', Courier, monospace;
    color: white; overflow: hidden;
    overscroll-behavior-y: contain; touch-action: none;
}

canvas#aviaryCanvas {
    display: block; width: 100%; height: 100%;
    position: absolute; top: 0; left: 0; z-index: 1;
}

/* HUD Header */
.ui-container {
    position: absolute; top: 15px; left: 50%;
    transform: translateX(-50%); z-index: 10;
    background: rgba(131, 110, 249, 0.1);
    padding: 8px 25px; border-radius: 12px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(131, 110, 249, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none; text-align: center; width: max-content;
}

h1 { margin: 0 0 2px 0; font-size: 1rem; letter-spacing: 1px; }
h1 span { color: #ff00c8; text-shadow: 0 0 10px rgba(255, 0, 200, 0.7); }
p { font-size: 0.9rem; color: #fff; margin: 0; font-weight: bold; }
#scoreVal, #levelVal { color: #00ffd5; text-shadow: 0 0 10px rgba(0, 255, 213, 0.5); }

/* STRICT EVENT BLOCKING ON OVERLAYS */
.overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 50; display: flex; justify-content: center; align-items: center;
    opacity: 1; transition: opacity 0.3s ease;
    pointer-events: auto;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

/* Legacy Modals (Game Over, Cert) */
.glass-box {
    text-align: center; background: rgba(131, 110, 249, 0.05);
    border: 1px solid var(--monad-purple);
    padding: 25px 20px; border-radius: 20px;
    box-shadow: 0 0 40px rgba(131, 110, 249, 0.2);
    width: 85%; max-width: 380px;
}

.glass-box h2 { color: #fff; font-size: 1.6rem; margin: 0 0 10px 0; text-shadow: 0 0 10px var(--monad-purple); }

input[type="text"] {
    width: 100%; padding: 12px; margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.6); border: 1px solid var(--monad-purple);
    color: white; border-radius: 8px; font-family: inherit; font-size: 0.9rem;
    box-sizing: border-box; outline: none; text-align: center; transition: 0.3s;
}
input[type="text"]:focus { border-color: #00ffd5; box-shadow: 0 0 15px rgba(0, 255, 213, 0.4); }

.glow-on-hover {
    width: 100%; padding: 12px; border: none; outline: none; color: #fff;
    background: rgba(131, 110, 249, 0.2); cursor: pointer;
    border-radius: 8px; font-weight: bold; text-transform: uppercase;
    letter-spacing: 1px; border: 1px solid var(--monad-purple); transition: 0.3s;
}
.glow-on-hover:active { transform: scale(0.95); background: rgba(131, 110, 249, 0.4); }
.glow-on-hover.secondary { border-color: #00ffd5; background: rgba(0, 255, 213, 0.1); }
.glow-on-hover.x-btn { border-color: #fff; background: rgba(255, 255, 255, 0.1); }

.button-group.horizontal { display: flex; gap: 10px; margin-top: 15px; }

.cert-box { padding: 15px; }
.cert-wrapper {
    width: 100%; aspect-ratio: 4/5;
    background: #000; border-radius: 10px; overflow: hidden;
    border: 2px solid #836ef9; box-shadow: 0 0 20px rgba(131, 110, 249, 0.5);
    margin-bottom: 15px;
}
#certCanvas { width: 100%; height: 100%; object-fit: contain; }

@keyframes shakeError {
    0% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-8px); }
    100% { transform: translateX(0); }
}

.error-shake {
    animation: shakeError 0.3s ease-in-out;
    border-color: #ff0000 !important;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6) !important;
}
.error-shake::placeholder { color: #ff4d4d !important; }

/* =========================================
   📱 ANDROID NATIVE APP UI STYLES (COMPACT)
   ========================================= */

.android-app-view {
    background: linear-gradient(180deg, #150524 0%, var(--monad-dark) 100%) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    
    /* FIX: Align to top so content doesn't get squished, allow scrolling if screen is tiny */
    align-items: flex-start;
    overflow-y: auto; 
}

.app-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100%;
    max-width: 480px; 
    padding: 30px 20px 20px 20px; /* Reduced padding */
    box-sizing: border-box;
    margin: 0 auto;
}

.app-header {
    text-align: center;
    margin-bottom: 10px;
}

/* Material Design style chip - Compact */
.app-subtitle-chip {
    color: #e0e0e0;
    font-size: 0.85rem; /* Resized */
    font-weight: bold;
    text-align: center;
    margin: 10px 0 20px 0;
    background: rgba(131, 110, 249, 0.15);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid rgba(131, 110, 249, 0.3);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* App-style Grid Layout - Compact */
.how-to-play-app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px; /* Tighter gap */
    width: 100%;
}

/* Elevated Native Cards - Compact */
.instruction-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(131, 110, 249, 0.15);
    border-radius: 16px; 
    padding: 12px 8px; /* Reduced padding */
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
}

.instruction-card:active {
    transform: scale(0.96);
    background: rgba(131, 110, 249, 0.15);
}

.instruction-card .icon {
    font-size: 1.5rem; /* Resized icon */
    display: block;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.instruction-card p {
    font-size: 0.75rem; /* Resized text */
    color: #cccccc;
    margin: 0;
    line-height: 1.2;
}

.instruction-card strong {
    color: #00ffd5;
    display: block;
    margin-bottom: 2px;
    font-size: 0.85rem; /* Resized strong text */
    text-transform: uppercase;
}

/* Bottom Nav / Action Area - Pushed to bottom safely */
.app-bottom-bar {
    width: 100%;
    margin-top: auto; /* FIX: Automatically pushes the button down, taking up remaining space */
    padding-top: 25px; /* Minimum space between grid and button */
}

/* Massive, native-feeling primary button - Compact */
.play-btn-app {
    width: 100%;
    font-size: 1.15rem !important; /* Resized */
    padding: 18px !important; /* Resized */
    border-radius: 100px !important; 
    box-shadow: 0 6px 20px rgba(131, 110, 249, 0.4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 10px rgba(131, 110, 249, 0.4); }
    50% { box-shadow: 0 0 25px rgba(131, 110, 249, 0.8), 0 0 15px rgba(0, 255, 213, 0.6); border-color: #00ffd5; }
    100% { box-shadow: 0 0 10px rgba(131, 110, 249, 0.4); }
}

.start-pulse {
    animation: pulseGlow 2s infinite;
    background: linear-gradient(45deg, rgba(131, 110, 249, 0.2), rgba(0, 255, 213, 0.1));
    border: 2px solid var(--monad-purple);
    transition: all 0.3s ease;
}

.start-pulse:hover {
    background: linear-gradient(45deg, rgba(131, 110, 249, 0.5), rgba(0, 255, 213, 0.3));
    transform: scale(1.05);
}

/* --- MASCOT HOME SCREEN STYLES (COMPACT) --- */
.mascot-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px 0 10px 0;
}

.home-mascot {
    width: 85px; /* Shrink Mascot size */
    height: 85px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--monad-purple);
    box-shadow: 
        0 0 20px rgba(131, 110, 249, 0.6),
        inset 0 0 10px rgba(0, 0, 0, 0.5);
    background-color: var(--monad-purple);
    animation: floatMascot 3s ease-in-out infinite;
}

@keyframes floatMascot {
    0% { transform: translateY(0px); box-shadow: 0 0 15px rgba(131, 110, 249, 0.5); }
    50% { transform: translateY(-6px); box-shadow: 0 8px 25px rgba(131, 110, 249, 0.8), 0 0 15px rgba(0, 255, 213, 0.4); }
    100% { transform: translateY(0px); box-shadow: 0 0 15px rgba(131, 110, 249, 0.5); }
}

/* --- 🟢 CSS3 HARDWARE-ACCELERATED EFFECTS --- */
#deadline {
    position: absolute;
    top: 200px;
    left: 0;
    width: 100%;
    height: 3px;
    background: repeating-linear-gradient(90deg, transparent, transparent 10px, rgba(255,255,255,0.15) 10px, rgba(255,255,255,0.15) 20px);
    z-index: 5;
    pointer-events: none;
    transition: background 0.3s ease;
}

#deadline.on-fire {
    background: #fff;
    height: 5px;
    box-shadow: 
        0 0 10px #fff,
        0 -10px 20px #ffea00,
        0 -20px 40px #ff6600,
        0 -40px 80px #ff0000;
    animation: cssFireBurn 0.15s infinite alternate;
}

@keyframes cssFireBurn {
    0% { box-shadow: 0 0 10px #fff, 0 -10px 20px #ffea00, 0 -20px 40px #ff6600, 0 -40px 60px #ff0000; transform: scaleY(1); }
    100% { box-shadow: 0 0 15px #fff, 0 -15px 30px #ffea00, 0 -30px 50px #ff6600, 0 -50px 90px #ff0000; transform: scaleY(1.3); }
}

#cssCountdown {
    background: rgba(0,0,0,0.4);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 45; 
    pointer-events: none;
    flex-direction: column;
}

#cssCountdown h1 {
    font-size: 8rem; /* Resized */
    color: #ff3333;
    margin: 0;
    text-shadow: 0 0 40px red, 0 0 80px darkred;
}

#cssCountdown p {
    font-size: 1.5rem; /* Resized */
    color: white;
    letter-spacing: 4px;
    text-shadow: 0 0 20px red;
    margin-top: -15px;
}

.pulse-anim {
    animation: heartbeat 1s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes heartbeat {
    0% { transform: scale(1.5); opacity: 0; }
    20% { transform: scale(1); opacity: 1; }
    80% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* =========================================
   🎵 AUDIO CONTROLS
   ========================================= */
.audio-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100; /* Kept high to stay above overlays */
    width: 45px;
    height: 45px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    background: rgba(131, 110, 249, 0.2); 
    border: 1px solid var(--monad-purple);
    color: white; 
}

.audio-btn.muted-state {
    border-color: #ff3333;
    background: rgba(255, 51, 51, 0.15);
    box-shadow: 0 0 15px rgba(255, 51, 51, 0.4);
}
