/* Bouncy Ball - Mobile-First Styles */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --dark-color: #1a1a2e;
    --darker-color: #0f0f1a;
    --light-color: #f7f7f7;
    --success-color: #6BCB77;
    --danger-color: #FF4444;
    --purple-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --sunset-gradient: linear-gradient(135deg, #FF6B6B 0%, #FFE66D 100%);
    --ocean-gradient: linear-gradient(135deg, #4ECDC4 0%, #556270 100%);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    background: var(--darker-color);
    color: var(--light-color);
}

/* Prevent pull-to-refresh and overscroll */
body {
    overscroll-behavior: none;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Main App Container */
#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--dark-color);
    background-image: url('../assets/background.png');
    background-size: cover;
    background-position: center;
}

/* Overlay for better readability */
#app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.7);
    z-index: 0;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 1;
    padding: 20px;
    padding-top: env(safe-area-inset-top, 20px);
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.screen.active {
    display: flex;
}

/* Menu Screen */
#menu-screen {
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.app-icon {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    animation: bounce 2s ease-in-out infinite;
}

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

.app-title {
    font-size: 2.5rem;
    font-weight: 900;
    background: var(--sunset-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 280px;
}

/* Buttons */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--sunset-gradient);
    color: var(--dark-color);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.btn-secondary {
    background: var(--ocean-gradient);
    color: var(--light-color);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-icon {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Levels Screen */
#levels-screen {
    padding-top: 70px;
}

.screen-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top));
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.screen-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--light-color);
}

.back-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--light-color);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

.stars-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 230, 109, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--accent-color);
}

.stars-display .star-icon {
    font-size: 1.2rem;
}

/* Level Grid */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
}

.level-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 16px;
    color: var(--light-color);
    font-weight: 700;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.level-btn.unlocked {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(86, 98, 112, 0.2) 100%);
    border-color: var(--secondary-color);
}

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

.level-btn.completed {
    background: linear-gradient(135deg, rgba(107, 203, 119, 0.2) 0%, rgba(78, 205, 196, 0.2) 100%);
    border-color: var(--success-color);
}

.level-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-btn .lock-icon {
    font-size: 1.5rem;
    opacity: 0.7;
}

.level-stars {
    display: flex;
    gap: 2px;
    font-size: 0.7rem;
}

.level-stars .star {
    color: #444;
}

.level-stars .star.earned {
    color: var(--accent-color);
}

/* Settings Screen */
#settings-screen {
    padding-top: 70px;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.settings-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 600;
    font-size: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 60px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch.active {
    background: var(--success-color);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    background: var(--light-color);
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
    left: calc(100% - 28px);
}

/* Language Selector */
.language-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.lang-btn {
    flex: 1;
    min-width: 80px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--light-color);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.lang-btn.active {
    background: var(--purple-gradient);
    border-color: rgba(255, 255, 255, 0.3);
}

.lang-btn:active {
    transform: scale(0.95);
}

/* About Screen */
#about-screen {
    padding-top: 70px;
}

.about-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
    -webkit-overflow-scrolling: touch;
    margin-top: 60px;
    padding-top: 20px;
}

.about-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.about-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 12px;
}

.about-section p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: rgba(247, 247, 247, 0.8);
}

.policy-text {
    font-size: 0.95rem;
    line-height: 1.8;
    color: rgba(247, 247, 247, 0.9);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: 'Nunito', sans-serif;
    margin: 0;
    padding: 0;
    text-align: left;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Policy screen specific styles */
#policy-screen .about-content {
    padding: 25px 20px 30px;
    margin-top: 75px;
    padding-top: 30px;
    scroll-padding-top: 0;
}

#policy-screen .about-content:first-child {
    scroll-margin-top: 0;
}

#policy-screen .about-section {
    padding: 20px;
    margin-bottom: 0;
    margin-top: 0;
}

#policy-screen .policy-text {
    margin-top: 0;
    padding-top: 0;
}

@media (max-width: 480px) {
    #policy-screen .about-content {
        padding: 20px 15px 25px;
        margin-top: 65px;
        padding-top: 20px;
    }
    
    #policy-screen .about-section {
        padding: 15px;
    }
    
    .policy-text {
        font-size: 0.9rem;
        line-height: 1.7;
    }
    
    .about-content {
        margin-top: 60px;
        padding-top: 15px;
    }
}

.version-info {
    text-align: center;
    padding: 20px;
    color: rgba(247, 247, 247, 0.5);
    font-size: 0.9rem;
}

/* Game Screen */
#game-screen {
    padding: 0;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
    z-index: 10;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.level-indicator {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
}

.stars-counter {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    color: var(--accent-color);
}

.stars-counter .star-icon {
    font-size: 1.2rem;
}

.pause-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--light-color);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pause-btn:active {
    transform: scale(0.9);
}

/* Game Canvas */
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Control Zones Overlay (visual hint) */
.control-zones {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    display: flex;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-screen.show-controls .control-zones {
    opacity: 1;
}

.control-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.1);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--dark-color);
    border-radius: 24px;
    padding: 30px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 20px;
}

.modal-title.success {
    background: var(--sunset-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-title.failure {
    color: var(--danger-color);
}

.modal-stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    font-size: 2.5rem;
}

.modal-stars .star {
    color: #444;
    transition: all 0.3s ease;
}

.modal-stars .star.earned {
    color: var(--accent-color);
    animation: starPop 0.5s ease;
}

@keyframes starPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.modal-message {
    font-size: 1rem;
    color: rgba(247, 247, 247, 0.7);
    margin-bottom: 25px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Pause Modal */
.pause-modal .modal-buttons {
    gap: 10px;
}

/* Tap to Start Overlay */
.tap-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    cursor: pointer;
}

.tap-overlay.hidden {
    display: none;
}

.tap-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--light-color);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.tap-hint {
    font-size: 0.9rem;
    color: rgba(247, 247, 247, 0.6);
    margin-top: 10px;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--darker-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-ball {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: loadingBounce 0.6s ease-in-out infinite;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
}

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

.loading-text {
    margin-top: 20px;
    font-size: 1rem;
    color: rgba(247, 247, 247, 0.6);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .levels-grid {
        grid-template-columns: repeat(5, 1fr);
        max-width: 500px;
        margin: 0 auto;
    }
    
    .modal {
        max-width: 400px;
    }
    
    .menu-buttons {
        max-width: 320px;
    }
}

@media (max-height: 600px) {
    .app-icon {
        width: 80px;
        height: 80px;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

