:root {
  --bg: #14110e; --surface: #1c1813; --surface-2: #2a231b; --line: #f1e6cf22;
  --text: #cdbfa4; --strong: #f1e6cf; --gold: #e2b04a; --red: #c0392b; --green: #4caf50;
  --sea: #021c28;
  font-family: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#app { position: relative; height: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--sea); }
.leaflet-container { background: var(--sea); font: inherit; }

/* Kontinente */
#continents {
  position: absolute; top: 12px; left: 56px; z-index: 1000;
  display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 380px);
}
#continents button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: rgba(20, 17, 14, .88); color: var(--strong);
  border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px;
}
#continents button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
#continents button .n { color: var(--text); font-weight: 400; margin-left: 4px; }

/* Seitenleiste */
#panel {
  position: absolute; top: 12px; right: 12px; bottom: 44px; width: 300px; z-index: 1000;
  display: flex; flex-direction: column;
  background: rgba(20, 17, 14, .92); border: 1px solid var(--line); border-radius: 6px;
}
#panel-toggle {
  position: absolute; top: 6px; left: -46px; width: 38px; height: 34px;
  font-size: 18px; cursor: pointer; color: var(--strong);
  background: rgba(20, 17, 14, .92); border: 1px solid var(--line); border-radius: 4px;
}
#panel.closed { width: 0; border: 0; }
#panel.closed #panel-body { display: none; }
#panel-body { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 12px; gap: 10px; }
#summary { font-size: 14px; line-height: 1.4; }
#summary strong { color: var(--gold); }
#summary .hint { display: block; font-size: 12px; margin-top: 4px; }
#search {
  font: inherit; font-size: 14px; width: 100%; padding: 7px 10px; border-radius: 4px;
  background: var(--bg); color: var(--strong); border: 1px solid #f1e6cf33;
}
#search:focus { outline: none; border-color: var(--gold); }
#filters { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
#filters input { accent-color: var(--gold); }
#list { overflow-y: auto; min-height: 0; flex: 1; margin: 0 -12px; padding: 0 12px; }
#list h3 {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold);
  margin: 12px 0 4px; font-weight: 600;
}
#list button {
  display: flex; width: 100%; align-items: center; gap: 8px; text-align: left; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text); background: none; border: 0;
  border-radius: 4px; padding: 4px 6px;
}
#list button:hover, #list button.following { background: var(--surface-2); color: var(--strong); }
#list .name { color: var(--strong); font-weight: 600; }
#list .meta { margin-left: auto; font-size: 12px; white-space: nowrap; }
#list .empty { font-size: 13px; padding: 4px 6px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Statuszeile */
#status {
  position: absolute; left: 12px; bottom: 12px; z-index: 1000; font-size: 12px;
  background: rgba(20, 17, 14, .88); border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px;
}
#status.stale { color: #ffb4a8; border-color: #c0392b88; }

/* Marker */
.lm-dot { border-radius: 50%; border: 1px solid rgba(0, 0, 0, .7); }
.lm-bot .lm-dot { width: 8px; height: 8px; opacity: .85; }
.lm-player .lm-dot { width: 14px; height: 14px; border: 2px solid var(--gold); box-shadow: 0 0 8px var(--gold); }
.lm-dead .lm-dot { opacity: .35; }
.lm-combat .lm-dot { box-shadow: 0 0 0 3px rgba(192, 57, 43, .7); }
.lm-label {
  position: absolute; left: 50%; top: -18px; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--strong);
  text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none;
}
.lm-zone {
  white-space: nowrap; font-family: Vollkorn, Georgia, serif; font-size: 15px; font-weight: 600;
  color: #f1e6cfcc; text-shadow: 0 0 4px #000, 0 0 2px #000; pointer-events: none;
  transform: translate(-50%, -50%); display: inline-block;
}
.zones-off .lm-zone { display: none; }
/* Gebietskarte: Schaltknopf mit Abstand zu den Kontinenten, Karte weich einblenden */
#continents .lm-zonemap-btn { margin-left: 10px; }
.lm-zonemap { animation: lm-zonemap-in .35s ease-out; }
@keyframes lm-zonemap-in { from { opacity: 0; } }

/* Popup */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content-wrapper { border: 1px solid var(--line); border-radius: 6px; }
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b { color: var(--strong); font-size: 15px; }
.leaflet-popup-content .tag {
  display: inline-block; font-size: 11px; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; margin-left: 4px;
}
.leaflet-popup-content button {
  margin-top: 6px; font: inherit; font-size: 12px; cursor: pointer; color: var(--gold);
  background: none; border: 1px solid var(--gold); border-radius: 3px; padding: 2px 8px;
}
.leaflet-container a.leaflet-popup-close-button { color: var(--text); }
.leaflet-bar a { background: var(--surface); color: var(--strong); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-control-attribution { display: none; }

@media (max-width: 700px) {
  #continents { left: 12px; top: auto; bottom: 48px; max-width: calc(100% - 24px); }
  #panel { top: 12px; bottom: auto; max-height: 55%; width: calc(100% - 70px); }
  #panel.closed { width: 0; }
}

/* Hauptstädte und Belagerungen */
.lm-city-icon { overflow: visible; }
.lm-city {
  position: absolute; left: 0; bottom: 10px; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px;
  white-space: nowrap; cursor: pointer; padding: 3px 8px; border-radius: 4px;
  background: rgba(20, 17, 14, .85); border: 1px solid var(--line); box-shadow: 0 2px 6px #0008;
}
.lm-city::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(20, 17, 14, .85);
}
.lm-alliance { border-color: #3b7dd899; }
.lm-horde { border-color: #c0392b99; }
.lm-city-name { font-family: Vollkorn, Georgia, serif; font-weight: 700; font-size: 13px; color: var(--strong); }
.lm-city-n {
  font-size: 11px; font-weight: 700; color: var(--bg); background: var(--gold);
  border-radius: 9px; padding: 0 6px; line-height: 16px;
}
.lm-city-siege { flex-basis: 100%; text-align: center; font-size: 11px; font-weight: 700; color: #ffb4a8; }
.lm-siege { border-color: #c0392b; animation: lm-pulse 1.6s ease-in-out infinite; }
@keyframes lm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .7); }
  50% { box-shadow: 0 0 0 8px rgba(192, 57, 43, 0); }
}
@media (prefers-reduced-motion: reduce) { .lm-siege { animation: none; } }
.siege-banner {
  display: block; width: 100%; margin-top: 8px; text-align: left; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; color: #ffb4a8;
  background: #c0392b22; border: 1px solid #c0392b88; border-radius: 4px; padding: 6px 8px;
}

/* Tabs */
#tabs { display: flex; flex-wrap: wrap; gap: 0 2px; border-bottom: 1px solid var(--line); }
#tabs[hidden] { display: none; }
#tabs button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 7px; margin-bottom: -1px;
}
#tabs button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
#view-list, #view-stats, #view-profile, #view-feed, #view-top, #view-guilds { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; overflow-y: auto; }
#view-list { overflow: hidden; }
#view-list[hidden], #view-stats[hidden], #view-profile[hidden], #view-feed[hidden], #view-top[hidden], #view-guilds[hidden] { display: none; }
#view-stats, #view-profile, #view-feed, #view-top, #view-guilds { margin: 0 -12px; padding: 0 12px 8px; }

/* Statistik */
.st-h { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 10px 0 6px; font-weight: 600; }
.st-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.st-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
.st-kpi b { display: block; color: var(--strong); font-size: 18px; font-variant-numeric: tabular-nums; }
.st-kpi span { font-size: 11px; }
.st-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 6px; font-size: 12px; margin: 3px 0; }
.st-row .bar { height: 8px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.st-row .bar i { display: block; height: 100%; border-radius: 2px; }
.st-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--strong); }
.st-faction { display: flex; height: 22px; border-radius: 4px; overflow: hidden; font-size: 12px; font-weight: 600; color: #fff; }
.st-faction div { display: flex; align-items: center; padding: 0 8px; white-space: nowrap; min-width: 0; }
.st-zone { all: unset; cursor: pointer; display: grid; grid-template-columns: 1fr 34px; gap: 6px; width: 100%; font-size: 12px; padding: 3px 4px; border-radius: 3px; }
.st-zone:hover { background: var(--surface-2); color: var(--strong); }
.st-zone .n { text-align: right; color: var(--strong); }

/* Profil */
.pf-back { align-self: flex-start; font: inherit; font-size: 12px; cursor: pointer; color: var(--gold); background: none; border: 0; padding: 0; }
.pf-head h2 { font-family: Vollkorn, Georgia, serif; font-size: 22px; margin: 2px 0 0; line-height: 1.2; }
.pf-head p { margin: 2px 0; font-size: 13px; }
.pf-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-actions button {
  font: inherit; font-size: 12px; cursor: pointer; color: var(--gold);
  background: none; border: 1px solid var(--gold); border-radius: 3px; padding: 3px 9px;
}
.pf-actions button:hover { background: var(--gold); color: var(--bg); }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pf-grid div { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; font-size: 11px; }
.pf-grid b { display: block; color: var(--strong); font-size: 15px; font-variant-numeric: tabular-nums; }
.pf-sec { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 6px 0 -4px; font-weight: 600; }
.pf-quote { font-style: italic; font-size: 13px; border-left: 2px solid var(--gold); padding-left: 8px; margin: 0; }
.pf-eq { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.pf-eq li { display: grid; grid-template-columns: 76px 1fr 26px; gap: 6px; padding: 2px 0; border-bottom: 1px solid var(--line); }
.pf-eq .slot { color: var(--text); opacity: .8; }
.pf-eq .il { text-align: right; font-variant-numeric: tabular-nums; }
.pf-chron h4 { margin: 0 0 4px; font-family: Vollkorn, Georgia, serif; font-size: 15px; color: var(--strong); }
.pf-chron p { margin: 0; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; }
.pf-chron small { display: block; margin-top: 4px; font-size: 11px; }
.pf-muted { font-size: 12px; opacity: .8; }

/* Nemesis */
.lm-nemesis {
  display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 13px; background: #2a0d0b; border: 2px solid #c0392b; box-shadow: 0 0 10px #c0392b; color: #ffb4a8;
}

/* Einbettung (kleine Karte auf der Startseite) */
.embed #panel, .embed #continents, .embed .leaflet-control-zoom { display: none; }
.embed #map { cursor: pointer; }
.embed #status { bottom: 8px; left: 8px; }
#embed-open {
  position: absolute; right: 8px; top: 8px; z-index: 1000; font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--bg); background: var(--gold); border-radius: 4px; padding: 5px 10px;
}
#embed-open[hidden] { display: none; }
#view-stats > *, #view-profile > *, #view-feed > *, #view-top > *, #view-guilds > * { flex-shrink: 0; }

/* Live-Ereignisse */
#feed-badge {
  display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; line-height: 16px; text-align: center; color: var(--bg); background: var(--gold);
}
#feed-badge[hidden] { display: none; }
.fd { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px;
  width: 100%; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 12.5px; line-height: 1.4; }
.fd:hover { background: var(--surface-2); }
.fd .ic { grid-row: span 2; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface-2); font-size: 12px; }
.fd .tx b { color: var(--strong); font-weight: 600; }
.fd .tm { font-size: 11px; opacity: .75; }
.fd.new { animation: fd-new 2.5s ease-out; }
@keyframes fd-new { from { background: #e2b04a33; } to { background: transparent; } }
.fd-filter { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.fd-filter input { accent-color: var(--gold); }

/* Ping auf der Karte */
.lm-ping { position: relative; width: 0; height: 0; pointer-events: none; }
.lm-ping::before, .lm-ping::after {
  content: ''; position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--ping, #e2b04a); animation: lm-ping 1.6s ease-out 3; opacity: 0;
}
.lm-ping::after { animation-delay: .5s; }
.lm-ping span {
  position: absolute; left: 50%; top: -38px; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 600;
  color: var(--strong); background: rgba(20, 17, 14, .9); border: 1px solid var(--ping, #e2b04a); border-radius: 4px; padding: 1px 6px;
}
@keyframes lm-ping { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lm-ping::before, .lm-ping::after { animation: none; opacity: 1; } }

/* Bestenliste */
.tp-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.tp-cats button { font: inherit; font-size: 12px; cursor: pointer; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 2px 9px; }
.tp-cats button[aria-pressed="true"] { color: var(--bg); background: var(--gold); border-color: var(--gold); }
.tp-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 22px 1fr auto; gap: 6px;
  align-items: center; width: 100%; padding: 4px; border-radius: 3px; font-size: 13px; }
.tp-row:hover { background: var(--surface-2); }
.tp-row .rk { text-align: right; font-variant-numeric: tabular-nums; opacity: .7; }
.tp-row .v { font-variant-numeric: tabular-nums; color: var(--strong); }
.tp-row .sub { display: block; font-size: 11px; opacity: .75; }

/* Gilden */
.gd-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  width: 100%; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.gd-row:hover, .gd-row.on { background: var(--surface-2); }
.gd-row b { color: var(--strong); }
.gd-row .sub { grid-column: 1 / -1; font-size: 11px; opacity: .8; }
.gd-row .on-n { color: var(--green); font-weight: 600; }
.hl-on .lm:not(.lm-hl) { opacity: .12; }
.lm-hl .lm-dot { box-shadow: 0 0 0 2px var(--gold), 0 0 8px var(--gold); }

/* Gegenstands-Tooltip */
.pf-eq li { cursor: pointer; }
.pf-eq li.open { background: var(--surface-2); }
.it-tip { grid-column: 1 / -1; margin: 4px 0 2px; padding: 8px 10px; border-radius: 4px; background: #070a14f2;
  border: 1px solid #f1e6cf33; font-size: 12px; line-height: 1.5; color: #fff; }
.it-tip .n { font-weight: 600; font-size: 13px; }
.it-tip .row { display: flex; justify-content: space-between; gap: 8px; }
.it-tip .g { color: #1eff00; }
.it-tip .y { color: #ffd100; }

/* 3D-Ansicht im Profil */
.pf-model { position: relative; height: 340px; margin: 4px 0 2px; border-radius: 6px; border: 1px solid var(--line);
  background: radial-gradient(ellipse 60% 60% at 50% 40%, #2a231b, #14110e); display: flex; align-items: center; justify-content: center; }
.pf-model[hidden] { display: none; }
.pf-model canvas { border-radius: 6px; }
.pf-link { font-size: 12px; align-self: center; color: var(--gold); text-decoration: none; }
.pf-link:hover { text-decoration: underline; }

/* Belagerungsalarm: rote Zone um die Stadt und Hinweis oben auf der Karte */
.lm-alarm-zone { fill: #c0392b; fill-opacity: .18; stroke: #ff5a45; stroke-width: 2; stroke-dasharray: 6 5; animation: lm-alarm 1.4s ease-in-out infinite; }
@keyframes lm-alarm { 0%, 100% { stroke-opacity: 1; fill-opacity: .22; } 50% { stroke-opacity: .35; fill-opacity: .06; } }
#lm-alarm {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 1000; /* oben liegen die Kontinent-Reiter */
  display: flex; flex-direction: column; gap: 6px; max-width: calc(100% - 120px);
}
#lm-alarm[hidden] { display: none; }
#lm-alarm button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: #fff; text-align: center;
  background: repeating-linear-gradient(-45deg, #7d1810 0 12px, #8f1d14 12px 24px);
  border: 1px solid #e74c3c; border-radius: 4px; padding: 6px 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
#lm-alarm b { background: #fff; color: #8f1d14; border-radius: 3px; padding: 0 5px; margin-right: 4px; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
@media (prefers-reduced-motion: reduce) { .lm-alarm-zone { animation: none; } }

/* Markierung für ?ort= (z. B. Kopfgeldbrett) */
.lm-ort { position: relative; width: 0; height: 0; }
.lm-ort-ring { position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid #c0392b;
  box-shadow: 0 0 0 3px rgba(0,0,0,.5), 0 0 18px rgba(192,57,43,.8); animation: lm-ort-puls 1.6s ease-in-out infinite; }
.lm-ort b { position: absolute; left: 0; top: 22px; transform: translateX(-50%); white-space: nowrap; padding: .15rem .45rem; border-radius: 4px;
  font: 700 12px/1.3 system-ui, sans-serif; color: #F1E6CF; background: rgba(20,17,14,.9); border: 1px solid #c0392b; }
@keyframes lm-ort-puls { 50% { transform: scale(1.25); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .lm-ort-ring { animation: none; } }
