/* ==========================================================================
   Smash Fest! - Mobile & Desktop Game Stylesheet
   Festive carnival aesthetics, glassmorphism, responsive HUD & touch controls
   ========================================================================== */

:root {
    --primary: #ff3366;
    --primary-glow: rgba(255, 51, 102, 0.4);
    --gold: #ffd700;
    --gold-glow: rgba(255, 215, 0, 0.45);
    --accent: #00d2d3;
    --bg-dark: rgba(18, 22, 34, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.12);
    --border-glass: rgba(255, 255, 255, 0.25);
    --text-light: #ffffff;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Montserrat", sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
    position: fixed;
    background-color: #121826;
    font-family: var(--font-main);
    color: var(--text-light);
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    touch-action: none;
}

#canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ==========================================
   HUD Layout (Optimized for iPhone Dynamic Island & Home Bar)
   ========================================== */
#hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    overscroll-behavior: none;
}

.hud-interactive {
    pointer-events: auto;
    touch-action: manipulation;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.hud-panel {
    background: var(--bg-dark);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-glass);
    border-radius: 18px;
    padding: 8px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 10px;
}

.level-badge {
    display: flex;
    flex-direction: column;
}

.level-badge .game-logo {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

.level-badge .level-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

/* Center Stats */
.stats-group {
    display: flex;
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #a0aec0;
}

.stat-val {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.stat-val.gold {
    color: var(--gold);
}

/* Top Controls */
.top-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--bg-dark);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.btn-icon:hover {
    transform: translateY(-2px);
    background: rgba(30, 38, 58, 0.95);
    border-color: var(--accent);
}

.btn-icon:active {
    transform: scale(0.92);
}

.btn-lang {
    width: auto;
    padding: 0 12px;
    font-size: 13px;
}

.ammo-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 55px;
}

.ammo-balls {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 3px;
}

.ammo-ball-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #8892b0, #202738 70%, #0d111a);
    box-shadow: 0 2px 4px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.4);
    border: 1px solid #4a5568;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Level Cleared Celebration Toast */
.level-cleared-banner {
    position: absolute;
    top: calc(75px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.95), rgba(255, 107, 107, 0.95));
    border: 2px solid #fff;
    border-radius: 24px;
    padding: 10px 22px;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.5);
    z-index: 100;
    pointer-events: none;
    animation: bannerPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.level-cleared-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) scale(0.7);
    visibility: hidden;
}

.cleared-text {
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

@keyframes bannerPop {
    0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Bottom Booster Tray */
.bottom-bar {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
    padding-bottom: 6px;
}

.booster-dock {
    display: flex;
    gap: 10px;
    background: var(--bg-dark);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 22px;
    padding: 8px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.booster-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 8px 14px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 68px;
}

.booster-btn .b-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.booster-btn .b-name {
    font-size: 11px;
    font-weight: 700;
    color: #e2e8f0;
}

.booster-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-3px);
}

.booster-btn.active {
    background: linear-gradient(135deg, rgba(255, 51, 102, 0.4), rgba(255, 215, 0, 0.25));
    border-color: var(--gold);
    box-shadow: 0 0 16px var(--gold-glow);
    transform: translateY(-4px) scale(1.05);
}

.booster-btn.active .b-name {
    color: var(--gold);
}

/* Big Tactile Fire Button */
.btn-fire {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #ff2a5f, #ff6b35);
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-radius: 22px;
    padding: 12px 24px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 42, 95, 0.55), inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, filter 0.2s ease;
    min-height: 56px;
}

.btn-fire .fire-icon {
    font-size: 26px;
    filter: drop-shadow(0 0 8px rgba(255, 230, 0, 0.8));
    animation: firePulse 1.2s infinite alternate ease-in-out;
}

@keyframes firePulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(255, 230, 0, 0.5)); }
    100% { transform: scale(1.18); filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.9)); }
}

.btn-fire .fire-text {
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.btn-fire:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 12px 30px rgba(255, 42, 95, 0.75);
    filter: brightness(1.1);
}

.btn-fire:active {
    transform: scale(0.92);
    box-shadow: 0 4px 14px rgba(255, 42, 95, 0.4);
}

/* Aim instruction prompt */
.aim-tip {
    position: absolute;
    bottom: calc(95px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #e2e8f0;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: pulseTip 2s infinite ease-in-out;
}

@keyframes pulseTip {
    0%, 100% { opacity: 0.85; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.03); }
}

/* ==========================================
   Modals & Popups
   ========================================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 24, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 20px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-card {
    background: linear-gradient(145deg, #1f2738, #131926);
    border: 2px solid var(--border-glass);
    border-radius: 28px;
    padding: 30px 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px var(--primary-glow);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 26px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    margin-bottom: 8px;
}

.modal-subtitle {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 20px;
}

.stars-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 16px 0 22px 0;
}

.win-star {
    font-size: 44px;
    color: #4a5568;
    filter: grayscale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s ease;
}

.win-star.active {
    color: var(--gold);
    filter: drop-shadow(0 0 16px var(--gold-glow));
    transform: scale(1.2);
}

.score-summary-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 14px;
    color: #cbd5e1;
}

.summary-row.total {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 800;
    font-size: 17px;
    color: var(--gold);
}

.btn-primary {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #ff3366, #ff6b6b);
    border: none;
    border-radius: 18px;
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 51, 102, 0.4);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    margin-bottom: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(255, 51, 102, 0.6);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    width: 100%;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Level Select Grid */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 20px 0;
    max-height: 50vh;
    overflow-y: auto;
    padding: 4px;
}

.level-card {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #fff;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s;
    position: relative;
}

.level-card:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.level-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.2);
}

.lvl-num {
    font-size: 20px;
    font-weight: 900;
    color: var(--gold);
}

.lvl-name {
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.lvl-stars {
    font-size: 11px;
    color: var(--gold);
}

/* Responsive tweaks for mobile screens */
@media (max-width: 600px) {
    #hud-overlay {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    .top-bar {
        gap: 6px;
    }
    .hud-panel {
        padding: 5px 8px;
        gap: 6px;
        border-radius: 14px;
    }
    .level-badge .game-logo {
        font-size: 8px;
    }
    .level-badge .level-title {
        font-size: 13px;
        max-width: 85px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .stat-item {
        min-width: 42px;
    }
    .stat-label {
        font-size: 8px;
    }
    .stat-val {
        font-size: 13px;
    }
    .ammo-ball-icon {
        width: 10px;
        height: 10px;
    }
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 13px;
        border-radius: 10px;
    }
    .btn-lang {
        padding: 0 6px;
        font-size: 11px;
    }
    .levels-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .booster-dock {
        padding: 6px 10px;
        gap: 6px;
    }
    .booster-btn {
        padding: 6px 8px;
        min-width: 52px;
    }
    .booster-btn .b-icon {
        font-size: 18px;
    }
    .booster-btn .b-name {
        font-size: 9px;
    }
    .aim-tip {
        font-size: 11px;
        padding: 5px 12px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }
}
