* {
    box-sizing: border-box;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100dvh;
    background: #0a3d62;
    overflow: hidden;
    font-family: sans-serif;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.intro-skipped #titleScreen,
html.intro-skipped #startOverlay {
    display: none !important;
}

.group-top {

    width: 350px;
    margin: 0 auto;
    position: absolute;
    top: 10px;
}

#ui {
    position: absolute;
    top: 30px;
    width: 350px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    font-size: 18px;
    z-index: 90;
    pointer-events: none;
    display: none;
}

#homeIconBtn, #soundToggle {
    position: absolute;
    top: 0px;
    padding: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    z-index: 100;
    height: 42px;
    display: flex;
    align-items: center;
}

#homeIconBtn {
    left: 10px;
}

#soundToggle {
    right: 10px;
    width: 85px;
    justify-content: center;
}


#startBtn {
    font-size: 20px;
    padding: 12px 24px;
    background: #212121;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.3s;
    display: none;
    z-index: 3;
}

#restartBtn {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    padding: 12px 24px;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.3s;
    backdrop-filter: blur(8px);
    background: rgba(226, 118, 48, 0.85);
    z-index: 999;
    display: none;
}

#restartBtn:hover {
    background: #ff974d;
}

#startBtn:hover {
    background-color: #000;
}

#gameWrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    z-index: 10;
}

#gameWrapper.blurred {
    backdrop-filter: blur(6px);
    background-color: rgba(10, 61, 98, 0.4);
    position: relative;
}

#gameWrapper.blurred::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(0 0 0 / 40%);
    backdrop-filter: blur(6px);
    z-index: 5;
    pointer-events: none;
}

#gameWrapper.rocking {
    animation: bottleRock 5s ease-in-out infinite;
}

#startOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.blurredBg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("./../../assets/images/start-game.webp");
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#startOverlay button {
    position: relative;
    z-index: 2;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    z-index: 1;
    transform-origin: center center;
    margin: 0 auto;
}

@keyframes bottleRock {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    20% {
        transform: translateY(-1.5px) rotate(-0.7deg);
    }

    40% {
        transform: translateY(1.5px) rotate(0.7deg);
    }

    60% {
        transform: translateY(-1px) rotate(-0.5deg);
    }

    80% {
        transform: translateY(1px) rotate(0.5deg);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

.shake {
    animation: shake 0.2s;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px);
    }

    25% {
        transform: translate(-2px, 0px);
    }

    50% {
        transform: translate(2px, 2px);
    }

    75% {
        transform: translate(-1px, -1px);
    }

    100% {
        transform: translate(0px, 0px);
    }
}

footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 175px;
    overflow: hidden;
    line-height: 0;
    z-index: 5;
    pointer-events: none;
    background: #0a3d62;
}

footer svg {
    width: 200%;
    height: 100%;
}

.wave1,
.wave2 {
    animation: waveAnim 8s linear infinite;
}

.wave1 {
    fill: #0a3d62;
    animation: waveAnim 8s linear infinite;
}

.wave2 {
    fill: rgba(255, 255, 255, 0.1);
    animation-direction: reverse;
}

@keyframes waveAnim {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

#titleScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: end;
    flex-direction: column;
}

.titleBackground {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

@media (min-width: 601px) {

    .titleBackground {

        background-image: url(./../../assets/images/intro-desktop.jpg);
        height: 100dvh;
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center top;
    }

}

#startGameButton {
    position: relative;
    z-index: 2;
    font-size: 24px;
    padding: 14px 28px;
    background: #e27630;
    color: white;
    border: none;
    cursor: pointer;
    font-family: monospace;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 60px;
}

#titleContent {
    position: relative;
    z-index: 2;
    max-width: 90%;
    text-align: center;
    color: white;
    font-family: monospace;
}

#introText p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.4;
    font-style: italic;
}

#introText {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    justify-content: center;
    align-items: start;
    display: flex;
    width: 300px;
    text-align: left;
    flex-direction: column;
}

#introText a {

    color: #fff;
}

#lifeBarWrapper {
    margin-top: 12px;
    text-align: center;
    position: relative;
    height: 40px;
}

#lifePercentage {
    position: absolute;
    top: 25px;
    right: 0;
    font-size: 16px;
    color: white;
    left: 0;
    margin: 0 auto;
}

#lifeBarContainer {
    display: flex;
    justify-content: center;
    gap: 3px;
    width: 90%;
    height: 20px;
    margin: 0 auto;
    padding: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
}

.life-block {
    width: 10px;
    height: 100%;
    border-radius: 4px;
    background: #00ff5e;
    box-shadow: 0 0 4px #00ff5e, 0 0 8px #00ff5e, 0 0 12px #00ff5e;
    transition: opacity 0.3s ease;
    opacity: 0.2;
}

.life-block.active {
    opacity: 1;
}

#lifeBar {
    height: 100%;
    width: 100%;
    background: #00ff5e;
    box-shadow: 0 0 5px #00ff5e, 0 0 10px #00ff5e, 0 0 15px #00ff5e,
    0 0 20px #00ff5e;
    transition: width 0.3s ease;
}

#scoreWrapper {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    font-size: 16px;
    padding: 0;
    margin: 0;
    transform: none;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #2c3e50;
}

.rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.content {
    position: relative;
    z-index: 1;
    color: white;
    padding: 20px;
}

.raindrop {
    position: absolute;
    width: 2px;
    height: 30px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50% 50% 0 0;
    transform: rotate(0deg);
    animation: fall linear infinite;
    opacity: 0.7;
}

@keyframes fall {
    0% {
        transform: translateY(-100vh);
        opacity: 0.7;
    }

    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

.splash {
    position: absolute;
    width: 5px;
    height: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    animation: splash-animation 0.3s ease-out;
    opacity: 0;
}

@keyframes splash-animation {
    0% {
        transform: scale(0.1);
        opacity: 0.9;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.ocean {
    position: absolute;
    bottom: -40px;
    width: 100%;
    height: 5%;
    pointer-events: none;
    z-index: 4;
}

.wave {
    background: url(./../../assets/images/wave.svg) repeat-x;
    position: absolute;
    top: -198px;
    width: 6400px;
    height: 198px;
    -webkit-animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
    animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
    transform: translate3d(0, 0, 0);
}

.wave:nth-of-type(2) {
    top: -175px;
    -webkit-animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite,
    swell 7s ease -1.25s infinite;
    animation: wave 7s cubic-bezier(0.36, 0.45, 0.63, 0.53) -0.125s infinite,
    swell 7s ease -1.25s infinite;
    opacity: 1;
}

@-webkit-keyframes wave {
    0% {
        margin-left: 0;
    }

    100% {
        margin-left: -1600px;
    }
}

@keyframes wave {
    0% {
        margin-left: 0;
    }

    100% {
        margin-left: -1600px;
    }
}

@-webkit-keyframes swell {

    0%,
    100% {
        transform: translate3d(0, -25px, 0);
    }

    50% {
        transform: translate3d(0, 5px, 0);
    }
}

@keyframes swell {

    0%,
    100% {
        transform: translate3d(0, -25px, 0);
    }

    50% {
        transform: translate3d(0, 5px, 0);
    }
}

/* Responsivo até 600px */
@media (max-width: 600px) {
    #gameWrapper {
        width: min(100vw, calc(100dvh * 9 / 16 - 20px));
        margin: 0 auto;
        height: auto;
    }

    .wave {
        top: auto !important;
        bottom: 0;
    }

    .wave:nth-of-type(2) {
        top: auto !important;
        bottom: 0;
    }

    .ocean {
        height: 180px;
        overflow: hidden;
    }

    #ui {
        width: 100%;
        max-width: 100%;
        top: 10px;
        left: 0;
        transform: none;
        font-size: 16px;
        text-align: center;
    }

    #scoreWrapper {
        flex-direction: column;
        gap: 8px;
        font-size: 18px;
    }
}

#homeBtn {
    position: absolute;
    top: calc(45% + 60px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    padding: 15px 20px;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    background: rgba(0, 133, 255, 0.85);
    z-index: 999;
    width: 200px;
}

#homeBtn:hover {
    background: #00aaff;
}

.mobile-only, .close-mobile-only {
    display: none;
}

#rotateWarning {
    display: none;
    position: fixed;
    z-index: 99999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0a3d62;
    color: white;
    font-family: monospace;
    font-size: 18px;
    text-align: center;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

#loaderScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 16px;
    z-index: 99999;
    text-align: center;
}

#loaderText {
    animation: blink 1.5s infinite;
    width: 80%;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


@media screen and (orientation: landscape) and (max-width: 768px) {
    #rotateWarning {
        display: flex;
    }

    #gameWrapper,
    #titleScreen,
    #startOverlay,
    #ui,
    #restartBtn,
    #homeBtn,
    .ocean,
    .rain-container {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .titleBackground {
        background-image: url("./../../assets/images/intro-mobile.webp");
        height: 100dvh;
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center top;
    }

    #titleContent {
        display: flex;
        flex-direction: column;
        position: absolute;
        bottom: 80px;
    }

    #introText {
        background-color: rgb(0 0 0 / 88%);
        top: inherit;
        height: 100vh;
        width: 100%;
        text-align: center;
        bottom: 0;
        display: none;
        z-index: 99;
        flex-direction: column;
        align-items: center;
    }

    #introText a {

        color: #fff;
    }

    #aboutGameBtn {
        font-size: 16px;
        margin-top: 12px;
        padding: 10px 22px;
        border: none;
        color: white;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(4px);
        font-family: monospace;
        display: inline-block;
        z-index: 2;
    }

    #startGameButton {
        margin-bottom: 0;
    }

    .close-mobile-only {
        display: block;
        font-size: 19px;
        margin: 0 auto;
    }
}