@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');



:root {

    --primary: #7841c9;

    --primary-light: #9f6fea;

    --primary-dark: #5d21b0;

    --secondary: #ff4757;

    --secondary-light: #ff6b7a;

    --success: #20bf6b;

    --warning: #f7b731;

    --info: #3b82f6;

    --bg-light: #f8f9ff;

    --bg-dark: #121212;

    --text-light: #f8f9ff;

    --text-dark: #333333;

}



* {

    margin: 0;

    padding: 0;

    box-sizing: border-box;

    font-family: 'Poppins', sans-serif;

}



body {

    background: var(--bg-light);

    background-image: linear-gradient(to bottom right, #e0e8ff, #f8f9ff);

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    min-height: 100vh;

    margin: 0;

    overflow-x: hidden;

    transition: background 0.5s ease;

}

.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Changed from center to space-between */
    align-items: center;
    z-index: 30;
    transition: all 0.3s ease;
    padding: 20px 10px 20px 10px; /* Added padding top/bottom */
    overflow-y: auto; /* Add scroll if content is too tall */
    box-sizing: border-box; /* Include padding in height calculation */
}

body.dark-mode {

    background: var(--bg-dark);

    background-image: linear-gradient(to bottom right, #1a1a2e, #121212);

    color: var(--text-light);

}



.game-container {

    width: 360px;
    height: 640px;
    position: relative;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    margin: 0 auto;
    max-width: 100%; /* Add this to ensure it fits on smaller screens */
    max-height: 100vh; /* Add this to ensure it fits on smaller screens */

}



body.dark-mode .game-container {

    background: #1e1e30;

    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);

}



canvas {

    display: block;

    background: white;

    transition: background 0.3s ease;

}



body.dark-mode canvas {

    background: #1e1e30;

}



.game-info {

    position: absolute;

    top: 15px;

    left: 15px;

    display: flex;

    flex-direction: column;

    gap: 5px;

    z-index: 20;

    display: none;

}



.score {

    font-size: 18px;

    color: var(--primary);

    font-weight: bold;

    background: rgba(255, 255, 255, 0.8);

    padding: 5px 10px;

    border-radius: 20px;

    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

    transition: all 0.3s ease;

}



.level {

    font-size: 16px;

    color: var(--secondary);

    font-weight: bold;

    background: rgba(255, 255, 255, 0.8);

    padding: 5px 10px;

    border-radius: 20px;

    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

    transition: all 0.3s ease;

}



.active-power {

    font-size: 16px;

    color: var(--success);

    font-weight: bold;

    background: rgba(255, 255, 255, 0.8);

    padding: 5px 10px;

    border-radius: 20px;

    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

    opacity: 0;

    transition: all 0.3s ease;

}



.active-power.visible {

    opacity: 1;

}



body.dark-mode .score,

body.dark-mode .level,

body.dark-mode .active-power {

    background: rgba(30, 30, 48, 0.8);

    color: var(--text-light);

}



.menu, .game-over {

    position: absolute;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    background: rgba(255, 255, 255, 0.95);

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    z-index: 30;

    transition: all 0.3s ease;

}



.level-select {

    position: absolute;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    background: rgba(255, 255, 255, 0.95);

    display: flex;

    flex-direction: column;

    justify-content: flex-start;

    align-items: center;

    z-index: 30;

    transition: all 0.3s ease;

    padding: 20px 10px;

    overflow-y: auto;

}



.menu.hidden, .level-select.hidden, .game-over.hidden {

    opacity: 0;

    pointer-events: none;

}



.game-over {

    background: rgba(255, 255, 255, 0.9);

    display: none;

}



.game-over.show {

    display: flex;

}



body.dark-mode .menu,

body.dark-mode .level-select,

body.dark-mode .game-over {

    background: rgba(30, 30, 48, 0.95);

}

.pause-button {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(120, 65, 201, 0.8); /* var(--primary) with opacity */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 25;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    color: white;
}

.pause-button:active {
    transform: scale(0.9);
    background-color: var(--primary-dark);
}

.pause-button.play {
    /* Different icon for play state (when game is paused) */
}

body.dark-mode .pause-button {
    background-color: rgba(159, 111, 234, 0.8); /* var(--primary-light) with opacity */
}

body.dark-mode .pause-button:active {
    background-color: var(--primary);
}

/* Hide pause button when game is not running */
.menu:not(.hidden) ~ .pause-button,
.level-select:not(.hidden) ~ .pause-button,
.game-over.show ~ .pause-button {
    display: none;
}

/* Fullscreen styles */
.game-container:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-container:-moz-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-container:-ms-fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-container:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Maintain aspect ratio in fullscreen */
.game-container:fullscreen canvas {
    width: auto;
    height: 98vh;
    max-height: 98vh;
}


.title-container {
    position: relative;
    margin-bottom: 20px; /* Reduced from 30px */
    text-align: center;
    padding-top: 10px;
}



h1 {
    font-size: 38px; /* Reduced from 42px */
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 5px; /* Reduced from 10px */
    text-shadow: 2px 2px 0 var(--primary-light);
    letter-spacing: 2px;
}



body.dark-mode h1 {

    color: var(--primary-light);

    text-shadow: 2px 2px 0 var(--primary-dark);

}



.subtitle {
    font-size: 14px; /* Reduced from 16px */
    color: var(--secondary);
    margin-bottom: 20px; /* Reduced from 30px */
}



body.dark-mode .subtitle {

    color: var(--secondary-light);

}



h2 {

    font-size: 28px;

    color: var(--secondary);

    margin: 10px 0 20px 0;

}



body.dark-mode h2 {

    color: var(--secondary-light);

}



.final-stats {

    background: rgba(255, 255, 255, 0.8);

    border-radius: 10px;

    padding: 15px 25px;

    margin-bottom: 20px;

    text-align: center;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

}



body.dark-mode .final-stats {

    background: rgba(30, 30, 48, 0.8);

}



.btn-container {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced from 10px */
    width: 200px;
    margin-bottom: 10px;
}



.level-buttons {

    display: flex;

    flex-wrap: wrap;

    justify-content: center;

    gap: 10px;

    max-width: 340px;

    margin-bottom: 20px;

    padding: 5px;

    max-height: 500px;

    overflow-y: auto;

}



.level-btn {

    width: 50px;

    height: 50px;

    display: flex;

    justify-content: center;

    align-items: center;

    background: white;

    border: 2px solid var(--primary);

    border-radius: 8px;

    font-size: 18px;

    font-weight: bold;

    color: var(--primary);

    cursor: pointer;

    transition: all 0.2s ease;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

}



.level-btn:hover {

    background: var(--primary-light);

    color: white;

    transform: translateY(-3px);

}



.level-btn.locked {

    background: #e0e0e0;

    border-color: #aaa;

    color: #888;

    cursor: not-allowed;

}



.level-btn.completed {

    background: var(--success);

    border-color: var(--success);

    color: white;

}



body.dark-mode .level-btn {

    background: #2a2a40;

    border-color: var(--primary-light);

    color: var(--primary-light);

}



body.dark-mode .level-btn:hover {

    background: var(--primary);

}



body.dark-mode .level-btn.locked {

    background: #232333;

    border-color: #444;

    color: #666;

}



.btn {

    background: var(--primary);

    color: white;

    border: none;

    padding: 10px 15px;

    margin: 3px 0;

    border-radius: 30px;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    transition: all 0.2s ease;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

    text-transform: uppercase;

    letter-spacing: 1px;

    width: 100%;

    text-align: center;

}



.btn:hover {

    background: var(--primary-light);

    transform: translateY(-3px);

    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);

}



.btn.secondary {

    background: var(--secondary);

}



.btn.secondary:hover {

    background: var(--secondary-light);

}



.btn.tertiary {

    background: #f0f0f0;

    color: var(--text-dark);

}



.btn.tertiary:hover {

    background: #e0e0e0;

}



body.dark-mode .btn.tertiary {

    background: #2a2a40;

    color: var(--text-light);

}



body.dark-mode .btn.tertiary:hover {

    background: #3a3a50;

}



.controls {

    position: absolute;

    bottom: 20px;

    right: 20px;

    display: flex;

    gap: 10px;

}



.control-btn {

    width: 40px;

    height: 40px;

    border-radius: 50%;

    background: var(--primary);

    color: white;

    display: flex;

    justify-content: center;

    align-items: center;

    cursor: pointer;

    transition: all 0.2s ease;

    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

}



.control-btn:hover {

    background: var(--primary-light);

    transform: translateY(-2px);

}



.dark-mode-toggle {

    position: absolute;

    top: 20px;

    right: 20px;

    z-index: 40;

}



/* Power-up animation */

@keyframes pulse {

    0% { transform: scale(1); }

    50% { transform: scale(1.1); }

    100% { transform: scale(1); }

}



@keyframes rotate {

    0% { transform: rotate(0deg); }

    100% { transform: rotate(360deg); }

}



@keyframes fadeIn {

    from { opacity: 0; }

    to { opacity: 1; }

}



@keyframes bounceIn {

    0% { transform: scale(0.3); opacity: 0; }

    50% { transform: scale(1.1); }

    70% { transform: scale(0.9); }

    100% { transform: scale(1); opacity: 1; }

}



/* Level transition animation */

@keyframes levelUp {

    0% { 

        transform: scale(1);

        opacity: 0;

    }

    50% { 

        transform: scale(1.5);

        opacity: 1;

    }

    100% { 

        transform: scale(1);

        opacity: 0;

    }

}



.level-up-notification {

    position: absolute;

    top: 50%;

    left: 50%;

    transform: translate(-50%, -50%);

    font-size: 36px;

    font-weight: bold;

    color: var(--success);

    text-align: center;

    z-index: 40;

    opacity: 0;

    pointer-events: none;

}



.powerup {

    position: absolute;

    width: 20px;

    height: 20px;

    border-radius: 50%;

    animation: pulse 1s infinite ease-in-out;

}



.obstacle {

    position: absolute;

    width: 20px;

    height: 20px;

    background: #555;

    border-radius: 3px;

}



/* Loading indicator */

.loader {

    width: 48px;

    height: 48px;

    border: 5px solid var(--primary);

    border-bottom-color: transparent;

    border-radius: 50%;

    display: inline-block;

    box-sizing: border-box;

    animation: rotate 1s linear infinite;

}



.loading {

    position: absolute;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

    background: rgba(255, 255, 255, 0.9);

    display: flex;

    justify-content: center;

    align-items: center;

    z-index: 50;

}



body.dark-mode .loading {

    background: rgba(30, 30, 48, 0.9);

}



/* Directional buttons */

.directional-buttons {

    position: absolute;

    bottom: 50px; /* Increased from 15px to avoid hiding behind address bar */

    left: 50%;

    transform: translateX(-50%);

    display: flex;

    flex-direction: column;

    align-items: center;

    z-index: 25;

    width: 150px;

}



.horizontal-buttons {

    display: flex;

    justify-content: space-between;

    width: 100%;

    margin: 5px 0;

}



.direction-btn {

    width: 50px;

    height: 50px;

    background-color: rgba(120, 65, 201, 0.5); /* Increased transparency from 0.8 to 0.5 to make food items more visible */

    border: none;

    border-radius: 10px;

    color: white;

    display: flex;

    justify-content: center;

    align-items: center;

    cursor: pointer;

    transition: all 0.2s ease;

    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

}



.direction-btn:active {

    transform: scale(0.9);

    background-color: var(--primary-dark);

}



body.dark-mode .direction-btn {

    background-color: rgba(159, 111, 234, 0.5); /* Increased transparency from 0.8 to 0.5 for dark mode */

}



body.dark-mode .direction-btn:active {

    background-color: var(--primary);

}



/* Hide directional buttons when game is not running */

.menu:not(.hidden) ~ .directional-buttons,

.level-select:not(.hidden) ~ .directional-buttons,

.game-over.show ~ .directional-buttons {

    display: none;

}`

@media (max-height: 640px) {
    h1 {
        font-size: 32px;
        margin-bottom: 2px;
    }
    
    .subtitle {
        font-size: 12px;
        margin-bottom: 15px;
    }
    
    .btn-container {
        gap: 5px;
    }
    
    .btn {
        padding: 8px 12px;
        margin: 2px 0;
        font-size: 13px;
    }
    
    .menu {
        padding: 10px 10px;
    }
}

/* Add responsive scaling for smaller devices */
@media (max-height: 700px) {
    .game-container {
        height: 90vh;
        width: calc(90vh * 9 / 16); /* Maintain 9:16 aspect ratio */
    }
}

/* Logo Styling */
.menu-logo {
    width: 120px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
    animation: pulseLogo 2s infinite ease-in-out;
}

.gameover-logo {
    width: 80px;
    height: auto;
    margin: 5px auto 10px;
    display: block;
}

/* Splash Screen */
.splash-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-logo-container {
    margin-bottom: 20px;
    animation: splashLogoAnimation 2s infinite alternate;
}

.splash-logo {
    width: 150px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
}

.splash-text {
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: fadeInOut 1.5s infinite;
}

@keyframes splashLogoAnimation {
    0% {
        transform: scale(1) rotate(0deg);
    }
    100% {
        transform: scale(1.1) rotate(5deg);
    }
}

@keyframes fadeInOut {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes pulseLogo {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}