body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: radial-gradient(circle at center, #101a30 0%, #050510 100%);
    color: #ffffff;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
}

/* Landing Page Overlay */
#landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed to start for scrolling */
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease;
    overflow-y: auto;
    /* Allow scrolling on small screens */
    padding: 40px 20px;
    box-sizing: border-box;
}

header {
    text-align: center;
    margin-bottom: 20px;
    animation: fadeInDown 0.8s ease-out;
    flex-shrink: 0;
}

.logo {
    font-size: clamp(40px, 15vw, 80px);
    /* Responsive font size */
    font-weight: 900;
    letter-spacing: 15px;
    margin: 0;
    background: linear-gradient(135deg, #00ffaa 0%, #00ccff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(0, 255, 170, 0.3));
}

.tagline {
    font-size: clamp(12px, 4vw, 18px);
    color: #aaddff;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    animation: fadeInUp 1s ease-out;
    width: 100%;
    max-width: 400px;
}

.play-box {
    background: rgba(255, 255, 255, 0.05);
    padding: clamp(20px, 8vw, 40px);
    border-radius: 24px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.play-box input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 12px;
    color: white;
    font-size: 18px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.play-box input:focus {
    border-color: #00ffaa;
}

#play-btn {
    background: linear-gradient(135deg, #00ffaa 0%, #00cc88 100%);
    border: none;
    padding: 15px;
    border-radius: 12px;
    color: #050510;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 255, 170, 0.3);
}

#play-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 255, 170, 0.5);
}

.game-info {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 16px;
    width: 100%;
    box-sizing: border-box;
}

.game-info h3 {
    margin-top: 0;
    color: #00ffaa;
    font-size: 18px;
}

.game-info p {
    font-size: 14px;
    line-height: 1.5;
}

.landing-footer {
    margin-top: 40px;
    /* Push footer down */
    margin-bottom: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    width: 100%;
    flex-shrink: 0;
}

.landing-footer nav {
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    /* Wrap links on small screens */
}

.landing-footer nav a {
    color: #aaddff;
    text-decoration: none;
    transition: color 0.3s;
    white-space: nowrap;
}

.landing-footer nav a:hover {
    color: #00ffaa;
}

/* Responsive adjustments for In-game UI */
@media (max-width: 600px) {
    #hud {
        top: 10px;
        left: 10px;
        scale: 0.85;
        transform-origin: top left;
    }

    #lang-toggle {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Leaderboard UI */
#leaderboard {
    position: fixed;
    top: 70px;
    /* Below the language toggle */
    right: 20px;
    width: 220px;
    background: rgba(0, 5, 15, 0.7);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    pointer-events: auto;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 50;
    font-family: 'Segoe UI', sans-serif;
    animation: fadeInRight 0.5s ease-out;
}

.leaderboard-header {
    font-size: 14px;
    font-weight: bold;
    color: #00ffaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 170, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.leaderboard-item.loading {
    color: #666;
    font-style: italic;
    justify-content: center;
    padding: 20px 0;
}

.rank-num {
    color: #aaddff;
    font-weight: bold;
    margin-right: 8px;
}

.rank-1 {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.rank-2 {
    color: #c0c0c0;
}

.rank-3 {
    color: #cd7f32;
}

.player-name {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.player-mass {
    font-weight: bold;
    color: #00ffaa;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 600px) {
    #leaderboard {
        width: 130px;
        top: 60px;
        right: 10px;
        font-size: 11px;
        padding: 10px;
    }

    .leaderboard-header {
        font-size: 11px;
        margin-bottom: 8px;
    }
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.stat-bar {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 16px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    color: #aaddff;
    width: fit-content;
}

#evolution-status {
    font-size: 20px;
    font-weight: bold;
    color: #44ff88;
    margin-top: 4px;
    text-shadow: 0 0 10px rgba(68, 255, 136, 0.4);
}

/* Evolution Guide Styles */
#evolution-guide {
    position: fixed;
    left: 20px;
    top: 180px;
    background: rgba(0, 10, 20, 0.85);
    padding: 18px;
    border-radius: 16px;
    color: white;
    font-size: 13px;
    z-index: 100;
    border: 1px solid rgba(0, 255, 170, 0.2);
    backdrop-filter: blur(15px);
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    min-width: 200px;
}

/* Mobile specific styling for the guide */
#evolution-guide.mobile-guide {
    left: auto;
    right: 10px;
    top: 150px;
    /* Below leaderboard and language toggle */
    width: 160px;
    min-width: 0;
    padding: 12px;
    font-size: 11px;
    background: rgba(0, 5, 15, 0.9);
}

#evolution-guide.mobile-guide .guide-title {
    font-size: 12px !important;
}


#lang-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    pointer-events: auto;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

#lang-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #00ffaa;
}

.lang-picker {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #aaddff;
    padding: 6px 15px;
    border-radius: 15px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    backdrop-filter: blur(5px);
}

.lang-picker:hover {
    background: rgba(0, 255, 170, 0.1);
    border-color: #00ffaa;
    color: #fff;
}

#notifications {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: rgba(0, 20, 40, 0.85);
    padding: 12px 24px;
    border-radius: 30px;
    border: 1px solid rgba(0, 255, 170, 0.4);
    color: #00ffaa;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(0, 255, 170, 0.2);
    animation: notificationAnim 3s forwards;
}

@keyframes notificationAnim {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    15% {
        opacity: 1;
        transform: translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

canvas {
    display: block;
}

/* Game Over Modal */
#game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.5s ease;
    pointer-events: auto;
}

.modal-content {
    background: rgba(20, 30, 50, 0.6);
    padding: 60px 40px;
    border-radius: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
    max-width: 450px;
    width: 90%;
}

.modal-content h2 {
    font-size: clamp(32px, 10vw, 56px);
    margin: 0 0 20px;
    background: linear-gradient(135deg, #FF3366 0%, #FF9933 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 5px;
    font-weight: 900;
}

.final-score {
    font-size: 28px;
    color: #aaddff;
    margin-bottom: 40px;
}

#retry-btn {
    background: linear-gradient(135deg, #00ffaa 0%, #00ccff 100%);
    border: none;
    padding: 18px 50px;
    border-radius: 15px;
    color: #050510;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#retry-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(0, 255, 170, 0.5);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
}

#joystick-container {
    position: absolute;
    bottom: 50px;
    left: 50px;
    width: 150px;
    height: 150px;
    pointer-events: auto;
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
}

#joystick-stick {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, rgba(0, 255, 170, 0.5), rgba(0, 204, 255, 0.5));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-shadow: 0 0 25px rgba(0, 255, 170, 0.3);
    transition: transform 0.05s linear;
}

#boost-btn {
    position: absolute;
    bottom: 70px;
    right: 50px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255, 51, 102, 0.1);
    border: 2px solid rgba(255, 51, 102, 0.3);
    color: #ff3366;
    font-weight: 900;
    font-size: 16px;
    letter-spacing: 2px;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
    box-shadow: 0 0 30px rgba(255, 51, 102, 0.1);
}

#boost-btn:active {
    background: rgba(255, 51, 102, 0.3);
    transform: scale(0.9);
    box-shadow: 0 0 60px rgba(255, 51, 102, 0.4);
    border-color: #ff3366;
}

@media (max-width: 600px) {
    #joystick-container {
        bottom: 30px;
        left: 30px;
        width: 120px;
        height: 120px;
    }

    #joystick-stick {
        width: 50px;
        height: 50px;
    }

    #boost-btn {
        bottom: 40px;
        right: 30px;
        width: 90px;
        height: 90px;
        font-size: 12px;
    }
}