html,
body {
    min-height: 100vh;
    min-width: 100vw;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #000;
    background-image: url("img/img/5_background/bg.bild.png");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    font-family: "Milonga", serif;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

@font-face {
    font-family: "Milonga";
    src: url("fonts/Milonga-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

h1 {
    font-size: 48px;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.75),
        0 0 8px rgba(255, 255, 255, 0.18);
    margin: 10px 0;
    font-family: "Milonga", serif;
    letter-spacing: 2px;
    position: relative;
    z-index: 2;
}

a,
li {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

button {
    color: #0b06a1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

#game-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    /* Use dynamic viewport height on supporting browsers, fallback to 100vh */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: auto;
    min-width: auto;
}

#startContainer {
    width: 100%;
    height: 100%;
    max-width: 920px;
    max-height: 480px;
    position: relative;
    aspect-ratio: 920 / 480;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 20px;
    box-shadow: inset 0 0 110px rgba(98, 199, 9, 0.3);
    background: transparent;
    /* Prevent canvas from being clipped or distorted */
    object-fit: contain;
}

#startButton,
#playAgainBtn,
#mainMenuBtn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.2rem, 4vw, 2rem);
    padding: clamp(10px, 2vw, 15px) clamp(20px, 4vw, 30px);
    cursor: pointer;
    z-index: 20;
    background-color: rgba(24, 3, 43, 0.795);    
    border: 2px solid #b2c509;
    border-radius: 10px;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}
#mainMenuBtn {
        display: none;

    top: calc(50% + 70px);
}

#startButton:hover,
#playAgainBtn:hover,
#mainMenuBtn:hover  {
    background-color: rgb(255, 150, 0);
    transform: translate(-50%, -50%) scale(1.05);
}

#playAgainBtn {
    display: none;
}

#top-buttons {
    position: absolute;
    top: clamp(4px, 1.5vw, 10px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1100;
}

#fullscreen-btn,
#mute-btn,
#info-btn {
    position: static;
    padding: clamp(4px, 1.5vw, 10px);
    font-size: clamp(20px, 5vw, 30px);
    border: none;
    background: transparent;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1100;
    pointer-events: auto;
    transition: background 0.2s ease, opacity 0.3s ease, transform 0.3s ease;
    line-height: 1;
}
#fullscreen-btn:hover,
#mute-btn:hover,
#info-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}


#impressum {
    background: transparent;
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 700px);
    max-width: 92%;
    font-size: clamp(12px, 2.5vw, 18px);
    font-family: "Milonga", serif;
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
    border-radius: 14px;
    text-align: center;
    z-index: 900;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    line-height: 1.4;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

.canvas-btn {
    pointer-events: auto;
    font-size: clamp(10px, 5vw, 15px);
    padding: clamp(12px, 2vw, 2px) clamp(12px, 2vw, 32px);
    margin: 0 4px;
    border: none;   
    border-radius: 10px;
    background-color: rgba(24, 3, 43, 0.795);   
    color: white;
    cursor: pointer;
    z-index: 1090;
    transition: background-color 0.2s ease, transform 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}


/* Remove old conflicting mobile rules that hide buttons */
@media screen and (max-width: 600px) {

    #fullscreen-btn,
    #mute-btn,
    #info-btn {
        display: flex;
    }
}

#controls-overlay {
    position: absolute;
    width: 500px;
    max-width: 90%;    
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#controls-overlay.show {
    opacity: 1;
    pointer-events: all;
}

#controls-box {
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    padding: 45px 40px;
    border-radius: 15px;
    color: white;
    backdrop-filter: blur(6px);
    font-size: large;
}

.hide-ui {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
    transition: opacity 0.4s ease, transform 0.3s ease;
}

.show-ui {
    opacity: 1 !important;
    pointer-events: all !important;
    transform: translateY(0);
}

#touch-buttons {
    display: none;
}

@media screen and (min-width: 1025px) and (max-width: 1380px) {
    #touch-buttons.show-touch-buttons {
        display: flex;
        position: absolute;
        bottom: 50px;
        left: 0;
        right: 0;
        width: 100%;
        justify-content: space-between;
        align-items: flex-end;
        padding: 4px;
        z-index: 1090;
        pointer-events: none;
        flex-wrap: nowrap;
        bottom: 10px;
    }

    #leftBtn {
        order: 1;
    }

    #rightBtn {
        order: 2;
        margin-right: auto;
    }

    #jumpBtn {
        order: 3;
    }

    #throwBtn {
        order: 4;
    }
}

/* Show touch buttons on mobile/tablet sizes */
@media screen and (max-width: 1366px) {
    #touch-buttons.show-touch-buttons {
        display: flex;
        position: absolute;
        bottom: 50px;
        left: 0;
        right: 0;
        width: 100%;
        justify-content: space-between;
        align-items: flex-end;
        padding: 4px;
        z-index: 1090;
        pointer-events: none;
        flex-wrap: nowrap;
        bottom: 10px;
    }

    /* Reorder buttons: LEFT group first, RIGHT group last */
    #leftBtn {
        order: 1;
    }

    #rightBtn {
        order: 2;
        margin-right: auto;
    }

    #jumpBtn {
        order: 3;
    }

    #throwBtn {
        order: 4;
    }

    /* Push fullscreen/mute buttons to sit above touch buttons */
    #fullscreen-btn {
        bottom: clamp(2px, 1vw, 6px);
        z-index: 1110;
    }

    #mute-btn {
        bottom: clamp(2px, 1vw, 6px);
        z-index: 1110;
    }
}

@media screen and (max-width: 600px) {
    #touch-buttons.show-touch-buttons {
        display: flex;
        bottom: clamp(44px, 8vh, 50px);
        padding: 0 clamp(10px, 4vw, 16px);
        bottom: 10px;
    }

    #fullscreen-btn {
        bottom: 2px;
        z-index: 1110;
    }

      


    #mute-btn {
        bottom: 2px;
        z-index: 1110;
    }
}

@media screen and (max-width: 480px) {
    #touch-buttons.show-touch-buttons {
        bottom: 10px;
        padding: 0 8px;
    }

   
    
}

/* Base button styling */

#throwBtn img {
    width: 20px;
    height: 17px;
}

/* Smaller touch button text on very small screens */
@media screen and (max-width: 400px) {
   
 #touch-buttons.show-touch-buttons {
    bottom: 10px;
        display: flex;
    }

 
}

#game-container,
#impressum,
#controls-box,
#fullscreen-btn,
#mute-btn,
#info-btn,
.canvas-btn,
#startButton,
#playAgainBtn {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

button {
    cursor: pointer;
    background-color: transparent;
    border: 2px solid white;
    color: white;
    padding: 8px 16px;
    font-size: 18px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* ===== ORIENTATION WARNING ===== */
#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-size: clamp(1.2rem, 5vw, 2rem);
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
    gap: 16px;
}

/* Add a subtitle hint for better spacing */
#orientation-warning::after {
    content: "Landscape mode recommended for best experience";
    display: block;
    font-size: clamp(0.7rem, 2.5vw, 1rem);
    opacity: 0.7;
    margin-top: 8px;
}

@media screen and (orientation: portrait) and (max-width: 1024px) {
    #orientation-warning {
        display: flex;
    }

     #touch-buttons.show-touch-buttons {
        bottom: 10px;
        display: flex;
    }

    #game-container {
        display: none;
    }

    /* Keep impressum visible at bottom of orientation screen */
    #impressum {
        display: block !important;
        position: fixed;
        bottom: 14px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1300;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.16);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
        font-size: clamp(12px, 2.5vw, 18px);
        padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
        width: min(92%, 700px);
        max-width: 92%;
        text-align: center;
        line-height: 1.4;
        color: #fff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
        pointer-events: auto;
    }
}

/* Landscape: show game, show impressum with proper spacing */
@media screen and (max-width: 1024px) and (orientation: landscape) {
    #impressum {
        bottom: 80px;
        background-color: transparent;
        font-size: clamp(10px, 2vw, 14px);
        padding: 6px 10px;
        width: min(90%, 600px);
    }
    
 #touch-buttons.show-touch-buttons {
    bottom: 10px;
        display: flex;
    }

    #game-container {
        display: flex;
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
    }

    h1 {
        font-size: clamp(20px, 4vw, 32px);
        margin: 4px 0;
    }
}

@media screen and (orientation: landscape) {
    #orientation-warning {
        display: none;
    }

    #game-container {
        display: flex;
    }

    #impressum {
        position: fixed;
        background-color: transparent;
        border: 1px solid rgba(255, 255, 255, 0.16);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    }
}

/* ===== IMPRESSUM PAGE (lang="de") ===== */
html[lang="de"] #impressum {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    width: min(92%, 940px);
    max-width: 940px;
    margin: 20px auto 40px;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(0, 0, 0, 0.5);
    display: block;
}

html[lang="de"] h1 {
    margin-top: 20px;
}

/* Consolidate impressum responsive rules - remove conflicts and overlaps */
@media screen and (max-width: 900px) {
    #impressum:not([lang="de"]) {
        position: fixed;
        z-index: 900;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.16);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    }
}

/* Specific fix for very short viewports (e.g. landscape phones) */
@media screen and (max-height: 450px) and (orientation: landscape) {
    h1 {
        display: none;
    }

    

    
    #game-container {
        height: 100vh;
        height: 100dvh;
    }

    #impressum:not([lang="de"]) {
        display: none;
    }

    #fullscreen-btn {
        bottom: 2px;
        right: 4px;
        font-size: 16px;
        z-index: 1110;
    }

    #mute-btn {
        bottom: 2px;
        left: 4px;
        font-size: 16px;
        z-index: 1110;
    }

    #info-btn {
        top: 2px;
        right: 4px;
        font-size: 20px;
    }

    #touch-buttons.show-touch-buttons {
        bottom: 10px;
        z-index: 1090;
    }

   

    #startButton,
    #playAgainBtn {
        font-size: 22px;
        padding: 6px 12px;
    }
}