@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Inter:wght@400;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    background: #000;
    font-family: 'Inter', sans-serif;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
    z-index: 10;
    padding: 24px 32px;
}

#score {
    font-family: 'Fredoka One', cursive;
    font-size: 36px;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    transition: transform 0.15s ease;
    display: none;
}

#score::before {
    content: '\1FA99 ';
}

#score.bump {
    transform: scale(1.3);
}

/* Title Screen */
#title-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 100;
    transition: opacity 0.5s ease;
}

#title-screen h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 96px;
    color: #FFD700;
    text-shadow: 4px 4px 8px rgba(0,0,0,0.5);
    letter-spacing: 8px;
    animation: titlePulse 2s ease-in-out infinite;
}

#title-screen h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 32px;
    color: #87CEEB;
    margin-top: 8px;
    letter-spacing: 4px;
}

#title-screen .subtitle {
    color: #aaa;
    font-size: 16px;
    margin-top: 12px;
    font-style: italic;
}

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

#start-btn, #replay-btn {
    font-family: 'Fredoka One', cursive;
    font-size: 28px;
    padding: 16px 64px;
    margin-top: 48px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a2e;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
    pointer-events: all;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#start-btn:hover, #replay-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(255, 215, 0, 0.5);
}

.controls-hint {
    margin-top: 32px;
    display: flex;
    gap: 32px;
    color: #667;
    font-size: 14px;
}

.controls-hint span {
    background: rgba(255,255,255,0.08);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Show desktop or touch hints based on device */
.touch-controls-hint { display: none; }

@media (hover: none) and (pointer: coarse) {
    .desktop-controls { display: none !important; }
    .touch-controls-hint { display: flex !important; }
}

/* Win Screen */
#win-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
}

#win-screen h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 80px;
    color: #FFD700;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    animation: titlePulse 1.5s ease-in-out infinite;
}

#final-score {
    font-family: 'Fredoka One', cursive;
    font-size: 36px;
    color: #87CEEB;
    margin-top: 16px;
}

/* Death Toast */
#death-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Fredoka One', cursive;
    font-size: 48px;
    color: #ff6b6b;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.7);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#death-toast.show {
    opacity: 1;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    z-index: 200;
    color: #87CEEB;
    font-size: 18px;
    transition: opacity 0.5s ease;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(135, 206, 235, 0.2);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Touch Controls */
#touch-controls {
    position: fixed;
    inset: 0;
    z-index: 15;
    pointer-events: none;
}

#joystick-base {
    display: none;
    position: fixed;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    pointer-events: none;
}

#joystick-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.6);
    transition: transform 0.05s ease-out;
}

#jump-btn {
    position: fixed;
    bottom: 40px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.2);
    color: #FFD700;
    font-family: 'Fredoka One', cursive;
    font-size: 14px;
    pointer-events: all;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#jump-btn:active {
    background: rgba(255, 215, 0, 0.45);
    transform: scale(0.92);
}

/* Responsive - mobile/tablet */
@media (max-width: 768px) {
    #title-screen h1 {
        font-size: 48px;
        letter-spacing: 4px;
    }

    #title-screen h2 {
        font-size: 20px;
    }

    #start-btn, #replay-btn {
        font-size: 22px;
        padding: 14px 48px;
        margin-top: 32px;
    }

    .controls-hint {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-top: 20px;
    }

    .controls-hint span {
        font-size: 12px;
        padding: 6px 10px;
    }

    #score {
        font-size: 24px;
    }

    #hud {
        padding: 16px 16px;
    }

    #win-screen h1 {
        font-size: 48px;
    }

    #final-score {
        font-size: 24px;
    }

    #death-toast {
        font-size: 32px;
    }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    #jump-btn {
        bottom: calc(40px + env(safe-area-inset-bottom));
        right: calc(30px + env(safe-area-inset-right));
    }

    #hud {
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-left: calc(16px + env(safe-area-inset-left));
    }
}

.hidden {
    display: none !important;
}
