/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { 
    width: 100%; height: 100%; overflow: hidden;
    font-family: 'Outfit', sans-serif;
    background: #0a0a1a;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* ===== CANVAS ===== */
#game-container { position: fixed; inset: 0; z-index: 0; }
#game-canvas { width: 100%; height: 100%; display: block; }

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 5, 20, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease;
}
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== LOADING SCREEN ===== */
#loading-screen {
    position: fixed; inset: 0; z-index: 999;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a0a0a 0%, #0a0a2a 50%, #0a1a1a 100%);
}
.loader-content { text-align: center; }
.loader-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(3rem, 8vw, 6rem);
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #ff6b6b);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 2s linear infinite;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255,107,107,0.3));
}
@keyframes shimmer { to { background-position: 200% center; } }

.loader-bar {
    width: 280px; height: 6px; margin: 2rem auto;
    background: rgba(255,255,255,0.1);
    border-radius: 3px; overflow: hidden;
}
.loader-fill {
    height: 100%; width: 0%; border-radius: 3px;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d);
    transition: width 0.3s ease;
}
.loader-text { color: rgba(255,255,255,0.5); font-size: 0.9rem; }

/* ===== GLASS PANEL ===== */
.glass-panel {
    background: rgba(15, 15, 35, 0.85);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 3rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ===== MAIN MENU ===== */
.menu-content { text-align: center; animation: slideUp 0.6s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.game-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(4rem, 12vw, 9rem);
    line-height: 0.95;
    background: linear-gradient(180deg, #ff6b6b 0%, #ee5a24 40%, #ffd93d 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 30px rgba(255,107,107,0.4));
    margin-bottom: 0.5rem;
    letter-spacing: 4px;
    animation: titlePulse 3s ease-in-out infinite;
}
@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.game-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: rgba(255,255,255,0.6);
    margin-bottom: 2.5rem;
}

/* ===== BUTTONS ===== */
.menu-btn {
    display: block; width: 280px; margin: 0.8rem auto;
    padding: 1rem 2rem;
    border: none; border-radius: 16px;
    font-family: 'Bangers', cursive;
    font-size: 1.5rem; letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
}
.menu-btn.primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
    box-shadow: 0 8px 30px rgba(238,90,36,0.4);
}
.menu-btn.primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 40px rgba(238,90,36,0.6);
}
.menu-btn.secondary {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.12);
}
.menu-btn.secondary:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}
.menu-btn:active { transform: scale(0.97) !important; }

/* ===== HOW TO PLAY ===== */
.how-content { max-width: 440px; text-align: center; animation: slideUp 0.4s ease; }
.how-content h2 {
    font-family: 'Bangers', cursive;
    font-size: 2.5rem; margin-bottom: 1.5rem;
    color: #ffd93d;
}
.instructions { text-align: left; margin-bottom: 2rem; }
.instruction-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.instruction-item .icon { font-size: 1.8rem; flex-shrink: 0; width: 40px; text-align: center; }
.instruction-item p { font-size: 0.95rem; color: rgba(255,255,255,0.7); line-height: 1.4; }
.instruction-item strong { color: #ffd93d; }

/* ===== HUD ===== */
#hud { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.hud-top {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 1.2rem 1.5rem;
}
.hud-lives {
    display: flex; gap: 4px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}
.hud-lives .heart {
    font-size: 1.6rem;
    transition: all 0.3s ease;
    animation: heartBeat 1.5s ease infinite;
}
.hud-lives .heart.lost { opacity: 0.2; transform: scale(0.7); filter: grayscale(1); }
@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
}

.hud-score {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 0.5rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
}
.score-label { font-size: 0.65rem; letter-spacing: 3px; color: rgba(255,255,255,0.4); }
#hud-score-value {
    font-family: 'Bangers', cursive;
    font-size: 2rem; color: #ffd93d;
    text-shadow: 0 0 20px rgba(255,217,61,0.4);
}
.hud-best {
    font-family: 'Bangers', cursive;
    font-size: 1.1rem; color: rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
}

.hud-powerup {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    background: rgba(255,217,61,0.15);
    border: 1px solid rgba(255,217,61,0.3);
    padding: 0.6rem 1.5rem;
    border-radius: 30px;
    font-family: 'Bangers', cursive;
    font-size: 1.1rem; letter-spacing: 2px;
    color: #ffd93d;
    animation: powerupPulse 1s ease infinite;
}
@keyframes powerupPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(255,217,61,0.2); }
    50% { box-shadow: 0 0 30px rgba(255,217,61,0.4); }
}

/* ===== PAUSE MENU ===== */
.pause-content { max-width: 420px; text-align: center; animation: slideUp 0.4s ease; }
.pause-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(3rem, 8vw, 4rem);
    color: #ffd93d;
    text-shadow: 0 0 40px rgba(255,217,61,0.4);
    margin-bottom: 1.5rem;
}

/* ===== GAME OVER ===== */
.gameover-content { max-width: 420px; text-align: center; animation: slideUp 0.5s ease; }
.gameover-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(3rem, 8vw, 5rem);
    color: #ff6b6b;
    text-shadow: 0 0 40px rgba(255,107,107,0.4);
    margin-bottom: 1.5rem;
}
.gameover-stats { margin-bottom: 2rem; }
.stat {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stat-label { color: rgba(255,255,255,0.5); font-size: 1rem; }
.stat-value {
    font-family: 'Bangers', cursive;
    font-size: 1.8rem; color: #ffd93d;
}

/* ===== LEADERBOARD & SUBMIT ===== */
.score-submit { margin: 1.5rem 0; }
.score-submit p { margin-bottom: 0.5rem; color: #fff; font-weight: 600; font-size: 1.1rem; }
#player-name {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 0.8rem;
    outline: none;
}
#player-name:focus { border-color: #ffd93d; box-shadow: 0 0 10px rgba(255,217,61,0.2); }
#btn-submit-score { font-size: 1.2rem; margin-top: 0; padding: 0.8rem 1rem; }

.leaderboard { 
    margin: 1.5rem 0; 
    background: rgba(0,0,0,0.3); 
    border-radius: 12px; 
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}
.leaderboard h3 { 
    font-family: 'Bangers', cursive; 
    color: #ffd93d; 
    letter-spacing: 2px;
    margin-bottom: 0.8rem;
}
#leaderboard-list {
    list-style: none;
    text-align: left;
}
#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.95rem;
}
#leaderboard-list li:last-child { border-bottom: none; }
.leaderboard .rank { color: rgba(255,255,255,0.5); width: 30px; font-family: monospace; }
.leaderboard .name { color: #fff; flex: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 1rem; }
.leaderboard .pts { color: #ffd93d; font-family: 'Bangers', cursive; font-size: 1.1rem; text-align: right; }

/* ===== SCREEN EFFECTS ===== */
#screen-flash {
    position: fixed; inset: 0; z-index: 90;
    pointer-events: none;
    background: rgba(255, 50, 50, 0.3);
    opacity: 0;
    transition: opacity 0.1s ease;
}
#screen-flash.active { opacity: 1; }

/* ===== SHAKE ANIMATION ===== */
.shake {
    animation: shake 0.3s ease;
}
@keyframes shake {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-4px, 2px); }
    40% { transform: translate(4px, -2px); }
    60% { transform: translate(-2px, 4px); }
    80% { transform: translate(2px, -4px); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .menu-btn { width: 240px; font-size: 1.3rem; padding: 0.9rem 1.5rem; }
    .glass-panel { padding: 2rem 1.5rem; margin: 1rem; }
    .hud-top { padding: 0.8rem 1rem; }
    #hud-score-value { font-size: 1.5rem; }
    .hud-lives .heart { font-size: 1.3rem; }
}
