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

body {
    overflow: hidden;
    background: #0a1628;
    font-family: 'Bungee', Impact, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: all;
}

.screen.active {
    display: flex;
}

/* Title Screen */
.title-container {
    text-align: center;
    padding: 20px;
    max-width: 600px;
}

.game-title {
    font-family: 'Bungee Shade', 'Bungee', Impact, sans-serif;
    font-size: clamp(2.2rem, 7vw, 4.5rem);
    color: #ffe135;
    text-shadow: 
        4px 4px 0 #c4420a,
        -2px -2px 0 #ff6b35,
        0 0 30px rgba(255, 225, 53, 0.4);
    line-height: 1.1;
    margin-bottom: 8px;
    animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0) rotate(-0.5deg); }
    50% { transform: translateY(-8px) rotate(0.5deg); }
}

.title-icons {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin: 10px 0;
    animation: iconBounce 1.5s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.subtitle {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(0.8rem, 2.5vw, 1.1rem);
    color: #7fdbff;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(127, 219, 255, 0.5);
}

.game-btn {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    padding: 14px 48px;
    border: 4px solid #c4420a;
    border-radius: 50px;
    background: linear-gradient(180deg, #ffe135 0%, #ffb800 100%);
    color: #5a2d00;
    cursor: pointer;
    display: block;
    margin: 12px auto;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 6px 0 #8b5e00, 0 8px 20px rgba(0,0,0,0.4);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #8b5e00, 0 12px 25px rgba(0,0,0,0.5);
}

.game-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #8b5e00, 0 4px 10px rgba(0,0,0,0.3);
}

.game-btn.secondary {
    background: linear-gradient(180deg, #7fdbff 0%, #39a0c9 100%);
    border-color: #1a6e8e;
    color: #0a2a3a;
    box-shadow: 0 6px 0 #1a6e8e, 0 8px 20px rgba(0,0,0,0.4);
    font-size: clamp(0.85rem, 2.2vw, 1.1rem);
    padding: 10px 36px;
}

.game-btn.secondary:hover {
    box-shadow: 0 8px 0 #1a6e8e, 0 12px 25px rgba(0,0,0,0.5);
}

.game-btn.secondary:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #1a6e8e, 0 4px 10px rgba(0,0,0,0.3);
}

.game-btn.pulse {
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.instructions {
    margin: 18px auto;
    max-width: 380px;
}

.instructions p {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(0.65rem, 1.8vw, 0.85rem);
    color: #a0d8ef;
    margin: 6px 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.highscore {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: #ffcc00;
    margin-top: 16px;
    padding: 10px 24px;
    background: rgba(0,0,0,0.4);
    border-radius: 20px;
    border: 2px solid rgba(255, 204, 0, 0.3);
    display: inline-block;
}

/* Game Over Screen */
.gameover-container {
    text-align: center;
    padding: 20px;
    max-width: 550px;
    background: radial-gradient(ellipse at center, rgba(180, 20, 20, 0.25) 0%, transparent 70%);
    border-radius: 30px;
    padding: 30px;
}

.gameover-title {
    font-family: 'Bungee Shade', 'Bungee', Impact, sans-serif;
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    color: #ff4444;
    text-shadow: 
        3px 3px 0 #7a0000,
        0 0 20px rgba(255, 68, 68, 0.5);
    line-height: 1.1;
    animation: shakeTitle 0.5s ease-in-out;
}

@keyframes shakeTitle {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-2deg); }
    40% { transform: translateX(10px) rotate(2deg); }
    60% { transform: translateX(-6px) rotate(-1deg); }
    80% { transform: translateX(6px) rotate(1deg); }
}

.gameover-icons {
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 8px 0 12px;
}

.death-message {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(0.8rem, 2.2vw, 1.1rem);
    color: #ffaa44;
    font-style: italic;
    margin-bottom: 16px;
}

.final-stats {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    padding: 14px 20px;
    margin: 14px auto;
    max-width: 340px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: clamp(0.75rem, 2vw, 1rem);
    color: #cce;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-row:last-child {
    border-bottom: none;
    color: #ffe135;
    font-size: clamp(0.85rem, 2.3vw, 1.15rem);
}

.new-highscore {
    font-family: 'Bungee', Impact, sans-serif;
    font-size: clamp(1rem, 2.8vw, 1.4rem);
    color: #ffe135;
    animation: newHS 0.6s ease-in-out infinite alternate;
    margin: 10px 0;
}

@keyframes newHS {
    0% { transform: scale(1); text-shadow: 0 0 10px #ffe135; }
    100% { transform: scale(1.08); text-shadow: 0 0 25px #ffe135, 0 0 50px #ffb800; }
}

/* Joystick */
#joystick-zone {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 20;
    pointer-events: all;
}

#joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 3px solid rgba(255, 255, 255, 0.25);
    position: relative;
    backdrop-filter: blur(4px);
}

#joystick-knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 225, 53, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
}

/* Footer */
#game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 15;
    text-align: center;
    padding: 6px 10px;
    font-family: 'Bungee', Impact, sans-serif;
    font-size: 0.55rem;
    color: rgba(160, 216, 239, 0.5);
    background: linear-gradient(transparent, rgba(10, 22, 40, 0.8));
    pointer-events: none;
}

#game-footer a {
    color: rgba(255, 225, 53, 0.6);
    text-decoration: none;
    pointer-events: all;
    margin-left: 12px;
}

#game-footer a:hover {
    color: #ffe135;
}

@media (max-width: 600px) {
    .game-btn {
        padding: 12px 36px;
    }
    .instructions {
        margin: 12px auto;
    }
}