/* ==========================================================================
   Dark Ages · Pixel-UI
   Alle Farben stammen aus NEW_PAL (js/art.js) — UI und Spielfläche teilen sich
   damit eine Palette. Formregeln, die überall gelten:
     · border-radius: 0 (global im Reset erzwungen)
     · kein backdrop-filter — Tiefe kommt aus 2px-Bevels, nicht aus Blur
     · Rahmen 2px, Bevel 2px, Abstände in Vielfachen von 4
     · Trefferflächen ≥ 44px (Regel steht unten bei "Mobile / Responsive")
   ========================================================================== */
:root {
    /* Grund & Panel */
    --ink: #08070b;
    --panel-hi: #33281c;
    /* Bevel oben/links */
    --panel-lo: #0c0907;
    /* Bevel unten/rechts */
    --edge: #0a0806;
    /* harte Außenkante */

    /* Bestehende Tokennamen — auf die Pixel-Palette umgehängt, damit alle
       Regeln weiter greifen, die sie schon benutzen. */
    --bg-deep: #08070b;
    --bg-panel: #171310;
    /* jetzt deckend: der Blur dahinter ist weg */
    --bg-card: #1f1913;
    --border: #33281c;
    --border-bright: #8f6435;
    --text: #cabe98;
    /* pal 18 */
    --text-bright: #eeebe8;
    /* pal 22 */
    --text-dim: #8a7e6e;
    --text-faint: #57503f;
    --gold: #e8b84a;
    --gold-mid: #c98a10;
    /* pal 7 */
    --gold-dk: #7a5205;
    --red: #cc0000;
    /* pal 23 */
    --fire: #e2571f;
    /* pal 8 */
    --fire-dk: #8a2c0e;
    /* pal 16 */
    --green: #5cb85c;
    --blue: #4fc3f7;
    --sun: #fff824;               /* pal 24 — Leuchtakzente */

    /* Material */
    --wood: #5e3a20;
    /* pal 4 */
    --wood-dk: #3a2515;
    /* pal 10 */
    --wood-hi: #8f6435;
    /* pal 14 */
    --steel: #9fabbc;
    /* pal 3 */
    --steel-dk: #2c303d;
    /* pal 6 */
    --stone: #7d838f;
    /* pal 5 */
    --stone-dk: #565f70;

    /* Wiederverwendbare Schatten-Rezepte */
    --bevel: inset 2px 2px 0 var(--panel-hi), inset -2px -2px 0 var(--panel-lo);
    --bevel-in: inset 2px 2px 0 var(--panel-lo), inset -2px -2px 0 #241d16;
    --drop: 4px 4px 0 rgba(0, 0, 0, 0.55);

    /* Schriften
       ------------------------------------------------------------------
       WICHTIG — Pixelschriften sind nur auf ihrem eigenen Raster scharf.
       Jede andere Größe lässt der Browser weichzeichnen, und dann sieht die
       Schrift aus wie eine normale Schrift mit eckigen Buchstaben:

         Jersey 15   scharf bei  15px und 30px
         Silkscreen  scharf bei   8px, 12px und 16px
         MedievalSharp ist KEIN Pixelfont — beliebige Größen, bewusst weich
                     (Kontrast für Wortmarke und Screen-Titel)

       Neue Regeln bitte an diese Werte halten. Einzige bewusste Ausnahme:
       Eingabefelder stehen auf 16px, weil iOS sonst beim Fokussieren
       hineinzoomt — dort ist die leichte Unschärfe der kleinere Übel. */
    /* Jersey 15: kompakt genug für lange deutsche Wörter UND mit eindeutigen
       Ziffern — anders als die meisten runden Pixel-Fonts, bei denen 5/S und
       2/8 kollidieren. Zahlen in Labels laufen zusätzlich in Silkscreen. */
    --font-body: 'Jersey 15', 'Courier New', Courier, monospace;
    --font-ui: 'Silkscreen', 'Courier New', monospace;
    --font-display: 'MedievalSharp', cursive;
}

* {
    box-sizing: border-box;
    /* Pixel-Look: keine Rundungen, nirgends. Bewusst global statt in jeder
       Regel einzeln — so kann sie auch niemand versehentlich wieder einführen. */
    border-radius: 0;
}

body {
    margin: 0;
    /* Das Wabenmuster steckt NICHT mehr hier, sondern in #menu-bg — eine
       Hintergrundfläche kann nicht zwei Reihen in verschiedene Richtungen
       bewegen. Hier bleiben nur Scanlines, Lichtschein und Grundfarbe. */
    background:
        repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.30) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
        radial-gradient(115% 60% at 50% 22%, rgba(120, 80, 20, 0.16) 0%, rgba(8, 7, 11, 0) 62%),
        var(--ink);
    color: var(--text);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

input,
textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* ── Animierter Wabenhintergrund (Menüs) ──────────────────────────────────
   Zwei Ebenen mit je einer 34×116-Kachel: Ebene A zeichnet das Sechseck in
   die obere Kachelhälfte, Ebene B in die untere und sitzt zusätzlich um eine
   halbe Kachelbreite versetzt (background-position 17px) — zusammen ergibt
   das die versetzte Wabe. A wandert nach links, B nach rechts.

   Bewegt wird per `transform`, nicht per `background-position`: transform
   läuft auf dem Compositor, background-position würde jeden Frame neu
   zeichnen. Der Weg ist exakt eine Kachelbreite (34px), dadurch springt die
   Schleife nicht sichtbar. Die Ebenen ragen links/rechts über den Rand
   hinaus, damit beim Verschieben keine Kante hereinwandert. */
#menu-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.menu-bg-layer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40px;
    right: -40px;
    background-repeat: repeat;
    background-size: 34px 116px;
    will-change: transform;
}

.menu-bg-a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='116' viewBox='0 0 34 116'%3E%3Cpath d='M17 1 L33 10 L33 28 L17 37 L1 28 L1 10 Z' fill='none' stroke='%23c98a10' stroke-opacity='0.10' stroke-width='1'/%3E%3C/svg%3E");
    animation: hexDriftLeft 5s linear infinite;
}

.menu-bg-b {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='116' viewBox='0 0 34 116'%3E%3Cpath d='M17 59 L33 68 L33 86 L17 95 L1 86 L1 68 Z' fill='none' stroke='%23c98a10' stroke-opacity='0.10' stroke-width='1'/%3E%3C/svg%3E");
    background-position: 17px 0;
    animation: hexDriftRight 5s linear infinite;
}

@keyframes hexDriftLeft {
    to {
        transform: translateX(-34px);
    }
}

@keyframes hexDriftRight {
    to {
        transform: translateX(34px);
    }
}

/* Im Spiel deckt die Karte den Hintergrund ohnehin ab — dann braucht die
   Animation auch nicht zu laufen (js/main.js setzt die Klasse). */
body.in-game #menu-bg {
    display: none;
}

/* Wer Bewegung reduziert haben will, bekommt das ruhende Muster. */
@media (prefers-reduced-motion: reduce) {
    .menu-bg-layer {
        animation: none;
    }
}

h2 {
    margin-top: 5px;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 4px;
    color: var(--gold);
    text-shadow: 0 3px 0 #000, 0 0 20px rgba(232, 184, 74, 0.28);
}

#app-version {
    position: fixed;
    right: 10px;
    bottom: 8px;
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--text-faint);
    letter-spacing: 1.5px;
    z-index: 500;
    pointer-events: none;
}

/* Panel: harte Kante außen, 2px-Bevel innen, harter Schlagschatten. */
.screen-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--bg-panel);
    padding: 28px;
    border: 2px solid var(--edge);
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 200;
    margin-top: 20px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--bevel), var(--drop);
    animation: fadeInUp 0.4s ease;
}

.screen-box::-webkit-scrollbar {
    width: 6px;
}

.screen-box::-webkit-scrollbar-track {
    background: transparent;
}

.screen-box::-webkit-scrollbar-thumb {
    background: var(--wood-hi);
}

.setup-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.setup-group label {
    font-family: var(--font-ui);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: var(--text-dim);
}

/* ── Ecknieten ────────────────────────────────────────────────────────────
   Markieren genau EINE Sache pro Screen: die, die gerade dran ist. Das
   Elternelement braucht position: relative. */
.stud {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--wood-hi);
    pointer-events: none;
}

.stud--tl {
    top: 4px;
    left: 4px;
}

.stud--tr {
    top: 4px;
    right: 4px;
}

.stud--bl {
    bottom: 4px;
    left: 4px;
}

.stud--br {
    bottom: 4px;
    right: 4px;
}

/* ── Kachel-Auswahl (js/segmented.js) ─────────────────────────────────────
   Ersetzt die <select>-Dropdowns im Setup-Screen. Das native <select> bleibt
   im DOM und ist weiterhin die Datenquelle — nur unsichtbar. */
.seg-native {
    display: none;
}

.seg {
    display: flex;
    gap: 6px;
}

.seg-col {
    flex-direction: column;
}

.seg-item {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 4px;
    background: #131010;
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 #241d16, inset -2px -2px 0 var(--panel-lo);
    color: var(--text-dim);
    font-family: var(--font-body);
    cursor: pointer;
    text-align: center;
}

/* Teams: Icon links, Text rechts — die Beschreibungen brauchen die Breite. */
.seg-col .seg-item {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
}

.seg-col .seg-item .seg-title,
.seg-col .seg-item .seg-sub {
    text-align: left;
}

.seg-col .seg-item .seg-title {
    flex: 0 0 auto;
}

.seg-item-on {
    background: #241a0c;
    box-shadow: inset 2px 2px 0 var(--gold-dk), inset -2px -2px 0 var(--panel-lo), 0 0 0 2px var(--gold-mid);
    color: var(--text-bright);
}

.seg-item-off {
    background: #121110;
    color: #3f3931;
    cursor: not-allowed;
    box-shadow: inset 2px 2px 0 #1c1917, inset -2px -2px 0 #0b0a09;
}

/* Die Icons haben eigene Farben und wirkten auf gesperrten Kacheln sonst
   voll aktiv, obwohl der Text daneben schon ausgegraut war. */
.seg-item-off .ic {
    filter: grayscale(1);
    opacity: 0.35;
}

.seg-item:not(.seg-item-on):not(.seg-item-off):hover {
    background: #1d1815;
}

.seg-title {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.seg-item-on .seg-title {
    color: var(--gold);
}

.seg-sub {
    font-size: 15px;
    line-height: 1.3;
    color: var(--text-dim);
}

.seg-col .seg-sub {
    font-size: 15px;
}

.seg-item-off .seg-sub {
    color: #3f3931;
}

/* Spielerzahl: die Ziffer ist das Element, nicht die Beschriftung. */
.seg-big {
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--text-bright);
}

.seg-item-on .seg-big {
    color: var(--gold);
}

/* Wenn Icon + Titel + Text in einer Zeile stehen, soll der Text den Rest
   füllen und der Titel darüber stehen — dafür eine kleine innere Spalte. */
.seg-col .seg-item {
    flex-wrap: wrap;
}

.seg-col .seg-item .seg-sub {
    flex: 1 1 100%;
    margin-left: 30px;
    margin-top: -3px;
}

/* ── Pixel-Icons (js/icons.js) ────────────────────────────────────────────
   Größen als Klassen statt Inline-Style, damit sie überall gleich sind.
   vertical-align hält sie auf der Grundlinie, wenn sie mitten im Text stehen;
   in Flex-Zeilen (HUD, Buttons) ist das wirkungslos. */
.ic {
    display: inline-block;
    vertical-align: -0.15em;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.ic-12 {
    width: 12px;
    height: 12px;
}

.ic-14 {
    width: 14px;
    height: 14px;
}

.ic-20 {
    width: 20px;
    height: 20px;
}

.ic-24 {
    width: 24px;
    height: 24px;
}

.ic-32 {
    width: 32px;
    height: 32px;
}

.ic-40 {
    width: 40px;
    height: 40px;
}

.ic-48 {
    width: 48px;
    height: 48px;
}

/* Eingaben sind EINGESENKT — Bevel invertiert gegenüber Panels/Buttons. */
input,
select,
textarea {
    padding: 10px 14px;
    background: #0d0b09;
    color: var(--text-bright);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--gold-mid);
    box-shadow: var(--bevel-in), 0 0 0 2px rgba(201, 138, 16, 0.35);
}

/* ── Gift/Resource-Transfer Slider (Diplomatie) ─────────────────────────── */
.gift-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.gift-label {
    flex: 0 0 auto;
    min-width: 46px;
    font-size: 15px;
    color: var(--text-dim);
    white-space: nowrap;
    text-align: left;
}

.gift-label b {
    color: var(--gold);
    font-weight: 700;
}

.gift-slider {
    --fill: 0%;
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 28px;
    min-height: 28px;
    padding: 0;
    margin: 0;
    border: none;
    outline: none;
}

.gift-slider:disabled {
    opacity: 0.4;
}

.gift-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: linear-gradient(to right,
            var(--gold) 0%, var(--gold) var(--fill),
            rgba(180, 150, 100, 0.25) var(--fill), rgba(180, 150, 100, 0.25) 100%);
}

.gift-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 18px;
    margin-top: -8px;
    background: var(--gold-mid);
    border: 2px solid var(--edge);
    cursor: pointer;
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

.gift-slider::-moz-range-track {
    height: 4px;
    background: rgba(180, 150, 100, 0.25);
}

.gift-slider::-moz-range-progress {
    height: 4px;
    background: var(--gold);
}

.gift-slider::-moz-range-thumb {
    width: 14px;
    height: 18px;
    border: 2px solid var(--edge);
    background: var(--gold-mid);
    cursor: pointer;
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

/* Button-Anatomie (siehe Design-System, Abschnitt 04):
   Fläche + Bevel oben/links hell + Bevel unten/rechts dunkel + 4px-Sockel.
   Beim Drücken fährt der Knopf um genau diese 4px nach unten und der Sockel
   verschwindet — die Bewegung ersetzt jeden Hover-Effekt (Touch hat keinen). */
.action-btn {
    margin-top: 4px;
    padding: 10px 14px;
    background: #3a2b1c;
    color: var(--text-bright);
    border: 2px solid var(--edge);
    font-weight: 400;
    font-size: 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    transition: none;
    box-shadow:
        inset 2px 2px 0 rgba(201, 147, 97, 0.30),
        inset -2px -2px 0 rgba(0, 0, 0, 0.55),
        0 4px 0 var(--edge);
    font-family: var(--font-ui);
    position: relative;
}

/* In-game action buttons are even more compact */
#ui-container .action-btn {
    margin-top: 0;
    padding: 8px 10px;
    font-size: 8px;
    letter-spacing: 0.5px;
}

.action-btn:hover {
    background: #46351f;
}

.action-btn:active {
    transform: translateY(4px);
    box-shadow:
        inset 2px 2px 0 rgba(0, 0, 0, 0.55),
        inset -2px -2px 0 rgba(201, 147, 97, 0.16);
}

.action-btn:disabled {
    background: #141211;
    color: #3f3931;
    cursor: not-allowed;
    transform: none;
    box-shadow:
        inset 2px 2px 0 #1c1917,
        inset -2px -2px 0 #0b0a09,
        0 4px 0 var(--edge);
}

/* Primäraktion: die eine Sache, die auf dem Screen als nächstes dran ist.
   js/ui.js + index.html vergeben .primary bewusst sparsam. */
.action-btn.primary {
    background: var(--gold-mid);
    color: #1c1305;
    box-shadow:
        inset 2px 2px 0 #f0cf6a,
        inset -2px -2px 0 var(--gold-dk),
        0 4px 0 #3a2604;
}

.action-btn.primary:hover {
    background: #dd9a17;
}

.action-btn.primary:active {
    transform: translateY(4px);
    box-shadow:
        inset 2px 2px 0 var(--gold-dk),
        inset -2px -2px 0 #f0cf6a;
}

/* ── Aktionsfarben ────────────────────────────────────────────────────────
   Fünf Familien statt der früher ~20 fest im JS verdrahteten Material-Farben
   (js/input.js). Zugeordnet wird nach Bedeutung der Aktion, damit man die Art
   einer Fähigkeit an der Farbe erkennt, bevor man den Text gelesen hat. */
.action-btn.act-fire {
    /* Kampf & Feuer */
    background: var(--fire-dk);
    color: #f8e5de;
    box-shadow: inset 2px 2px 0 var(--fire), inset -2px -2px 0 #3d1205, 0 4px 0 #2a0c03;
}

.action-btn.act-fire:hover {
    background: #a4360f;
}

.action-btn.act-build {
    /* Bau & Stein */
    background: var(--stone-dk);
    color: #eef2f7;
    box-shadow: inset 2px 2px 0 var(--steel), inset -2px -2px 0 #262c37, 0 4px 0 #171a22;
}

.action-btn.act-build:hover {
    background: #66707f;
}

.action-btn.act-gold {
    /* Gold & Handel */
    background: var(--gold-mid);
    color: #1c1305;
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk), 0 4px 0 #3a2604;
}

.action-btn.act-gold:hover {
    background: #dd9a17;
}

.action-btn.act-shadow {
    /* Schatten & Spionage */
    background: var(--steel-dk);
    color: #c8d2e0;
    box-shadow: inset 2px 2px 0 var(--stone-dk), inset -2px -2px 0 #14171e, 0 4px 0 #0d0f14;
}

.action-btn.act-shadow:hover {
    background: #3a4052;
}

.action-btn.act-earth {
    /* Erde & Unterwelt */
    background: var(--wood-dk);
    color: #d8c3a8;
    box-shadow: inset 2px 2px 0 var(--wood-hi), inset -2px -2px 0 #1a0f08, 0 4px 0 #120a05;
}

.action-btn.act-earth:hover {
    background: #4c3220;
}

.action-btn.act-ally {
    /* Bündnis / Zustimmung */
    background: #2c6b2c;
    color: #e6f7e6;
    box-shadow: inset 2px 2px 0 #5cb85c, inset -2px -2px 0 #133a13, 0 4px 0 #0c260c;
}

.action-btn.act-ally:hover {
    background: #357f35;
}

/* Gedrückt-Zustand ist für alle Familien gleich: Sockel weg, Bevel invertiert. */
.action-btn.act-ally:active,
.action-btn.act-fire:active,
.action-btn.act-build:active,
.action-btn.act-gold:active,
.action-btn.act-shadow:active,
.action-btn.act-earth:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

/* Nicht bezahlbar: :disabled gewinnt über die Familienfarbe. */
.action-btn.act-ally:disabled,
.action-btn.act-fire:disabled,
.action-btn.act-build:disabled,
.action-btn.act-gold:disabled,
.action-btn.act-shadow:disabled,
.action-btn.act-earth:disabled {
    background: #141211;
    color: #3f3931;
    box-shadow: inset 2px 2px 0 #1c1917, inset -2px -2px 0 #0b0a09, 0 4px 0 var(--edge);
}

/* === UNIFIED TOP HUD === */
#game-hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 10px;
    padding-top: calc(6px + env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(8, 7, 11, 0.96) 0%, rgba(8, 7, 11, 0.70) 62%, rgba(8, 7, 11, 0) 100%);
    z-index: 150;
    font-family: var(--font-ui);
    font-size: 12px;
    text-shadow: 1px 1px 0 #000;
    pointer-events: auto;
    gap: clamp(3px, 1.5vw, 6px);
}

/* clamp() statt fester rem-Werte: Gold/Holz/Stein/Kristalle (jetzt IMMER
   alle vier sichtbar, s.o.) sollen auf jeder Bildschirmbreite ohne Umbruch
   oder Abschneiden passen — die Schrift skaliert dafür stufenlos mit der
   Viewport-Breite statt an einem festen Breakpoint zu kippen. Der
   Erschließungs-Status (beliebig langer Spielername) lag früher zusätzlich
   in dieser Zeile und sprengte auf schmalen Phones selbst mit Ellipsis noch
   die Breite (Jonathans Meldung) — er steckt jetzt stattdessen im
   Ranglisten-Dropdown (updateScoreboard, js/ui.js), daher bleibt diese
   Zeile bewusst wieder simpel nicht-schrumpfend wie vor dieser Funktion.*/
#resource-hud {
    display: flex;
    align-items: center;
    gap: clamp(4px, 1.8vw, 8px);
    white-space: nowrap;
    font-size: clamp(0.62rem, 3vw, 0.8rem);
    flex-shrink: 0;
}

/* Eine Ressource = Icon + Zahl + optionales Einkommen, als eigene Gruppe.
   Die früheren "|"-Trennstriche entfallen — die Gruppen trennt jetzt der
   gap von #resource-hud (js/ui.js updateHUD baut das Markup). */
.res {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.res b {
    font-weight: 400;
    color: var(--text-bright);
}

.income-text {
    font-size: 8px;
    color: var(--green);
    font-weight: normal;
}

/* Rangliste-Trigger sitzt als eigene eingesenkte Platte in der HUD-Zeile,
   damit er als antippbar lesbar ist statt als loser Text. */
#scoreboard {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
    cursor: pointer;
    position: relative;
    padding: 0 7px;
    background: #141110;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    /* #game-hud zentriert seine Kinder vertikal (align-items:center) statt sie
       zu strecken — ohne stretch wäre #scoreboard nur so hoch wie die kleine
       Punktzahl-Badge und läge dadurch mittig IN der HUD-Zeile. #scoreboard-
       popup hängt sich aber per top:100% relativ an DIESES Element — ohne
       stretch würde das Dropdown mitten in der HUD-Leiste beginnen statt
       sauber darunter (genau das von Jonathan gemeldete Überlappen).
       Seit dem Pixel-Umbau hat #scoreboard einen eigenen Rahmen und ist als
       Platte erkennbar — gestreckt würde sie die durch den Fade gewachsene
       HUD-Höhe mitfüllen und unnötig hoch wirken. Das Dropdown hängt jetzt
       stattdessen mit festem Abstand an der PLATTE (margin-top unten). */
    align-self: center;
}

.score-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.score-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: clamp(0.6rem, 2.6vw, 0.7rem);
    opacity: 0.9;
    white-space: nowrap;
}

.score-badge .score-dot {
    width: 6px;
    height: 6px;
    display: inline-block;
    flex-shrink: 0;
}

/* Zeigt an, dass hinter der einzelnen Badge (nur Platz 1, siehe
   updateScoreboard) noch eine ganze Rangliste steckt — ohne dieses Hinweis-
   Chevron sähe die HUD-Zeile aus wie EIN Spielerscore statt "Platz 1 von N,
   antippen für alle". */
.score-compact-chevron {
    font-size: 8px;
    color: var(--text-dim);
    opacity: 0.8;
}

#canvas-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: #050505;
    display: none;
    z-index: 1;
    overflow: hidden;
}

canvas {
    background-color: #050505;
    display: block;
    touch-action: none;
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
}

#canvas-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
}

/* Overlay für DOM-basierte Schadenszahlen (3D-Renderer) */
#float-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.float-text {
    position: absolute;
    transform: translate(-50%, -100%);
    font: 24px var(--font-ui);
    -webkit-text-stroke: 4px #000;
    paint-order: stroke fill;
    white-space: nowrap;
}

#ui-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    display: none;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
    background: linear-gradient(to top, rgba(5, 5, 5, 0.92) 0%, rgba(5, 5, 5, 0.65) 55%, transparent 100%);
    pointer-events: none;
}

#ui-container>* {
    pointer-events: auto;
}

/* Der Inhalt wird auf Lesebreite begrenzt und zentriert: das Panel selbst ist
   so breit wie der Bildschirm, aber auf dem Desktop lagen Name (links) und
   HP-Zahl (rechts) sonst fast einen Meter auseinander. */
#info-panel>* {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

#info-panel {
    padding: 8px 10px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    text-align: center;
    font-weight: 400;
    white-space: pre-line;
    min-height: 16px;
    /* War fix 70px — das reicht für Titel + zwei Detailzeilen, aber viele
       Infotexte (Kristallader, Einheiten mit Schadensvorschau + Hinweis) sind
       länger und wurden mitten im Satz abgeschnitten. An die Bildschirmhöhe
       koppeln, damit auf normalen Handys praktisch alles komplett passt. */
    max-height: clamp(70px, 26vh, 200px);
    overflow-y: auto;
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.35;
    color: var(--text-bright);
}

/* Boden/Luft/Turm-Auswahlkarten brauchen mehr Platz als reiner Text —
   an die Bildschirmhöhe koppeln statt an einen festen Pixelwert */
#info-panel:has(.stack-picker) {
    max-height: 32vh;
}

/* Passt der Inhalt trotz max-height nicht, wäre er ohne das hier unlesbar:
   pointer-events:none (damit man die Karte durch das Panel hindurch ziehen
   kann) unterbindet auch das Scrollen. js/ui.js setzt .is-scrollable per
   MutationObserver nur dann, wenn wirklich etwas abgeschnitten ist — sonst
   bleibt das Panel wie bisher komplett klick-durchlässig. */
#info-panel.is-scrollable {
    pointer-events: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
    /* Scroll-Hinweis: angedeutete Kante unten, verschwindet am Listenende */
    box-shadow: inset 0 -14px 12px -12px rgba(0, 0, 0, 0.95);
}

#info-panel.is-scrollable.is-at-end {
    box-shadow: none;
}

#info-panel::-webkit-scrollbar {
    width: 3px;
}

#info-panel::-webkit-scrollbar-thumb {
    background: rgba(180, 150, 100, 0.3);
}

/* ── Info-Panel-Kopfzeile (js/ui.js infoHead / infoStats) ─────────────────
   Name links, Zustandsmarken daneben, HP rechts — darunter die HP-Leiste.
   Die HP steht bewusst NUR hier als Zahl; die Leiste wiederholt sie grafisch,
   im Namen taucht sie nicht mehr auf. */
.ip-head {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    text-align: left;
}

.ip-name {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ip-hp {
    margin-left: auto;
    flex: 0 0 auto;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-bright);
}

.ip-hp-max {
    color: var(--text-dim);
}

.ip-badge {
    flex: 0 0 auto;
    padding: 3px 5px;
    background: #241d16;
    border: 2px solid var(--edge);
    box-shadow: inset 1px 1px 0 var(--panel-hi), inset -1px -1px 0 var(--panel-lo);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
}

.ip-badge-gold {
    background: #241a0c;
    color: var(--gold);
    box-shadow: inset 1px 1px 0 var(--gold-dk), inset -1px -1px 0 var(--panel-lo);
}

.ip-badge-fire {
    background: #2a1008;
    color: #ff9d7d;
    box-shadow: inset 1px 1px 0 var(--fire-dk), inset -1px -1px 0 #120503;
}

.ip-badge-cyan {
    background: #0d2530;
    color: #7fe3ff;
    box-shadow: inset 1px 1px 0 #1f5f78, inset -1px -1px 0 #06131a;
}

.ip-badge-green {
    background: #16210f;
    color: #8fd98f;
    box-shadow: inset 1px 1px 0 #2c4020, inset -1px -1px 0 #070c05;
}

.ip-stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 2px;
}

.ip-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-bright);
}

/* Segmentierte HP-Leiste (js/ui.js hpBar) — bewusst kein glatter Balken:
   ein Block je HP zeigt, wie viele Treffer die Einheit noch aushält. */
.hp-bar {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin: 5px 0 3px;
}

/* flex-shrink statt einer festen Blockzahl: hohe Maxima (Hauptgebäude 30,
   Alter Wurm 24) passen dadurch vollständig ins Panel, ohne dass die Leiste
   Blöcke zusammenfassen und damit die Zahl verfälschen müsste. */
.hp-bar i {
    flex: 0 1 7px;
    width: 7px;
    min-width: 2px;
    height: 10px;
    background: var(--green);
    box-shadow: inset 1px 1px 0 #8fd98f, inset -1px -1px 0 #2a5c2a;
}

.hp-bar-foe i {
    background: var(--red);
    box-shadow: inset 1px 1px 0 #ff6b6b, inset -1px -1px 0 #6b0000;
}

.hp-bar i.off {
    background: #241d1d;
    box-shadow: inset 1px 1px 0 #2e2626, inset -1px -1px 0 #0c0808;
}

/* Bonus-HP über dem Maximum (Ereignis "Kriegslust" hebt Einheiten auf max+2):
   eigene Farbe, damit man sieht, dass diese Blöcke nicht nachwachsen. */
.hp-bar i.over {
    background: var(--gold);
    box-shadow: inset 1px 1px 0 #fff3c4, inset -1px -1px 0 var(--gold-dk);
}

.info-detail {
    font-size: 15px;
    color: var(--text-dim);
    font-weight: normal;
    margin-top: 3px;
    font-family: var(--font-body);
    line-height: 1.3;
}

#action-menu {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    transition: opacity 0.3s ease;
}

/* Einheiten-Kaufmenü: horizontal scrollen statt den Screen mit mehreren
   Zeilen nach oben zuzubauen. Inhalt sitzt ZENTRIERT statt linksbündig —
   aber bewusst über auto-Margins auf erstem/letztem Kind statt
   justify-content: center: bei center + Überlauf schiebt Flexbox den
   Inhalt symmetrisch über BEIDE Ränder hinaus und der linke Teil wäre
   unerreichbar abgeschnitten (Scroll-Ursprung bleibt links). Auto-Margins
   dagegen werden bei Platzmangel zu 0 aufgelöst — passt alles rein, ist es
   mittig; läuft es über, scrollt es normal ab ganz links. Die Start-
   Scrollposition wird dann in showActionMenu (js/ui.js) auf die Mitte
   gesetzt, damit man mit 2 Fraktionen nach links UND rechts scrollen kann
   statt immer nur nach rechts. */
.recruit-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.recruit-scroll> :first-child {
    margin-left: auto;
}

.recruit-scroll> :last-child {
    margin-right: auto;
}

.recruit-scroll .action-btn {
    flex: 0 0 auto;
    min-width: 92px;
    margin-top: 0;
}

/* Mehrfach-Auswahl: Boden- und Lufteinheit teilen sich ein Hex */
.stack-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.stack-card {
    /* Basis 140px + Umbruch: drei Karten (Boden + Luft + Turm) nebeneinander
       wären auf einem schmalen Handy je ~120px breit und die Namen restlos
       abgeschnitten. So stehen zwei nebeneinander, die dritte rutscht darunter. */
    flex: 1 1 140px;
    max-width: 240px;
    min-height: 48px;
    padding: 9px 10px;
    background: #241d16;
    border: 2px solid var(--edge);
    /* Knopf-Anatomie wie überall sonst: Sockel unten, der beim Drücken
       verschwindet — die Karten SIND Schaltflächen. */
    box-shadow: var(--bevel), 0 4px 0 var(--edge);
    margin-bottom: 4px;
    cursor: pointer;
    transition: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 5px;
    font-family: var(--font-body);
    color: var(--text);
    /* #info-panel ist normalerweise reiner Text (pointer-events:none) —
       die Karten müssen Klicks aber gezielt wieder annehmen */
    pointer-events: auto;
}

.stack-card:hover { background: #33281c; }

.stack-card:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

.stack-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.stack-name {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stack-hp {
    flex: 0 0 auto;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-bright);
}

.stack-sub {
    font-size: 15px;
    color: var(--text-dim);
    line-height: 1.3;
}

/* Bedeutung über eine 4px-Kante links statt über eine Neon-Rahmenfarbe. */
.stack-card-attack { border-left: 4px solid var(--fire); }
.stack-card-move   { border-left: 4px solid var(--steel); }

.stack-hint {
    margin-top: 6px;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
}

/* Die Karten tragen die Spielerfarbe als kleines Banner — hier etwas
   kompakter als in der Rangliste. */
.stack-card .score-dot {
    width: 8px;
    height: 10px;
}

#intermission-screen,
#win-screen {
    display: none;
    position: relative;
    z-index: 200;
}

/* "Zug beendet"/"Zug wird gesendet"/"nicht gesendet" (js/lobby.js
   _showIntermissionState) und "Offene Partien" (js/lobby.js chooseJoinLobby)
   haben nur ein paar Zeilen Inhalt. Als gewöhnliches Flex-Kind der Body-
   Spalte (bzw. per body.app-view auf volle Höhe gezogen, siehe
   `body.app-view .screen-box:not(.modal-box)` weiter unten) klebten sie am
   oberen Bildschirmrand fest, mit viel totem Platz darunter — auf dem Handy
   schlecht mit dem Daumen erreichbar. Fixiert und über die klassische
   "inset:0; margin:auto"-Technik zentriert statt per transform: die
   fadeInUp-Animation auf .screen-box animiert selbst transform, das würde
   ein zentrierendes translate() für die Dauer der Animation überschreiben
   und den Kasten je nach Timing seitlich verschoben stehen lassen. */
#intermission-screen,
#join-screen {
    position: fixed;
    inset: 0;
    margin: auto;
    flex: none;
    height: fit-content;
    max-height: 90vh;
    overflow-y: auto;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 3, 6, 0.94);
    z-index: 100;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 20px;
    /* #game-hud liegt mit z-index 150 UEBER diesen Overlays (Absicht: man soll
       beim Forschen/Fraktion-Waehlen seine Ressourcen sehen). Ohne diesen
       Freiraum schoben sich Titel und Karten unter die Leiste. */
    padding-top: calc(68px + env(safe-area-inset-top));
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Forschung dockt oben an (Jonathans Wunsch): unten angedockt sprangen die
   Karten je nach Anzahl der Forschungen an eine andere Hoehe. */
#research-overlay {
    justify-content: flex-start;
}

.cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
    margin-bottom: 20px;
}

.card {
    background: var(--bg-card);
    border: 2px solid var(--edge);
    padding: 12px;
    flex: 1 1 45%;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: none;
    box-shadow: var(--bevel), var(--drop);
}

.card:hover {
    background: #2a2219;
}

.card:active {
    box-shadow: var(--bevel-in);
}

/* Gesperrt: bleibt als Platte stehen, verliert nur Farbe — ein reines
   opacity-Absenken ließ die Karte auf dem dunklen Overlay verschwinden. */
.card.disabled {
    background: #121110;
    border-color: #1c1917;
    color: #4f4941;
    cursor: not-allowed;
    box-shadow: inset 2px 2px 0 #1c1917, inset -2px -2px 0 #0b0a09;
}

.card.disabled h3 {
    color: #6d6558;
}

.card.bought {
    background: #16210f;
    box-shadow:
        inset 2px 2px 0 #2c4020,
        inset -2px -2px 0 #070c05,
        0 0 0 2px var(--green);
    cursor: default;
}

.card h3 {
    margin: 0;
    color: var(--gold);
    border-bottom: 2px solid var(--panel-hi);
    padding-bottom: 6px;
    font-size: 15px;
    font-family: var(--font-body);
}

.card p {
    margin: 0;
    font-size: 15px;
    flex-grow: 1;
    color: var(--text-dim);
    line-height: 1.4;
}

/* ── Fraktionskarten (Draft + Übersicht) ──────────────────────────────────
   Aufbau wie im Design-Guide: Icon + Name, Trennlinie, Passive, Beschriftung
   "Spezial", Einheitenliste, Kostenchips unten. */
.fac-card {
    text-align: left;
    gap: 8px;
}

.fac-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fac-head h3 {
    margin: 0;
    border: none;
    padding: 0;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-bright);
}

.fac-sep {
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--panel-hi) 0 4px, transparent 4px 8px);
}

.fac-card p {
    color: #a2917a;
    text-align: left;
    flex-grow: 0;
}

.fac-label {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.fac-special {
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-dim);
}

.fac-cost {
    display: flex;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.badge-cost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--text);
}

.fac-upgrade {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: var(--text-dim);
}

.fac-upgrade-none {
    color: var(--text-faint);
}

/* Kosten als eingesenkter Chip statt als bunte Textzeile */
.card .cost {
    align-self: center;
    padding: 3px 8px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
    font-family: var(--font-ui);
    color: var(--text);
    font-size: 8px;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Fraktions-Fenster (window.openFactionOverview, js/ui.js): Zeile mit dem
   AKTUELL wirksamen Passiv-Wert (z.B. "+2 Max-HP") — bewusst in Gold statt im
   gedimmten Beschreibungstext, damit sofort auffällt, wie stark die Passive
   gerade ist. */
.passive-value {
    color: var(--gold);
    font-weight: bold;
    font-size: 15px;
    text-align: left;
}

/* Reliquien-Fenster (window.openRelicShop, js/ui.js): Kristall-Bestand-Kopfzeile,
   gleiche Cyan-Farbe wie die bisherigen Reliquien-Buttons im Dorf-Menü
   (border-color:#7fe3ff, ehemals js/input.js). */
.crystal-header {
    color: #7fe3ff;
    font-weight: bold;
    font-size: 15px;
    text-align: center;
    margin-bottom: 10px;
}

/* Handel-Fenster (window.openTradeShop, js/ui.js): Ressourcen-Wahl als Chip-
   Buttons statt <select> — größere Touch-Ziele, besser für Smartphones
   (Korrektur Juli 2026, Jonathans Feedback: Dropdowns wirkten "clunky"). */
.trade-section-label {
    color: var(--text-dim);
    font-size: 15px;
    margin-bottom: 6px;
}

.trade-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.trade-chip {
    flex: 1 1 64px;
    min-width: 64px;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: #131010;
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 #241d16, inset -2px -2px 0 var(--panel-lo);
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: none;
}

/* Enthält seit dem Pixel-Umbau ein <svg> statt eines Emoji — die frühere
   font-size steuerte dessen Größe, die Größe kommt jetzt aus der ic-Klasse. */
.trade-chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.trade-chip.selected {
    background: #241a0c;
    box-shadow: inset 2px 2px 0 var(--gold-dk), inset -2px -2px 0 var(--panel-lo), 0 0 0 2px var(--gold-mid);
    color: var(--gold);
}

/* Kurs-Anzeige zwischen Verkaufen/Kaufen-Chipreihen (z.B. "💰 1 → 1 🪵" oder
   "💎 1 → 3 💰") — zeigt sofort, ob gerade der 1:1- oder der 1:3-Kristallkurs
   greift, ohne dass man es erst am Ergebnis unten ablesen muss. */
.trade-rate {
    text-align: center;
    color: var(--gold);
    font-weight: bold;
    font-size: 15px;
    margin-top: -6px;
}

/* Wappen auf dem Login-Screen (index.html, Pixel-SVG statt Icon.png) */
.game-crest {
    width: 104px;
    height: 104px;
    margin: 4px auto 0;
    display: block;
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.8));
}

.login-wordmark {
    margin: 14px 0 0;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 4px;
    color: var(--gold);
    text-shadow: 0 3px 0 #000, 0 0 20px rgba(232, 184, 74, 0.28);
}

.login-tagline {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* === TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    /* Ohne feste Breite schrumpft ein fixiertes Element bei left:50% auf die
       halbe Bildschirmbreite — lange Toasts liefen dann über den Rand hinaus
       und wurden abgeschnitten (Tutorial-Stupser auf dem Handy). */
    width: max-content;
    max-width: calc(100vw - 32px);
    align-items: center;
}

.toast {
    padding: 10px 20px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    font-weight: 400;
    text-align: center;
    animation: toastIn 0.2s ease, toastOut 0.3s ease 2.2s forwards;
    box-shadow: var(--bevel), var(--drop);
    /* Umbrechen statt abschneiden: kurze Toasts bleiben einzeilig, lange
       werden zweizeilig statt über den Bildschirmrand zu laufen. */
    white-space: normal;
    text-wrap: balance;
    max-width: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-bright);
    position: relative;
}

/* Zustandsfarbe sitzt als 4px-Kante links statt als Rahmenfarbe — auf dem
   2px-Pixelrahmen wäre eine Einfärbung kaum zu sehen. */
.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--gold-mid);
}

.toast.error::before {
    background: var(--fire);
}

.toast.error {
    color: #ff9d7d;
}

.toast.success::before {
    background: var(--green);
}

.toast.success {
    color: #8fd98f;
}

.toast.info::before {
    background: var(--blue);
}

.toast.info {
    color: #9adcf7;
}

.toast.gold::before {
    background: var(--gold);
}

.toast.gold {
    color: var(--gold);
}

/* === EVENT OVERLAY === */
#event-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 250;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
}

.event-card {
    background: #1b0f0a;
    border: 2px solid var(--fire-dk);
    padding: 22px 18px;
    max-width: 300px;
    text-align: center;
    box-shadow:
        inset 2px 2px 0 #4a1a08,
        inset -2px -2px 0 #0c0605,
        0 0 0 2px var(--edge),
        var(--drop),
        0 0 26px rgba(226, 87, 31, 0.20);
    animation: fadeInUp 0.5s ease 0.15s both;
}

.event-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.event-card .event-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.8));
}

/* Runde + "Ereignis" als Kopfzeile — ordnet die Karte zeitlich ein, statt
   sie kontextlos aufpoppen zu lassen. */
.event-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--fire);
}

.event-meta-sep {
    width: 2px;
    height: 10px;
    background: #4a1a08;
}

.event-meta-kind {
    color: var(--text-dim);
}

.event-card .stud {
    background: var(--fire);
}

.event-card h2 {
    color: var(--fire);
    margin: 0 0 10px;
    font-size: 1.6rem;
    letter-spacing: 2px;
    font-family: var(--font-display);
    text-shadow: 0 3px 0 #000, 0 0 24px rgba(226, 87, 31, 0.4);
}

.event-card p {
    color: #e0cfc0;
    margin: 0 0 16px;
    line-height: 1.5;
    font-size: 15px;
}

/* === SCOREBOARD (now inside #game-hud) === */
/* Rangliste-Dropdown (#scoreboard-popup, js/ui.js updateScoreboard): eine
   Karte pro Spieler. Kopfzeile (Punkte + Fraktionen) ist immer sichtbar;
   Forschungen/Reliquien stecken in .score-card-details und werden erst per
   Antippen der Karte aufgeklappt (Chevron dreht sich als Hinweis) — die volle
   Aufschlüsselung für JEDEN Spieler gleichzeitig wirkte laut Jonathans
   Feedback überladen und "verlor den Charme" der kompakten Rangliste. */
.score-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    text-align: left;
    transition: none;
}

.score-card:not(.score-dead) {
    cursor: pointer;
}

.score-card:not(.score-dead):hover {
    background: #2a2219;
}

.score-card-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    min-width: 0;
}

.score-rank {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12px;
    min-width: 16px;
}

/* flex:1 + min-width:0 + ellipsis: der Name ist das einzige Element, das bei
   Platzmangel schrumpft/abgeschnitten wird — Fraktionen und Punktzahl (die
   Sachen, die laut Jonathan "auf einen Blick" sichtbar sein sollen) bleiben
   davon unberührt (flex: 0 0 auto unten), egal wie lang der Spielername oder
   wie schmal der Bildschirm ist. Ohne min-width:0 ignoriert ein Flex-Item mit
   overflow:visible seine intrinsische Breite beim Schrumpfen — das war der
   Grund, warum lange Namen bisher aus der Karte herausliefen. */
.score-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
}

.score-factions {
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: 1px;
    opacity: 0.9;
}

/* Erschließungs-Status (js/ui.js updateScoreboard): zog aus der oberen
   HUD-Zeile hierher um (siehe #resource-hud, game.css) — hier ist Platz für
   den Namen des Spielers unbegrenzt vorhanden (score-name kürzt bei Bedarf
   selbst per Ellipsis, s.o.), ohne den Menü-Button zu gefährden. */
.score-hz-badge {
    flex: 0 0 auto;
    white-space: nowrap;
    color: var(--blue);
    font-size: 12px;
}

/* Erschließung angehalten (Gegner im Kern der Herzkaverne): der Zähler steht,
   ist aber nicht verloren — gedämpft statt bunt, damit "läuft" und "steht"
   auf einen Blick auseinandergehen. */
.score-hz-badge.is-paused {
    color: var(--text-dim);
}

.score-total {
    flex: 0 0 auto;
    color: var(--gold);
    font-weight: bold;
    white-space: nowrap;
}

.score-chevron {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.score-card.expanded .score-chevron {
    transform: rotate(90deg);
}

.score-card-details {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin-top: 5px;
    padding-top: 6px;
    border-top: 1px solid rgba(180, 150, 100, 0.15);
}

.score-card.expanded .score-card-details {
    display: flex;
}

.score-subrow {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
}

.score-subrow b {
    color: var(--text);
}

.score-legend {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    opacity: 0.7;
}

/* Spielerfarbe: als kleines Banner auf dunkler Platte statt als leuchtender
   Punkt — die Spielerfarben (#00e5ff …) sind Neon und kippen den Screen,
   sobald sie ohne dunkle Fassung auftreten. */
.score-dot {
    width: 9px;
    height: 11px;
    display: inline-block;
    border: 1px solid var(--edge);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.45), inset 1px 1px 0 rgba(255, 255, 255, 0.30);
    flex-shrink: 0;
}

.score-dead {
    opacity: 0.4;
}

.score-dead .score-total {
    text-decoration: line-through;
}

/* === VETERAN STAR === */
.vet-star {
    color: var(--gold);
    font-size: 12px;
}

/* === ANIMATIONS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        text-shadow: 0 4px 0 #000, 0 0 20px rgba(232, 184, 74, 0.30);
    }

    50% {
        text-shadow: 0 4px 0 #000, 0 0 40px rgba(232, 184, 74, 0.65);
    }
}

@keyframes crownGlow {

    0%,
    100% {
        filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.85)) drop-shadow(0 0 10px rgba(232, 184, 74, 0.45));
    }

    50% {
        filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.85)) drop-shadow(0 0 26px rgba(232, 184, 74, 0.95));
    }
}

/* Strahlenkranz: liegt hinter allem, deshalb bekommt der restliche Inhalt
   z-index 1. Der Kranz geht ueber die Panelkanten hinaus — .screen-box
   schneidet ihn ab (overflow), das ist gewollt. */
.win-rays {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.28;
    pointer-events: none;
}

#win-screen>*:not(.win-rays) {
    position: relative;
    z-index: 1;
}

.win-crown {
    width: 88px;
    height: 88px;
    margin: 6px auto 0;
    display: block;
    animation: crownGlow 2.4s ease infinite;
}

.win-title {
    margin: 14px 0 0;
    font-family: var(--font-display);
    font-size: 3rem;
    letter-spacing: 8px;
    color: var(--gold);
    animation: pulseGlow 2s ease infinite;
}

/* Endscreen des Verlierers (js/diplomacy.js showWin setzt .is-defeat): derselbe
   Kasten, aber ohne Triumph — Strahlenkranz und Titel in Feuer/Stein statt Gold,
   kein pulsierendes Leuchten. Eine eigene Overlay-Variante wäre doppelte
   Struktur für zwei Farbwerte. */
#win-screen.is-defeat .win-rays g {
    fill: var(--fire-dk);
}

/* Kein `color:` — die Symbole in js/icons.js tragen ihre Farben fest im
   Sprite, currentColor greift dort nicht. Das Totenkopf-Symbol bringt seine
   eigene mit, hier fällt nur das goldene Pulsieren weg. */
#win-screen.is-defeat .win-crown {
    animation: none;
    filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.85));
}

/* "NIEDERLAGE" ist doppelt so lang wie "SIEG" und lief bei 3rem + 8px Laufweite
   auf dem Handy aus dem Kasten heraus. */
#win-screen.is-defeat .win-title {
    color: var(--stone);
    animation: none;
    font-size: clamp(1.5rem, 9vw, 2.6rem);
    letter-spacing: 4px;
}

.win-msg {
    margin: 6px 0 0;
    font-size: 15px;
    color: #a2917a;
    line-height: 1.5;
}

/* Endstand-Leiste im Siegbildschirm (js/diplomacy.js showWin) */
.win-stats {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
}

.win-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.win-stat-value {
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--gold);
}

.win-stat-label {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.win-stat-sep {
    width: 2px;
    background: var(--panel-hi);
    flex: 0 0 2px;
}

/* === AUFGEBEN BUTTON === */
#menu-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #3a2b1c;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}

#menu-btn:hover {
    background: #46351f;
}

#menu-btn:active {
    box-shadow: var(--bevel-in);
}

/* Kamerafokus-Schieberegler: stufenloser, rein manueller Regler unten rechts
   am Bildschirmrand statt des früheren Drei-Zustands-Buttons. Oben (Wert
   +100) = Luftansicht (blau), unten (Wert -100) = Unterwelt (violett), Mitte
   (Wert 0, Default) = Standard.
   Vertikalisierung über `writing-mode: vertical-lr; direction: rtl;` direkt
   auf dem <input type=range> statt des früheren horizontal-gebaut-und-per-
   transform-gedreht-Hacks: der Rotation-Hack drehte die Box um ihre eigene
   Ecke (transform-origin: top left + translate), was den Thumb sichtbar
   außermittig in seiner Wrap-Box sitzen ließ, weil das gedrehte Element noch
   die horizontalen Maße für Layout-Zwecke behielt. writing-mode kehrt
   stattdessen die Schreibrichtung des Elements selbst um (unterstützt ab
   Chrome 119 / Firefox 120 / Safari 17.4 — das Projekt nutzt an anderer
   Stelle bereits `:has()`, moderne Browser sind hier ok) — der Slider ist
   dadurch nativ vertikal und zentriert sich selbst korrekt in der Wrap-Box,
   kein `.cfs-track`-Hilfselement mehr nötig. `direction: rtl` sorgt dafür,
   dass der Wertebereich in Leserichtung "aufsteigend nach oben" verläuft
   (min unten, max oben) — ohne rtl würde vertical-lr allein min oben/max
   unten anordnen, das wäre für +100=Luftansicht oben genau verkehrt.
   Positionierung: der Wrap ist ein Kind von #ui-container (position: fixed
   an der Unterkante, wächst mit Infotext/Aktionsmenü nach OBEN) und ankert
   per position: absolute mit bottom: 100% an dessen OBERKANTE statt fest am
   Screen — ein fester bottom-Pixelwert lag je nach Höhe der Leiste mitten
   auf den Infotexten. So rutscht der Slider automatisch mit hoch und runter,
   wenn die Leiste ihre Höhe ändert, und verdeckt nie den Text darunter. */
#camera-focus-slider-wrap {
    position: absolute;
    right: 10px;
    bottom: calc(100% + 6px);
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 9px 6px;
    background: rgba(8, 7, 11, 0.88);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
}

.cfs-label {
    font-size: 0.95rem;
    line-height: 1;
    opacity: 0.5;
    filter: grayscale(0.6);
    transition: opacity 0.15s ease, filter 0.15s ease;
}

#camera-focus-slider-wrap.active:not(.focus-underworld) .cfs-label-air {
    opacity: 1;
    filter: none;
    text-shadow: 0 0 6px rgba(79, 195, 247, 0.8);
}

#camera-focus-slider-wrap.focus-underworld .cfs-label-underworld {
    opacity: 1;
    filter: none;
    text-shadow: 0 0 6px rgba(192, 132, 252, 0.8);
}

/* width 28px MIT padding 0 10px (global box-sizing: border-box, siehe Reset
   oben): die Content-Box — und damit der Track, der sie füllt — bleibt 8px
   schmal und exakt zentriert, aber die Touch-Trefffläche ist die vollen 28px
   breit. Ein nackter 8px-Input wäre auf dem Smartphone kaum zu greifen. */
#camera-focus-slider {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 28px;
    padding: 0 10px;
    height: 130px;
    margin: 0;
    background: transparent;
    cursor: pointer;
    /* Nur der Thumb soll klick-/ziehbar sein, nicht die Leiste selbst (sonst
       springt der Wert bei jedem Klick auf die Leiste an diese Stelle). Die
       Leiste (inkl. Track) wird per pointer-events:none unklickbar; der
       Thumb hebt das gezielt wieder auf (::-webkit-slider-thumb /
       ::-moz-range-thumb unten), da Pseudo-Elemente ihren eigenen
       pointer-events-Wert setzen können. */
    pointer-events: none;
}

/* Gradient läuft entlang der neuen (vertikalen) Achse: unten violett
   (Unterwelt) -> Mitte neutral -> oben blau (Luftansicht), passend zu
   direction:rtl (min unten, max oben). */
#camera-focus-slider::-webkit-slider-runnable-track {
    width: 8px;
    background: linear-gradient(180deg, #1a3a5c 0%, #0d0b09 50%, #3a1a4a 100%);
    border: 2px solid var(--edge);
}

#camera-focus-slider::-moz-range-track {
    width: 8px;
    background: linear-gradient(180deg, #1a3a5c 0%, #0d0b09 50%, #3a1a4a 100%);
    border: 2px solid var(--edge);
}

#camera-focus-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 16px;
    /* exakt mittig auf dem 8px-Track: (22 - 8) / 2 */
    margin-left: -7px;
    background: var(--stone);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 var(--steel), inset -2px -2px 0 var(--steel-dk);
    pointer-events: auto;
    cursor: pointer;
}

#camera-focus-slider::-moz-range-thumb {
    width: 22px;
    height: 16px;
    background: var(--stone);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 var(--steel), inset -2px -2px 0 var(--steel-dk);
    pointer-events: auto;
    cursor: pointer;
}

#game-menu-popup {
    position: fixed;
    top: calc(36px + env(safe-area-inset-top));
    right: 10px;
    z-index: 300;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel), var(--drop);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    min-width: 170px;
}

#game-menu-popup button {
    min-height: 44px;
    padding: 10px 14px;
    background: #241d16;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    font-size: 15px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
}

#game-menu-popup button:hover:not(:disabled) {
    background: #33281c;
}

#game-menu-popup button:active:not(:disabled) {
    box-shadow: var(--bevel-in);
}

#game-menu-popup button:disabled {
    background: #141211;
    color: #3f3931;
    cursor: default;
    box-shadow: inset 2px 2px 0 #1c1917, inset -2px -2px 0 #0b0a09;
}

/* Rangliste-Dropdown (#scoreboard-popup, js/ui.js toggleScoreboard): hängt
   direkt unter dem #scoreboard-Trigger links (position:absolute relativ zu
   #scoreboard, das schon position:relative hat) — Jonathans Wunsch: es soll
   dort aufklappen, wo man auf die Punktzahl tippt, nicht oben rechts wie das
   Menü. Klicks im Popup selbst stoppen ihre Propagation (siehe index.html),
   sonst würde jeder Klick auf eine Karte über den onclick von #scoreboard
   sofort wieder zuklappen. */
#scoreboard-popup {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    z-index: 300;
    width: 260px;
    max-width: calc(100vw - 20px);
    max-height: 70vh;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel), var(--drop);
    padding: 10px;
}

.scoreboard-popup-header {
    font-family: var(--font-ui);
    color: var(--gold);
    font-size: 8px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--panel-hi);
}

#menu-surrender-item {
    color: #ff9d7d;
}

#menu-surrender-item:hover:not(:disabled) {
    background: #33160c !important;
}

/* === AUFGEBEN BESTÄTIGUNGS-OVERLAY === */
#surrender-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 400;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

#surrender-overlay.open {
    display: flex;
}

.surrender-card {
    background: #1b0f0a;
    border: 2px solid var(--fire-dk);
    padding: 26px 22px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow:
        inset 2px 2px 0 #4a1a08,
        inset -2px -2px 0 #0c0605,
        0 0 0 2px var(--edge),
        var(--drop);
    animation: fadeInUp 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.surrender-card .surrender-icon {
    font-size: 2.2rem;
}

.surrender-card h3 {
    margin: 0;
    font-family: var(--font-display);
    color: var(--fire);
    font-size: 1.4rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 0 #000;
}

.surrender-card p {
    margin: 0;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1.45;
}

.surrender-card .surrender-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Teilen sich das Button-Rezept mit .action-btn — nur die Fläche wechselt. */
.btn-confirm-surrender,
.btn-cancel-surrender,
.btn-confirm-end-turn,
.btn-cancel-end-turn {
    min-height: 44px;
    padding: 10px 18px;
    border: 2px solid var(--edge);
    font-family: var(--font-ui);
    font-size: 12px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
}

.btn-confirm-surrender {
    background: var(--fire-dk);
    color: #f8e5de;
    box-shadow: inset 2px 2px 0 var(--fire), inset -2px -2px 0 #3d1205, 0 4px 0 #2a0c03;
}

.btn-confirm-surrender:hover {
    background: #a4360f;
}

.btn-confirm-surrender:active {
    transform: translateY(4px);
    box-shadow: inset 2px 2px 0 #3d1205, inset -2px -2px 0 var(--fire);
}

.btn-cancel-surrender,
.btn-cancel-end-turn {
    background: #241d16;
    color: var(--text-dim);
    box-shadow: inset 2px 2px 0 var(--panel-hi), inset -2px -2px 0 var(--panel-lo), 0 4px 0 var(--edge);
}

.btn-cancel-surrender:hover,
.btn-cancel-end-turn:hover {
    background: #33281c;
    color: var(--text);
}

.btn-cancel-surrender:active,
.btn-cancel-end-turn:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

/* === ZUG BEENDEN BESTÄTIGUNGS-OVERLAY === */
#end-turn-confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 400;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

#end-turn-confirm-overlay.open {
    display: flex;
}

.end-turn-confirm-card {
    background: #1f1913;
    border: 2px solid var(--gold-mid);
    padding: 26px 22px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow:
        inset 2px 2px 0 var(--gold-dk),
        inset -2px -2px 0 var(--panel-lo),
        0 0 0 2px var(--edge),
        var(--drop);
    animation: fadeInUp 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.end-turn-confirm-card .end-turn-confirm-icon {
    font-size: 2.2rem;
}

.end-turn-confirm-card h3 {
    margin: 0;
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1.4rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 0 #000;
}

.end-turn-confirm-card p {
    margin: 0;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1.45;
}

.end-turn-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-confirm-end-turn {
    background: var(--gold-mid);
    color: #1c1305;
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk), 0 4px 0 #3a2604;
}

.btn-confirm-end-turn:hover {
    background: #dd9a17;
}

.btn-confirm-end-turn:active {
    transform: translateY(4px);
    box-shadow: inset 2px 2px 0 var(--gold-dk), inset -2px -2px 0 #f0cf6a;
}

/* === RANKED/NORMAL-WAHL (js/lobby.js chooseGameMode) === */
#gamemode-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 400;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

#gamemode-overlay.open {
    display: flex;
}

.gamemode-card {
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    padding: 26px 22px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: var(--bevel), 0 0 0 2px var(--edge), var(--drop);
    animation: fadeInUp 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gamemode-card h3 {
    margin: 0;
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1.4rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 0 #000;
}

.gamemode-sub {
    margin: 0 0 4px;
    color: var(--text-dim);
    font-size: 15px;
}

.gamemode-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 14px 12px 16px;
    border: 2px solid var(--edge);
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--bevel), 0 4px 0 var(--edge);
    cursor: pointer;
}

.gamemode-choice:hover {
    background: var(--panel-hi);
}

.gamemode-choice:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

.gamemode-choice .ic {
    color: var(--steel);
}

.gamemode-choice.is-ranked .ic {
    color: var(--gold);
}

.gamemode-choice-title {
    font-family: var(--font-ui);
    font-size: 16px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-bright);
}

.gamemode-choice.is-ranked .gamemode-choice-title {
    color: var(--gold);
}

.gamemode-choice-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.35;
}

/* Nicht-klickbare Erinnerung im Setup-Screen, welcher Modus gerade gewählt
   ist (js/lobby.js showCreateGameModal setzt Text/Klasse). */
.setup-mode-badge {
    display: none;
    align-self: center;
    font-family: var(--font-ui);
    font-size: 12px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 4px 10px;
    border: 2px solid var(--edge);
    background: var(--bg-card);
    color: var(--text-dim);
}

.setup-mode-badge.is-ranked {
    display: inline-block;
    color: var(--gold);
    border-color: var(--gold-dk);
}

.setup-mode-badge.is-normal {
    display: inline-block;
}

/* Lobby-Screen: Modus-Zeile neben der Team-/Diplomatie-Zeile (js/lobby.js
   _renderLobbyScreen). */
.lobby-ranked-badge {
    display: none;
    font-family: var(--font-ui);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gold);
}

.lobby-ranked-badge.is-ranked {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lobby-ranked-badge.is-normal {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-dim);
}

/* Im Spielmenü über dem (im Ranked gesperrten) Rückgängig-Knopf — erklärt
   ohne extra Klick, warum der Knopf grau ist. */
.menu-ranked-marker {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-family: var(--font-ui);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gold);
    border-bottom: 2px solid var(--edge);
}

.menu-ranked-marker.is-normal {
    color: var(--text-dim);
}

/* Spielliste (js/lobby.js refreshGameList): Ranked-Badge neben Status-Badge,
   beide in einem Wrapper (hält sie als ein Flex-Kind von .game-card zusammen). */
.game-card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.game-badge.ranked-badge {
    background: var(--gold-dk);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.game-badge.normal-badge {
    background: var(--bg-card);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ── Login / Auth ─────────────────────────────────────────────────────────── */
#login-screen,
#username-setup {
    gap: 12px;
}

/* Die vier Ansichten des Login-Screens (Anmelden, Registrieren, Passwort
   vergessen, neues Passwort) — js/auth.js showLoginStep. */
.login-step {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.login-hint {
    font-size: 15px;
    color: var(--text-dim);
    text-align: center;
}

/* Rechtliche Links unter dem Login (Datenschutz) — bewusst leise */
.login-legal {
    font-size: 15px;
    opacity: 0.7;
    margin-top: 4px;
}

.text-link {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    /* Buttons erben die Schrift nicht von selbst — ohne diese Zeile stand der
       Link in der Systemschrift des Browsers. Jersey 15 bei 15px (Raster). */
    font-family: var(--font-body);
    font-size: 15px;
    padding: 0;
    text-decoration: underline;
}

/* ── Home Screen ─────────────────────────────────────────────────────────── */
/* Der Home-Screen verhält sich wie eine App-Startseite, nicht wie eine
   Webseite: er füllt die Bildschirmhöhe und scrollt NICHT. Was wächst, ist
   allein die Spieleliste (#game-list, flex:1) — sie ist der wichtigste
   Bereich. Die Bestenliste bekommt einen Deckel, die Aktionen sitzen fest
   am unteren Rand.
   `body.app-view` wird in showHomeScreen gesetzt (js/lobby.js). */
#home-screen {
    gap: 10px;
    /* Bewusst KEIN height:100% — das setzt die Flex-Basis auf die volle
       Bodyhöhe, und der Kasten schrumpft danach nicht exakt auf den freien
       Platz zurück (er ragte dadurch unten aus dem Bild). Die Höhe kommt
       allein aus flex-grow unten. */
    max-height: none;
    overflow: hidden;
}

/* ── App-Screens: füllen die Bildschirmhöhe, scrollen selbst nicht ───────
   Gesetzt von showHomeScreen und showFriendsPanel (js/lobby.js). Scrollen
   darf nur die jeweilige LISTE darin, nicht die Seite — sonst fühlt sich das
   an wie eine Webseite statt wie eine App.

   Zwei Fallstricke, die hier bewusst mit abgeräumt sind:
   1. `min-height` schlägt `height` — die Basisregel setzt `min-height:100vh`
      und muss zurückgesetzt werden, sonst bleibt der Body 100vh hoch (und
      100vh zählt auf dem Handy die Adressleiste mit, 100dvh nicht).
   2. Der Seitentitel bekommt hier feste Außenabstände. Mit dem Browser-
      Standard (0.83em, also ~27px je nach Schriftgröße) ging die Rechnung
      nicht auf und der Kasten ragte unten heraus. */
body.app-view {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
}

body.app-view #main-title {
    flex: 0 0 auto;
    margin: 6px 0 8px;
    font-size: 1.5rem;
}

/* Gilt für die VOLLBILD-Menüs (Start, Lobby, Profil, Freunde), die sich im
   App-Modus über die ganze Höhe spannen sollen. Dialoge tragen zusätzlich
   .modal-box und sind hier ausgenommen: sie brauchen ihre max-height und ihr
   overflow, sonst wächst ein voller Einstellungs-Dialog über den Bildschirm
   hinaus und lässt sich weder sehen noch scrollen (gemeldet Sept 2026 —
   die Sprachzeile ganz oben war dadurch unerreichbar). */
body.app-view .screen-box:not(.modal-box) {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    margin: 0 0 8px;
    /* auto statt hidden: passt der Inhalt nach dem Verdichten (fitBox,
       js/ui.js) immer noch nicht — viele Mitspieler in der Lobby auf einem
       kleinen Gerät —, wird er scrollbar statt unsichtbar abgeschnitten. */
    overflow-y: auto;
}



/* Nebenaktionen als Dreierreihe am Fuß */
.home-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    flex: 0 0 auto;
    margin-top: 2px;
}

/* Kompaktvariante: Icon über der Beschriftung, damit drei nebeneinander
   passen, ohne dass die Wörter abgeschnitten werden. */
.action-btn.compact {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 58px;
    padding: 8px 4px;
    font-size: 8px;
    letter-spacing: 0.8px;
    position: relative;
}

/* Zähler offener Freundschaftsanfragen oben rechts am Freunde-Knopf
   (js/lobby.js updateFriendRequestBadge). */
.req-count-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fire-dk);
    color: #fff;
    border: 2px solid var(--edge);
    box-shadow: inset 1px 1px 0 var(--fire), inset -1px -1px 0 #3d1205;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 0;
    line-height: 1;
}

.req-count-badge[hidden] {
    display: none;
}

/* Kopfleiste des Home-Screens (index.html, gefüllt in js/lobby.js) */
.home-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    flex: 0 0 auto;
    padding: 11px 12px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
}

.home-banner-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
    text-align: left;
}

.home-banner-name {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-banner-sub {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-banner-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    padding: 6px 8px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--gold);
}

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex: 0 0 auto;
}

/* Steht die Überschrift allein (Bestenliste), gehört sie in die Mitte —
   space-between hat sie sonst an den linken Rand geklebt. */
.home-header:has(> h3:only-child) {
    justify-content: center;
}

.home-header h3 {
    margin: 0;
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1.1rem;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 7px;
}

/* Titel von Screens und Modals — ersetzt die früheren Inline-Schriftangaben
   in index.html, damit sie dem Token folgen statt jede für sich. */
.screen-title {
    margin: 0;
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1.25rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 0 #000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Titel der Vollbild-Overlays (Forschung, Fraktion, Reliquien, Handel).
   Kleiner als die globale h2-Regel: auf dem Handy fraß der 2rem-Titel sonst
   ein Drittel der Höhe, bevor die erste Karte kam. */
.overlay-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 18px;
    font-size: 1.5rem;
    text-align: center;
    text-wrap: balance;
}

#home-username {
    font-size: 15px;
    color: var(--text-dim);
}

/* Der einzige wachsende Bereich des Home-Screens: nimmt die Resthöhe und
   scrollt bei Bedarf intern — der Screen selbst bleibt unbeweglich. */
#game-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    /* Basis 0: nimmt den Rest der Kastenhöhe. Eine feste min-height würde den
       Kasten von innen aufblähen und ihn wieder aus dem Bild schieben. */
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    /* Gedeckelt, damit eine lange Bestenliste "Meine Spiele" nicht nach unten
       schiebt — Zeilen sind einzeilig, der Schnitt liegt also immer zwischen
       zwei Zeilen. Der Maskenverlauf weicht die Kante zusätzlich auf.
       Anteilig statt fix: auf kleinen Handys blieb von "Meine Spiele" sonst
       kaum etwas übrig, auf großen war unnötig Luft. */
    flex: 0 1 auto;
    /* Deckel bewusst knapp: "Meine Spiele" ist der wichtigere Bereich und
       bekommt den Rest. Auf kleinen Handys blieben mit 26dvh nur ~50px für
       die Spieleliste übrig, also weniger als eine Karte. */
    max-height: min(190px, 21dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
}

/* One line per row. Nur der Name kürzt mit Ellipse — Rang, Siege und der
   Button/Status behalten immer ihre volle Breite, damit man bei langen Namen
   trotzdem die Siege sieht. */
#leaderboard-list .friend-row>span {
    white-space: nowrap;
}

/* Zeilen ohne Button (ich selbst / bereits befreundet) sonst niedriger als
   Zeilen mit Button (der hat min-height 44px) → einheitliche Höhe erzwingen. */
#leaderboard-list .friend-row {
    min-height: 52px;
    flex: 0 0 auto;
}

#leaderboard-list .lb-rank {
    flex: 0 0 auto;
    color: var(--text-dim);
}

#leaderboard-list .lb-name {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
    /* .screen-box zentriert sonst den Namen im gewachsenen Span */
}

/* Rating ist die Hauptzahl der Zeile — kräftiger als die Bilanz daneben. */
#leaderboard-list .lb-rating {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
}

#leaderboard-list .lb-wins {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    text-align: right;
}

/* Vorläufig: zu wenige gewertete Partien für einen echten Rang. */
#leaderboard-list .lb-provisional {
    opacity: 0.62;
}

#leaderboard-list .lb-provisional .lb-rating {
    font-weight: 400;
    font-style: italic;
}

#leaderboard-list .lb-tag {
    flex: 0 0 auto;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    opacity: 0.75;
}

#leaderboard-list .friend-row .action-btn {
    flex-shrink: 0;
    margin-top: 0;
    padding: 6px 10px;
    font-size: 12px;
}

.game-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    cursor: pointer;
    transition: none;
    gap: 8px;
}

.game-card:hover {
    background: #2a2219;
}

.game-card:active {
    box-shadow: var(--bevel-in);
}

/* "Du bist dran": die eine Karte pro Screen, die Gold UND Ecknieten bekommt. */
.game-card-active {
    background: #241a0c;
    box-shadow:
        inset 2px 2px 0 var(--gold-dk),
        inset -2px -2px 0 var(--panel-lo),
        0 0 0 2px var(--gold-mid);
    position: relative;
}

/* Beendete Spiele: sichtbar gedimmt, damit "läuft noch" vs. "vorbei" auch ohne
   den Blick aufs Badge sofort klar ist — Karte bleibt aber voll lesbar/klickbar. */
.game-card-finished {
    opacity: 0.6;
}

.game-card-finished:hover {
    opacity: 0.85;
}

.game-card-active::before,
.game-card-active::after {
    content: "";
    position: absolute;
    top: 4px;
    width: 4px;
    height: 4px;
    background: var(--gold);
}

.game-card-active::before {
    left: 4px;
}

.game-card-active::after {
    right: 4px;
}

.game-card-name {
    font-size: 15px;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Flex-Items schrumpfen ohne min-width:0 nie unter ihre Inhaltsbreite
       (Standard min-width:auto) — das ellipsis oben griff dadurch nie, ein
       langer Wait-Badge-Name (s.u.) drückte den Spielnamen bis auf 0 Breite
       weg und verschob den Delete-Button mit (Jonathans Meldung). flex:1 hält
       den Namen als bevorzugten Platznehmer, min-width als Untergrenze. */
    min-width: 0;
    flex: 1 1 auto;
}

.game-badge {
    font-family: var(--font-ui);
    font-size: 8px;
    padding: 4px 6px;
    white-space: nowrap;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 2px solid var(--edge);
}

.turn-badge {
    background: var(--gold-mid);
    color: #1c1305;
    box-shadow: inset 1px 1px 0 #f0cf6a, inset -1px -1px 0 var(--gold-dk);
}

.wait-badge {
    background: #1a1714;
    color: var(--text-dim);
    box-shadow: inset 1px 1px 0 #26211b, inset -1px -1px 0 #0b0a09;
    /* Einziges Badge mit variabler Länge (Nutzername) — ohne Deckel nimmt es
       sich per white-space:nowrap (.game-badge) so viel Platz wie der Name
       lang ist und quetscht den Spielnamen daneben weg (s. .game-card-name). */
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-badge {
    background: var(--steel-dk);
    color: var(--steel);
    box-shadow: inset 1px 1px 0 #3f4557, inset -1px -1px 0 #171a22;
}

.spectator-badge {
    background: #2a1633;
    color: #ce93d8;
    box-shadow: inset 1px 1px 0 #43254f, inset -1px -1px 0 #140a18;
}

.finished-badge {
    background: #1a1714;
    color: var(--text-dim);
    box-shadow: inset 1px 1px 0 #26211b, inset -1px -1px 0 #0b0a09;
    /* Kein eigenes opacity hier — die ganze Karte ist schon per .game-card-finished
       gedimmt, ein zweites opacity würde sich multiplizieren und die Beschriftung
       zu blass machen. */
}

/* Offene Einladung (Sept 2026): die Karte hebt sich ab, solange sie eine
   Entscheidung von mir verlangt — sonst geht sie zwischen den laufenden Partien
   unter und der Host wartet auf eine Zusage, die niemand gesehen hat. */
.invite-badge {
    background: var(--gold-dk);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: inset 1px 1px 0 #9c6a08, inset -1px -1px 0 #3d2802;
}

.game-card-invite {
    border-color: var(--gold-mid);
}

.game-accept-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--green);
    flex-shrink: 0;
}

.game-accept-btn:hover {
    background: #12300f;
}

.lobby-invite-hint {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.35;
    color: var(--text-dim);
    text-align: left;
}

.game-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 6px;
    color: var(--text);
    opacity: 0.8;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.game-delete-btn:hover {
    opacity: 1;
    color: var(--red, #e05c4d);
    background: #33160c;
}

/* ── Lobby Screen ─────────────────────────────────────────────────────────── */
#lobby-screen {
    gap: 12px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
}

#lobby-player-count {
    font-size: 15px;
    color: var(--text-dim);
}

#lobby-player-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.player-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    font-size: 15px;
}

/* Host-only, in der Namenszeile eines belegten (nicht-eigenen) Slots
   (js/lobby.js _renderLobbyScreen). */
.player-slot-kick-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    color: var(--red);
    cursor: pointer;
}

.player-slot-kick-btn:active {
    transform: translateY(2px);
}

/* Rechte Seite eines belegten Slots: Freundschaft + (Host) Rauswerfen. */
.player-slot-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-slot-friend-btn {
    height: 32px;
    padding: 0 8px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    color: var(--gold);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
}

.player-slot-friend-btn:active {
    transform: translateY(2px);
}

.player-slot-tag {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-dim);
}

/* Freier Platz: Schraffur statt gestricheltem Rand — eine gestrichelte Linie
   gibt es im Pixel-Raster nicht, die Diagonalstreifen lesen sich als "leer". */
.player-slot-empty {
    color: var(--text-faint);
    font-style: normal;
    background: repeating-linear-gradient(45deg, #121010 0 6px, #161311 6px 12px);
    border-color: #221c16;
    box-shadow: none;
}

.invite-section {
    width: 100%;
}

.invite-section p {
    margin: 0 0 4px;
    font-size: 15px;
    color: var(--text-dim);
}

.link-row {
    display: flex;
    gap: 6px;
    width: 100%;
}

.link-row input {
    flex: 1;
    font-size: 0.75rem;
    min-width: 0;
}

.link-row button {
    min-height: 44px;
    padding: 8px 12px;
    background: #3a2b1c;
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55), 0 4px 0 var(--edge);
    color: var(--text-bright);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.link-row button:hover {
    background: #46351f;
}

.link-row button:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

#lobby-friend-invite {
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* ── Diplomatie-Fenster (#dip-overlay, js/diplomacy.js openDiplomacy) ─────────
   Spieler werden in drei Gruppen gebündelt statt einzeln mit sich
   wiederholenden "Verbündet mit: ..."-Zeilen aufgelistet: das eigene Team
   (.dip-card-ally, einzeln gelistet — Ressourcenaustausch ist pro Spieler),
   fremde Bündnisse (.dip-card-enemy, EINE Karte pro Team statt einer pro
   Mitglied) und unverbündete Einzelspieler (.dip-card-neutral). */
.dip-section-title {
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
    margin: 10px 0 4px;
}

.dip-section-title:first-child {
    margin-top: 0;
}

.dip-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    text-align: left;
}

/* Verhältnis als 4px-Kante links: eine Einfärbung des 2px-Pixelrahmens wäre
   zu schwach, um Bündnis und Feind auf einen Blick zu trennen. */
.dip-card-ally {
    border-left: 4px solid var(--green);
}

.dip-card-enemy {
    border-left: 4px solid var(--fire);
}

.dip-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dip-name {
    font-weight: bold;
}

.dip-badge {
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
}

.dip-badge-enemy {
    color: #ff5252;
}

.dip-team-names {
    font-size: 15px;
    color: var(--text-dim);
}

.dip-member-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px;
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dip-member-row:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.dip-action-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.dip-action-btn {
    padding: 4px 8px;
    font-size: 12px;
    margin-top: 0;
}

/* ── Profil (js/lobby.js showProfileScreen) ──────────────────────────────── */
.profile-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    flex: 0 0 auto;
    padding: 16px 14px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    text-align: left;
}

.profile-ident {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.profile-name {
    font-family: var(--font-body);
    font-size: 30px;
    line-height: 1;
    color: var(--gold);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-status {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-dim);
    line-height: 1.5;
}

/* Vier Kennzahlen nebeneinander — auf schmalen Handys umbrechend statt
   zusammengequetscht. */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    flex: 0 0 auto;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
}

.profile-stat-value {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-bright);
}

.profile-stat-value.is-gold { color: var(--gold); font-size: 16px; }

.profile-stat-label {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    text-align: center;
}

/* Der wachsende, scrollbare Bereich des Profil-Screens */
#profile-history {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#profile-screen .screen-title,
#profile-screen > .action-btn {
    flex: 0 0 auto;
}

.profile-empty {
    margin: 0;
    padding: 12px 4px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-faint);
    text-align: center;
}

.hist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding: 9px 10px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    text-align: left;
}

/* Sieg/Niederlage als Marke statt als Farbe der ganzen Zeile — die Zeile
   bleibt so lesbar, das Ergebnis ist trotzdem auf einen Blick da. */
.hist-mark {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 8px;
    border: 2px solid var(--edge);
}

.hist-mark.is-win {
    background: #2c6b2c;
    color: #e6f7e6;
    box-shadow: inset 1px 1px 0 var(--green), inset -1px -1px 0 #133a13;
}

.hist-mark.is-loss {
    background: var(--fire-dk);
    color: #f8e5de;
    box-shadow: inset 1px 1px 0 var(--fire), inset -1px -1px 0 #3d1205;
}

.hist-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.hist-name {
    font-size: 15px;
    color: var(--text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-meta {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.hist-delta {
    flex: 0 0 auto;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-dim);
}

.hist-delta.is-up   { color: var(--green); }
.hist-delta.is-down { color: #ff9d7d; }

.hist-rating {
    flex: 0 0 auto;
    width: 42px;
    text-align: right;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-bright);
}

/* Die Kopfleiste führt ins Profil. Damit man das sieht, trägt sie dieselbe
   Knopf-Anatomie wie jeder andere Button im Spiel: 4px-Sockel unten, der beim
   Drücken verschwindet, während der Knopf um genau diese 4px einsinkt.
   Das ist die vorhandene Formsprache statt einer neuen Verzierung — wer einmal
   irgendeinen Knopf gedrückt hat, erkennt sie wieder. */
button.home-banner {
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    box-shadow:
        inset 2px 2px 0 var(--panel-hi),
        inset -2px -2px 0 var(--panel-lo),
        0 4px 0 var(--edge);
    /* Platz für den Sockel, damit die Karte darunter nicht anstößt */
    margin-bottom: 4px;
}

button.home-banner:hover { background: #201a14; }

button.home-banner:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

/* Zusätzlicher, sehr zurückhaltender Hinweis: das Chevron rückt alle paar
   Sekunden kurz nach rechts. Lange Ruhephase (~4s), dann ein 3px-Stups —
   genug, um den Blick einmal dorthin zu ziehen, ohne zu blinken.
   transform statt left/right: läuft auf dem Compositor. */
@keyframes chevronNudge {
    0%, 84%, 100% { transform: translateX(0); }
    90%           { transform: translateX(3px); }
    95%           { transform: translateX(0); }
}

.home-banner-chevron {
    flex: 0 0 auto;
    color: var(--gold);
    animation: chevronNudge 5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .home-banner-chevron { animation: none; }
}

}

/* ── Friends Panel ───────────────────────────────────────────────────────── */
#friends-panel {
    gap: 12px;
}

.friend-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    gap: 8px;
}

#friend-requests-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    flex: 0 0 auto;
}

/* Der einzige wachsende Bereich des Freunde-Screens: nimmt die Resthöhe und
   scrollt intern, damit die Seite selbst stehen bleibt. */
#friends-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#friends-panel .setup-group,
#friends-panel .screen-title,
#friends-panel > .action-btn {
    flex: 0 0 auto;
}

.action-btn.secondary {
    background: #1a1613;
    color: var(--text-dim);
    box-shadow: inset 2px 2px 0 #241d16, inset -2px -2px 0 #0b0908, 0 4px 0 var(--edge);
}

.action-btn.secondary:hover {
    background: #241d16;
    color: var(--text);
}

.action-btn.secondary:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

/* ── Friend Picker Overlay ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-box {
    margin: 0;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    animation: fadeInUp 0.25s ease;
}

#friend-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    overflow-y: auto;
    max-height: 45vh;
}

.friend-picker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    cursor: pointer;
    transition: none;
    user-select: none;
    min-height: 48px;
    font-size: 15px;
}

.friend-picker-row:hover {
    background: #2a2219;
}

.friend-picker-row:active {
    box-shadow: var(--bevel-in);
}

.friend-picker-row.selected {
    background: #241a0c;
    box-shadow: inset 2px 2px 0 var(--gold-dk), inset -2px -2px 0 var(--panel-lo), 0 0 0 2px var(--gold-mid);
}

.picker-check {
    width: 20px;
    height: 20px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #1a1510;
}

.friend-picker-row.selected .picker-check {
    background: var(--gold-mid);
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

.friend-picker-row.selected .picker-check::after {
    content: '✓';
    font-weight: bold;
}

/* ── Mobile / Responsive ────────────────────────────────────────────────── */

/* Touch targets: all interactive elements at least 44px */
.action-btn,
input,
select {
    min-height: 44px;
}

/* Prevent iOS Safari from zooming in on input focus */
input,
select,
textarea {
    font-size: max(16px, 1rem);
}

/* On small screens: tighter padding, full-width box */
@media (max-width: 480px) {
    .screen-box {
        padding: 20px 14px;
        margin: 8px;
        width: calc(100% - 16px);
        max-width: none;
        max-height: calc(100dvh - 16px);
    }

    .modal-backdrop {
        padding: 8px;
        align-items: flex-end;
    }

    .modal-box {
        max-height: 90dvh;
    }
}

/* Landscape on phone: tighter spacing */
@media (max-height: 600px) and (orientation: landscape) {
    .screen-box {
        gap: 10px;
        padding: 14px 16px;
    }
}

/* Ensure scrollable body on menu screens without breaking game canvas.
   All gameplay UI (#canvas-wrapper, #game-hud, #ui-container) is
   position:fixed, so it stays put regardless of body scroll — this is
   safe to enable globally. touch-action must be overridden too, since
   overflow alone doesn't re-enable touch/swipe scrolling; the game
   canvas keeps its own touch-action:none independent of this. */
body {
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
}

/* Safe area padding for notched phones (home screen, lobby, friends) */
.screen-box {
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
}

/* App-Screens nutzen ihre Höhe komplett aus — dort reicht der reine
   Safe-Area-Abstand, ein zusätzliches Polster nähme der Liste Platz. */
body.app-view .screen-box {
    padding: 14px 14px max(14px, calc(env(safe-area-inset-bottom) + 6px));
}

/* === RADIAL-MENÜ (Langdruck-Auswahlrad) ===
   Ersetzt die aus dem HUD entfernten Buttons Forschung/Fraktion/Diplomatie/
   Reliquien/Zug beenden (js/radialmenu.js, ausgelöst durch 0.7s Druck ohne
   Ziehen auf #canvas-wrapper, siehe js/input.js). Overlay UND alle Kinder
   bekommen pointer-events:none — das Antippen/Anvisieren läuft komplett über
   document-pointermove/-up-Listener mit Distanz-/Winkelberechnung zum
   Druckpunkt (radialmenu.js), NICHT über elementFromPoint: der Finger selbst
   verdeckt sonst genau den Kreis, den er gerade ansteuert, und ein Hit-Test
   über das DOM würde dann "danebenliegen" registrieren, sobald der Finger
   knapp neben statt exakt auf dem Kreis steht. Die Hintergrund-Vignette
   (radial-gradient) wird pro Öffnung inline auf den Druckpunkt zentriert
   gesetzt (JS), da sich der Druckpunkt bei jedem Öffnen ändert. */
#radial-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
}

#radial-menu-overlay.radial-menu-visible {
    opacity: 1;
}

.radial-circle {
    position: absolute;
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    color: var(--text);
    font-family: var(--font-ui);
    transform: scale(0.4);
    opacity: 0;
    box-shadow: var(--bevel), var(--drop);
    transition: transform 150ms ease, opacity 150ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

/* Einblend-Animation: erst NACH dem Einfügen ins DOM wird diese Klasse per
   requestAnimationFrame auf #radial-menu-overlay gesetzt (radialmenu.js),
   damit der Übergang von scale(0.4)/opacity:0 tatsächlich animiert statt
   sofort im Endzustand zu starten. */
#radial-menu-overlay.radial-menu-visible .radial-circle {
    opacity: 1;
    transform: scale(1);
}

/* Kaufbar (aktuell nur "Fraktion", wenn die nächste Kultur leistbar ist):
   grüner Puls statt starrem Rand, damit der Kaufanreiz auffällt, ohne den
   Gold-Highlight für das anvisierte Ziel (.active, unten) zu überdecken —
   .active steht bewusst NACH dieser Regel und gewinnt bei gleicher
   Spezifität, falls beide Klassen gleichzeitig anliegen. */
@keyframes radialAffordablePulse {

    0%,
    100% {
        box-shadow: var(--bevel), 0 0 0 2px rgba(92, 184, 92, 0.55);
    }

    50% {
        box-shadow: var(--bevel), 0 0 0 2px #78ffa0, 0 0 18px 4px rgba(92, 184, 92, 0.65);
    }
}

.radial-circle.affordable {
    animation: radialAffordablePulse 1.4s ease-in-out infinite;
}

/* Anvisiert: der Kreis, dessen Mittelpunkt dem Zeiger am nächsten liegt UND
   dessen Abstand zum Druckpunkt > ~40px ist (radialmenu.js) — darunter gilt
   die Mitte/Abbrechen-Zone, kein Kreis wird hervorgehoben. */
.radial-circle.active {
    transform: scale(1.18);
    background: var(--gold-mid);
    color: #1c1305;
    box-shadow:
        inset 2px 2px 0 #f0cf6a,
        inset -2px -2px 0 var(--gold-dk),
        0 0 0 2px var(--gold),
        var(--drop);
}

/* Deaktiviert (Zustand wird beim Öffnen einmalig berechnet, ändert sich
   während des Haltens nicht): ausgegraut, löst bei Loslassen keine Aktion
   aus (radialmenu.js zeigt bei Forschung stattdessen einen Hinweis-Toast). */
.radial-circle.disabled {
    opacity: 0.4;
    filter: grayscale(0.7);
}

.radial-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.radial-label {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.2;
    text-align: center;
    max-width: 58px;
}

.radial-center-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
    background: var(--gold);
    border: 2px solid var(--edge);
    opacity: 0;
    transition: opacity 150ms ease;
}

#radial-menu-overlay.radial-menu-visible .radial-center-dot {
    opacity: 1;
}

/* ── Einstellungs-Modal (js/settings.js) ─────────────────────────────────── */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    min-height: 48px;
}

.settings-row-col {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.settings-label {
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
}

.settings-status {
    font-size: 15px;
    color: var(--text-dim);
    line-height: 1.4;
}

.settings-row-col .action-btn,
.settings-row-col input {
    width: 100%;
    margin: 0;
}

/* Toggle-Schalter */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-knob {
    position: absolute;
    inset: 0;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
}

.toggle-knob::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
    background: var(--stone);
    box-shadow: inset 2px 2px 0 var(--steel), inset -2px -2px 0 var(--steel-dk);
    transition: transform 0.12s steps(3);
}

.toggle-switch input:checked+.toggle-knob {
    background: #2a1f08;
}

.toggle-switch input:checked+.toggle-knob::before {
    transform: translateX(22px);
    background: var(--gold-mid);
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

/* Lautstärke-Slider — Element bleibt 44px hoch (Touch-Target-Regel unten),
   sichtbar ist nur der 6px-Track via Pseudo-Elemente (Pattern wie
   #camera-focus-slider). */
#settings-music-vol {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    min-width: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
}

#settings-music-vol::-webkit-slider-runnable-track {
    height: 10px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
}

#settings-music-vol::-moz-range-track {
    height: 10px;
    background: #0d0b09;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel-in);
}

#settings-music-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 20px;
    margin-top: -7px;
    /* mittig auf dem 10px-Track inkl. 2px-Rand */
    background: var(--gold-mid);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

#settings-music-vol::-moz-range-thumb {
    width: 16px;
    height: 20px;
    background: var(--gold-mid);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 #f0cf6a, inset -2px -2px 0 var(--gold-dk);
}

/* === RÜCKBLICK (js/recap.js) ==============================================
   Nicht-blockierendes Panel am Zugstart: was seit dem eigenen letzten Zug im
   eigenen Sichtfeld passiert ist. Liegt bewusst UNTER #game-hud (z-index 150)
   und ist kein .overlay — das Spielfeld bleibt bedienbar, während es offen ist.
   Formkanon wie überall: 2px-Rahmen, 2px-Bevel, kein Blur, keine Rundungen,
   Trefferflächen >= 44px, Silkscreen nur auf 8/12/16px, Jersey 15 auf 15px. */

/* Farbkanal je Aktionsart. Steht als Token auf :root, weil js/recap.js
   (recapPulseColor) denselben Wert für den Karten-Puls ausliest — sonst gäbe
   es einen zweiten, von Hand gepflegten Farbsatz im JS. */
:root {
    --rc-fire: #e2571f;
    --rc-gold: #e8b84a;
    --rc-build: #9fabbc;
    --rc-earth: #b07a3c;
    --rc-move: #8a7e6e;
}

#recap-btn {
    width: 38px;
    height: 38px;
    display: none;
    /* per JS auf flex, sobald es etwas zu berichten gibt */
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
    background: #3a2b1c;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}

#recap-btn:hover {
    background: #46351f;
}

#recap-btn:active {
    box-shadow: var(--bevel-in);
}

/* Zähler als kleine Ecke oben rechts — Silkscreen auf 8px, dem einzigen
   scharfen Raster in dieser Größe. */
#recap-btn-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 14px;
    padding: 0 3px;
    font-family: var(--font-ui);
    font-size: 8px;
    line-height: 14px;
    text-align: center;
    color: #1c1305;
    background: var(--gold-mid);
    border: 2px solid var(--edge);
}

/* Griff mich an: sobald etwas Eigenes getroffen wurde, wechselt der Knopf auf
   Feuer statt Gold — man soll am HUD sehen, ob es dringend ist. */
#recap-btn.has-hit {
    background: #4a1c0b;
}

#recap-btn.has-hit #recap-btn-count {
    background: var(--fire);
    color: #f8e5de;
}

#recap-panel {
    display: none;
    position: fixed;
    left: 8px;
    top: calc(64px + env(safe-area-inset-top));
    width: 300px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 200px);
    z-index: 140;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel), var(--drop);
    flex-direction: column;
    overflow: hidden;
}

#recap-panel.open {
    display: flex;
}

.recap-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 8px 10px;
    border-bottom: 2px solid var(--panel-hi);
    background: var(--bg-card);
}

.recap-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--gold);
}

.recap-close {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    padding: 0;
    background: #3a2b1c;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    font-family: var(--font-ui);
    font-size: 12px;
    cursor: pointer;
}

.recap-close:hover {
    background: #46351f;
}

#recap-body {
    overflow-y: auto;
    padding: 4px 0;
}

.recap-empty {
    padding: 12px 10px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
}

.recap-group+.recap-group {
    border-top: 2px solid var(--panel-hi);
    margin-top: 4px;
    padding-top: 4px;
}

.recap-name {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 4px;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.recap-group.has-hit .recap-name {
    color: var(--text-bright);
}

/* Eine Zeile = eine zusammengefasste Aktionsart. Volle Breite und 44px hoch,
   damit sie auf dem Handy sicher zu treffen ist. */
.recap-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 4px 10px;
    background: transparent;
    border: 0;
    border-left: 4px solid transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}

.recap-row:hover {
    background: var(--bg-card);
}

.recap-row:active {
    box-shadow: var(--bevel-in);
}

.recap-ic {
    display: flex;
    flex-shrink: 0;
}

.recap-label {
    flex: 1;
    min-width: 0;
}

.recap-label b {
    color: var(--fire);
    font-weight: normal;
}

/* Zähler: vor der Auswahl die Anzahl ("×2"), beim Durchsteppen die Position
   ("2/5"). Silkscreen auf 8px — dem Raster, auf dem sie scharf ist. */
.recap-step {
    flex-shrink: 0;
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--text-dim);
}

.recap-row.hit {
    border-left-color: var(--fire);
    background: #24140d;
}

.recap-row.rc-k-fire .recap-ic {
    color: var(--rc-fire);
}

.recap-row.rc-k-gold .recap-ic {
    color: var(--rc-gold);
}

.recap-row.rc-k-build .recap-ic {
    color: var(--rc-build);
}

.recap-row.rc-k-earth .recap-ic {
    color: var(--rc-earth);
}

.recap-row.rc-k-move .recap-ic {
    color: var(--rc-move);
}

.recap-foot {
    padding: 6px 10px;
    border-top: 2px solid var(--panel-hi);
    background: var(--bg-card);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1.2px;
    color: var(--text-faint);
}

/* Rückblick-Zeilen: Einheiten-Sprites, Schaden, Kill-Marke, Auswahl.
   Die Sprites kommen als data-URL aus js/recap.js (recapSpriteURL) und sind
   winzige Bitmaps in Originalgröße — image-rendering: pixelated ist hier keine
   Kosmetik, ohne sie interpoliert der Browser sie zu Matsch. */
.recap-unit {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Sprites sind oben/unten transparent — der Versatz setzt die Figur auf
       dieselbe Grundlinie wie den Text daneben. */
    margin-bottom: -2px;
}

/* Ziel eines Angriffs: kleiner als der Angreifer, damit die Zeile als
   "der da → den da" gelesen wird und nicht als Paar gleichrangiger Symbole. */
.recap-unit.small {
    width: 14px;
    height: 14px;
    margin-right: 2px;
    vertical-align: -2px;
}

.recap-arrow {
    color: var(--text-faint);
    padding: 0 1px;
}

/* Zahlen in Silkscreen (8px-Raster), wie alle Zahlen in der UI. */
.recap-dmg {
    flex-shrink: 0;
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--rc-fire);
}

.recap-kill {
    display: flex;
    flex-shrink: 0;
    color: var(--rc-fire);
}

/* Ausgewählte Zeile: dieselbe Farbe wie die Hervorhebung auf der Karte
   (window.recapFocus), damit Zeile und Feld erkennbar zusammengehören. */
.recap-row.selected {
    background: #2a2318;
    box-shadow: inset 0 0 0 2px var(--panel-hi);
}

.recap-row.selected .recap-step {
    color: var(--gold);
}

/* Eingeklappter Rückblick (js/recap.js setRecapCollapsed).
   Auf dem Handy geht das Panel über die volle Breite und deckt damit genau die
   Bildschirmmitte ab, in die Renderer.centerOn das angetippte Feld legt — man
   wählt ein Ereignis und sieht das Ergebnis nicht. Eingeklappt bleibt nur die
   gewählte Zeile stehen, das Spielfeld liegt frei. Deshalb klappt das Auswählen
   auf schmalen Geräten automatisch ein. */
.recap-list-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #3a2b1c;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

.recap-list-btn:hover {
    background: #46351f;
}

/* Der Titel schiebt die beiden Knöpfe nach rechts. */
.recap-head .recap-title {
    flex: 1;
    min-width: 0;
}

/* Eingeklappt: alles ausblenden ausser der gewählten Zeile. Kein eigenes
   Markup dafür — die Liste bleibt im DOM, damit Aufklappen ohne Neuaufbau
   funktioniert und die Auswahl erhalten bleibt. */
#recap-panel.collapsed {
    max-height: none;
}

#recap-panel.collapsed #recap-body {
    overflow: visible;
    padding: 0;
}

#recap-panel.collapsed .recap-group {
    margin: 0;
    padding: 0;
    border-top: 0;
}

#recap-panel.collapsed .recap-name,
#recap-panel.collapsed .recap-empty,
#recap-panel.collapsed .recap-foot,
#recap-panel.collapsed .recap-row:not(.selected) {
    display: none;
}

/* Eingeklappt ohne Auswahl (Standardzustand beim Zugstart): statt eines leeren
   Kastens die Kurzfassung. Bewusst kein automatischer Sprung auf das erste
   Ereignis — eine Kamerafahrt, die niemand ausgelöst hat, ist genau das, was
   der Rückblick nicht mehr tun soll (js/recap.js syncRecapSelState). */
#recap-summary {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 10px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
}

#recap-panel.collapsed:not(.has-sel) #recap-summary {
    display: flex;
}

#recap-panel.collapsed:not(.has-sel) #recap-body {
    display: none;
}

.recap-sum-n {
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--gold);
}

#recap-summary b {
    color: var(--rc-fire);
    font-weight: normal;
}

/* In der Einzelansicht braucht die Zeile keine Auswahl-Umrandung mehr — sie
   IST die Auswahl. Der farbige Streifen links bleibt (Treffer-Markierung). */
#recap-panel.collapsed .recap-row.selected {
    background: transparent;
    box-shadow: none;
}

/* Blätter-Leiste: nur eingeklappt sichtbar. */
#recap-nav {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    border-top: 2px solid var(--panel-hi);
    background: var(--bg-card);
}

#recap-panel.collapsed #recap-nav {
    display: flex;
}

.recap-nav-btn {
    min-width: 56px;
    height: 40px;
    padding: 0;
    background: #3a2b1c;
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.recap-nav-btn:hover {
    background: #46351f;
}

.recap-nav-btn:active {
    box-shadow: var(--bevel-in);
}

#recap-nav-pos {
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--text-dim);
}

/* Auf schmalen Geräten volle Breite: 300px neben dem Spielfeld bringt nichts,
   wenn das Spielfeld selbst nur 360px breit ist. */
@media (max-width: 480px) {
    #recap-panel {
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 46vh;
    }
}

/* ── Passt-auf-einen-Bildschirm (Sept 2026) ──────────────────────────────────
   Ein Screen soll wie in einer App ohne Scrollen auskommen. Passt der Inhalt
   nicht, wird er DICHTER gesetzt — nicht kleiner gerendert: Jersey 15 und
   Silkscreen sind nur auf ihrem eigenen Raster scharf (siehe "Schriften" in
   CLAUDE.md), ein freies Herunterskalieren würde die ganze UI verwaschen.
   Reduziert werden deshalb Abstände, Innenabstände und Mindesthöhen; einzig
   der Titel darf schrumpfen, weil MedievalSharp kein Pixelfont ist.
   Trefferflächen bleiben bei mindestens 44px.
   Gesetzt wird die Stufe von fitBox() in js/ui.js. */

.fit-1 { gap: 12px; padding: 20px; }
.fit-2 { gap: 8px;  padding: 16px; }
.fit-3 { gap: 4px;  padding: 12px; }

.fit-1 .settings-row { padding: 10px 14px; min-height: 44px; }
.fit-2 .settings-row { padding: 8px 12px;  min-height: 44px; }
.fit-3 .settings-row { padding: 6px 12px;  min-height: 44px; }

.fit-2 .settings-row-col { gap: 6px; }
.fit-3 .settings-row-col { gap: 4px; }

.fit-1 .overlay-title, .fit-1 .screen-title { margin-bottom: 12px; }
.fit-2 .overlay-title, .fit-2 .screen-title { margin-bottom: 8px; font-size: 1.3rem; }
.fit-3 .overlay-title, .fit-3 .screen-title { margin-bottom: 4px; font-size: 1.15rem; }

.fit-2 .action-btn { margin-top: 0; padding: 8px 12px; }
.fit-3 .action-btn { margin-top: 0; padding: 6px 12px; }

/* Die Statuszeile der E-Mail ist der längste Fließtext im Dialog — sie darf
   in der dichtesten Stufe enger laufen (Jersey 15 bleibt auf 15px). */
.fit-3 .settings-status { line-height: 1.2; }

/* Lobby: die Spielerplätze sind der größte Block, sobald viele mitspielen —
   in den dichten Stufen enger, Trefferfläche bleibt bei 44px. */
.fit-1 .player-slot { padding: 10px 12px; }
.fit-2 .player-slot { padding: 8px 12px; }
.fit-3 .player-slot { padding: 6px 12px; }
.fit-2 #lobby-player-list, .fit-3 #lobby-player-list { gap: 6px; }
.fit-3 .invite-section p { margin-bottom: 2px; }

/* Zeilen dürfen im Flex-Container NICHT unter ihre Inhaltshöhe schrumpfen.
   Ohne das presst ein zu voller Kasten seine Kinder zusammen, bis Texte und
   Knöpfe übereinanderliegen — und zwar lautlos: die Höhe des Kastens stimmt
   dann rechnerisch, nur der Inhalt quillt aus den Zeilen heraus (gesehen beim
   Einstellungs-Dialog, Sept 2026). Lieber überläuft der Kasten sichtbar und
   fitBox verdichtet ihn bzw. er wird scrollbar. */
.settings-row,
.player-slot,
.friend-row,
.hist-row,
.settings-row .action-btn,
.screen-box > .action-btn {
    flex-shrink: 0;
}

/* In den dichten Stufen dürfen Auswahlfeld und Regler die Zeile nicht höher
   machen als nötig — sie trieben sie auf 60px, während eine Umschalt-Zeile
   mit 44px auskommt (Trefferfläche bleibt gewahrt, die Zeile selbst ist 44). */
.fit-2 .settings-row select,
.fit-3 .settings-row select,
.fit-2 .settings-row input[type="range"],
.fit-3 .settings-row input[type="range"] {
    padding-top: 4px;
    padding-bottom: 4px;
    min-height: 32px;
    height: 32px;
}

.fit-3 { padding: 8px; }

/* ══ Tutorial (js/tutorial.js) ═════════════════════════════════════════════
   Formkanon wie überall: keine Rundungen, kein Blur, 2px-Rahmen, Abstände in
   Vielfachen von 4, Silkscreen nur auf 8/12/16px, Jersey 15 auf 15px. */

.tut-intro {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
    margin: 0;
}

#tutorial-chapters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Kapitelkachel: Marke links (Nummer / Haken / Schloss), Titel und Untertitel
   rechts. Erledigte tragen den Haken in Gold — der Fortschritt soll auf einen
   Blick ablesbar sein, ohne die Kachel zu öffnen. */
.tut-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px;
    text-align: left;
    background: var(--bg-card);
    color: var(--text);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.22), inset -2px -2px 0 rgba(0, 0, 0, 0.55), 0 4px 0 var(--edge);
    cursor: pointer;
    font-family: var(--font-ui);
}

.tut-tile:hover { background: #2a2219; }

.tut-tile:active {
    transform: translateY(4px);
    box-shadow: var(--bevel-in);
}

.tut-tile.is-soon {
    background: #141211;
    color: #3f3931;
    cursor: not-allowed;
    box-shadow: inset 2px 2px 0 #1c1917, inset -2px -2px 0 #0b0a09, 0 4px 0 var(--edge);
}

.tut-tile-mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #100d0b;
    border: 2px solid var(--edge);
}

.tut-tile-num {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-dim);
}

.tut-tile-check { color: var(--gold); }
.tut-tile-lock { color: #3f3931; opacity: 0.45; }

.tut-tile-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tut-tile-title {
    font-family: var(--font-ui);
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text-bright);
}

.tut-tile.is-soon .tut-tile-title { color: #4a443c; }

.tut-tile-sub {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.1;
    color: var(--text-dim);
}

/* ── Popup ────────────────────────────────────────────────────────────────
   Steht oben oder unten, nie in der Mitte: dort liegt das Feld, auf das die
   Kamera zentriert. Welche Seite, entscheidet js/tutorial.js aus der Lage des
   Ziels (tutPlacePopup) — geometrisch, nicht per Breakpoint. */
.tut-popup {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    width: calc(100% - 32px);
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel), var(--drop);
}

.tut-popup.at-top { top: calc(76px + env(safe-area-inset-top)); }
.tut-popup.at-bottom { bottom: calc(16px + env(safe-area-inset-bottom)); }

.tut-popup-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold);
}

.tut-popup-title {
    font-family: var(--font-ui);
    font-size: 12px;
    letter-spacing: 0.5px;
    flex: 1;
}

.tut-popup-pos {
    font-family: var(--font-ui);
    font-size: 8px;
    color: var(--text-faint);
}

.tut-popup-text {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.2;
    color: var(--text-bright);
}

.tut-popup-actions {
    display: flex;
    gap: 8px;
}

.tut-popup-actions .action-btn {
    flex: 1 1 0;
    min-height: 44px;
    margin-top: 0;
}

/* Beenden ist die Nebenaktion — schmaler als "Verstanden". */
.tut-popup-actions .action-btn:first-child { flex: 0 0 96px; }

/* ── Ring ─────────────────────────────────────────────────────────────────
   Ein Element für beide Zielarten (Feld und Knopf). pointer-events:none ist
   Pflicht: der Ring liegt über dem Ziel, das angetippt werden soll. */
#tut-ring,
#ward-ring {
    position: fixed;
    z-index: 390;
    pointer-events: none;
    animation: tutPulse 1.1s steps(2, end) infinite;
}

/* Vier Eckklammern statt eines geschlossenen Kastens: ein Rahmen sieht auf
   einem Hexfeld aus wie ein weiteres Bedienelement, die Klammern lesen sich
   als "hierhin". Jede Ecke ist ein eigenes Element mit genau zwei Kanten. */
#tut-ring span,
#ward-ring span {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 3px solid var(--gold);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

#tut-ring span:nth-child(1),
#ward-ring span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
#tut-ring span:nth-child(2),
#ward-ring span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
#tut-ring span:nth-child(3),
#ward-ring span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
#tut-ring span:nth-child(4),
#ward-ring span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* Harte Stufen statt weicher Blende — dieselbe Haltung wie überall sonst:
   das Bild bleibt pixelig, nichts wird weichgezeichnet. */
@keyframes tutPulse {
    0% { opacity: 1; }
    50% { opacity: 0.25; }
    100% { opacity: 1; }
}

/* Langdruck-Schritte: im Ring läuft die Geste als Vorführung — ein Kreis,
   der sich schließt, darunter "HALTEN". Text allein ("haltet den Finger auf die
   Karte") wurde oft als Tippen gelesen. Denselben Kreis sieht man danach beim
   echten Halten (#hold-indicator), Vorbild und Rückmeldung gleichen sich. */
#tut-ring.is-hold { animation: none; }
#tut-ring .tut-hold-demo { display: none; }
#tut-ring.is-hold .tut-hold-demo {
    display: flex;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.tut-hold-demo b {
    display: block;
    width: 64px;
    height: 64px;
}
.tut-hold-demo b .hold-arc {
    animation: holdArcDemo 1.8s linear infinite;
}
.tut-hold-demo em {
    font-style: normal;
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--gold);
    background: rgba(12, 9, 6, 0.85);
    padding: 2px 4px;
}
@keyframes holdArcDemo {
    0% { stroke-dashoffset: 100; }
    60% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 0; }
}

/* Halte-Anzeige am Finger (js/input.js showHoldIndicator) — gilt im ganzen
   Spiel, nicht nur im Tutorial. Ein Kreis UM den Druckpunkt, groß genug, dass
   der Finger ihn nicht verdeckt; er schließt sich von oben im Uhrzeigersinn,
   und wenn sich die Enden berühren, geht das Rad auf.
   Bewusste Ausnahme vom Pixel-Kanon (keine Rundungen): die Geste "schließt
   sich um den Finger" lebt von der Kreisform (Jonathans Vorgabe). Gezeichnet
   als SVG-Kreis, border-radius bleibt global 0. */
#hold-indicator {
    position: fixed;
    z-index: 480;
    width: 96px;
    height: 96px;
    margin: -48px 0 0 -48px;
    pointer-events: none;
    display: none;
}
#hold-indicator.is-on { display: block; }
#hold-indicator svg,
.tut-hold-demo svg {
    width: 100%;
    height: 100%;
    display: block;
    transform: rotate(-90deg);   /* Start oben statt rechts */
    overflow: visible;
}
.hold-track {
    fill: none;
    stroke: rgba(12, 9, 6, 0.7);
    stroke-width: 10;
}
.hold-arc {
    fill: none;
    stroke: var(--gold);
    stroke-width: 6;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}
#hold-indicator.is-on .hold-arc {
    animation: holdArc var(--hold-ms, 550ms) linear forwards;
}
@keyframes holdArc {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: 0; }
}

#tut-help-btn {
    width: 38px;
    height: 38px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #3a2b1c;
    color: var(--gold);
    border: 2px solid var(--edge);
    box-shadow: inset 2px 2px 0 rgba(201, 147, 97, 0.30), inset -2px -2px 0 rgba(0, 0, 0, 0.55);
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}

#tut-help-btn:active { box-shadow: var(--bevel-in); }

/* ── Offene Partien (js/lobby.js refreshOpenGames) ────────────────────────
   Dieselbe Karte wie in "Meine Spiele", nur mit drei Zeilen statt einer:
   Name, wer sie aufgemacht hat, und unter welchen Bedingungen gespielt wird.
   Bei Fremden sind genau das die Fragen, die unter Freunden nie aufkamen. */
.open-game-card {
    align-items: flex-start;
}

.open-game-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
    /* .screen-box zentriert seinen Text — bei drei Zeilen untereinander
       (Name, Host, Bedingungen) liest sich das schlecht. */
    text-align: left;
}

.open-game-meta {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.1;
    color: var(--text-dim);
}

/* Hinweiszeile unter einer leeren Liste. Eine leere Liste ist bei kleiner
   Spielerzahl der Normalfall und darf nicht wie ein Fehler aussehen. */
.list-hint {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.2;
    color: var(--text-dim);
    margin: 0;
    padding: 4px 0;
}

/* Erklärzeile unter der Zugfrist-Auswahl im Erstellen-Dialog. */
.setup-hint {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.15;
    color: var(--text-dim);
    margin-top: 4px;
    display: block;
}

/* Restzeit auf der Karte der eigenen Partie (js/lobby.js deadlineText).
   Zweite Zeile unter dem Namen, damit sie die Badges rechts nicht verdrängt. */
/* Name und Restzeit als Spalte. Die Fristzeile darf NICHT im Namen stecken:
   .game-card-name schneidet per ellipsis ab (nowrap), der längere Fristtext
   wurde darin zu "wird in 2 h übe…". */
.game-card-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.game-card-deadline {
    display: block;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.1;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Rot erst, wenn es wirklich eng wird: Mahnung raus oder unter sechs Stunden.
   Vorher wäre es ein Daueralarm, der nichts mehr bedeutet. */
.game-card-deadline.is-urgent {
    color: var(--fire);
}

/* Benachrichtigungs-Hinweis vor gewerteten Partien (js/lobby.js pushGate).
   Teilt sich die Karte mit der Zug-Rückfrage — dieselbe Form für dieselbe
   Sache: ein Dialog, der bewusst im Weg steht. */
#push-gate-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 420;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

#push-gate-overlay.open {
    display: flex;
}

.push-gate-note {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
    margin: 0;
}

/* Sichtbarkeit der eigenen Lobby (js/lobby.js _renderLobbyScreen). */
/* ── KI-Mitspieler & Modus in der Lobby (Okt 2026) ─────────────────────── */
#lobby-mode-row {
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
}

#lobby-mode-select {
    min-height: 44px;
    font-size: 16px;
}

#lobby-bot-add {
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.lobby-bot-label {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.lobby-bot-levels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* Stufe eines Bots in seiner Lobby-Zeile — dieselbe Form wie das
   Freundschafts-Tag, farblich als Schatten/Spionage-Ton abgesetzt. */
.player-slot-bot {
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--blue);
}

/* Teamwahl: ein Knopf, der durch die Teams schaltet */
.player-slot-team-btn {
    height: 32px;
    min-width: 44px;
    padding: 0 8px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
}

.player-slot-team-btn:active {
    transform: translateY(2px);
}

.player-slot-team-btn:disabled {
    cursor: default;
    transform: none;
}

.player-slot-team-btn.t0 { border-color: var(--gold); color: var(--gold); }
.player-slot-team-btn.t1 { border-color: var(--blue); color: var(--blue); }
.player-slot-team-btn.t2 { border-color: var(--red); color: var(--red); }

#lobby-visibility-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

#lobby-visibility-text {
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-dim);
    text-align: left;
    flex: 1;
    min-width: 0;
}

#lobby-visibility-btn {
    margin-top: 0;
    flex: 0 0 auto;
    min-height: 44px;
}

/* Fusszeile der Einstellungen: zwei Links nebeneinander statt uebereinander */
.settings-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 16px;
}

/* Karten waehlen / aufdecken (js/cards.js) */
.cards-sub {
    max-width: 500px;
    margin: 0 0 12px;
    font-size: 15px;
    text-align: center;
    color: var(--text);
}
#cards-list .fac-card { flex-basis: 100%; }
.card-reveal {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -8px;
}

/* ── Burg (js/castle.js) ─────────────────────────────────────────────────── */
.home-main { display: flex; gap: 8px; width: 100%; flex: 0 0 auto; }
.home-main .action-btn { flex: 1 1 0; min-width: 0; padding-left: 6px; padding-right: 6px; }

#castle-screen { position: fixed; inset: 0; z-index: 140; background: #0d0f14; overflow: hidden; }
#castle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#castle-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.castle-tag {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    white-space: nowrap;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1;
    color: var(--text-bright);
    background: #17130f;
    border: 2px solid var(--edge);
}
.castle-tag.is-ready { pointer-events: auto; min-width: 44px; min-height: 44px; justify-content: center; cursor: pointer; background: #3a2b1c; box-shadow: var(--bevel); }
#castle-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
    pointer-events: none;
}
#castle-top .action-btn { pointer-events: auto; width: 44px; min-height: 44px; padding: 0; flex: 0 0 auto; }
#castle-res { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 12px; background: #17130f; border: 2px solid var(--edge); font-family: var(--font-body); font-size: 15px; color: var(--text-bright); }
#castle-res span { display: flex; align-items: center; gap: 4px; }
#castle-res .is-full { color: var(--gold); }
#castle-res .castle-cap { color: var(--text-dim); }
#castle-panel {
    position: absolute;
    left: 50%; bottom: calc(8px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: calc(100% - 16px);
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #17130f;
    border: 2px solid var(--edge);
    box-shadow: var(--bevel);
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text);
}
#castle-panel p { margin: 0; }
#castle-panel .action-btn { width: 100%; margin: 0; padding: 12px 4px; letter-spacing: 0; }
.castle-tag.is-name { white-space: normal; max-width: 96px; text-align: center; padding: 2px 4px; background: rgba(23, 19, 15, 0.8); }
#castle-panel .is-short { color: #ff8a70; }
#castle-panel .action-btn:disabled { opacity: 0.45; }
.castle-cost { display: flex; gap: 16px; color: var(--text-bright); }
.castle-cost span { display: flex; align-items: center; gap: 4px; }
.castle-row { display: flex; gap: 8px; }
.castle-row .action-btn { flex: 1 1 0; min-width: 0; }
.castle-head { display: flex; align-items: center; gap: 8px; color: var(--text-bright); }
.castle-list { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.castle-item { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 8px; text-align: left; background: var(--bg-card); border: 2px solid var(--edge); color: var(--text-bright); font-family: var(--font-body); font-size: 15px; cursor: pointer; flex: 0 0 auto; }
.castle-item:disabled { opacity: .5; cursor: default; }
.castle-item-text { flex: 1 1 auto; }
.castle-item small, .castle-head small { font-size: 15px; color: var(--text-dim); }
.castle-price { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }

.castle-troop { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 30vh; overflow-y: auto; flex: 0 0 auto; }
.castle-soldier { display: flex; flex-direction: column; min-height: 44px; padding: 6px 8px; text-align: left; background: var(--bg-card); border: 2px solid var(--edge); color: var(--text-bright); font-family: var(--font-body); font-size: 15px; cursor: pointer; }
.castle-soldier small { font-size: 15px; color: var(--text-dim); }
.castle-soldier.is-on { border-color: var(--gold-mid); background: #3a2b1c; }
.castle-soldier:disabled { opacity: .5; cursor: default; }

/* ── Feldzug-Kampf (js/battle.js) ────────────────────────────────────────── */
#battle-top, #battle-actions { display: none; }
.in-battle #battle-top { position: fixed; top: 0; left: 0; right: 0; z-index: 150; display: flex; gap: 8px; align-items: stretch; padding: calc(8px + env(safe-area-inset-top)) 8px 0; pointer-events: none; }
#battle-top .action-btn { pointer-events: auto; width: 44px; min-height: 44px; padding: 0; margin: 0; flex: 0 0 auto; }
#battle-goal { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: #17130f; border: 2px solid var(--edge); font-family: var(--font-body); font-size: 15px; color: var(--text); }
#battle-goal b { color: var(--gold); }
.turn-btn { margin-left: auto !important; }
/* Ganz unten, unter dem Infotext: dessen Hoehe wechselt, die Knoepfe bleiben stehen */
.in-battle #battle-actions { order: 99; display: flex; gap: 8px; width: 100%; pointer-events: auto; }
#battle-actions .action-btn { flex: 1 1 0; min-height: 48px; min-width: 0; margin: 0; padding: 8px 2px; font-size: 8px; letter-spacing: 0; }
#battle-actions #battle-end { font-size: 12px; flex-grow: 1.3; }
#battle-actions .action-btn:disabled { opacity: .45; }
.in-battle #camera-focus-slider-wrap, .in-battle #recap-panel { display: none !important; }
#battle-result { z-index: 200; justify-content: center; gap: 12px; text-align: center; font-family: var(--font-body); font-size: 15px; color: var(--text-bright); }
#battle-result p { margin: 0; max-width: 320px; }
.battle-loot { display: flex; gap: 16px; justify-content: center; }
.battle-loot span { display: flex; gap: 4px; align-items: center; }

.castle-soldier.is-hero b { color: var(--gold); }
.castle-sub { margin-top: 8px; color: var(--text-bright); }
.castle-sub small { font-size: 15px; font-weight: normal; color: var(--text-dim); }
.castle-tag.is-name { pointer-events: auto; cursor: pointer; justify-content: center; }
.castle-tag.is-locked { opacity: .75; }
.castle-tag.is-done { color: #a5d67c; }
.castle-tag.is-way { color: #17130f; background: #7ffbea; border-color: #d8fff9; }
#castle-canvas, #castle-labels { transition: opacity .3s; }
.is-dive #castle-canvas, .is-dive #castle-labels { opacity: 0; }
#castle-panel { z-index: 3; }
.castle-tag.is-next { max-width: 140px; min-height: 44px; padding: 4px 10px; color: #17130f; background: var(--gold); border-color: #fff2c4; z-index: 2; animation: castle-next 1.2s ease-in-out infinite; }
@keyframes castle-next { 50% { margin-top: -6px; } }
@media (prefers-reduced-motion: reduce) { .castle-tag.is-next { animation: none; } }

.castle-item.is-on { border-color: var(--gold-mid); background: #3a2b1c; }
.battle-card { padding: 12px; background: #2a1f14; border: 2px solid var(--gold-mid); }
.battle-hero-pic { width: 48px; height: 48px; vertical-align: middle; image-rendering: pixelated; }
.castle-prize { margin: 4px 0; }

/* ── Endgegner (js/bossmodel.js) ─────────────────────────────────────────── */
#battle-boss { position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 8px; right: 8px; z-index: 149; max-width: 560px; margin: 0 auto; padding: 8px 10px; background: #17130f; border: 2px solid #5d1519; pointer-events: none; font-family: var(--font-body); font-size: 15px; color: var(--text-bright); }
body:not(.in-battle) #battle-boss { display: none !important; }
.boss-line { display: flex; justify-content: space-between; }
.boss-line b { color: #ff8a70; }
#boss-bar { position: relative; height: 16px; margin: 6px 0; background: #2a1012; border: 2px solid var(--edge); }
#boss-bar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 33%, #17130f 33%, #17130f 33.8%, transparent 33.8%, transparent 66.4%, #17130f 66.4%, #17130f 67.2%, transparent 67.2%); }
#boss-fill { display: block; height: 100%; background: #c93a2c; transition: width .4s steps(12); }
#battle-boss.is-open { border-color: var(--gold); }
#battle-boss.is-open #boss-say { color: var(--gold); }
#battle-boss.is-warn #boss-say { color: #ff8a70; }
#boss-title { position: fixed; left: 0; right: 0; top: 30%; z-index: 190; display: flex; flex-direction: column; gap: 8px; padding: 20px 12px; text-align: center; pointer-events: none; opacity: 0; background: rgba(10, 5, 6, .82); border-top: 2px solid #8e2f2a; border-bottom: 2px solid #8e2f2a; }
#boss-title:empty { display: none; }
#boss-title b { font-family: var(--font-display); font-size: 38px; line-height: 1; color: #ffb24a; }
#boss-title span { font-family: var(--font-body); font-size: 15px; color: var(--text-bright); }
#boss-title.is-on { animation: boss-title 2.6s ease-out forwards; }
@keyframes boss-title { 0% { opacity: 0; transform: scale(1.5); } 12% { opacity: 1; transform: scale(1); } 78% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #boss-title.is-on { animation-timing-function: steps(1); } }

/* ── Hauptmenue: zwei Tore vor der Burg ──────────────────────────────────── */
.gates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gate { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 124px; padding: 14px 6px; cursor: pointer; color: #fff6dc; border: 2px solid var(--edge); box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .22), inset -2px -2px 0 rgba(0, 0, 0, .45), 0 4px 0 #0d0b09; font-family: var(--font-body); }
.gate:active { transform: translateY(4px); box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .4); }
.gate.is-campaign { background: #a86a12; }
.gate.is-versus { background: #8e2f2a; }
.gate b { font-family: var(--font-display); font-size: 24px; line-height: 1; font-weight: normal; text-align: center; }
.gate small { font-size: 15px; text-align: center; color: #ffe9b8; }
.gate i { position: absolute; top: -8px; right: -4px; min-width: 28px; height: 28px; line-height: 24px; font-style: normal; font-family: var(--font-ui); font-size: 16px; text-align: center; background: var(--gold); color: #17130f; border: 2px solid var(--edge); }
#castle-panel:has(.gates) { background: none; border: none; box-shadow: none; padding: 0 0 8px; }
.more-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.more-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 68px; padding: 6px 2px; cursor: pointer; background: var(--bg-card); border: 2px solid var(--edge); color: var(--text-bright); font-family: var(--font-body); font-size: 15px; line-height: 1; text-align: center; overflow-wrap: anywhere; }

/* ── Kartentisch ─────────────────────────────────────────────────────────── */
/* Ueber den Fenstern (.screen-box, z 200): Heldenhalle und Kartentisch gehen auch aus der Lobby auf */
#deck-screen { position: fixed; inset: 0; z-index: 230; flex-direction: column; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px calc(8px + env(safe-area-inset-bottom)); overflow-y: auto; background: #3b2717 repeating-linear-gradient(90deg, #3b2717 0 62px, #33210f 62px 64px); font-family: var(--font-body); font-size: 15px; color: var(--text-bright); user-select: none; -webkit-user-select: none; }
.deck-head { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 420px; }
.deck-head .action-btn { width: 44px; min-height: 44px; margin: 0; padding: 0; }
.deck-head h2, #deck-screen h3 { margin: 0; font-family: var(--font-display); font-weight: normal; color: var(--gold); }
.deck-tab { flex: 1 1 0; min-height: 44px; font: 15px/1 var(--font-body); color: var(--text-dim); background: #17130f; border: 2px solid var(--edge); cursor: pointer; }
.deck-tab.is-on { color: var(--gold); border-color: var(--gold-mid); background: #3a2b1c; }
#deck-stage, #cards-stage { flex: 0 0 auto; width: 100%; max-width: 420px; height: clamp(130px, 26vh, 240px); border: 2px solid var(--edge); background: #1b2638; overflow: hidden; }
#cards-stage { height: 20vh; }
.card-canvas { display: block; width: 100%; height: 100%; }
#deck-scroll { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 420px; overflow-y: auto; }
#deck-scroll h3:not(:empty) { padding: 12px 0 8px; }
#deck-mine, #deck-rest { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 0; }
.pcard-tag { position: absolute; top: 0; right: 0; padding: 3px 5px; font-size: 15px; line-height: 1; color: #ffe08a; background: #17130f; pointer-events: none; }
.card-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.card-slots button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 4px 2px; font: 15px/1 var(--font-body); color: var(--text-bright); background: #3a2b1c; border: 2px solid var(--gold-mid); cursor: pointer; }
.card-slots button:disabled { opacity: .55; border-color: var(--edge); background: var(--bg-card); cursor: default; }
#cards-list .fac-card.is-on { border-color: var(--gold); }
#hero-bar button.is-card { gap: 4px; background: #3a2b1c; border-color: var(--gold-mid); }
.pcard { position: relative; display: flex; flex-direction: column; padding: 0; aspect-ratio: 5 / 6; cursor: grab; touch-action: none; background: #f0e2bd; border: 3px solid #17130f; box-shadow: 0 4px 0 rgba(0, 0, 0, .5); font-family: var(--font-body); color: #2a1d12; }
/* Sammlung und Schmiede werden gewischt, nur die Deckkarten zieht man (sonst liess sich die lange Schmiedeliste am Handy nicht scrollen) */
#deck-rest .pcard, .pcard[data-zone="lock"] { touch-action: pan-y; }
.pcard-art { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; min-height: 0; background: var(--kind); }
.pcard-name { padding: 4px 2px; font-size: 15px; line-height: 1; text-align: center; overflow-wrap: anywhere; pointer-events: none; }
.pcard.is-war { --kind: #a8442e; } .pcard.is-king { --kind: #c98a10; } .pcard.is-life { --kind: #3f7a3a; } .pcard.is-trick { --kind: #2f6f8f; }
.pcard.is-picked { border-color: #ffe08a; transform: translateY(-4px); }
.pcard.is-over { border-color: #fff; transform: scale(1.06); }
.pcard.is-away { opacity: .3; }
.pcard.is-locked { filter: grayscale(.45) brightness(.8); cursor: pointer; }
.pcard.is-ghost { position: fixed; z-index: 5; pointer-events: none; transform: translate(-50%, -60%) rotate(-4deg); }
#deck-info { flex: 0 0 auto; width: 100%; max-width: 420px; min-height: 92px; padding: 10px 12px; background: #17130f; border: 2px solid var(--edge); }
#deck-info p { margin: 4px 0 0; }
#deck-info .action-btn { width: 100%; margin: 8px 0 0; }
.deck-tip { color: var(--gold); }

/* ── Heldenhalle und Heldenleiste (js/herohall.js) ───────────────────────── */
#hero-screen { position: fixed; inset: 0; z-index: 240; flex-direction: column; background: #0c1018; font-family: var(--font-body); font-size: 15px; color: var(--text-bright); user-select: none; -webkit-user-select: none; }
#hero-view { position: relative; flex: 1 1 auto; min-height: 0; touch-action: none; cursor: grab; }
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hero-title { position: absolute; left: 16px; top: calc(12px + env(safe-area-inset-top)); pointer-events: none; text-shadow: 0 2px 0 #000; }
#hero-title h2 { margin: 0; font: 34px/1.1 var(--font-display); color: var(--gold); }
#hero-close { position: absolute; right: 12px; top: calc(12px + env(safe-area-inset-top)); width: 44px; min-height: 44px; margin: 0; padding: 0; }
#hero-panel { flex: none; width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); background: #15131d; border-top: 2px solid var(--edge); }
#hero-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; }
#hero-stats b, #hero-text b { color: var(--gold); }
#hero-text { min-height: 60px; line-height: 1.25; }
#hero-text small { font-size: 15px; color: var(--text-dim); }
#hero-skills, #hero-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#hero-skills button, #hero-bar button { min-height: 48px; min-width: 0; padding: 4px 2px; font: 15px/1 var(--font-body); color: var(--text-bright); background: #2b2438; border: 2px solid #4b4260; box-shadow: 0 4px 0 #0a090e; cursor: pointer; }
#hero-skills button.is-ult, #hero-bar button.is-ult { background: #6a3d10; border-color: var(--gold-mid); }
#hero-skills button.is-on, #hero-bar button.is-on { border-color: #fff; }
#hero-list { grid-template-columns: repeat(5, 1fr); margin: 10px 0 0; }
#hero-list .is-locked img { filter: brightness(.6) grayscale(.5); }
#hero-list button { display: flex; flex-direction: column; align-items: center; padding: 0 0 4px; background: none; border: 0; border-bottom: 4px solid var(--edge); font: 15px/1 var(--font-body); color: var(--text-dim); cursor: pointer; }
#hero-list button.is-on { color: var(--gold); border-color: var(--gold); }
#hero-list img { width: 44px; height: 44px; }
#hero-lead { width: 100%; margin: 10px 0 0; }
#hero-lead.is-short { filter: grayscale(.8) brightness(.7); }
/* Fest UNTER Infotext und Aktionsmenue (order): was darueber waechst oder
   verschwindet, schiebt die Leiste nicht. Im Feldzug direkt ueber Rueckgaengig/Zug beenden. */
#hero-bar { order: 98; position: relative; gap: 8px; align-items: center; width: 100%; max-width: 520px; margin: 0 auto; padding: 2px 0 4px; }
#hero-bar button { flex: 0 1 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#hero-bar button.is-off { opacity: .55; }
#hero-bar small { font-size: 15px; color: var(--gold); }
#hero-bar .hb-skill { position: relative; flex: 0 0 56px; width: 56px; height: 56px; min-height: 56px; padding: 0; }
#hero-bar .hb-skill.is-off svg { filter: grayscale(.8) brightness(.75); }
#hero-bar .hb-skill.is-off { opacity: 1; }
#hero-bar .hb-skill.is-on { background: #4b3a14; border-color: #fff; box-shadow: 0 0 0 2px var(--gold), 0 4px 0 #0a090e; }
#hero-bar .hb-skill.is-ult::after { content: ''; position: absolute; inset: 2px; border: 2px solid rgba(255, 224, 138, .35); pointer-events: none; }
#hero-bar .hb-skill em { position: absolute; font: 12px/1 var(--font-ui); font-style: normal; pointer-events: none; }
#hero-bar .hb-wait { inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px !important; color: #fff; background: rgba(10, 9, 14, .62); text-shadow: 0 2px 0 #000; }
#hero-bar .hb-lock { right: -2px; bottom: -2px; display: flex; align-items: center; gap: 1px; padding: 1px 3px; color: #17130f; background: var(--text-dim); }
#hero-bar .hb-go { right: -4px; top: -4px; padding: 2px; color: #17130f; background: #a5d67c; animation: hb-go .8s ease-in-out infinite; }
@keyframes hb-go { 50% { transform: translateY(-3px); } }
.in-battle #battle-actions { order: 99; }
.hb-info { display: flex; gap: 8px; align-items: flex-start; text-align: left; }
.hb-info > svg { flex: 0 0 auto; padding: 4px; background: #2b2438; border: 2px solid #4b4260; box-sizing: content-box; }
.hb-info small { font-size: 15px; color: var(--gold); }
.hb-how { color: #a5d67c; }
#hero-skills button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
#hero-skills button span { overflow-wrap: anywhere; hyphens: auto; }
.hb-face { position: relative; flex: 0 0 48px; height: 48px; background: #17130f; border: 2px solid var(--gold-mid); }
#hero-bar button.hb-face { flex: 0 0 52px; width: 52px; height: 52px; min-height: 52px; padding: 0; background: #17130f; border: 2px solid var(--gold-mid); box-shadow: 0 4px 0 #0a090e; }
.hero-own { display: flex; align-items: center; justify-content: center; gap: 4px; color: #4fc3f7; }
.hb-face img { width: 100%; height: 100%; display: block; }
.hb-face i { position: absolute; right: -2px; bottom: -2px; padding: 0 4px; font: 12px var(--font-ui); color: #17130f; background: var(--gold); }
.castle-soldier { position: relative; }
.castle-soldier.is-hero:has(img) { padding-right: 44px; }
.castle-soldier img { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; }

/* ── Burg: Bauen und Verwalten wie in Aufbauspielen (Dez 2026) ──────────────
   Leeres Feld antippen tut nichts mehr ausser abwaehlen. Gebaut wird ueber den
   Knopf "Bauen" (Laden mit Kacheln), der Platz wird vorgeschlagen und erst mit
   dem Haken bestaetigt. Ein Gebaeude zeigt eine kurze Leiste statt des ganzen
   Panels, Ausbauen fragt einmal nach (Kosten, Zeit, Gewinn). */
.castle-head-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.castle-head-end .castle-cost, .castle-head-end span { display: flex; align-items: center; gap: 4px; }
#castle-panel .action-btn.castle-x { width: 44px; min-height: 44px; padding: 0; flex: 0 0 auto; }
.castle-fab-row { display: flex; justify-content: flex-end; }
.castle-fab { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 14px; cursor: pointer; font: 15px/1 var(--font-body); color: #17130f; background: var(--gold); border: 2px solid #fff2c4; box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .35), inset -2px -2px 0 rgba(0, 0, 0, .25), 0 4px 0 #0d0b09; }
.castle-fab span { font-family: var(--font-display); font-size: 22px; }
.castle-fab small { display: flex; align-items: center; gap: 2px; padding: 2px 4px; font-size: 15px; color: var(--text-bright); background: #17130f; }
.castle-fab:active { transform: translateY(4px); box-shadow: none; }
.castle-shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 52vh; overflow-y: auto; }
.shop-card { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 6px 4px 8px; cursor: pointer; text-align: center; background: var(--bg-card); border: 2px solid var(--edge); box-shadow: 0 4px 0 #0d0b09; color: var(--text-bright); font: 15px/1 var(--font-body); }
.shop-card:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.shop-card b { font-weight: normal; overflow-wrap: anywhere; }
.shop-card small { font-size: 15px; line-height: 1; color: var(--text-dim); }
.shop-pic { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; background: #0f0d0a; }
.shop-pic i { position: absolute; right: 2px; bottom: 2px; padding: 0 3px; font: 12px var(--font-ui); font-style: normal; color: var(--text-bright); background: rgba(23, 19, 15, .85); }
.shop-price { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; }
.shop-price span { display: flex; align-items: center; gap: 2px; }
.shop-card:disabled { cursor: default; }
.shop-card.is-locked { opacity: .5; }
.shop-card.is-locked svg { filter: grayscale(.8); }
.shop-card.is-poor { opacity: .8; }
.castle-status { display: flex; align-items: center; gap: 4px; color: var(--text-bright); }
.ctx-row { display: flex; gap: 6px; }
.ctx-btn { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 68px; padding: 6px 2px; cursor: pointer; text-align: center; background: var(--bg-card); border: 2px solid var(--edge); box-shadow: 0 4px 0 #0d0b09; color: var(--text-bright); font: 15px/1 var(--font-body); overflow-wrap: anywhere; }
.ctx-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.ctx-btn:disabled { opacity: .5; cursor: default; }
.ctx-btn.is-up { background: #3d4a1c; border-color: #8fb04a; }
.ctx-btn.is-gold { background: #3a2b1c; border-color: var(--gold-mid); }
.ctx-btn.is-max { color: var(--gold); }
.ctx-price { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 4px; font-size: 15px; }
.ctx-price span { display: flex; align-items: center; gap: 2px; }
.castle-up { color: var(--text-bright); }

/* ── Lobby: Held und Deck je Spieler (Dez 2026, js/lobby.js _lobbyLoadout) ──
   Eine schmale zweite Zeile, damit die Lobby auch mit sechs Spielern auf einen
   Handy-Bildschirm passt: Bild 28px, Karten als 12px-Symbole in 18px-Kacheln
   (neun 16px-Kacheln = 153px, passt neben den Helden ab 320px Breite). */
.player-slot.has-loadout { flex-wrap: wrap; padding: 8px 12px; row-gap: 4px; }
.slot-loadout { flex: 1 0 100%; display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot-hero { display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; min-height: 32px; padding: 0 4px 0 0; font: 15px/1 var(--font-body); color: var(--text-dim); background: none; border: 0; }
.slot-hero span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-hero img { width: 28px; height: 28px; image-rendering: pixelated; background: #120f17; border: 2px solid var(--edge); }
.slot-hero-q { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; font: 16px/1 var(--font-ui); font-style: normal; color: var(--text-faint); background: #120f17; border: 2px solid var(--edge); }
.slot-deck { display: flex; flex-wrap: nowrap; align-items: center; gap: 1px; margin-left: auto; padding: 2px; background: none; border: 2px solid transparent; min-height: 32px; flex: 0 0 auto; }
.slot-deck.is-mine { border-color: var(--gold-mid); background: #241a12; }
.slot-deck i { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: #2a2018; border: 1px solid #4a3826; color: var(--gold); }
.slot-hero.is-mine, .slot-deck.is-mine { cursor: pointer; }
.slot-hero.is-mine { color: var(--gold); }
.slot-hero.is-mine:active, .slot-deck.is-mine:active { transform: translateY(2px); }

/* ── Heldenleiste zum Ansehen (fremder Held, js/herohall.js peekUnit) ──
   Kleiner als die eigene Leiste (40 statt 56px): sie ist Auskunft, kein
   Bedienfeld. Haken = bereit, Zahl = Runden Pause, Schloss = ab Stufe n. */
#hero-bar.is-peek { gap: 4px; justify-content: flex-start; padding: 0 0 2px; }
.hb-peek { position: relative; flex: 0 0 36px; width: 36px; height: 36px; background: #17130f; border: 2px solid #8a3030; }
.hb-peek img { width: 100%; height: 100%; display: block; }
.hb-peek i { position: absolute; right: -2px; bottom: -2px; padding: 0 3px; font: 8px/12px var(--font-ui); font-style: normal; color: #17130f; background: var(--gold); }
#hero-bar .hb-skill.is-peek { flex: 0 0 40px; width: 40px; height: 40px; min-height: 40px; box-shadow: 0 2px 0 #0a090e; }
#hero-bar .hb-skill.is-peek .hb-wait { font-size: 12px !important; }
#hero-bar .hb-ready { right: -2px; bottom: -2px; padding: 1px; color: #17130f; background: #a5d67c; }

/* ── Burgangriff (js/castle.js raidList, js/battle.js) ──
   Drittes Tor als flache Leiste unter den beiden grossen, damit die Burg auf
   dem Handy nicht nach unten waechst. */
.gate.is-raid { grid-column: 1 / -1; flex-direction: row; min-height: 56px; padding: 8px 12px; gap: 12px; background: #4a2a5e; }
.gate.is-raid b { font-size: 20px; white-space: nowrap; }
.gate.is-raid small { margin-left: auto; }
.raid-target { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 56px; padding: 4px 8px; text-align: left; background: var(--bg-card); border: 2px solid var(--edge); box-shadow: 0 4px 0 #0a090e; color: var(--text-bright); font: 15px/1.1 var(--font-body); cursor: pointer; }
.raid-target:active { transform: translateY(4px); box-shadow: none; }
.raid-target img, .raid-facts img { width: 40px; height: 40px; flex: 0 0 40px; background: #120f17; border: 2px solid var(--edge); }
.raid-facts img { width: 24px; height: 24px; flex-basis: 24px; vertical-align: middle; }
.raid-facts { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.raid-target-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.raid-target-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.raid-target-text small, .raid-loot { color: var(--text-dim); }
.raid-loot { flex: 0 0 auto; text-align: right; font: 8px/14px var(--font-ui); }
.raid-reports p { margin: 2px 0; padding: 4px 8px; background: var(--bg-card); border-left: 4px solid var(--edge); }
.raid-reports p.is-hit { border-left-color: #c0392b; }
.raid-reports p.is-held { border-left-color: #6fbf4a; }
.raid-reports small { display: block; color: var(--text-dim); }
.castle-status.is-damaged { color: #ff8a65; }
.raid-stars, .raid-result-stars { color: var(--gold); letter-spacing: 2px; }
.raid-result-stars { font-size: 30px; margin: 0; }

/* Verteidigung aufstellen: Hinweis auf nicht platzierte Figuren */
.raid-miss { color: var(--gold); font-family: var(--font-ui); font-size: 8px; margin-left: 4px; }

/* Rache, Freunde, gesperrte Ziele, fremde Burg ansehen */
.raid-target.is-rev { border-color: #c0392b; background: #3a1c1c; }
.raid-target.is-blocked { opacity: .65; }
.raid-rev { color: #ff8a65; margin: 4px 0; }
.castle-tag.is-damaged { pointer-events: auto; min-width: 44px; min-height: 44px; justify-content: center; cursor: pointer; color: #ff8a65; background: #3a1c1c; border-color: #c0392b; box-shadow: var(--bevel); }
#castle-screen.is-visit #castle-top > .action-btn:first-child { visibility: hidden; }

/* ── Burgwart (js/warden.js) ─────────────────────────────────────────────
   Portraet + Sprechblase, ueber allem, was er erklaert (Burg, Heldenhalle,
   Kartentisch, Kampf). Der Ring liegt knapp darunter. */
#ward-ring { z-index: 590; }
.ward-bubble {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    width: calc(100% - 24px);
    max-width: 440px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: var(--bg-panel);
    border: 2px solid var(--edge);
    box-shadow: var(--bevel), var(--drop);
}
.ward-bubble.at-top { top: calc(68px + env(safe-area-inset-top)); }
.ward-bubble.at-bottom { bottom: calc(16px + env(safe-area-inset-bottom)); }
.ward-face {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    background: #17130f;
    border: 2px solid var(--edge);
}
.ward-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ward-name { font-family: var(--font-ui); font-size: 8px; color: var(--gold); letter-spacing: .5px; text-transform: uppercase; }
.ward-text { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.2; color: var(--text-bright); }
.ward-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.ward-actions .action-btn { flex: 1 1 0; min-height: 44px; margin-top: 0; }
.ward-bubble.is-list .ward-actions .action-btn { flex: 1 1 40%; }

/* Ansehen / Rangliste der Burgen (Dez 2026) */
.raid-offer i { font-style: normal; font: 8px/14px var(--font-ui); }
.raid-offer .is-up, .raid-reports small.is-up { color: var(--green); }
.raid-offer .is-down, .raid-reports small.is-down { color: var(--red); }
.raid-ladder { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; min-height: 44px; padding: 8px 12px; margin: 0 0 8px; font: 12px/16px var(--font-ui); color: var(--gold); background: var(--bg-panel); border: 2px solid var(--edge); box-shadow: var(--bevel); cursor: pointer; }
.raid-ladder small { font: 8px/12px var(--font-ui); color: var(--text-dim); }
.raid-ranks { display: flex; flex-direction: column; gap: 2px; }
.raid-rank { display: grid; grid-template-columns: 36px 1fr auto 48px; gap: 8px; align-items: center; margin: 0; padding: 4px 8px; font: 8px/16px var(--font-ui); }
.raid-rank b { font: 15px/16px var(--font-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.raid-rank small { color: var(--text-dim); }
.raid-rank span:last-child { text-align: right; color: var(--gold); }
.raid-rank.is-me { background: var(--bg-panel); outline: 2px solid var(--gold); }
