/* Schriften lokal ausgeliefert. Vorher lud diese Datei sie per @import von
 * fonts.googleapis.com - damit ging die IP jedes Besuchers an Google, ohne
 * Einwilligung (vgl. LG Muenchen I, 20.01.2022, Az. 3 O 17493/20).
 * Quelle: Google Fonts, Open Font License. Dateien in static/fonts/.
 */
@font-face {
    font-family: 'Fredoka One';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/FredokaOne-400-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/Poppins-400-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/Poppins-400-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/Poppins-600-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/Poppins-600-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/Poppins-700-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/Poppins-700-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


:root {
    --color-bg: #111827; /* Dunkelgrau/Blau */
    --color-panel: #1F2937; /* Etwas helleres Grau/Blau */
    --color-card: #374151;
    --color-primary: #A855F7; /* Leuchtendes Lila */
    --color-secondary: #34D399; /* Leuchtendes Grün/Mint */
    --color-accent: #FBBF24; /* Leuchtendes Gelb/Gold */
    --color-text: #F9FAFB; /* Sehr helles Grau */
    --color-text-muted: #9CA3AF;
    --color-danger: #F43F5E; /* Leuchtendes Pink/Rot */
    /* Diese Werte waren in game_base.css und make_it_meme.css dutzendfach hart
     * kodiert. Als Token sind sie an einer Stelle pflegbar - und die Spielseiten
     * sprechen damit dieselbe Sprache wie Lobby und Profil. */
    --color-info: #3B82F6;           /* Blau fuer Hinweise und Promote */
    --color-deep: #020617;           /* Tiefster Grund der Spielseiten */
    --rgb-deep: 15, 23, 42;
    --rgb-slate: 148, 163, 184;
    --rgb-info: 59, 130, 246;

    --font-primary: 'Poppins', sans-serif;
    --font-headings: 'Fredoka One', cursive;
    --border-radius: 16px;
    --shadow-glow: 0 0 15px -5px;

    /* Harte Offset-Schatten statt weichem Schein: schaerfere Kante, wirkt
     * moderner und spielerischer, ohne einen Farbwert zu aendern. */
    --shadow-hard: 4px 4px 0;
    --shadow-hard-sm: 3px 3px 0;
    --border-chunky: 2px;

    /* Breiten-Skala. Vorher lag alles in festen 480px - der Avatar-Editor mit
     * seinen 20 Bedienelementen war darin die Engstelle. */
    --width-narrow: 480px;
    --width-default: 560px;
    --width-wide: 760px;

    /* Mindestmass fuer Tippflaechen: Apple empfiehlt 44pt, Material 48dp,
     * WCAG 2.5.8 fordert 24px. 44 erfuellt AA und AAA. */
    --touch-min: 44px;

    /* Kleinere Nebenaktionen (Kicken, Leiter uebergeben, Kopieren). Mit Maus
     * genuegen 34px; auf Touch-Geraeten wird daraus unten --touch-min. */
    --action-size: 34px;
}

html {
    /* Vorher overflow-y:scroll - das erzwang dauerhaft eine Scrollleiste und
     * verschob zentrierte Inhalte um deren halbe Breite nach links.
     * scrollbar-gutter reserviert den Platz nur, verhindert aber den Sprung. */
    scrollbar-gutter: stable;
}

@media (pointer: coarse) {
    :root {
        --action-size: var(--touch-min);
    }
}

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

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    /* Spalte statt Reihe: vorher lagen Inhalt und Footer nebeneinander.
     * Die Zentrierung macht jetzt margin:auto am Container - anders als
     * align-items:center klippt das bei hohem Inhalt nichts weg. */
    display: flex;
    flex-direction: column;
    /* dvh statt vh: auf Mobilbrowsern rechnet 100vh gegen den grossen Viewport
     * (eingefahrene Adressleiste) und ist damit hoeher als sichtbar. */
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-headings);
    color: var(--color-text);
    letter-spacing: 1px;
    text-align: center;
}

/* Panels leben von der Zentrierung, Fliesstext nicht: auf den Rechtsseiten
 * sahen zentrierte Abschnittsueberschriften wie ein Fehler aus. */
.legal h1,
.legal h2,
.legal h3 {
    text-align: left;
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-primary);
}


/* --- ZENTRIERTER CONTAINER --- */
.centered-container {
    width: 100%;
    max-width: var(--container-max, var(--width-default));
    /* auto auf allen Seiten: zentriert vertikal, schiebt den Footer nach unten
     * und faellt bei zu hohem Inhalt auf 0 zurueck statt abzuschneiden. */
    margin: auto;
}

/* Breitenvarianten: per Zusatzklasse am Container. */
.container-narrow { --container-max: var(--width-narrow); }
.container-wide { --container-max: var(--width-wide); }

.panel {
    background-color: var(--color-panel);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    border: 1px solid var(--color-card);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: fade-in-slide-up 0.7s ease-out forwards;
}

@keyframes fade-in-slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-header {
    text-align: center;
    margin-bottom: 2rem;
}

.panel-header h1 {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.panel-header p {
    color: var(--color-text-muted);
}

.panel-header .username-display {
    color: var(--color-secondary);
    font-weight: bold;
}


/* --- FORMULAR-STILE --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.form-control {
    width: 100%;
    background-color: var(--color-bg);
    border: 2px solid var(--color-card);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px -2px var(--color-primary);
}

/* --- BUTTON-STILE --- */
.btn {
    width: 100%;
    padding: 0.8rem 1rem;
    font-family: var(--font-headings);
    font-size: 1.1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
    z-index: 1;
    display: block;
    text-align: center;
    /* Harte Kante statt flachem Rechteck: dicker Rahmen plus versetzter
     * Schatten ohne Weichzeichnung. Das ist der Griff, der die Oberflaeche
     * moderner und gleichzeitig spielerischer macht. */
    border: var(--border-chunky) solid rgba(15, 23, 42, 0.55);
    box-shadow: var(--shadow-hard) rgba(15, 23, 42, 0.55);
}

.btn:hover:not(:disabled) {
    transform: translate(-1px, -1px);
    box-shadow: 5px 5px 0 rgba(15, 23, 42, 0.55);
}

.btn:active:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(15, 23, 42, 0.55);
}
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: rgba(255,255,255,0.2);
    transition: width 0.4s ease;
    z-index: -1;
}
.btn:hover:not(:disabled)::before {
    width: 100%;
}
.btn:disabled {
    cursor: not-allowed;
    filter: grayscale(60%);
    opacity: 0.7;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
    box-shadow: var(--shadow-glow) var(--color-primary);
}
.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-bg);
    box-shadow: var(--shadow-glow) var(--color-secondary);
}
.btn-accent {
    background: var(--color-accent);
    color: var(--color-bg);
    box-shadow: var(--shadow-glow) var(--color-accent);
}
.btn-danger {
    background: var(--color-danger);
    color: var(--color-text);
    box-shadow: var(--shadow-glow) var(--color-danger);
}
.btn-card {
    background: var(--color-card);
    color: var(--color-text);
}


/* --- MODAL STYLES --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: none;
}
.modal.show {
    display: block;
    overflow: hidden auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: #000;
    z-index: 1040;
}
.modal-content {
    background-color: var(--color-panel);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-primary);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.3);
}
/* Das Fenster stand vorher 1rem rechts der Mitte: .modal-dialog hatte
 * left:50% mit translate(-50%,-50%) UND margin:0 1rem - bei absoluter
 * Positionierung addiert sich der Rand zum Versatz.
 *
 * Kein Flex auf .modal, weil Bootstraps JS beim Oeffnen style="display:block"
 * inline setzt und das jede Stylesheet-Regel schlaegt. Die Zentrierung macht
 * deshalb der Dialog selbst - wie in Bootstraps eigenem CSS, das hier nicht
 * geladen ist (nur das JS). */
.modal-dialog {
    max-width: 480px;
    width: 100%;
    margin: 1rem auto;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 2rem);
}

.modal-dialog-centered .modal-content {
    width: 100%;
}
.modal-header, .modal-footer {
    border-bottom: none;
    border-top: 1px solid var(--color-card);
    padding: 1rem 1.5rem;
}
.modal-header {
    border-top: none;
    position: relative;
}
.modal-header .modal-title {
    font-size: 1.5rem;
    color: var(--color-primary);
}
.modal-body {
    padding: 1.5rem;
    color: var(--color-text-muted);
}
.modal-footer .btn {
    min-width: 120px;
    font-size: 1rem;
}
.modal-footer .btn-secondary {
    background: var(--color-card);
}
.modal-backdrop.show {
    opacity: 0.7;
    backdrop-filter: blur(5px);
}

body.modal-open {
    overflow: hidden;
}

/* --- AVATAR EDITOR (INDEX) --- */
.avatar-editor {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: 14px;
    background-color: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--color-card);
}

.avatar-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.avatar-editor-header span:first-child {
    font-weight: 600;
    color: var(--color-secondary);
}

.avatar-editor-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.avatar-tabs {
    display: inline-flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-radius: 999px;
    padding: 0.12rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--color-card);
}

.avatar-tab-btn {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    /* War 0.25rem/0.8rem und damit deutlich unter Fingergroesse. */
    min-height: var(--touch-min);
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
}

.avatar-tab-btn.is-active {
    background: var(--color-accent);
    color: #fff;
}

.avatar-editor-body {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.avatar-tab-content {
    flex: 1;
    display: none;
}

.avatar-tab-content.is-active {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Die Standard-Ansicht zentrierte bisher nur ihren Inhalt, sass als schmales
 * Flex-Element aber am linken Rand der Zeile. Volle Breite zentriert alles. */
.avatar-standard-preview {
    width: 100%;
}

.avatar-canvas {
    /* Quadratisch, weil der Avatar quadratisch ist - die Bitmap ist 256x256
     * (profile.js). Vorher stand hier flex:0 0 160px, was im Spaltencontainer
     * des Studios auf die Hoehe wirkte; die Breite fiel auf die 256px der
     * Bitmap zurueck und die Zeichnung wurde gequetscht. Jetzt feste Kante
     * plus aspect-ratio als Sicherung. */
    flex: 0 0 auto;
    width: 200px;
    height: 200px;
    aspect-ratio: 1 / 1;
    touch-action: none; /* Zeichnen auf dem Touchscreen scrollt sonst die Seite */
    border-radius: 14px;
    border: 2px solid var(--color-card);
    background-color: #111827;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    cursor: crosshair;
}

.avatar-tools {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Mehr Luft: drei benannte Gruppen statt vier gleichformatiger Reihen. */
    gap: 0.9rem;
    min-width: 0;
}

.avatar-tool-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.avatar-tool-btn {
    flex: 1;
    min-height: var(--touch-min);
    font-size: 0.9rem;
    padding: 0.5rem 0.7rem;
}

.avatar-tool-btn.is-active {
    box-shadow: 0 0 0 1px var(--color-secondary);
}

/* Farbfelder: 32px mit 8px Abstand, also 40px von Mitte zu Mitte. Die alten
 * 24 bzw. 22 Pixel lagen am bzw. unter dem WCAG-Minimum von 24. Volle 44px
 * waeren bei sechs Feldern nebeneinander breiter als ein Telefon. */
.avatar-color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
}

.avatar-color-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 2px solid #ffffff;
    cursor: pointer;
    padding: 0;
    outline: none;
}

.avatar-color-btn.is-active {
    box-shadow: 0 0 0 2px var(--color-secondary);
}

.avatar-bg-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.avatar-bg-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 2px solid #ffffff;
    cursor: pointer;
    padding: 0;
    outline: none;
}

.avatar-bg-btn.is-active {
    box-shadow: 0 0 0 2px var(--color-secondary);
}

.avatar-bg-btn-transparent {
    border-color: #ffffff;
}

.avatar-standard-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.avatar-standard-box {
    /* Gleiche Kante und gleicher Radius wie die Zeichenflaeche: beide zeigen
     * denselben Gegenstand, naemlich den quadratischen Avatar. */
    width: 96px;
    height: 96px;
    border-radius: 14px;
    /* Der Verlauf kommt jetzt aus dem erzeugten SVG (avatar-identity.js) und
     * wird aus dem Namen abgeleitet - vorher stand hier ein fester. */
    background-color: var(--color-card);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    border: var(--border-chunky) solid rgba(var(--rgb-deep), 0.5);
}

.avatar-standard-box svg {
    display: block;
    width: 100%;
    height: 100%;
}

.avatar-standard-letter {
    font-family: var(--font-headings);
    font-size: 2.4rem;
    color: #fff;
}

.avatar-standard-text {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-align: center;
}

.avatar-message {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-secondary);
    min-height: 1em;
}

/* --- RESPONSIVE --- */
/* Vorher gab es hier eine einzige Media Query fuer den Avatar-Editor. Profil und
 * Lobbyerstellung waren damit praktisch unresponsiv, und der kleinste Breakpoint
 * im Projekt lag bei 480px - typische Telefone liegen bei 360-412px. */

@media (max-width: 700px) {
    body {
        padding: 0.75rem;
    }

    .panel {
        padding: 1.75rem 1.25rem;
    }

    .panel-header h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 600px) {
    .avatar-editor-body {
        flex-direction: column;
        align-items: center;
    }

    /* Zeichenflaeche darf hier wachsen, weil sie die Spalte allein hat -
     * und bleibt dabei quadratisch. */
    .avatar-canvas {
        flex: 0 0 auto;
        width: min(260px, 72vw);
        height: min(260px, 72vw);
    }

    .avatar-tools {
        width: 100%;
    }
}

@media (max-width: 380px) {
    body {
        padding: 0.5rem;
    }

    .panel {
        padding: 1.25rem 1rem;
        border-radius: 14px;
    }

    .panel-header h1 {
        font-size: 1.35rem;
        letter-spacing: 0.5px;
    }

    .btn {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    /* Felder duerfen hier etwas kleiner werden, bleiben aber ueber dem
     * WCAG-Minimum von 24px. */
    .avatar-color-btn,
    .avatar-bg-btn {
        width: 28px;
        height: 28px;
    }
}

.d-none {
    display: none !important;
}

/* Close-Button im Modal-Kopf (unabhängig von Bootstrap-CSS) */
.btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    /* War 24x24 - exakt am WCAG-Minimum. Die Flaeche ist jetzt fingergross,
     * das Kreuz darin bleibt zierlich. */
    width: var(--touch-min);
    height: var(--touch-min);
    padding: 0;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.btn-close::before {
    content: '×';
    font-size: 1.3rem;
    line-height: 1;
    color: var(--color-text-muted);
}
.btn-close:hover::before {
    color: var(--color-text);
}
.btn-close-white::before {
    color: #fff;
}

/* --- FUSSZEILE --- */
/* Impressum und Datenschutzerklaerung muessen von jeder Seite aus mit einem Klick
 * erreichbar sein (5 DDG: "leicht erkennbar, unmittelbar erreichbar und staendig
 * verfuegbar"). Vorher zwei nackte Links, jetzt mit Markenbezug. */
.site-footer {
    width: 100%;
    max-width: 1100px;
    margin: 2.5rem auto 0;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    border-top: 1px solid var(--color-card);
    font-size: 0.85rem;
}

.site-footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-headings);
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.site-footer-mark {
    width: 22px;
    height: 22px;
    opacity: 0.85;
}

.site-footer-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.site-footer-links a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-min);
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.site-footer-links a:hover,
.site-footer-links a:focus-visible {
    color: var(--color-text);
    border-bottom-color: var(--color-secondary);
}

@media (max-width: 480px) {
    .site-footer {
        justify-content: center;
        text-align: center;
    }

    .site-footer-links {
        gap: 1rem;
    }
}

/* --- KOPFZEILE --- */
/* Vorher gab es auf Startseite, Lobbyerstellung und Lobby ueberhaupt keinen
 * Header - keinen Ort, der "das hier ist Multigame" sagt, und keinen festen
 * Platz fuer Name, Avatar und Lobby-Code. Bewusst keine graue Corporate-Leiste:
 * dicker Rahmen, harter Offset-Schatten, Fredoka One. */
.site-header {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 1.5rem;
    padding: 0.6rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--color-panel);
    border: var(--border-chunky) solid var(--color-card);
    border-radius: 999px;
    box-shadow: var(--shadow-hard-sm) rgba(0, 0, 0, 0.45);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: var(--touch-min);
    padding-right: 0.4rem;
    color: var(--color-text);
    text-decoration: none;
}

.brand:hover {
    color: var(--color-text);
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    transition: transform 0.25s ease;
}

/* Kleines Zwinkern beim Darueberfahren - das Verspielte darf man sehen. */
.brand:hover .brand-mark {
    transform: rotate(-10deg) scale(1.06);
}

.brand-name {
    font-family: var(--font-headings);
    font-size: 1.35rem;
    letter-spacing: 0.5px;
    line-height: 1;
}

.brand-name-accent {
    color: var(--color-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.header-lobby {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--color-card);
}

.header-lobby-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

.header-lobby-code {
    font-family: var(--font-headings);
    font-size: 1rem;
    color: var(--color-accent);
    letter-spacing: 1px;
}

.header-player {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    /* Anker fuer den Hinweis darunter. */
    position: relative;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* Ausserhalb einer Lobby fuehrt die Kachel zur Profilbearbeitung. */
.header-player-link:hover,
.header-player-link:focus-visible {
    background: rgba(var(--rgb-deep), 0.7);
    border-color: var(--color-card);
    color: var(--color-text);
}

.header-player-edit {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    color: var(--color-text-muted);
}

.header-player-link:hover .header-player-edit,
.header-player-link:focus-visible .header-player-edit {
    color: var(--color-secondary);
}

/* In der Lobby ist das Profil gesperrt - die Kachel ist dann kein Link. */
.header-player.is-locked {
    cursor: default;
}

/* Hinweis unter der Kachel. Erscheint bei Hover und bei Fokus, damit er auch
 * per Tastatur und auf Touch-Geraeten (kein Hover) erreichbar ist. */
.header-tip {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 20;
    width: max-content;
    max-width: min(17rem, calc(100vw - 2rem));
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: var(--color-card);
    border: 1px solid var(--color-primary);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--color-text);
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    pointer-events: none;
}

.header-player:hover .header-tip,
.header-player:focus .header-tip,
.header-player:focus-visible .header-tip,
.header-player:focus-within .header-tip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Kleine Spitze zur Kachel hin. */
.header-tip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 1.1rem;
    border: 6px solid transparent;
    border-bottom-color: var(--color-primary);
}

.header-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    /* Rundes Quadrat wie die Spielerkarten in der Lobby - Avatare sind
     * quadratisch, ein Kreis wuerde sie beschneiden. */
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-card);
    border: 2px solid var(--color-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-avatar-initial {
    font-family: var(--font-headings);
    font-size: 1rem;
    color: var(--color-text);
}

.header-player-name {
    font-weight: 600;
    font-size: 0.95rem;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .site-header {
        padding: 0.5rem 0.7rem;
        border-radius: 20px;
        margin-bottom: 1rem;
    }

    .brand-name {
        font-size: 1.15rem;
    }

    /* Auf schmalen Schirmen traegt der Avatar die Information, der Name
     * weicht - sonst draengt die Zeile den Lobby-Code heraus. */
    .header-player-name {
        display: none;
    }

    .header-lobby-label {
        display: none;
    }
}

/* --- AVATAR-STUDIO (personalisierte Ansicht) --- */
/* Vorher lagen Zeichenflaeche und vier Button-Reihen ohne Gliederung
 * nebeneinander, die Beschriftungen "Farbe" und "Hintergrund" standen inline in
 * derselben Zeile wie die Farbfelder. Jetzt drei benannte Gruppen. */
.avatar-studio {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.avatar-studio-canvas {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.avatar-canvas-hint {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-align: center;
    max-width: 200px;
}

.avatar-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.avatar-field-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

/* Die Haupthandlung steht eigenstaendig unter dem Studio, nicht als vierte
 * Button-Reihe in der Werkzeugspalte. */
.avatar-action-btn {
    width: 100%;
    font-size: 1rem;
}

.avatar-standard-preview .avatar-action-btn {
    max-width: 18rem;
}

@media (max-width: 600px) {
    .avatar-studio {
        flex-direction: column;
        align-items: center;
    }

    .avatar-studio-canvas {
        width: 100%;
    }

    .avatar-canvas-hint {
        max-width: none;
    }

    .avatar-tools {
        width: 100%;
    }

    /* Felder mittig, damit die Spalte nicht ausgefranst wirkt. */
    .avatar-field {
        align-items: center;
    }

    .avatar-color-row,
    .avatar-bg-row {
        justify-content: center;
    }
}
