* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: "Courier New", monospace;
    overflow: hidden;
}

#game {
    position: relative;
    width: 400px;
    height: 600px;
    overflow: hidden;
    background: #5ec8ff;
    border: 6px solid #000;
    image-rendering: pixelated;
}

/* =========================
   CÉU
========================= */

#sky {
    position: absolute;
    inset: 0;
    background: linear-gradient(#55c7ff, #b7edff);
}

.cloud {
    position: absolute;
    width: 105px;
    height: 30px;
    background: white;
    border-radius: 20px;
    opacity: .95;
    z-index: 2;
}

.cloud::before,
.cloud::after {
    content: "";
    position: absolute;
    background: white;
    border-radius: 50%;
}

.cloud::before {
    width: 45px;
    height: 45px;
    left: 12px;
    top: -20px;
}

.cloud::after {
    width: 50px;
    height: 50px;
    right: 8px;
    top: -25px;
}

.cloud-text {
    position: absolute;
    left: 0;
    top: 8px;
    width: 100%;
    text-align: center;
    font-size: 8px;
    font-weight: 900;
    color: #000;
    white-space: nowrap;
    z-index: 5;
}

.cloud1 {
    top: 80px;
    left: 20px;
}

.cloud2 {
    top: 160px;
    left: 250px;
    transform: scale(.8);
}

.cloud3 {
    top: 250px;
    left: 120px;
    transform: scale(.7);
}

.cloud4 {
    top: 330px;
    left: 300px;
    transform: scale(.65);
}

/* =========================
   HUD
========================= */

#hud {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    z-index: 20;
    text-align: center;
    pointer-events: none;
}

#score {
    font-size: 42px;
    font-weight: bold;
    color: white;
    text-shadow:
        3px 3px 0 #000,
        -2px -2px 0 #000;
}

#combo {
    font-size: 14px;
    color: #ffe600;
    font-weight: bold;
    text-shadow: 2px 2px #000;
}

#lives {
    position: absolute;
    right: 15px;
    top: 5px;
    font-size: 18px;
}

#powerupHud {
    margin-top: 5px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px #000;
}

/* =========================
   BOSS
========================= */

#bossHud {
    display: none;
    position: absolute;
    top: 95px;
    left: 40px;
    width: 320px;
    z-index: 25;
    text-align: center;
}

#bossName {
    color: white;
    font-weight: bold;
    font-size: 13px;
    text-shadow: 2px 2px #000;
    margin-bottom: 5px;
}

#bossBar {
    width: 100%;
    height: 18px;
    background: #222;
    border: 3px solid #000;
}

#bossHealth {
    width: 100%;
    height: 100%;
    background: #e22;
}

/* =========================
   PINTO
========================= */

#bird {
    position: absolute;
    width: 42px;
    height: 34px;
    left: 80px;
    top: 280px;
    z-index: 10;
    background: #ffd21f;
    border: 3px solid #000;
    border-radius: 50%;
}

.bird-eye {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 2px solid #000;
    border-radius: 50%;
    right: 7px;
    top: 5px;
}

.bird-eye::after {
    content: "";
    position: absolute;
    width: 3px;
    height: 3px;
    background: #000;
    border-radius: 50%;
    right: 0;
    top: 1px;
}

.bird-wing {
    position: absolute;
    width: 20px;
    height: 13px;
    left: 5px;
    bottom: 3px;
    background: #f1ad00;
    border: 2px solid #000;
    border-radius: 50%;
}

.bird-beak {
    position: absolute;
    right: -12px;
    top: 12px;
    width: 15px;
    height: 10px;
    background: #ff7319;
    border: 2px solid #000;
}

.character-yellow {
    background: #ffd21f !important;
}

.character-red {
    background: #ef4444 !important;
}

.character-blue {
    background: #38a8ff !important;
}

.character-fire {
    background: #ff641c !important;
    box-shadow: 0 0 15px #ff3300;
}

.character-robot {
    background: #aaa !important;
}

/* =========================
   CANOS
========================= */

.pipe {
    position: absolute;
    width: 66px;
    background: #35a936;
    border: 4px solid #000;
    z-index: 5;
}

.pipe::before {
    content: "";
    position: absolute;
    width: 74px;
    height: 25px;
    left: -8px;
    background: #43c743;
    border: 4px solid #000;
}

.pipe.top {
    top: 0;
}

.pipe.bottom {
    bottom: 70px;
}

.pipe-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    writing-mode: vertical-rl;
    color: white;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    text-shadow:
        2px 2px #000,
        -1px -1px #000;
    pointer-events: none;
    z-index: 10;
}

/* =========================
   MOEDAS
========================= */

.coin {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffd700;
    border: 3px solid #000;
    z-index: 8;
}

.coin::after {
    content: "$";
    position: absolute;
    left: 5px;
    top: 0;
    font-size: 15px;
    font-weight: bold;
}

.coin.collecting {
    animation: coinCollect .3s forwards;
}

@keyframes coinCollect {
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* =========================
   POWER UPS
========================= */

.powerup {
    position: absolute;
    width: 28px;
    height: 28px;
    border: 3px solid #000;
    border-radius: 50%;
    z-index: 9;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 17px;
}

.powerup.shield {
    background: #55aaff;
}

.powerup.magnet {
    background: #ff5555;
}

.powerup.slow {
    background: #b65cff;
}

.powerup.life {
    background: #ff6b6b;
}

.powerup.turbo {
    background: #ffe600;
}

/* =========================
   CHÃO
========================= */

#ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 70px;
    background: #c98b3a;
    border-top: 5px solid #000;
    z-index: 9;
}

.grass {
    position: absolute;
    top: -15px;
    width: 100%;
    height: 15px;
    background: #43b83c;
    border-top: 3px solid #000;
    border-bottom: 3px solid #000;
}

.groundPattern {
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 10px,
            rgba(0,0,0,.1) 10px,
            rgba(0,0,0,.1) 20px
        );
}

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

#startScreen {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: linear-gradient(#42bfff, #b9edff);
    overflow-y: auto;
}

.title-screen {
    width: 95%;
    padding: 15px;
}

.title-screen h1,
.title-screen h2 {
    font-weight: 900;
    letter-spacing: 3px;
    text-shadow:
        4px 4px #000,
        -2px -2px #fff;
}

.title-screen h1 {
    font-size: 34px;
    color: #ffe000;
}

.title-screen h2 {
    font-size: 48px;
    color: #ff4b35;
}

.creator {
    margin: 10px 0 15px;
    font-size: 13px;
    font-weight: bold;
}

#characterSelect p,
#worldSelect p {
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 5px;
}

#worldSelect {
    margin-top: 8px;
}

.characters,
.worlds {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.character,
.world {
    width: 43px;
    height: 38px;
    border: 3px solid #000;
    background: white;
    font-size: 19px;
    cursor: pointer;
}

.character.selected,
.world.selected,
.difficulty.selected {
    background: #ffe000;
    transform: translateY(-2px);
    box-shadow: 3px 3px #000;
}

.locked {
    filter: grayscale(1);
    opacity: .6;
}

#startButton,
#restart,
.menuButton,
#menuButton,
.backButton,
#storyStartButton {
    margin-top: 9px;
    padding: 9px 20px;
    border: 4px solid #000;
    background: #ffe000;
    color: #000;
    font-family: "Courier New", monospace;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 4px 4px #000;
}

#startButton {
    font-size: 18px;
}

.menuButton {
    display: block;
    width: 210px;
    margin-left: auto;
    margin-right: auto;
    background: #5ec8ff;
    font-size: 12px;
}

#menuButton {
    background: #5ec8ff;
    font-size: 13px;
}

#startButton:hover,
.menuButton:hover,
#restart:hover,
#menuButton:hover,
.backButton:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px #000;
}

/* =========================
   TELAS
========================= */

.menuOverlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,.82);
    color: white;
    text-align: center;
}

.panel {
    width: 88%;
    max-height: 90%;
    overflow-y: auto;
    padding: 20px;
    background: #279bd2;
    border: 5px solid #000;
    box-shadow: 7px 7px #000;
}

.panel h2 {
    font-size: 26px;
    margin-bottom: 15px;
    color: #ffe000;
    text-shadow: 3px 3px #000;
}

.panel h3 {
    margin: 15px 0 7px;
}

.settingRow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding: 8px;
    background: rgba(0,0,0,.2);
    border: 2px solid #000;
}

.settingRow button {
    min-width: 60px;
    border: 3px solid #000;
    padding: 5px;
    font-weight: bold;
    cursor: pointer;
}

.difficultyButtons {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.difficulty {
    padding: 7px;
    border: 3px solid #000;
    cursor: pointer;
    font-weight: bold;
}

.shopItems {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shopItem {
    padding: 10px;
    border: 3px solid #000;
    background: #ffe000;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
}

.shopItem span {
    display: block;
    font-size: 10px;
    margin-top: 4px;
}

.achievement {
    margin: 6px 0;
    padding: 8px;
    border: 3px solid #000;
    background: #777;
    text-align: left;
}

.achievement.unlocked {
    background: #e6b800;
    color: #000;
}

.statsList {
    text-align: left;
    line-height: 2;
}

#storyProgress {
    margin: 15px 0;
    font-weight: bold;
}

#storyDescription {
    line-height: 1.5;
}

/* =========================
   GAME OVER
========================= */

#gameOver {
    position: absolute;
    inset: 0;
    z-index: 70;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(0,0,0,.86);
    color: white;
}

#gameOver h2 {
    font-size: 38px;
    color: #ff4444;
    text-shadow: 3px 3px #000;
    margin-bottom: 12px;
}

#gameOver p {
    margin-top: 5px;
    font-size: 12px;
}

#finalScore,
#bestScore,
#finalCoins {
    font-size: 23px;
    font-weight: bold;
}

#medal {
    margin-top: 10px;
    font-size: 28px;
}

#gameOverMessage {
    margin-top: 8px;
    color: #ffe000;
    font-size: 12px;
    font-weight: bold;
}

/* =========================
   PAUSA
========================= */

#pauseScreen {
    position: absolute;
    inset: 0;
    z-index: 65;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: rgba(0,0,0,.7);
    color: white;
    text-align: center;
}

#pauseScreen h2 {
    font-size: 40px;
    margin-bottom: 15px;
}

/* =========================
   POPUP
========================= */

#messagePopup {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    z-index: 100;
    padding: 10px 15px;
    background: #ffe000;
    border: 4px solid #000;
    font-weight: bold;
    font-size: 14px;
    display: none;
    pointer-events: none;
}

/* =========================
   PARTICULAS
========================= */

.particle {
    position: absolute;
    width: 7px;
    height: 7px;
    background: #ffe000;
    border: 2px solid #000;
    z-index: 15;
    pointer-events: none;
    animation: particleAnimation .6s forwards;
}

@keyframes particleAnimation {
    from {
        transform: translate(0,0);
        opacity: 1;
    }

    to {
        transform: translate(var(--x),var(--y)) rotate(180deg);
        opacity: 0;
    }
}

/* =========================
   DANO
========================= */

#game.damage {
    animation: damageFlash .2s;
}

@keyframes damageFlash {
    50% {
        filter: brightness(2);
    }
}

/* =========================
   MUNDOS
========================= */

.world-day #sky {
    background: linear-gradient(#55c7ff,#b7edff);
}

.world-night #sky {
    background: linear-gradient(#10163d,#263a78);
}

.world-night .cloud,
.world-night .cloud::before,
.world-night .cloud::after {
    background: #c5c9df;
}

.world-forest #sky {
    background: linear-gradient(#65c94a,#b6ed8b);
}

.world-forest #ground {
    background: #70452a;
}

.world-forest .grass {
    background: #176d2b;
}

.world-volcano #sky {
    background: linear-gradient(#ff6a32,#ffbd50);
}

.world-volcano #ground {
    background: #4b2020;
}

.world-volcano .grass {
    background: #a22;
}

.world-space #sky {
    background:
        radial-gradient(circle at 20% 30%, white 1px, transparent 2px),
        radial-gradient(circle at 80% 20%, white 1px, transparent 2px),
        radial-gradient(circle at 50% 70%, white 1px, transparent 2px),
        #080b30;
}

.world-space #ground {
    background: #272746;
}

.world-space .grass {
    background: #5555aa;
}

/* =========================
   MOBILE
========================= */

#mobileControl {
    display: none;
}

@media (max-width: 500px) {

    #game {
        width: 100vw;
        height: 100vh;
        border: none;
    }

    #mobileControl {
        display: block;
        position: absolute;
        bottom: 82px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 12;
        color: rgba(255,255,255,.4);
        font-size: 9px;
        pointer-events: none;
    }

    .title-screen h1 {
        font-size: 27px;
    }

    .title-screen h2 {
        font-size: 40px;
    }
}
