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

body {
    font-family: 'Exo 2', sans-serif;
    background: #000;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
}

/* Tap to Start Screen */
#tapToStart {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #000814 0%, #001d3d 50%, #000814 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    cursor: pointer;
    transition: opacity 0.5s ease-out;
}

#tapToStart.hidden {
    opacity: 0;
    pointer-events: none;
}

#tapToStart.fade-out {
    display: none;
}

.tap-content {
    text-align: center;
    animation: pulse-tap 2s infinite;
}

.tap-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: float-ufo 3s ease-in-out infinite;
    filter: drop-shadow(0 0 30px #00ff88);
}

.tap-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: #00ff88;
    text-shadow: 0 0 20px #00ff88, 0 0 40px rgba(0, 255, 136, 0.6), 0 0 60px rgba(0, 255, 136, 0.3);
    margin-bottom: 30px;
    letter-spacing: 6px;
}

.tap-instruction {
    font-family: 'Exo 2', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: #88ffcc;
    margin-bottom: 20px;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(136, 255, 204, 0.5);
}

.tap-hint {
    font-size: 40px;
    color: #00ff88;
    animation: bounce-hint 1.5s infinite;
    text-shadow: 0 0 15px #00ff88;
}

@keyframes pulse-tap {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

@keyframes bounce-hint {
    0%, 100% { transform: translateY(0px); opacity: 1; }
    50% { transform: translateY(15px); opacity: 0.6; }
}

/* Mobile optimization for tap screen */
@media (max-width: 480px) {
    .tap-title {
        font-size: 32px;
        letter-spacing: 4px;
        padding: 0 20px;
    }

    .tap-instruction {
        font-size: 16px;
        letter-spacing: 2px;
        padding: 0 20px;
    }

    .tap-icon {
        font-size: 60px;
    }
}

/* Video Intro */
#videoIntro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 1s ease-out;
}

#videoIntro.fade-out {
    opacity: 0;
    pointer-events: none;
}

#videoIntro.hidden {
    display: none;
}

#introVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* UI Overlay */
#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: none; /* Hidden until game starts */
}

#ui > * {
    pointer-events: auto;
}

/* Top HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 40, 0.85);
    border: 2px solid #00ff88;
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), inset 0 0 15px rgba(0, 255, 136, 0.1);
    backdrop-filter: blur(10px);
    min-width: 280px;
    max-width: 90vw;
    text-align: center;
}

#score {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #00ff88;
    text-shadow: 0 0 10px #00ff88, 0 0 20px rgba(0, 255, 136, 0.5);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

#weightBar {
    margin: 10px 0;
}

.weight-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    color: #88ffcc;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.weight-container {
    width: 100%;
    height: 18px;
    background: rgba(0, 50, 100, 0.5);
    border: 1px solid #00ff88;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

#weightFill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00ff88, #ffaa00, #ff4444);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
    transition: width 0.3s ease, background 0.3s ease;
    position: relative;
}

#weightFill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.weight-status {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 1px;
}

.weight-status.optimal { color: #00ff88; text-shadow: 0 0 5px #00ff88; }
.weight-status.warning { color: #ffaa00; text-shadow: 0 0 5px #ffaa00; }
.weight-status.critical { color: #ff4444; text-shadow: 0 0 5px #ff4444; animation: blink 0.5s infinite; }

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

#stats {
    display: flex;
    justify-content: space-around;
    margin-top: 8px;
    font-size: 13px;
    gap: 10px;
}

.stat {
    font-family: 'Exo 2', sans-serif;
    color: #88ffcc;
    text-shadow: 0 0 5px rgba(136, 255, 204, 0.5);
    font-weight: 400;
}

#altitude {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    color: #00ccff;
    margin-top: 8px;
    text-shadow: 0 0 5px #00ccff;
    letter-spacing: 1px;
}

#altitudeValue {
    font-weight: 700;
}

/* Buttons */
.btn {
    font-family: 'Orbitron', sans-serif;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 700;
    color: #00ff88;
    background: rgba(0, 20, 40, 0.85);
    border: 2px solid #00ff88;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3), inset 0 0 10px rgba(0, 255, 136, 0.1);
    backdrop-filter: blur(5px);
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.6), inset 0 0 15px rgba(0, 255, 136, 0.2);
}

.btn-trade {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    padding: 16px 32px;
    animation: pulse-trade 2s infinite;
}

@keyframes pulse-trade {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
        border-color: #00ff88;
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 170, 0, 0.6);
        border-color: #ffaa00;
    }
}

.btn-shop {
    position: absolute;
    bottom: 80px;
    right: 20px;
    padding: 12px 20px;
    font-size: 13px;
}

.btn-pause {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 10px 16px;
    font-size: 13px;
    z-index: 20;
}

#comboDisplay {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: rgba(255, 170, 0, 0.2);
    border: 2px solid #ffaa00;
    border-radius: 8px;
    padding: 10px 18px;
    color: #ffaa00;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-shadow: 0 0 10px #ffaa00;
    display: none;
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.4);
    letter-spacing: 1px;
}

#comboDisplay.active {
    display: block;
    animation: pulse-combo 0.5s infinite;
}

@keyframes pulse-combo {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Menu Screen */
#menuScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #000814 0%, #001d3d 50%, #000814 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1s ease-in; /* Match video fade-out timing */
}

#menuScreen.fade-in {
    opacity: 1;
}

.menu-stars {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

#ufoAnimation {
    position: absolute;
    top: 15%;
    font-size: 60px;
    animation: float-ufo 3s ease-in-out infinite;
    filter: drop-shadow(0 0 20px #00ff88);
}

@keyframes float-ufo {
    0%, 100% { transform: translateY(0px) rotate(-5deg); }
    50% { transform: translateY(-25px) rotate(5deg); }
}

#title {
    font-family: 'Orbitron', sans-serif;
    font-size: 42px;
    font-weight: 900;
    color: #00ff88;
    text-shadow: 0 0 20px #00ff88, 0 0 40px rgba(0, 255, 136, 0.6), 0 0 60px rgba(0, 255, 136, 0.3);
    margin-bottom: 8px;
    letter-spacing: 6px;
    animation: pulse-title 2s infinite;
    position: relative;
    z-index: 2;
    text-align: center;
}

@keyframes pulse-title {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

#subtitle {
    font-family: 'Exo 2', sans-serif;
    font-size: 16px;
    font-weight: 300;
    color: #88ffcc;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(136, 255, 204, 0.5);
    letter-spacing: 3px;
    position: relative;
    z-index: 2;
}

#menuStats {
    background: rgba(0, 20, 40, 0.7);
    border: 2px solid #00ff88;
    border-radius: 12px;
    padding: 20px 28px;
    margin-bottom: 30px;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 2;
    max-width: 90vw;
}

.menu-stat-line {
    font-family: 'Exo 2', sans-serif;
    color: #88ffcc;
    font-size: 15px;
    font-weight: 400;
    margin: 10px 0;
    text-shadow: 0 0 5px rgba(136, 255, 204, 0.5);
    letter-spacing: 1px;
}

.menu-emoji {
    display: inline-block;
    margin-right: 8px;
    font-size: 18px;
}

.btn-start {
    font-size: 20px;
    padding: 18px 40px;
    animation: glow-start 1.5s infinite;
    z-index: 2;
    letter-spacing: 3px;
}

@keyframes glow-start {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), inset 0 0 10px rgba(0, 255, 136, 0.1);
    }
    50% { 
        box-shadow: 0 0 40px rgba(0, 255, 136, 0.8), inset 0 0 20px rgba(0, 255, 136, 0.3);
    }
}

/* Shop Modal */
#shopModal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 3px solid #00ff88;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.5);
    backdrop-filter: blur(10px);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

#shopModal.active {
    display: block;
}

.shop-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #00ff88;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 0 0 15px #00ff88;
    letter-spacing: 2px;
}

.currency-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    color: #ffaa00;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ffaa00;
    letter-spacing: 1px;
}

.upgrade-item {
    background: rgba(0, 255, 136, 0.1);
    border: 2px solid #00ff88;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.upgrade-item:active {
    transform: scale(0.98);
}

.upgrade-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    color: #00ff88;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.upgrade-desc {
    font-family: 'Exo 2', sans-serif;
    font-size: 13px;
    color: #88ffcc;
    margin-bottom: 8px;
    font-weight: 300;
}

.upgrade-cost {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: #ffff00;
    text-shadow: 0 0 5px rgba(255, 255, 0, 0.5);
    font-weight: 600;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    font-size: 20px;
    padding: 5px;
    border-radius: 50%;
}

/* Game Over Screen */
#gameOverScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 150;
    backdrop-filter: blur(10px);
}

#gameOverScreen.active {
    display: flex;
}

.game-over-content {
    text-align: center;
    padding: 30px;
    background: rgba(0, 20, 40, 0.9);
    border: 3px solid #ff4444;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(255, 68, 68, 0.5);
    max-width: 90vw;
}

.game-over-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
    margin-bottom: 10px;
    letter-spacing: 4px;
    animation: shake 0.5s infinite;
}

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

.game-over-subtitle {
    font-family: 'Exo 2', sans-serif;
    font-size: 18px;
    color: #ffaa00;
    margin-bottom: 25px;
    letter-spacing: 2px;
}

#finalStats {
    margin: 25px 0;
}

.final-stat {
    font-family: 'Exo 2', sans-serif;
    font-size: 16px;
    color: #88ffcc;
    margin: 10px 0;
    letter-spacing: 1px;
}

.final-stat span {
    font-family: 'Orbitron', sans-serif;
    color: #00ff88;
    font-weight: 700;
}

.btn-restart {
    font-size: 18px;
    padding: 16px 36px;
    letter-spacing: 2px;
}

/* Pause Modal */
#pauseModal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(15px);
}

#pauseModal.active {
    display: flex;
}

.pause-content {
    text-align: center;
    padding: 30px;
    background: rgba(0, 20, 40, 0.95);
    border: 3px solid #00ff88;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.5);
    max-width: 90vw;
    min-width: 320px;
}

.pause-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: #00ff88;
    text-shadow: 0 0 20px #00ff88;
    margin-bottom: 25px;
    letter-spacing: 3px;
}

.settings-section {
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 255, 136, 0.05);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 10px;
}

.setting-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    color: #00ff88;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.setting-item {
    margin: 15px 0;
}

.setting-label {
    font-family: 'Exo 2', sans-serif;
    font-size: 15px;
    color: #88ffcc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    letter-spacing: 1px;
}

.setting-label input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #00ff88;
}

.difficulty-select {
    font-family: 'Orbitron', sans-serif;
    padding: 8px 12px;
    background: rgba(0, 20, 40, 0.9);
    border: 2px solid #00ff88;
    border-radius: 5px;
    color: #00ff88;
    font-size: 13px;
    cursor: pointer;
    letter-spacing: 1px;
}

.difficulty-select:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.btn-apply {
    margin-top: 15px;
    font-size: 13px;
    padding: 10px 20px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.btn-resume,
.btn-quit {
    font-size: 16px;
    padding: 14px 28px;
    letter-spacing: 2px;
}

.btn-quit {
    border-color: #ff4444;
    color: #ff4444;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.3);
}

.btn-quit:active {
    box-shadow: 0 0 25px rgba(255, 68, 68, 0.6);
}

/* Particle effects */
.particle {
    position: absolute;
    pointer-events: none;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #00ff88;
    text-shadow: 0 0 10px #00ff88;
    animation: float-up 1s ease-out forwards;
    letter-spacing: 1px;
}

@keyframes float-up {
    to {
        transform: translateY(-80px);
        opacity: 0;
    }
}

/* Mobile optimization */
@media (max-width: 480px) {
    #title {
        font-size: 32px;
        letter-spacing: 4px;
        text-align: center;
        width: 100%;
        padding: 0 20px;
    }

    #subtitle {
        font-size: 13px;
        text-align: center;
    }

    .btn {
        font-size: 12px;
        padding: 12px 20px;
    }

    #score {
        font-size: 18px;
    }

    .menu-stat-line {
        font-size: 13px;
    }
}

/* Prevent scrolling on mobile */
html, body {
    overscroll-behavior: none;
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* iOS Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}
