/* ============================================
   RESET & BASE STYLES
   ============================================ */

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

:root {
    --primary-black: #121212;
    --vibrant-red: #E63946;
    --neon-green: #2A9D8F;
    --bright-green: #06FFA5;
    --white: #FFFFFF;
    --gray: #2A2A2A;
    --light-gray: #3A3A3A;
    --gold: #FFD700;
    --silver: #C0C0C0;
    --bronze: #CD7F32;
}

body {
    font-family: 'Roboto', 'Oswald', sans-serif;
    background: var(--primary-black);
    background-image: url('assets/images/backgroundall.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--white);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    position: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   MAIN MENU
   ============================================ */

#mainMenu {
    justify-content: center;
    align-items: center;
    position: relative;
}

.menu-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('assets/images/backgroundall.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.stadium-lights {
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(230, 57, 70, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(42, 157, 143, 0.1) 0%, transparent 50%);
    animation: rotateLights 20s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes rotateLights {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.menu-content {
    position: relative;
    z-index: 100;
    text-align: center;
    padding: 20px;
    pointer-events: auto;
}

.game-title {
    font-family: 'Oswald', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--white);
    text-shadow: 0 0 20px rgba(230, 57, 70, 0.5),
                 0 0 40px rgba(230, 57, 70, 0.3),
                 0 4px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 60px;
    animation: titlePulse 2s ease-in-out infinite;
}

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

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 300px;
    margin: 0 auto;
}

.btn-image {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
    z-index: 10;
}

.btn-image img {
    width: 100%;
    height: auto;
    display: block;
    max-width: 300px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-image:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

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

/* ============================================
   BUTTONS
   ============================================ */

button {
    font-family: 'Oswald', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    border: none;
    border-radius: 12px;
    padding: 18px 32px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
    z-index: 10;
}

button:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--vibrant-red) 0%, #C1121F 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4),
                0 0 20px rgba(230, 57, 70, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.6),
                0 0 30px rgba(230, 57, 70, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
    border: 2px solid var(--light-gray);
}

.btn-secondary:hover {
    background: var(--light-gray);
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--vibrant-red) 0%, #C1121F 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
    margin-top: 20px;
}

.btn-back {
    background: transparent;
    color: var(--white);
    font-size: 1rem;
    padding: 10px 20px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
}

.btn-back:hover {
    background: var(--light-gray);
    border-color: var(--neon-green);
}

.btn-pause {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    font-size: 1.5rem;
    padding: 10px 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

/* ============================================
   SCREEN HEADER
   ============================================ */

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--gray);
    position: sticky;
    top: 0;
    z-index: 100;
}

.screen-header h2 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    flex: 1;
    text-align: center;
}

/* ============================================
   LEVEL SELECT
   ============================================ */

.chapters-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chapter-card {
    background: linear-gradient(135deg, var(--gray) 0%, var(--light-gray) 100%);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

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

.chapter-card:hover::before {
    left: 100%;
}

.chapter-card:hover {
    transform: translateY(-4px);
    border-color: var(--neon-green);
    box-shadow: 0 8px 25px rgba(42, 157, 143, 0.3);
}

.chapter-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.chapter-header h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.8rem;
    color: var(--white);
    margin-bottom: 5px;
}

.chapter-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.chapter-progress {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--primary-black);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-green) 0%, var(--bright-green) 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(42, 157, 143, 0.5);
}

.progress-text {
    font-size: 0.9rem;
    color: var(--white);
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.levels-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 100%;
}

.level-button {
    aspect-ratio: 1;
    background: var(--gray);
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.level-button:hover:not(.locked) {
    transform: scale(1.1);
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.4);
}

.level-button.locked {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--primary-black);
}

.level-button.completed {
    background: linear-gradient(135deg, var(--gray) 0%, var(--light-gray) 100%);
    border-color: var(--neon-green);
}

.level-stars {
    font-size: 0.7rem;
    color: var(--gold);
    margin-top: 2px;
    letter-spacing: 2px;
}

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

/* ============================================
   GAME SCREEN
   ============================================ */

#gameScreen {
    background: var(--primary-black);
    background-image: url('assets/images/backgroundplay.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--gray);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 600;
}

.game-info span {
    transition: all 0.3s ease;
}

#gameCanvas {
    flex: 1;
    width: 100%;
    min-height: 400px;
    display: block;
    background-image: url('assets/images/backgroundplay.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    touch-action: none;
    position: relative;
    z-index: 1;
}

.game-instructions {
    padding: 15px;
    text-align: center;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-top: 2px solid var(--gray);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, var(--gray) 0%, var(--light-gray) 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    border: 2px solid var(--neon-green);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(42, 157, 143, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--white);
}

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

.star {
    color: var(--gray);
    transition: all 0.3s ease;
}

.star.active {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    transform: scale(1.2);
}

.modal-content .btn-primary,
.modal-content .btn-secondary {
    width: 100%;
    margin: 10px 0;
}

/* ============================================
   ACHIEVEMENTS SCREEN
   ============================================ */

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px;
}

.stat-card {
    background: var(--gray);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 2px solid var(--light-gray);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
    font-weight: 400;
}

.stat-card p {
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    color: var(--neon-green);
    font-weight: 700;
}

.achievements-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.achievement-item {
    background: var(--gray);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 2px solid var(--light-gray);
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.2);
}

.achievement-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-black);
    border-radius: 50%;
    flex-shrink: 0;
}

.achievement-item.unlocked .achievement-icon {
    background: linear-gradient(135deg, var(--neon-green) 0%, var(--bright-green) 100%);
    box-shadow: 0 0 20px rgba(42, 157, 143, 0.4);
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    color: var(--white);
    margin-bottom: 5px;
}

.achievement-desc {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.achievement-progress {
    font-size: 0.8rem;
    color: var(--neon-green);
    margin-top: 5px;
}

/* ============================================
   SETTINGS SCREEN
   ============================================ */

.settings-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--gray);
    border-radius: 12px;
    border: 2px solid var(--light-gray);
}

.setting-item label {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--white);
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--light-gray);
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: var(--white);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(42, 157, 143, 0.4);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.reset-confirm {
    margin-top: 20px;
    padding: 20px;
    background: rgba(230, 57, 70, 0.1);
    border-radius: 12px;
    border: 2px solid var(--vibrant-red);
}

.reset-confirm p {
    margin-bottom: 15px;
    color: var(--white);
}

.reset-buttons {
    display: flex;
    gap: 10px;
}

.reset-buttons button {
    flex: 1;
}

/* ============================================
   ANIMATIONS & EFFECTS
   ============================================ */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s ease;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.flash {
    animation: flash 0.3s ease;
}

@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--neon-green);
    animation: confetti 1s ease-out forwards;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
    .game-title {
        font-size: 3rem;
        margin-bottom: 40px;
    }

    .menu-buttons {
        max-width: 100%;
    }

    button {
        font-size: 1rem;
        padding: 15px 25px;
    }

    .levels-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

@media (max-width: 360px) {
    .game-title {
        font-size: 2.5rem;
    }

    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideUp 0.3s ease;
}

