* {
    font-family: "Germania One", sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.85) 100%),
                url('img/custom_body_bg.png') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 14px;
}

#game-container {
    width: min(600px, calc(100vw - 28px), calc((100dvh - 28px) * 0.75));
    height: min(800px, calc(100dvh - 28px), calc((100vw - 28px) / 0.75));
    aspect-ratio: 3 / 4;
    background: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    border: 4px solid #c09050;
}

.screen {
    position: absolute; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

#loading-screen {
    background: url('img/jungle_loading_clean.png') no-repeat center center;
    background-size: cover;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: clamp(16px, 3vh, 28px);
}

#progress-container {
    width: 60%;
    height: 30px;
    background: rgba(0, 0, 0, 0.4);
    border: 3px solid #8b5a2b;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    position: relative;
    z-index: 10;
}
#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8bc34a, #4caf50);
    border-radius: 10px;
    transition: width 0.1s linear;
}

@keyframes float {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 25px rgba(255, 255, 255, 1));
    }

    100% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }
}

#progress-container {
    width: 60%;
    height: 30px;
    background: rgba(253, 246, 227, 0.9);
    border: 4px solid #c09050;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 30px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #8bc34a, #4caf50);
    transition: width 0.1s linear;
}

#loading-play-btn {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#loading-play-btn:hover {
    transform: scale(1.1) rotate(3deg);
}

#loading-play-btn:active {
    transform: scale(0.95);
}

/* --- LEVEL SCREEN --- */
#level-screen {
    background: url('img/jungle_game.png') no-repeat center center;
    background-size: cover;
    padding: clamp(104px, 18vh, 152px) clamp(12px, 2.4vw, 22px) clamp(12px, 2vh, 20px);
    gap: clamp(8px, 1.8vh, 16px);
    justify-content: flex-start;
}

.level-header {
    min-height: clamp(48px, 8vh, 74px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
}

.level-header h2 {
    color: #5d4037;
    text-shadow: 2px 2px 0px #f5deb3, -2px -2px 0px #f5deb3, 2px -2px 0px #f5deb3, -2px 2px 0px #f5deb3, 0px 5px 10px rgba(0, 0, 0, 0.3);
    font-size: clamp(26px, 5vw, 40px);
    font-weight: bold;
    text-align: center;
    line-height: 0.95;
}

.level-slider {
    display: flex;
    width: 200%;
    flex: 1;
    min-height: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.level-page {
    width: 50%;
    display: grid;
    grid-template-columns: repeat(var(--level-columns, 5), minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: clamp(8px, 1.8vh, 15px);
    padding: 0 clamp(8px, 2vw, 22px);
    align-content: start;
    min-height: 0;
}

.level-btn {
    background: #e6dac3;
    border: 3px solid #c09050;
    border-radius: 12px;
    color: #a08a70;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: not-allowed;
    position: relative;
    font-size: clamp(20px, 3.2vw, 24px);
    box-shadow: 0 4px 0 #c09050;
    aspect-ratio: 1.35 / 1;
    padding: 6px 4px;
}

.level-btn.unlocked {
    background: #f5deb3;
    border-color: #8b5a2b;
    color: #5d4037;
    cursor: pointer;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.8);
    box-shadow: 0 6px 0 #8b5a2b, 0 10px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

.level-btn.unlocked:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 #8b5a2b, 0 5px 5px rgba(0, 0, 0, 0.1);
}

.level-stars {
    display: flex;
    gap: 3px;
    margin-top: 4px;
}

.level-stars i {
    font-size: clamp(9px, 1.4vw, 11px);
    color: rgba(255, 255, 255, 0.5);
}

.level-stars i.filled {
    color: #8b5a2b;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}

.slider-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(14px, 3vw, 30px);
    flex-shrink: 0;
}

.slider-controls button {
    background: #f5deb3;
    border: 2px solid #8b5a2b;
    color: #5d4037;
    font-size: clamp(22px, 4vw, 30px);
    width: clamp(42px, 7vw, 60px);
    height: clamp(42px, 7vw, 60px);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 5px 0 #8b5a2b;
    transition: transform 0.1s;
}

.slider-controls button:active {
    transform: translateY(5px);
    box-shadow: 0 0px 0 #8b5a2b;
}

.slider-controls button:disabled {
    background: #e6dac3;
    color: #a08a70;
    border-color: #c09050;
    box-shadow: 0 5px 0 #c09050;
    cursor: not-allowed;
}

#page-indicator {
    color: #333;
    font-size: clamp(20px, 4vw, 28px);
    font-weight: bold;
    text-shadow: 1px 1px 0px #fff;
}

/* --- GAME SCREEN --- */
#game-screen {
    background: url('img/jungle_game.png') no-repeat center center;
    background-size: cover;
    padding: clamp(8px, 1.5vh, 12px);
    gap: clamp(8px, 1.5vh, 12px);
}

.top-bar {
    width: 100%;
    min-height: clamp(50px, 8vh, 70px);
    display: flex;
    justify-content: space-between;
    padding: 0 clamp(8px, 2vw, 20px);
    align-items: center;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    flex-shrink: 0;
}

.stats-header {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
    color: #5d4037;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 1px 1px 0px #fff;
}

.stats-header span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stats-header img {
    width: 24px;
    height: 24px;
}

.icon-btn {
    background: #f5deb3;
    border: 2px solid #8b5a2b;
    color: #5d4037;
    font-size: 24px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 0 #8b5a2b;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 #8b5a2b;
}

.icon-btn img {
    width: 24px;
}

canvas {
    display: block;
    margin: auto;
    border: 4px solid #c09050;
    border-radius: 12px;
    background: rgba(253, 246, 227, 0.5);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.15);
    width: min(calc(100% - 8px), calc((100dvh - 150px) * 0.857));
    max-width: 100%;
    height: auto;
    max-height: calc(100% - 8px);
    aspect-ratio: 6 / 7;
    flex: 1;
    min-height: 0;
}

/* --- GAME OVER / POPUP --- */
#gameover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
    backdrop-filter: blur(5px);
}

.popup-box {
    background: #fdf6e3;
    border: 6px solid #8b5a2b;
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
    width: 80%;
    animation: popup 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popup {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#popup-title {
    color: #5d4037;
    font-size: 40px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px #f5deb3, -2px -2px 0px #f5deb3, 2px -2px 0px #f5deb3, -2px 2px 0px #f5deb3, 0 3px 5px rgba(0, 0, 0, 0.2);
}

#popup-level-txt,
#popup-score-txt {
    color: #8b5a2b;
    font-size: 24px;
    margin: 5px 0;
    font-weight: bold;
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.stars-container i {
    font-size: 50px;
    color: #e0e0e0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stars-container i.filled {
    color: #8b5a2b;
    text-shadow: 0 5px 10px rgba(139, 90, 43, 0.5);
}

.stars-container i.animating {
    transform: scale(1.4) rotate(15deg);
}

.popup-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    background: #f5deb3;
    border: 2px solid #8b5a2b;
    padding: 15px;
    font-size: 24px;
    color: #5d4037;
    cursor: pointer;
    border-radius: 12px;
    font-family: inherit;
    font-weight: bold;
    box-shadow: 0 6px 0 #8b5a2b;
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.6);
}

.btn:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 #8b5a2b;
}

/* RESPONSIVE DESIGN FOR 576px */
@media (max-width: 576px) {
    #game-container {
        border-radius: 0;
        border: none;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        max-height: none;
    }
    .level-page {
        padding: 0 4px;
    }
    .popup-box {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-left: none;
        border-right: none;
        border-radius: 0;
        padding: 30px 15px;
    }
    .stats-header {
        font-size: 16px;
        gap: 8px;
    }
}

@media (max-height: 760px) {
    #level-screen {
        padding-top: clamp(112px, 17vh, 138px);
        gap: 8px;
    }

    .level-header {
        min-height: 40px;
    }

    .level-btn {
        font-size: clamp(18px, 3vw, 22px);
        padding: 4px 2px;
    }

    .level-page {
        gap: 8px;
    }
}
