@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&family=Pixelify+Sans:wght@400..700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="28" height="54" viewBox="0 0 24 24"><path fill="%23FFF" stroke="%23000" stroke-width="1.75" d="M5.5 3.21V20.8c0 .45.54.67.85.35l4.86-4.86a.5.5 0 0 1 .35-.15h6.87a.5.5 0 0 0 .35-.85L6.35 2.85a.5.5 0 0 0-.85.35Z"></path></svg>') 6 15, auto;
}

body {
    background-image: radial-gradient(
        circle,
        rgba(0, 17, 37, 1) 0%,
        rgba(0, 17, 37, 1) 25%,
        rgba(0, 0, 0, 1) 100%
    );
    background-size: cover;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#GameScreen {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-image: radial-gradient(
        circle,
        rgba(0, 17, 37, 1) 0%,
        rgba(0, 17, 37, 1) 25%,
        rgba(0, 0, 0, 1) 100%
    );
}

#GameScreen:fullscreen {
    width: 100vw;
    height: 100vh;
    display: flex;
}

#canvasWrapper {
    position: relative;
    width: min(100vw, calc(100vh * 1.5));
    height: auto;
    aspect-ratio: 1200 / 800;
    margin: 0 auto;
    line-height: 0;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    -webkit-touch-callout: none;
}

/* ─── HUD Button Overlay ─────────────────────────────────────── */

.button-Layout {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.button-Layout button {
    pointer-events: auto;
}

.top-right-btns {
    position: absolute;
    top: calc(1.2% + env(safe-area-inset-top, 0px));
    right: calc(0.8% + env(safe-area-inset-right, 0px));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(2px, .5vw, 8px);
    z-index: 5;
}

#SoundMuteButton {
    background: none;
    border: none;
    color: white;
    z-index: 5;
    width: clamp(20px, 2.5vw, 37.8px);
    height: clamp(16px, 2vw, 32.4px);
    padding: 0;
}

#SettingsButton {
    background: none;
    border: none;
    color: white;
    z-index: 5;
    width: clamp(22px, 2.8vw, 40px);
    height: clamp(22px, 2.8vw, 40px);
    padding: 0;
}

#FullscreenButton {
    background: none;
    border: none;
    color: white;
    z-index: 5;
    width: clamp(22px, 2.8vw, 40px);
    height: clamp(22px, 2.8vw, 40px);
    padding: 0;
}

#SoundMuteButton svg,
#SettingsButton svg,
#FullscreenButton svg {
    width: 100%;
    height: 100%;
}

#nextWaveBtn {
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: transparent;
    border: 2px solid #4de2f2;
    color: #4de2f2;
    font-family: 'Pixelify Sans', monospace;
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
    letter-spacing: 2px;
    padding: 8px 28px;
    transition: background 0.2s, color 0.2s;
    animation: pulse-border 1.2s ease-in-out infinite;
}

#nextWaveBtn:hover {
    background: #4de2f2;
    color: #151b2b;
}

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(77, 226, 242, 0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(77, 226, 242, 0); }
}

/* ─── Mobile touch controls ──────────────────────────────────── */

#Handy_Oben {
    position: absolute;
    top: 0;
    height: 50%;
    width: 100%;
    opacity: 0.1;
    z-index: 1;
    display: none;
}

#Handy_Unten {
    position: absolute;
    bottom: 0;
    height: 50%;
    width: 100%;
    opacity: 0.1;
    z-index: 1;
    display: none;
}

#Handy_shot {
    background-image: url("img/handy-shot-button3.png");
    background-size: cover;
    background-position: center;
    background-color: transparent;
    position: absolute;
    width: clamp(55px, 6.5vw, 75px);
    height: clamp(55px, 6.5vw, 75px);
    bottom: calc(3% + env(safe-area-inset-bottom, 0px));
    right: calc(2% + env(safe-area-inset-right, 0px));
    z-index: 2;
    border: none;
    filter: brightness(50%);
}

#Handy_shot:hover {
    filter: brightness(80%) drop-shadow(0 5px 5px rgba(0, 0, 0, 0.5));
}

.blink--effect {
    animation: blink 3s ease forwards;
}

@keyframes blink {
    0%   { opacity: 0.1; scale: 1; }
    33%  { opacity: 0.175; scale: 1.015; }
    66%  { opacity: 0.1; scale: 0.985; }
    85%  { opacity: 0.1; scale: 1; }
    100% { opacity: 0; scale: 1; }
}

/* ─── Main Menu ──────────────────────────────────────────────── */

.MainMenu {
    background: transparent;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#startBtn {
    background-image: url("img/start\ game.png");
    background-size: cover;
    background-position: center;
    background-color: transparent;
    border: none;
    filter: brightness(70%);
    width: clamp(120px, 15vw, 181px);
    height: clamp(40px, 5vw, 61.2px);
    position: absolute;
    bottom: 40%;
    left: 50%;
    transform: translate(-50%, 50%);
}

#settingsBtn {
    background-image: url("img/Volume.png");
    background-size: cover;
    background-position: center;
    background-color: transparent;
    border: none;
    filter: brightness(70%);
    width: clamp(120px, 15vw, 181px);
    height: clamp(40px, 5vw, 61.2px);
    position: absolute;
    bottom: calc(40% + clamp(44px, 5.5vw, 65px));
    left: 50%;
    transform: translate(-50%, 50%);
}

#settingsBtn:hover,
#startBtn:hover,
#backBtn:hover {
    filter: brightness(100%);
}

/* ─── Settings Menu ──────────────────────────────────────────── */

.settings-menu {
    width: 40%;
    height: 70%;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-radius: 5px;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    font-family: "Poppins", sans-serif;
    font-weight: 400;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to bottom right, #151b2b, #191f3c);
    overflow: hidden;
    overflow-y: auto;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 0 12px 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.settings-menu h2 {
    margin: 0;
    padding-left: 10px;
    font-size: clamp(1.1rem, 2vw, 1.75rem);
    font-weight: normal;
    letter-spacing: 1px;
    color: #fff;
}

#backBtn {
    background-image: url("img/back_arrow.png");
    background-size: cover;
    background-position: center;
    background-color: transparent;
    filter: brightness(70%);
    width: clamp(50px, 7vw, 80.8px);
    height: clamp(30px, 4.5vw, 50px);
    border: none;
    flex-shrink: 0;
}

.settingsMenuContent {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    padding: 10px 20px 20px;
}

.volume-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.volume-setting p {
    margin: 0;
    width: 35%;
    text-align: start;
    font-size: clamp(0.8rem, 1.5vw, 1.5rem);
}

.volume-setting input[type="range"] {
    flex: 1;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5), 0 0 10px 2px rgba(0, 0, 0, 0.5);
    -webkit-appearance: none;
    background: #2c2f4a;
    border-radius: 5px;
    height: 16px;
    min-width: 60px;
}

.volume-setting input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    transform: rotate(45deg);
    background: #51eeff;
    box-shadow: 2px 2px 10px 5px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s;
}

.volume-setting input[type="range"]:hover::-webkit-slider-thumb {
    background: #00eeff;
    transform: scale(0.95);
}

.volume-setting input[type="range"]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    transform: rotate(45deg);
    background: #51eeff;
    box-shadow: 2px 2px 10px 5px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s;
    border: none;
}

.volume-setting input[type="range"]:hover::-moz-range-thumb {
    background: #00eeff;
    transform: scale(0.95);
}

#MusicSlider-value,
#ShotSlider-value,
#HitSlider-value,
#MenuSlider-value,
#TypeSlider-value {
    font-size: clamp(0.7rem, 1.2vw, 1.2rem);
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.MobileLayout {
    display: flex;
    align-items: center;
    flex-direction: row;
    width: 100%;
}

.MobileLayout p {
    margin-right: 10px;
    width: 35%;
    text-align: start;
    font-size: clamp(0.8rem, 1.5vw, 1.5rem);
}

.checkBox {
    display: block;
    width: 20px;
    height: 20px;
    border: 3px solid black;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 0 2px #fff;
    flex-shrink: 0;
}

.checkBox div {
    width: 60px;
    height: 60px;
    background-color: #fff;
    top: -52px;
    left: -52px;
    position: absolute;
    transform: rotateZ(45deg);
    z-index: 2;
}

.checkBox input[type=checkbox]:checked + div {
    left: -10px;
    top: -10px;
}

.checkBox input[type=checkbox] {
    position: absolute;
    transform: translate(-50%, 0);
    visibility: hidden;
}

.transition {
    transition: 0.2s ease;
}

/* ─── Game Over Screen ───────────────────────────────────────── */

.game-over-screen {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    align-items: center;
    justify-content: center;
}

.game-over-content {
    background: linear-gradient(to bottom right, #151b2b, #191f3c);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    padding: clamp(20px, 4vw, 40px) clamp(24px, 5vw, 60px);
    text-align: center;
    color: #fff;
    font-family: "Poppins", sans-serif;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    min-width: clamp(240px, 40vw, 320px);
    max-width: 90vw;
}

.game-over-content h1 {
    font-size: clamp(1.6rem, 4vw, 3rem);
    letter-spacing: 4px;
    font-family: 'Pixelify Sans', monospace;
    color: #4de2f2;
    text-shadow: 0 0 20px rgba(77, 226, 242, 0.45);
    margin: 0;
}

.go-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.go-stats p {
    font-size: clamp(0.85rem, 1.5vw, 1.2rem);
    color: rgba(255, 255, 255, 0.82);
    margin: 0;
}

#restartBtn {
    background: transparent;
    border: 2px solid #4de2f2;
    color: #4de2f2;
    font-family: 'Pixelify Sans', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.2rem);
    letter-spacing: 2px;
    padding: 10px 32px;
    margin-top: 8px;
    transition: background 0.2s, color 0.2s;
}

#restartBtn:hover {
    background: #4de2f2;
    color: #151b2b;
}

/* ─── Event Log ──────────────────────────────────────────────── */

.Event-Log {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    font-family: monospace, 'Poppins', sans-serif;
    font-size: clamp(0.7rem, 1.1vw, 1.1rem);
    color: #fff;
    padding: 0 15px;
    border-right: 0.15rem solid white;
    pointer-events: none;
    overflow: hidden;
    white-space: pre-wrap;
    line-height: 1.4;
    animation: blink-caret 0.75s step-end infinite;
    z-index: 1;
    max-width: 50%;
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50%       { border-color: white; }
}

/* ─── Utility ────────────────────────────────────────────────── */

.hidden {
    display: none !important;
    pointer-events: none;
}

.Landscape-advise {
    display: none;
}

/* ─── Responsive Breakpoints ─────────────────────────────────── */

@media screen and (orientation: portrait) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    #canvasWrapper {
        width: 100vw;
        max-width: 100vw;
    }

    .settings-menu {
        width: 90%;
        height: 75%;
    }

    .Landscape-advise {
        display: block;
        position: absolute;
        width: 100%;
        text-align: center;
        padding: 1em;
        top: 20%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: white;
        font-size: clamp(16px, 4vw, 24px);
        letter-spacing: 2px;
        font-family: Geneva, Verdana, sans-serif;
        z-index: 10;
    }
}

@media screen and (orientation: portrait) and (max-width: 680px) {
    #SoundMuteButton {
        right: calc(7.2% + env(safe-area-inset-right, 0px));
    }

    #SettingsButton {
        right: calc(3.8% + env(safe-area-inset-right, 0px));
    }

    #FullscreenButton {
        right: calc(0.6% + env(safe-area-inset-right, 0px));
    }
}

@media screen and (orientation: landscape) and (max-width: 900px) {
    body {
        height: 100vh;
    }

    #GameScreen {
        width: 100vw;
        height: 100vh;
    }

    #canvasWrapper {
        height: 100vh;
        width: auto;
        aspect-ratio: 1200 / 800;
        max-width: 100vw;
    }

    canvas {
        height: 100%;
        width: 100%;
    }

    .settings-menu {
        width: 72%;
        height: 88%;
    }

    .settingsMenuContent {
        gap: 10px;
        padding: 8px 14px 14px;
    }

    .header-row {
        padding: 8px 0 10px 8px;
        margin-bottom: 10px;
    }
}

@media screen and (orientation: landscape) and (max-width: 680px) {
    .settings-menu {
        width: 86%;
        height: 92%;
    }

    .settingsMenuContent {
        gap: 7px;
    }

    .volume-setting input[type="range"] {
        height: 12px;
    }

    .game-over-content {
        gap: 10px;
    }
}