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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    font-family: 'Fredoka', 'Comic Sans MS', cursive, sans-serif;
    background: #000;
}

#game-canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

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

/* ========== UI Layer ========== */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* ========== HUD ========== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
}

#coin-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

#coin-icon {
    font-size: 1.5rem;
}

#level-indicator {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

#lives-display {
    font-size: 1.3rem;
}

/* ========== Touch Controls ========== */
#touch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75%;
    pointer-events: auto;
    z-index: 15;
}

#joystick-zone {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 45%;
    height: 100%;
}

#joystick-base {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: none;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -50%);
}

#joystick-thumb {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s;
}

#jump-button {
    position: absolute;
    right: 25px;
    bottom: max(30px, env(safe-area-inset-bottom));
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background: rgba(244, 114, 182, 0.7);
    border: 3px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 5;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.06s, background 0.06s;
}

#jump-button.pressed {
    transform: scale(0.9);
    background: rgba(244, 114, 182, 0.95);
}

/* ========== Overlays ========== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 100;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.overlay-content {
    text-align: center;
    padding: 40px 30px;
    max-width: 400px;
    width: 90%;
}

.game-title-text {
    font-size: 3rem;
    color: #fff;
    text-shadow: 3px 3px 0 rgba(244, 114, 182, 0.8), 6px 6px 0 rgba(0,0,0,0.15);
    margin-bottom: 10px;
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.game-subtitle {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 30px;
}

.big-button {
    display: inline-block;
    padding: 16px 50px;
    margin: 10px;
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #f472b6, #a78bfa);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 1px;
}

.big-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.big-button.secondary {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    font-size: 1rem;
    padding: 12px 35px;
}

.back-link {
    display: block;
    margin-top: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    text-decoration: none;
    pointer-events: auto;
}

/* Level Select */
#level-select {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.level-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s, background 0.1s;
}

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

.level-btn.unlocked {
    background: rgba(167, 139, 250, 0.5);
}

.level-btn.selected {
    background: rgba(244, 114, 182, 0.8);
    border-color: #fff;
    transform: scale(1.1);
}

.level-btn.locked {
    opacity: 0.35;
    pointer-events: none;
}

/* Death Screen */
.death-text {
    font-size: 3rem;
    color: #fff;
    animation: deathShake 0.4s ease-out;
}

@keyframes deathShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-15px); }
    40% { transform: translateX(15px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}

/* Level Complete */
.complete-title {
    font-size: 2.2rem;
    color: #fbbf24;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

#complete-stars {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

#complete-coins {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 25px;
}

/* Camera rotation zone - no longer used, camera handled on canvas */
#camera-zone {
    display: none;
}

/* View toggle button */
#view-toggle {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 15px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    z-index: 25;
    display: none;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

#view-toggle.active {
    background: rgba(244, 114, 182, 0.6);
    border-color: rgba(244, 114, 182, 0.8);
}

/* Pause Button */
#pause-button {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    z-index: 25;
    display: none;
}

/* Camera hint (mobile) */
#camera-hint {
    position: absolute;
    left: 50%;
    top: 5%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    z-index: 30;
    display: none;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    animation: hintFade 3s ease-out forwards;
}

@keyframes hintFade {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========== Desktop keyboard hint ========== */
@media (hover: hover) and (pointer: fine) {
    #touch-controls {
        display: none;
    }
    #camera-hint {
        display: none !important;
    }
    #hud::after {
        content: 'WASD + Mouse + Space  |  V = toggle view';
        font-size: 0.7rem;
        color: rgba(255,255,255,0.4);
        position: absolute;
        bottom: -18px;
        right: 20px;
    }
}

/* ========== Tablet adjustments ========== */
@media (min-width: 768px) {
    #jump-button {
        width: 100px;
        height: 100px;
        font-size: 1rem;
        right: 40px;
        bottom: 50px;
    }
    #joystick-base {
        width: 140px;
        height: 140px;
    }
    #joystick-thumb {
        width: 60px;
        height: 60px;
    }
}
