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

/* Allow touch scrolling on all elements by default */
* {
    touch-action: pan-y;
}

/* Buttons and interactive elements use manipulation for better touch response */
button, .btn, .level-btn, .chapter-card, .dpad-btn, .toggle, .game-header-btn, .back-btn {
    touch-action: manipulation;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pan-x;
    background-image: url('../assets/background-main.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-image: url('../assets/background-main.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    position: relative;
    touch-action: pan-y pan-x;
}

/* View Container */
.view {
    display: none;
    width: 100%;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    overflow: visible;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.view.active {
    display: block;
    pointer-events: all;
    opacity: 1;
    transform: translateX(0);
    height: auto;
    min-height: 100vh;
    position: relative;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
}

.view.slide-in {
    opacity: 1;
    transform: translateX(0);
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
    color: white;
    border: none;
    padding: 1.2rem 3rem;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(231, 76, 60, 0.4), 0 0 0 4px rgba(255,255,255,0.3);
    transition: all 0.2s;
    margin: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.4), 0 0 0 2px rgba(255,255,255,0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #3498DB 0%, #2980B9 100%);
    box-shadow: 0 8px 15px rgba(52, 152, 219, 0.4), 0 0 0 4px rgba(255,255,255,0.3);
}

.btn-secondary:active {
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4), 0 0 0 2px rgba(255,255,255,0.3);
}

.btn-yellow {
    background: linear-gradient(135deg, #F1C40F 0%, #F39C12 100%);
    box-shadow: 0 8px 15px rgba(241, 196, 15, 0.4), 0 0 0 4px rgba(255,255,255,0.3);
}

.btn-yellow:active {
    box-shadow: 0 4px 8px rgba(241, 196, 15, 0.4), 0 0 0 2px rgba(255,255,255,0.3);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 400px;
    padding-bottom: 2rem;
}

/* Navigation */
.back-btn {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 15px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 8px rgba(149, 165, 166, 0.4);
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    z-index: 10;
}

.back-btn:hover {
    background: linear-gradient(135deg, #7f8c8d 0%, #6c7a7b 100%);
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.5);
}

.back-btn:active {
    transform: translateX(0) scale(0.95);
    box-shadow: 0 2px 5px rgba(149, 165, 166, 0.3);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(231, 76, 60, 0.7);
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.2);
    min-height: 30px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(231, 76, 60, 0.9);
}

::-webkit-scrollbar-thumb:active {
    background: rgba(231, 76, 60, 1);
}

::-webkit-scrollbar-corner {
    background: rgba(0,0,0,0.1);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(231, 76, 60, 0.7) rgba(0,0,0,0.1);
}

/* Mobile scrollbar */
@media (max-width: 480px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-thumb {
        border-width: 1px;
        min-height: 20px;
    }
}

/* Mobile optimizations - Touch devices */
@media (max-width: 480px), (hover: none) and (pointer: coarse) {
    html {
        height: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y pan-x !important;
        position: relative !important;
    }
    
    html {
        background-image: url('../assets/background-main.png');
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        background-attachment: fixed !important;
    }
    
    body {
        font-size: 14px;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y pan-x !important;
        height: auto !important;
        min-height: 100vh !important;
        position: relative !important;
        background: transparent !important;
    }

    .view {
        min-height: 100vh !important;
        height: auto !important;
        touch-action: pan-y pan-x !important;
        -webkit-overflow-scrolling: touch !important;
        overflow: visible !important;
        position: relative !important;
    }
    
    .view.active {
        height: auto !important;
        min-height: 100vh !important;
        touch-action: pan-y pan-x !important;
        overflow: visible !important;
        position: relative !important;
        display: block !important;
    }
    
    /* Force scroll on mobile */
    .levels-grid,
    .chapters-container,
    .settings-content,
    .achievements-content {
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overflow: visible !important;
    }
    
    /* iOS Safari specific fixes */
    @supports (-webkit-touch-callout: none) {
        html {
            height: 100% !important;
            overflow-y: auto !important;
            -webkit-overflow-scrolling: touch !important;
            position: relative !important;
            touch-action: pan-y pan-x !important;
            background-image: url('../assets/background-main.png') !important;
            background-size: cover !important;
            background-position: center center !important;
            background-repeat: no-repeat !important;
            background-attachment: fixed !important;
        }
        
        body {
            height: auto !important;
            min-height: 100vh !important;
            overflow-y: auto !important;
            -webkit-overflow-scrolling: touch !important;
            position: relative !important;
            touch-action: pan-y pan-x !important;
            background: transparent !important;
        }
        
        .view {
            height: auto !important;
            min-height: 100vh !important;
            overflow: visible !important;
            position: relative !important;
            touch-action: pan-y pan-x !important;
        }
        
        .view.active {
            position: relative !important;
            display: block !important;
        }
    }
}

    .btn {
        padding: 0.9rem 1.8rem;
        font-size: 1.1rem;
        margin: 0.3rem;
    }

    .menu-buttons {
        gap: 0.6rem;
        max-width: 100%;
        padding: 0 0.5rem 1rem 0.5rem;
    }

    .logo {
        font-size: 2.2rem;
        margin-bottom: 0.8rem;
    }

    .chicken-icon {
        width: 100px;
        height: 100px;
        margin-bottom: 1rem;
    }

    .back-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .chapter-title {
        font-size: 1.1rem;
    }

    .chapter-emoji {
        font-size: 2rem;
    }

    .level-btn {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
        min-height: 45px;
    }

    .level-number {
        font-size: 1rem;
    }

    .setting-label {
        font-size: 0.95rem;
    }

    .privacy-section h2 {
        font-size: 1.2rem;
    }

    .privacy-section h3 {
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .btn {
        padding: 0.9rem 1.5rem;
        font-size: 1.1rem;
    }

    .logo {
        font-size: 2rem;
    }

    .chicken-icon {
        width: 100px;
        height: 100px;
    }
}

