/* ============================================================
   Mathe-Abenteuer – Layout
   ============================================================ */

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

html, body {
    height: 100%;
}

body {
    background-color: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    overflow: hidden;   /* kein Scroll → Rotation wird nicht blockiert */
}

/* Game-Container: passt sich Breite UND Höhe an.
   min() sorgt dafür, dass das Spiel nie höher als der Viewport wird
   und dabei das Seitenverhältnis 800:520 beibehält.
   Auf dem Desktop ist max-width 800px die Grenze. */
#game-container {
    /* Breite: max Viewport-Breite, aber nie breiter als das Seitenverhältnis 800:520 es bei Vollhöhe erlaubt */
    width: min(100vw, calc(100dvh * 800 / 520));
    max-width: 800px;
    /* Höhe explizit über aspect-ratio – verhindert Kollaps vor Canvas-Initialisierung */
    aspect-ratio: 800 / 520;
    background-color: #a8d8a8;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    position: relative;
}

/* Canvas: Phaser Scale.FIT setzt Breite/Höhe selbst passend zum Container */
#game-container canvas {
    display: block;
}

footer {
    color: #888;
    font-family: Arial, sans-serif;
    font-size: 13px;
    text-align: center;
    padding: 0.5rem 0;
    flex-shrink: 0;
}

/* ============================================================
   Login-Overlay
   ============================================================ */
#login-overlay {
    width: min(400px, 90vw);
    background: #a8d8a8;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    padding: 2rem;
    color: #2C3E50;
    font-family: Arial, sans-serif;
}

#login-overlay h1 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
    color: #2C3E50;
}

#login-overlay .mq-sub {
    text-align: center;
    color: #4a6050;
    margin-bottom: 1.5rem;
    font-style: italic;
}

#login-overlay input {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 2px solid #2C3E50;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    font-family: Arial, sans-serif;
}

#login-overlay input:focus {
    outline: none;
    border-color: #F5C842;
}

#login-overlay .mq-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

#login-overlay button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    background: #27AE60;
    color: #fff;
    transition: filter 0.15s;
    font-family: Arial, sans-serif;
}

#login-overlay button[data-action="register"] {
    background: #2980B9;
}

#login-overlay button:hover {
    filter: brightness(1.1);
}

#mq-login-error {
    min-height: 1.5rem;
    color: #E74C3C;
    font-weight: bold;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
    margin-top: 0.5rem;
}

#mq-login-error.mq-sichtbar {
    opacity: 1;
}

/* ---- Querformat auf Mobilgeräten ---- */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        padding: 0;
        justify-content: center;
        align-items: center;
        min-height: 100dvh;
        overflow: hidden;
    }

    #game-container {
        height: 100dvh;
        width: calc(100dvh * 800 / 520);
        max-width: 100dvw;
        aspect-ratio: 800 / 520;
        border-radius: 0;
        box-shadow: none;
    }

    footer {
        display: none;
    }
}

/* ---- Hochformat Mobilgeräte ---- */
@media (orientation: portrait) and (max-width: 600px) {
    body {
        justify-content: flex-start;
        padding-top: 0.5rem;
    }

    #game-container {
        border-radius: 6px;
    }
}
