* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #8b6914 #c4a870;
}

/* Webkit Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #c4a870, #b09060);
    border-left: 1px solid #8b6914;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b6914, #6b4a10);
    border-radius: 4px;
    border: 1px solid #5a3d0a;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #a07a1a, #8b6914);
}

::-webkit-scrollbar-corner {
    background: #c4a870;
}

body {
    font-family: 'MedievalSharp', cursive;
    background: #2a4a2a;
    color: #3b2a1a;
    overflow: hidden;
    height: 100vh;
}

/* === Top Bar (fixed wrapper for header + resource bar) === */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* === Header === */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    background:
        /* Feine Holzmaserung */
        repeating-linear-gradient(
            2deg,
            transparent 0px, transparent 3px,
            rgba(0,0,0,0.1) 3px, rgba(0,0,0,0.1) 4px,
            transparent 4px, transparent 9px,
            rgba(90,55,20,0.1) 9px, rgba(90,55,20,0.1) 10px
        ),
        /* Breitere Maserungsbänder */
        repeating-linear-gradient(
            178deg,
            transparent 0px, transparent 14px,
            rgba(0,0,0,0.06) 14px, rgba(0,0,0,0.06) 18px,
            transparent 18px, transparent 30px
        ),
        /* Holz-Grundfarbe */
        linear-gradient(180deg, #5a3a1e 0%, #4a2a12 30%, #3d2210 70%, #2e1a0c 100%);
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg, #8b6914, #daa520, #c4962a, #daa520, #8b6914) 1;
    box-shadow: 0 3px 10px rgba(20, 10, 0, 0.6), inset 0 1px 0 rgba(180, 140, 80, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

#header-left {
    display: flex;
    align-items: center;
}

#logo {
    height: 36px;
    width: auto;
    margin-right: 12px;
    filter: drop-shadow(1px 1px 2px rgba(59, 42, 26, 0.4));
    cursor: pointer;
}

#header h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #daa520;
    text-shadow:
        0 1px 0 rgba(0, 0, 0, 0.5),
        0 0 8px rgba(218, 165, 32, 0.3);
    letter-spacing: 4px;
}

/* === Header Center (castle-title + player-name / city-info) === */
#header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 0;
}

#city-info {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.05rem;
    color: #c4a870;
    font-style: italic;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

#city-info:empty {
    display: none;
}

#castle-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #e8d5a8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    letter-spacing: 3px;
    margin: 0;
}

#player-name {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #daa520;
    text-shadow:
        0 1px 0 rgba(0, 0, 0, 0.5),
        0 0 6px rgba(218, 165, 32, 0.25);
    letter-spacing: 2px;
    cursor: pointer;
}

#player-name:empty {
    display: none;
}

/* Spielername — klickbar für Namensänderung, dezenter Hover */
#player-name:hover {
    text-decoration: underline;
    text-decoration-color: rgba(218, 165, 32, 0.4);
    text-underline-offset: 3px;
}

/* Medieval Date in Header */
#medieval-date {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    color: #a08050;
    letter-spacing: 1.5px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    opacity: 0.85;
}
#medieval-date:empty { display: none; }

/* Event Banner Stack — top-left, all events stacked vertically */
#event-banner-stack {
    position: fixed;
    top: 52px;
    left: 12px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 320px;
}
body.castle-mode #event-banner-stack { display: none !important; }

/* Single event banner — compact by default, expandable on click */
.event-banner {
    background: linear-gradient(135deg, rgba(30, 20, 10, 0.92), rgba(50, 35, 15, 0.88));
    border: 1px solid #5a4020;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}
.event-banner.hidden { display: none; }

/* Header — always visible, one compact line */
.event-banner .eb-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
}
.event-banner .eb-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.event-banner .eb-title {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    flex: 1;
}
.event-banner .eb-arrow {
    font-size: 0.55rem;
    opacity: 0.5;
    transition: transform 0.2s;
}
.event-banner.expanded .eb-arrow {
    transform: rotate(180deg);
}

/* Body — hidden by default, shown on expand */
.event-banner .eb-body {
    display: none;
    padding: 0 10px 6px 28px;
}
.event-banner.expanded .eb-body {
    display: block;
}
.event-banner .eb-text {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #c4a870;
    line-height: 1.3;
}
.event-banner .eb-desc {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2px;
}

/* Peace — golden tones */
.event-banner.peace { border-color: #8b6914; }
.event-banner.peace .eb-icon { color: #daa520; }
.event-banner.peace .eb-title { color: #daa520; }
.event-banner.peace .eb-desc { color: #daa520; }
.event-banner.peace .eb-arrow { color: #daa520; }

/* Famine — amber/gold */
.event-banner.famine { border-color: #8a7030; }
.event-banner.famine .eb-icon { color: #daa520; }
.event-banner.famine .eb-title { color: #e8c860; }
.event-banner.famine .eb-arrow { color: #e8c860; }

/* Plague — sickly green */
.event-banner.plague { border-color: #3a6030; }
.event-banner.plague .eb-icon { color: #5a9a3a; }
.event-banner.plague .eb-title { color: #7aba5a; }
.event-banner.plague .eb-arrow { color: #7aba5a; }

/* Mobile — bottom position */
@media (max-width: 768px) {
    #event-banner-stack {
        top: auto;
        bottom: 48px;
        left: 8px;
        right: 8px;
        max-width: none;
    }
}

/* Castle-Back Button (in resource bar) — Metallnieten-Look */
#castle-back {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #e8d5a8;
    background: linear-gradient(180deg, #5a4a35 0%, #3a2a1a 100%);
    border: 1px solid #8b6914;
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    margin-right: 8px;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}

#castle-back:hover {
    background: linear-gradient(180deg, #6a5a42 0%, #4a3a28 100%);
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.2), 0 0 6px rgba(218, 165, 32, 0.3);
    color: #daa520;
}

/* === Castle Mode Toggles === */
body:not(.castle-mode) #castle-back { display: none; }
body:not(.castle-mode) #castle-title { display: none; }
body:not(.castle-mode) #player-name { display: none; }
body.castle-mode #city-info { display: none; }
body:not(.castle-mode) .castle-res { display: none !important; }
body:not(.castle-mode) .res-rate { display: none !important; }
body.castle-mode .map-res { display: none !important; }
body.castle-mode #map { display: none; }

/* === Unified Resource Bar === */
#resource-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 5px 16px;
    background:
        /* Feine Holzmaserung (leicht versetzt zum Header) */
        repeating-linear-gradient(
            1deg,
            transparent 0px, transparent 4px,
            rgba(0,0,0,0.08) 4px, rgba(0,0,0,0.08) 5px,
            transparent 5px, transparent 11px,
            rgba(70,45,15,0.08) 11px, rgba(70,45,15,0.08) 12px
        ),
        /* Breitere Bänder */
        repeating-linear-gradient(
            179deg,
            transparent 0px, transparent 12px,
            rgba(0,0,0,0.05) 12px, rgba(0,0,0,0.05) 15px,
            transparent 15px, transparent 24px
        ),
        /* Holz-Grundfarbe (dunkler als Header) */
        linear-gradient(180deg, #4a3a28 0%, #3a2a1a 50%, #2e2015 100%);
    border-bottom: 2px solid;
    border-image: linear-gradient(90deg, #6b4226, #8b6914, #6b4226) 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 -1px 0 rgba(180, 140, 80, 0.1);
    flex-wrap: wrap;
}

#resource-bar.hidden { display: none; }

.resource-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    color: #e8d5a8;
    min-width: 48px;
}

.res-top {
    display: flex;
    align-items: center;
    gap: 4px;
}

.resource-item .res-icon { display: inline-flex; }
.resource-item .res-icon svg { width: 16px; height: 16px; }

.resource-item .res-amount {
    font-weight: 700;
    min-width: 28px;
}

.resource-item .res-rate {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.65rem;
    color: #a89070;
    line-height: 1;
    min-height: 12px;
}

.resource-item .res-rate.positive { color: #6dbf6d; }
.resource-item .res-rate.negative { color: #e06060; }

/* Wappen-Button im Burghof (mittig oben) */
#stats-btn {
    display: block;
    margin: 8px auto 0;
    background: none;
    border: none;
    width: 64px;
    height: 72px;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    line-height: 0;
    padding: 0;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
    position: relative;
    z-index: 10;
}

#stats-btn:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px rgba(218, 165, 32, 0.6)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}

#stats-btn svg {
    width: 100%;
    height: 100%;
}

.res-actions {
    display: flex;
    gap: 6px;
    margin-left: 8px;
}

/* Auszahlen-Button — Metallnieten-Look */
.res-actions button {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #e8d5a8;
    background: linear-gradient(180deg, #5a4a35 0%, #3a2a1a 100%);
    border: 1px solid #8b6914;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.res-actions button:hover {
    background: linear-gradient(180deg, #6a5a42 0%, #4a3a28 100%);
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.2), 0 0 6px rgba(218, 165, 32, 0.3);
    color: #daa520;
}

/* + Gold Button — Gold-Akzent-Look (Call-to-Action) */
#deposit-btn {
    background: transparent;
    border: 1px solid #daa520;
    color: #daa520;
    text-shadow: 0 0 4px rgba(218, 165, 32, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#deposit-btn:hover {
    background: rgba(218, 165, 32, 0.15);
    box-shadow: 0 0 8px rgba(218, 165, 32, 0.4);
    color: #f0d050;
}

/* === Map === */
#map {
    position: fixed;
    top: var(--top-bar-h, 80px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
}

/* GPU-Beschleunigung für Marker-Pane (hunderte Terrain-Marker) */
.leaflet-marker-pane,
.leaflet-overlay-pane {
    will-change: transform;
}

/* === Flüsse === */
.river-line {
    filter: none;
}

.river-tooltip {
    font-family: 'MedievalSharp', cursive;
    font-size: 11px;
    color: #1a4a7a;
    background: rgba(180, 210, 240, 0.85);
    border: 1px solid #3a7cbd;
    border-radius: 3px;
    padding: 2px 8px;
    box-shadow: none;
}

/* === Bäume === */
.tree-marker {
    opacity: 0.85;
}

/* === Verstreute Einzelbäume === */
.scatter-tree {
    opacity: 0.55 !important;
}

/* === Hügel === */
.hill-marker {
    opacity: 0.7;
}

/* === Sümpfe === */
.marsh-marker {
    opacity: 0.75;
}

/* === Berge === */
.mountain-marker {
    opacity: 0.9;
}

/* === Castle Markers === */
.castle-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s ease, filter 0.25s ease;
    filter: drop-shadow(1px 2px 3px rgba(20, 10, 0, 0.6));
}

.castle-marker:hover {
    filter: drop-shadow(2px 3px 5px rgba(20, 10, 0, 0.8));
}

.castle-marker.player-city {
    filter: drop-shadow(0 0 8px rgba(218, 165, 32, 0.8)) drop-shadow(0 0 16px rgba(218, 165, 32, 0.4));
}

.castle-marker svg {
    width: 100%;
    height: 100%;
}

/* === City Labels === */
.city-label {
    font-family: 'MedievalSharp', cursive;
    font-size: 12px;
    font-weight: normal;
    color: #2a1a0a;
    text-shadow:
        0 0 5px rgba(200, 190, 140, 0.95),
        1px 1px 3px rgba(200, 190, 140, 0.9),
        -1px -1px 3px rgba(200, 190, 140, 0.9),
        2px 0 3px rgba(200, 190, 140, 0.8),
        0 2px 3px rgba(200, 190, 140, 0.8);
    white-space: nowrap;
    pointer-events: none;
}

.city-label-capital {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    color: #4a0a0a;
    text-shadow:
        0 0 5px rgba(200, 190, 140, 0.95),
        1px 1px 3px rgba(200, 190, 140, 0.9),
        -1px -1px 3px rgba(200, 190, 140, 0.9),
        2px 0 3px rgba(200, 190, 140, 0.8),
        0 2px 3px rgba(200, 190, 140, 0.8);
    white-space: nowrap;
    pointer-events: none;
}

/* === City Info Panel === */
#city-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #8b6914;
    border-radius: 4px;
    padding: 24px 28px;
    min-width: 240px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow:
        0 4px 16px rgba(59, 42, 26, 0.4),
        inset 0 0 30px rgba(139, 105, 20, 0.1);
    transition: opacity 0.3s, transform 0.3s;
}

#city-panel::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(139, 105, 20, 0.3);
    border-radius: 2px;
    pointer-events: none;
}

#city-panel.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.panel-divider {
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #8b6914, transparent);
    margin: 8px auto;
}

.panel-ornament {
    text-align: center;
    color: #8b6914;
    font-size: 0.8rem;
    line-height: 1;
}

.panel-ornament.top { margin-bottom: 6px; }
.panel-ornament.top::after { content: '\2726  \2726  \2726'; }
.panel-ornament.bottom { margin-top: 10px; }
.panel-ornament.bottom::after { content: '\2726  \2726  \2726'; }

#panel-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: #6b4226;
    font-size: 1.3rem;
    cursor: pointer;
    font-family: serif;
}

#panel-close:hover { color: #3b2a1a; }

#panel-city-name {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3b2a1a;
    text-align: center;
}

#panel-country {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.95rem;
    color: #6b4226;
    text-align: center;
}

#panel-population {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    color: #8b6914;
    text-align: center;
}

/* === Leaflet Overrides === */

.leaflet-control-zoom a {
    background: linear-gradient(180deg, #d4be92 0%, #c4a870 100%) !important;
    color: #3b2a1a !important;
    border-color: #8b6914 !important;
    font-family: 'Cinzel', serif !important;
    font-weight: 700 !important;
}

.leaflet-control-zoom a:hover {
    background: linear-gradient(180deg, #e8d5a8 0%, #d4be92 100%) !important;
}

.leaflet-control-attribution {
    background: rgba(212, 190, 146, 0.8) !important;
    font-family: 'MedievalSharp', cursive !important;
    font-size: 10px !important;
    color: #6b4226 !important;
}

.leaflet-control-attribution a {
    color: #8b6914 !important;
}

/* Vignette-Overlay für Kartenrand */
#map::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 600;
    box-shadow: inset 0 0 120px rgba(20, 10, 0, 0.25);
}

/* === Kompassrose === */
.compass-rose-control {
    width: 110px;
    height: 110px;
    opacity: 0.75;
    transition: opacity 0.3s;
    filter: drop-shadow(1px 2px 4px rgba(20, 10, 0, 0.4));
    pointer-events: none;
}

.compass-rose-control:hover {
    opacity: 1;
}

.compass-rose-control svg {
    width: 100%;
    height: 100%;
}

/* === Dekorative Kartenecken === */
.map-corner {
    position: absolute;
    width: 60px;
    height: 60px;
    z-index: 650;
    pointer-events: none;
}

.map-corner.top-left { top: 0; left: 0; }
.map-corner.top-right { top: 0; right: 0; transform: scaleX(-1); }
.map-corner.bottom-left { bottom: 0; left: 0; transform: scaleY(-1); }
.map-corner.bottom-right { bottom: 0; right: 0; transform: scale(-1, -1); }

.map-corner svg { width: 100%; height: 100%; }

/* === Wasser (Meer) — statisch für bessere Pan-Performance === */
.leaflet-container {
    background: #040e15;
}

//* Hillshade-Overlay: Gelände-Schummerung über Pergament */
.leaflet-hillshade-pane {
    filter: sepia(0.3) contrast(1.2) brightness(1.05);
}

/* === Schiffe === */
.ship-marker {
    opacity: 0.7;
    filter: drop-shadow(0 1px 2px rgba(0, 30, 50, 0.3));
}


/* === Seeungeheuer === */
.sea-monster-marker {
    opacity: 0.55;
}

/* Wolkenschatten: deaktiviert (Performance) */

/* === Occupied City Markers === */
.castle-marker.occupied-city {
    filter: drop-shadow(0 0 6px rgba(180, 50, 50, 0.5)) drop-shadow(1px 2px 3px rgba(20, 10, 0, 0.6));
}

.owner-wappen {
    pointer-events: none;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

.owner-name-label {
    font-family: 'MedievalSharp', cursive;
    font-size: 11px;
    font-weight: normal;
    color: #8b1a1a;
    white-space: nowrap;
    text-align: center;
    text-shadow: 0 0 4px rgba(255, 250, 240, 0.9), 0 0 2px rgba(255, 250, 240, 0.7);
    pointer-events: none;
}

.reinforce-map-icon {
    pointer-events: none;
}

.reinforce-map-badge {
    display: inline-block;
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: #fff;
    font-family: 'MedievalSharp', cursive;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #4caf50;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0,0,0,0.5);
}

/* === Enemy City Panel === */
#enemy-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #8b1a1a;
    border-radius: 4px;
    padding: 20px 24px;
    min-width: 260px;
    max-width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 16px rgba(59, 42, 26, 0.4);
}

#enemy-panel.hidden { display: none; }

#enemy-panel #enemy-panel-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #6b4226;
    cursor: pointer;
}

#enemy-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

#enemy-wappen { flex-shrink: 0; }

#enemy-details h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #3b2a1a;
    margin: 0;
}

#enemy-player-name {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    color: #8b1a1a;
}

#enemy-stats p {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin: 4px 0;
}

#btn-scout {
    display: block;
    width: 100%;
    margin-top: 8px;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    color: #fff;
    background: linear-gradient(180deg, #4a6a2a, #2a4a1a);
    border: 1px solid #1a3a0a;
    border-radius: 4px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.2s;
}
#btn-scout:hover { background: linear-gradient(180deg, #5a7a3a, #3a5a2a); }
#btn-scout:disabled { opacity: 0.5; cursor: not-allowed; }
#btn-scout.hidden { display: none; }

#enemy-scout-info {
    margin: 6px 0;
    padding: 6px 8px;
    background: rgba(139, 105, 20, 0.08);
    border-radius: 3px;
}
#enemy-scout-info.hidden { display: none; }

#btn-attack {
    display: block;
    width: 100%;
    margin-top: 12px;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #8b1a1a, #6b1010);
    border: 1px solid #4a0a0a;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-attack:hover {
    background: linear-gradient(180deg, #a52020, #8b1a1a);
}

#btn-attack.hidden { display: none; }

/* === Attack Panel === */
#attack-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1200;
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #8b1a1a;
    border-radius: 4px;
    padding: 20px 24px;
    min-width: 300px;
    max-width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(59, 42, 26, 0.4);
}

#attack-panel.hidden { display: none; }

#attack-panel #attack-panel-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #6b4226;
    cursor: pointer;
}

#attack-target-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #8b1a1a;
    margin: 0 0 8px 0;
}

#attack-target-info {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
}

#attack-target-info div { margin: 2px 0; }

#attack-unit-selection {
    margin-bottom: 10px;
}

#attack-march-section {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
}

#attack-march-hours {
    width: 60px;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    padding: 2px 4px;
    border: 1px solid #8b6914;
    border-radius: 3px;
    background: #f5edd4;
}

#attack-march-calc {
    font-size: 0.8rem;
    color: #6b4226;
    margin-left: 6px;
}

#attack-preview {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
}

#attack-preview div { margin: 2px 0; }

#btn-send-attack {
    display: block;
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #8b1a1a, #6b1010);
    border: 1px solid #4a0a0a;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-send-attack:hover:not(:disabled) {
    background: linear-gradient(180deg, #a52020, #8b1a1a);
}

#btn-send-attack:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Ally Badge (Enemy Panel) === */
.ally-badge {
    display: inline-block;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #1a5a1a;
    background: rgba(42, 122, 42, 0.15);
    border: 1px solid #2a7a2a;
    border-radius: 3px;
    padding: 2px 8px;
    margin-bottom: 6px;
}

#btn-reinforce-map {
    display: block;
    width: 100%;
    margin-top: 12px;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #2a6a2a, #1a4a1a);
    border: 1px solid #0a3a0a;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}
#btn-reinforce-map:hover { background: linear-gradient(180deg, #3a8a3a, #2a6a2a); }
#btn-reinforce-map.hidden { display: none; }

/* === Reinforce Panel (Map) === */
#reinforce-map-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1200;
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #2a6a2a;
    border-radius: 4px;
    padding: 20px 24px;
    min-width: 300px;
    max-width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(59, 42, 26, 0.4);
}
#reinforce-map-panel.hidden { display: none; }

#reinforce-map-panel #reinforce-map-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #6b4226;
    cursor: pointer;
}

#reinforce-target-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #1a5a1a;
    margin: 0 0 8px 0;
}

#reinforce-target-info {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
}
#reinforce-target-info div { margin: 2px 0; }

#reinforce-unit-selection { margin-bottom: 10px; }

#reinforce-map-preview {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
}
#reinforce-map-preview div { margin: 2px 0; }

#btn-send-reinforce-map {
    display: block;
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #2a6a2a, #1a4a1a);
    border: 1px solid #0a3a0a;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}
#btn-send-reinforce-map:hover:not(:disabled) { background: linear-gradient(180deg, #3a8a3a, #2a6a2a); }
#btn-send-reinforce-map:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Settle Button (City Panel) === */

#btn-settle {
    display: block;
    width: 100%;
    margin-top: 10px;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #2a7a2a, #1a5a1a);
    border: 1px solid #0e3e0e;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-settle:hover {
    background: linear-gradient(180deg, #3a9a3a, #2a7a2a);
}

#btn-settle.hidden { display: none; }

/* === Settle Panel === */

#settle-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1200;
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #2a7a2a;
    border-radius: 4px;
    padding: 20px 24px;
    min-width: 300px;
    max-width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(59, 42, 26, 0.4);
}

#settle-panel.hidden { display: none; }

#settle-panel #settle-panel-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #6b4226;
    cursor: pointer;
}

#settle-target-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #2a7a2a;
    margin: 0 0 8px 0;
}

#settle-from-section,
#settle-pop-section,
#settle-march-section {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
}

#settle-from-section label,
#settle-pop-section label,
#settle-march-section label,
#settle-resources label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
}

#settle-from-city,
#settle-pop-count,
#settle-march-hours {
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    padding: 4px 6px;
    border: 1px solid #8b6914;
    border-radius: 4px;
    background: linear-gradient(180deg, #e8d5a8, #d4be92);
    color: #3b2a1a;
    cursor: pointer;
    outline: none;
}

#settle-from-city:hover {
    background: linear-gradient(180deg, #f0e0c0, #e8d5a8);
}

#settle-from-city option {
    font-family: 'MedievalSharp', cursive;
    background: #e8d5a8;
    color: #3b2a1a;
}

#settle-resources {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    margin-bottom: 10px;
}

.settle-res-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.settle-res-row span {
    min-width: 60px;
}

.settle-res-row input {
    flex: 1;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    padding: 2px 4px;
    border: 1px solid #8b6914;
    border-radius: 3px;
    background: #f5edd4;
}

#settle-march-calc {
    font-size: 0.8rem;
    color: #6b4226;
    margin-left: 6px;
}

#settle-info {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #6b4226;
    margin-bottom: 10px;
    padding: 6px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
}

#btn-send-settlers {
    display: block;
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(180deg, #2a7a2a, #1a5a1a);
    border: 1px solid #0e3e0e;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-send-settlers:hover:not(:disabled) {
    background: linear-gradient(180deg, #3a9a3a, #2a7a2a);
}

#btn-send-settlers:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Animated Map Markers (inner divs, not Leaflet container) === */
/* Shadows always on, animations only at zoom >= 6 (body.zoom-animated) */
.army-anim { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
.army-anim.marching { filter: drop-shadow(0 0 6px rgba(180, 40, 40, 0.7)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.army-anim.returning { filter: drop-shadow(0 0 6px rgba(40, 140, 40, 0.7)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.army-anim.enemy.marching { filter: drop-shadow(0 0 6px rgba(120, 20, 40, 0.8)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
.army-anim.enemy.returning { filter: drop-shadow(0 0 5px rgba(80, 40, 100, 0.7)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
body.zoom-animated .army-anim { animation: army-pulse 2s ease-in-out infinite; }
body.zoom-animated .army-anim.enemy { animation: enemy-army-pulse 2.5s ease-in-out infinite; }

@keyframes enemy-army-pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.1); opacity: 1; }
}

.enemy-tooltip {
    background: linear-gradient(160deg, #e0c8c8, #d4a8a8) !important;
    border-color: #8b3a3a !important;
    color: #4a1a1a !important;
}

.enemy-popup-container .leaflet-popup-content-wrapper {
    background: linear-gradient(160deg, #e0c8c8 0%, #d4a8a8 40%, #c49898 100%) !important;
    border-color: #8b3a3a !important;
}

.enemy-popup-container .leaflet-popup-tip {
    background: #d4a8a8 !important;
    border-color: #8b3a3a !important;
}

@keyframes army-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Transport/Convoy */
.convoy-anim, .transport-anim { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
body.zoom-animated .convoy-anim, body.zoom-animated .transport-anim { animation: transport-bob 3s ease-in-out infinite; }

/* Settler */
.settler-anim { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
body.zoom-animated .settler-anim { animation: settler-bob 2.5s ease-in-out infinite; }

/* Raider */
.raider-anim { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
.raider-anim.enemy { filter: drop-shadow(0 0 5px rgba(120, 20, 20, 0.7)) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
body.zoom-animated .raider-anim { animation: raider-gallop 1.5s ease-in-out infinite; }

@keyframes transport-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes settler-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-1px) rotate(0.5deg); }
    75% { transform: translateY(-1px) rotate(-0.5deg); }
}

@keyframes raider-gallop {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-3px) scale(1.05); }
    60% { transform: translateY(0) scale(0.98); }
}

/* Animated dashed route lines (only when zoomed in) */
body.zoom-animated .route-animated path {
    animation: route-flow 1.5s linear infinite;
}

@keyframes route-flow {
    from { stroke-dashoffset: 20; }
    to { stroke-dashoffset: 0; }
}

.army-marker svg {
    width: 100%;
    height: 100%;
}

.army-tooltip {
    font-family: 'MedievalSharp', cursive;
    font-size: 12px;
    color: #3b2a1a;
    background: linear-gradient(160deg, #e8d5a8, #d4be92);
    border: 1px solid #8b6914;
    border-radius: 3px;
    padding: 4px 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.army-popup-container .leaflet-popup-content-wrapper {
    background: linear-gradient(160deg, #e8d5a8 0%, #d4be92 40%, #c4a870 100%);
    border: 2px solid #8b6914;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(59, 42, 26, 0.5);
}

.army-popup-container .leaflet-popup-tip {
    background: #d4be92;
    border: 1px solid #8b6914;
}

.army-popup {
    font-family: 'MedievalSharp', cursive;
    min-width: 180px;
}

.army-popup-title {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #3b2a1a;
    margin-bottom: 6px;
}

.army-popup-status {
    font-size: 0.85rem;
    color: #6b4226;
    margin-bottom: 4px;
}

.army-popup-troops {
    font-size: 0.8rem;
    color: #3b2a1a;
    margin-bottom: 4px;
    line-height: 1.4;
}

.army-popup-power {
    font-size: 0.85rem;
    color: #8b1a1a;
    font-weight: bold;
    margin-bottom: 4px;
}

.army-popup-eta {
    font-size: 0.85rem;
    color: #6b4226;
    margin-bottom: 8px;
}

.army-popup-btn {
    display: block;
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    color: #fff;
    border: 1px solid #4a0a0a;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
}

.army-recall-btn {
    background: linear-gradient(180deg, #b8860b, #8b6914);
    border-color: #6b4226;
}

.army-recall-btn:hover {
    background: linear-gradient(180deg, #d4a020, #b8860b);
}

.army-resolve-btn {
    background: linear-gradient(180deg, #2a7a2a, #1a5a1a);
    border-color: #0a3a0a;
}

.army-resolve-btn:hover {
    background: linear-gradient(180deg, #3a9a3a, #2a7a2a);
}

/* === Burg-Wimpel (animiert) === */
.castle-marker svg {
    position: relative;
}

/* === Audio Controls (bottom-left) === */
#audio-controls {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    display: flex;
    gap: 6px;
}

#audio-controls button {
    font-size: 1.1rem;
    background: rgba(60, 40, 20, 0.7);
    border: 1px solid #8b6914;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: #a08060;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, color 0.3s;
    line-height: 1;
    padding: 0;
}

#audio-controls button:hover { opacity: 0.9; }

#music-btn.playing {
    opacity: 1;
    color: #daa520;
    border-color: #daa520;
}

#sound-btn.enabled {
    opacity: 1;
    color: #daa520;
    border-color: #daa520;
}

#hd-map-btn {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
}

#hd-map-btn.active {
    opacity: 1;
    color: #daa520;
    border-color: #daa520;
    background: rgba(60, 40, 20, 0.9);
}

/* === Medieval Select (shared style for all dropdowns) === */
.lang-select,
.fee-select,
#city-switcher select {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #3b2a1a;
    background: linear-gradient(180deg, #e8d5a8, #d4be92);
    border: 1px solid #8b6914;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 235, 180, 0.4), 0 1px 2px rgba(59, 42, 26, 0.2);
}

.lang-select:hover,
.fee-select:hover,
#city-switcher select:hover {
    background: linear-gradient(180deg, #f0e0c0, #e8d5a8);
    border-color: #daa520;
}

.lang-select option,
.fee-select option,
#city-switcher select option {
    font-family: 'MedievalSharp', cursive;
    background: #e8d5a8;
    color: #3b2a1a;
}

/* === Wallet Section === */
#header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#wallet-balance {
    display: none;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #e8d5a8;
    text-shadow: 0 0 6px rgba(218, 165, 32, 0.3);
}
#wallet-balance::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url('../kleverlogo.png') center/contain no-repeat;
    vertical-align: middle;
    margin-right: 4px;
}

#wallet-address {
    display: none !important;
}

#wallet-btn {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    color: #3b2a1a;
    background: linear-gradient(180deg, #d4be92, #c4a870);
    border: 1px solid #8b6914;
    border-radius: 4px;
    padding: 5px 16px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

#wallet-btn:hover {
    background: linear-gradient(180deg, #e8d5a8, #d4be92);
    box-shadow: 0 2px 8px rgba(139, 105, 20, 0.3);
}

#wallet-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

#wallet-btn.connected {
    background: linear-gradient(180deg, #d4be92, #c4a870);
    color: #6b4226;
    border-color: #8b6914;
    font-size: 0.8rem;
}

#wallet-btn.connected:hover {
    background: linear-gradient(180deg, #e8d5a8, #d4be92);
}

/* === Header Menu (Gear Dropdown) === */
/* === City Switcher (shared header) === */
#city-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

#city-switcher.hidden { display: none; }

#header-menu-wrapper {
    position: relative;
}

#header-menu-btn {
    font-size: 1.6rem;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #c4a870;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

#header-menu-btn:active {
    transform: rotate(30deg);
}

#header-menu-btn:hover {
    color: #daa520;
    text-shadow: 0 0 6px rgba(218, 165, 32, 0.4);
}

#header-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: linear-gradient(160deg, #e8d5a8, #d4be92);
    border: 2px solid #8b6914;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(30, 20, 10, 0.4);
    z-index: 1100;
    margin-top: 4px;
}

#header-menu.hidden { display: none; }

.menu-section { padding: 6px 0; }
.menu-label {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #6b4226;
    display: block;
    margin-bottom: 4px;
}
.menu-divider { height: 1px; background: #8b6914; opacity: 0.3; margin: 6px 0; }
.menu-sub { font-size: 0.75rem; color: #6b4226; opacity: 0.8; display: block; margin-top: 2px; }
.menu-wallet-address {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.75rem;
    color: #5a3d24;
    opacity: 0.8;
    word-break: break-all;
}

.refcode-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: #3b2a1a;
    letter-spacing: 2px;
}

.refcode-row button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
}

/* === Menu Stats Grid === */
.menu-stats-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 8px;
    font-size: 0.78rem;
    color: #3b2a1a;
}

.menu-stat-label {
    font-family: 'MedievalSharp', cursive;
    color: #6b4226;
}

.menu-stat-players,
.menu-stat-cities,
.menu-stat-reserve,
.menu-stat-goldgen {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    text-align: right;
}

/* === Dev Reserve (admin only) === */
.dev-reserve-box {
    margin-top: 8px;
    padding: 6px 8px;
    background: linear-gradient(135deg, #2a1a3a 0%, #1a2a3a 100%);
    border: 1px solid #6a5acd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}

.dev-reserve-icon {
    font-size: 0.9rem;
}

.dev-reserve-label {
    font-family: 'MedievalSharp', cursive;
    color: #a8a0d0;
    flex: 1;
}

.menu-stat-devreserve,
.menu-stat-requests {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: #c8b0ff;
    text-align: right;
}

/* === Wallet Loading Overlay === */
#wallet-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(30, 20, 10, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

#wallet-loading.hidden {
    display: none;
}

#wallet-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

#loading-logo {
    width: 180px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(218, 165, 32, 0.5));
    animation: logo-pulse 2s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(218, 165, 32, 0.5)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 35px rgba(218, 165, 32, 0.8)); transform: scale(1.03); }
}

#loading-bar-container {
    width: 260px;
    height: 12px;
    background: linear-gradient(180deg, #3b2a1a 0%, #2a1a0a 100%);
    border: 2px solid #8b6914;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

#loading-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #8b6914 0%, #d4a820 50%, #f0c030 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(218, 165, 32, 0.6);
}

#loading-text {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.1rem;
    color: #d4be92;
    text-shadow: 0 0 10px rgba(218, 165, 32, 0.4);
}

/* === WishCity Button & Modal === */
#wishcity-actions {
    position: absolute;
    right: 16px;
}
.btn-wishcity {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.8rem;
    color: #e8d5a8;
    background: linear-gradient(180deg, #5a4a35 0%, #3a2a1a 100%);
    border: 1px solid #8b6914;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.btn-wishcity:hover {
    background: linear-gradient(180deg, #6a5a42 0%, #4a3a28 100%);
    box-shadow: inset 0 1px 0 rgba(180, 140, 80, 0.2), 0 0 6px rgba(218, 165, 32, 0.3);
    color: #daa520;
}

#wishcity-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1500;
    background: rgba(10, 8, 4, 0.7);
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 80px 24px 24px;
}
#wishcity-overlay.hidden { display: none; }

#wishcity-panel {
    width: 380px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background:
        repeating-linear-gradient(1deg, transparent 0px, transparent 4px, rgba(0,0,0,0.06) 4px, rgba(0,0,0,0.06) 5px),
        linear-gradient(180deg, #3a2a1a 0%, #2e2015 100%);
    border: 2px solid #8b6914;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(180, 140, 80, 0.15);
    position: relative;
}

#wishcity-panel h3 {
    font-family: 'Cinzel', serif;
    color: #daa520;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

#wishcity-close {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: none;
    color: #a08060;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
}
#wishcity-close:hover { color: #daa520; }

#wishcity-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#wishcity-input {
    flex: 1;
    background: #1a1408;
    border: 1px solid #6b4226;
    border-radius: 4px;
    color: #e8d5a8;
    padding: 6px 10px;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
}
#wishcity-input::placeholder { color: #7a6a50; }

#wishcity-search-btn {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    padding: 6px 14px;
}

#wishcity-results {
    max-height: 180px;
    overflow-y: auto;
}

.wishcity-result {
    padding: 8px 10px;
    border-bottom: 1px solid #3a2a1a;
    cursor: pointer;
    font-size: 0.85rem;
    color: #d4be92;
    transition: background 0.15s;
}
.wishcity-result:hover {
    background: rgba(218, 165, 32, 0.1);
    color: #daa520;
}
.wishcity-result .wc-name { font-weight: bold; }
.wishcity-result .wc-detail { color: #8a7a60; font-size: 0.8rem; }

#wishcity-preview { margin-top: 8px; }

.btn-wishcity-submit {
    width: 100%;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1408;
    background: linear-gradient(180deg, #daa520 0%, #b8860b 100%);
    border: 2px solid #8b6914;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.3);
}
.btn-wishcity-submit:hover {
    background: linear-gradient(180deg, #f0c030 0%, #daa520 100%);
    box-shadow: 0 0 12px rgba(218, 165, 32, 0.5);
}

/* ============================================
   MOBILE HAMBURGER MENU
   ============================================ */

/* Hamburger button — hidden on desktop */
#mobile-menu-btn {
    display: none;
    font-size: 1.4rem;
    background: none;
    border: none;
    color: #c4a870;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

/* Overlay */
#mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
}
#mobile-menu-overlay:not(.hidden) { display: block; }

/* Slide-in panel */
#mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: linear-gradient(180deg, #e8d5a8, #d4be92);
    border-right: 3px solid #6b4226;
    z-index: 2001;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    display: none;
}
#mobile-menu.mobile-menu-open {
    transform: translateX(0);
}

#mobile-menu-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 2px solid #8b6914;
    background: linear-gradient(180deg, #c4a265, #b8956a);
}
#mobile-menu-header span {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: #3b2a1a;
    font-weight: 700;
    flex: 1;
}
#mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #3b2a1a;
    cursor: pointer;
    padding: 4px;
}

#mobile-menu-content {
    padding: 8px 16px;
}

.mmenu-section { padding: 8px 0; }
.mmenu-divider { border-top: 1px solid rgba(139,105,20,0.3); }

#mobile-disconnect-btn {
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.9rem;
    padding: 8px;
    background: linear-gradient(180deg, #d4be92, #c4a870);
    border: 1px solid #8b6914;
    border-radius: 4px;
    color: #3b2a1a;
    cursor: pointer;
}
#mobile-disconnect-btn:hover { background: linear-gradient(180deg, #e8d5a8, #d4be92); }
#mobile-disconnect-btn.hidden { display: none; }

/* Mobile styles */
@media (max-width: 768px) {
    #mobile-menu-btn { display: block; }
    #mobile-menu { display: block; }

    /* Always hide on mobile */
    #header-menu-wrapper { display: none !important; }
    #wallet-address { display: none !important; }

    /* Before connect: show title + Connect button */
    #header h1 {
        font-size: 0.95rem;
        letter-spacing: 0.5px;
    }
    #wallet-btn {
        font-size: 0.75rem;
        padding: 4px 10px;
        white-space: nowrap;
    }

    /* After connect: hide title, wallet-btn; keep balance visible */
    body.mobile-connected #header h1 { display: none; }
    body.mobile-connected #wallet-btn { display: none !important; }
    body.mobile-connected #wallet-balance {
        display: inline !important;
        font-size: 0.75rem;
    }
    /* Map view: balance is in resource bar, hide from header */
    body.mobile-connected:not(.castle-mode) #wallet-balance { display: none !important; }

    /* Show player name centered on map view after connect */
    body.mobile-connected:not(.castle-mode) #city-info { display: none !important; }
    body.mobile-connected:not(.castle-mode) #castle-title { display: none !important; }
    body.mobile-connected:not(.castle-mode) #player-name {
        display: inline !important;
        font-size: 0.75rem;
        text-align: center;
        white-space: nowrap;
        letter-spacing: 1px;
    }
    /* Castle mode: hide non-essential header items on mobile */
    body.castle-mode #player-name { display: none !important; }
    body.castle-mode #medieval-date { display: none !important; }
    body.castle-mode #wallet-balance { display: none !important; }
    body.castle-mode #castle-title { font-size: 0.85rem; }
    body.mobile-connected:not(.castle-mode) #header-center {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Compact header */
    #header {
        gap: 6px;
    }
    #header-left {
        flex-shrink: 0;
    }
    #logo {
        height: 24px;
        margin-right: 0;
    }
    #header-center {
        flex: 1;
        min-width: 0;
    }
    #city-switcher select {
        font-size: 0.75rem;
        max-width: 130px;
        text-overflow: ellipsis;
    }

    #stats-btn {
        width: 48px;
        height: 56px;
        margin-top: 4px;
    }

    /* Region startscreen mobile overrides are below the desktop defaults */
}

/* === Region Startscreen === */
#region-startscreen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background:
        radial-gradient(ellipse at center, rgba(60, 40, 20, 0.9) 0%, rgba(20, 12, 5, 0.97) 100%),
        url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="200" height="200" filter="url(%23n)" opacity="0.08"/></svg>');
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: rs-fadein 0.5s ease-out;
}
#region-startscreen.hidden { display: none; }

@keyframes rs-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

#region-startscreen-inner {
    text-align: center;
    padding: 40px 24px;
    max-width: 700px;
}

.rs-logo {
    width: 160px;
    height: auto;
    filter: drop-shadow(0 0 24px rgba(218, 165, 32, 0.6));
    margin-bottom: 16px;
}

.rs-title {
    font-family: 'Cinzel', serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: #daa520;
    text-shadow: 0 2px 12px rgba(218, 165, 32, 0.5), 0 0 40px rgba(218, 165, 32, 0.2);
    margin-bottom: 4px;
}

.rs-subtitle {
    font-family: 'MedievalSharp', cursive;
    font-size: 1.1rem;
    color: #b09060;
    margin-bottom: 32px;
}

#rs-regions {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.rs-card {
    width: 280px;
    min-height: 140px;
    background:
        repeating-linear-gradient(1deg, transparent 0px, transparent 4px, rgba(0,0,0,0.05) 4px, rgba(0,0,0,0.05) 5px),
        linear-gradient(180deg, #3a2a1a 0%, #2a1c10 100%);
    border: 2px solid #6b4a26;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.rs-card:hover:not(.rs-card-disabled) {
    border-color: #daa520;
    box-shadow: 0 0 20px rgba(218, 165, 32, 0.3), inset 0 0 15px rgba(218, 165, 32, 0.05);
    transform: translateY(-2px);
}

.rs-card-active {
    border-color: #daa520;
    box-shadow: 0 0 12px rgba(218, 165, 32, 0.2);
}

.rs-card-disabled {
    opacity: 0.45;
    cursor: default;
    filter: grayscale(0.5);
}

.rs-card-icon {
    font-size: 2.4rem;
    line-height: 1;
}

.rs-card-map {
    width: 120px;
    height: 90px;
    margin-bottom: 4px;
    filter: drop-shadow(0 2px 6px rgba(218, 165, 32, 0.3));
}
.rs-card-map svg {
    width: 100%;
    height: 100%;
}
.rs-card:hover:not(.rs-card-disabled) .rs-card-map {
    filter: drop-shadow(0 2px 10px rgba(218, 165, 32, 0.5));
}

.rs-card-label {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #daa520;
}

.rs-card-desc {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    color: #a08060;
}

.rs-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.7rem;
    color: #1a1408;
    background: linear-gradient(180deg, #daa520, #b8860b);
    padding: 2px 8px;
    border-radius: 3px;
}

.rs-card-soon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.7rem;
    color: #a08060;
    background: rgba(60, 40, 20, 0.8);
    border: 1px solid #6b4a26;
    padding: 2px 8px;
    border-radius: 3px;
}

/* Region switch button in menus */
.btn-menu-region {
    width: 100%;
    font-family: 'MedievalSharp', cursive;
    font-size: 0.85rem;
    padding: 6px 8px;
    background: linear-gradient(180deg, #5a4a35 0%, #3a2a1a 100%);
    border: 1px solid #8b6914;
    border-radius: 4px;
    color: #e8d5a8;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s, color 0.2s;
}
.btn-menu-region:hover {
    background: linear-gradient(180deg, #6a5a42 0%, #4a3a28 100%);
    color: #daa520;
}

/* === Region Startscreen Mobile — MUST be after desktop defaults === */
@media (max-width: 768px) {
    #region-startscreen {
        align-items: flex-start;
        padding-top: 60px;
    }
    #region-startscreen-inner {
        padding: 10px 12px;
    }
    .rs-logo { width: 60px; margin-bottom: 4px; }
    .rs-title { font-size: 1.1rem; margin-bottom: 0; }
    .rs-subtitle { font-size: 0.8rem; margin-bottom: 6px; }
    #rs-regions { gap: 8px; }
    .rs-card {
        width: 42vw;
        min-height: auto;
        padding: 10px 6px;
        gap: 4px;
    }
    .rs-card-map { width: 70px; height: 55px; margin-bottom: 0; }
    .rs-card-label { font-size: 0.9rem; }
    .rs-card-desc { font-size: 0.65rem; }
    .rs-card-badge { font-size: 0.55rem; padding: 1px 5px; top: 4px; right: 4px; }
    .rs-card-soon { font-size: 0.55rem; padding: 1px 5px; top: 4px; right: 4px; }
}
