/* ========================================
   GRUNDLAYOUT
   ======================================== */

body {
    margin: 0;
    background: #dff4ff;
    font-family: Arial, sans-serif;
}


/* ========================================
   SPIEL-CONTAINER
   ======================================== */

.game-container {
    width: min(1600px, 100%);
    margin: 20px auto;
    text-align: center;
    box-sizing: border-box;
    padding: 0 15px;
}


h1 {
    color: #234;
}


.intro {
    color: #345;
}


/* ========================================
   SPIELFLÄCHE
   ======================================== */

.game-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}


canvas {
    display: block;

    /* interne Spielwelt bleibt 1600 × 900 */
    width: 100%;
    height: auto;

    background: #a9dcff;

    border-radius: 15px;

    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}


/* ========================================
   HINWEIS / STEUERUNG
   ======================================== */

.hint {
    color: #345;
    margin-top: 12px;
}


/* ========================================
   SMARTPHONE
   ======================================== */

@media (max-width: 600px) {

    .game-container {
        margin: 10px auto;
        padding: 0 8px;
    }

    h1 {
        font-size: 24px;
    }

    .intro {
        font-size: 14px;
    }

    canvas {
        border-radius: 10px;
    }

    .hint {
        font-size: 13px;
    }
}


/* ========================================
   EINGEBETTET AUF DER STARTSEITE (game.html?embed)
   ======================================== */

html.embed body {
    background: transparent;
    overflow: hidden;
}

html.embed .game-container {
    margin: 0;
    padding: 0;
    width: 100%;
}

html.embed h1,
html.embed .intro,
html.embed .hint {
    display: none;
}

html.embed canvas {
    border-radius: 0;
    box-shadow: none;
}


/* ========================================
   TOUCH-STEUERUNG (wird nur auf Touch-Geräten eingeblendet)
   ======================================== */

.game-stage {
    position: relative;
    width: 100%;
}

.touch-ui {
    position: absolute;
    inset: 0;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.joy-zone {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 60%;
    pointer-events: auto;
    touch-action: none;
}

/* Joystick: in Ruhe unten links angedeutet, beim Antippen unter dem Daumen */
.joy {
    position: absolute;
    left: 17%;
    top: 72%;
    width: clamp(72px, 30vh, 140px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(2, 51, 88, 0.18);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75), 0 2px 10px rgba(0, 0, 0, 0.15);
    opacity: 0.4;
    transition: opacity 0.15s ease;
}
.joy.is-on { opacity: 1; }

.joy__knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44%;
    aspect-ratio: 1;
    margin: -22% 0 0 -22%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.jump-btn {
    position: absolute;
    right: 4%;
    bottom: 9%;
    width: clamp(64px, 26vh, 124px);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: rgba(1, 117, 196, 0.78);
    color: #fff;
    font: 700 clamp(12px, 4.2vh, 18px) Arial, sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}
.jump-btn.is-down {
    transform: scale(0.92);
    background: #0175C4;
}

/* Nach dem Gipfel: Knöpfe weg, Antippen irgendwo = Nochmal */
.touch-ui.is-won .joy-zone { width: 100%; }
.touch-ui.is-won .joy,
.touch-ui.is-won .jump-btn { display: none; }

/* Handy quer (eigenes Fenster): Spielfeld ganz auf den Bildschirm */
@media (orientation: landscape) and (max-height: 520px) {
    html:not(.embed) .game-container { margin: 0 auto; padding: 0; }
    html:not(.embed) h1,
    html:not(.embed) .intro,
    html:not(.embed) .hint { display: none; }
    html:not(.embed) .game-stage { width: min(100vw, calc(100vh * 16 / 9)); margin: 0 auto; }
    html:not(.embed) canvas { border-radius: 0; box-shadow: none; }
}

/* Eingebettet / Vollbild: Spielfeld immer komplett sichtbar (16:9 einpassen) */
html.embed .game-wrapper {
    height: 100vh;
    align-items: center;
}
html.embed .game-stage,
html.embed .game-wrapper > canvas {
    width: min(100vw, calc(100vh * 16 / 9));
}

/* Hinweise je nach Gerät */
.hint--touch { display: none; }
html.touch .hint--desk { display: none; }
html.touch .hint--touch { display: block; }

html.embed, html.embed body { height: 100%; }
html.embed .game-container { height: 100%; }

/* Feinschliff Touch: Joystick größer und höher, Sprung-Knopf transparenter */
.joy { width: clamp(96px, 40vh, 180px); left: 16%; top: 60%; }
.jump-btn { background: rgba(1, 117, 196, 0.45); border-color: rgba(255, 255, 255, 0.6); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18); }
.jump-btn.is-down { background: rgba(1, 117, 196, 0.75); }
