/* ==========================================================================
   Regnum Mundi – Stylesheet (beide Kartenstile)
   Alle Farben als Variablen: .theme-antique (Pergament) und .theme-digital (Defcon-artig)
   ========================================================================== */

/* ---------- Farb- und Schriftvariablen ---------- */
:root,
.theme-antique {
  --font-ui: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --bg: #e6d6b3;
  --bg-elevated: #f4ead3;
  --panel: rgba(246, 237, 216, 0.96);
  --panel-border: #b89a6a;
  --ink: #3b2a1a;
  --ink-soft: #6e5741;
  --ink-faint: #9a8266;
  --accent: #8b2e1a;
  --accent-ink: #fff6e6;
  --accent-2: #b8862b;
  --ok: #4a6b2a;
  --danger: #9b2c1c;
  --warning-bg: #f3dfb0;
  --focus: #b8862b;
  --radius: 6px;
  --shadow: 0 6px 22px rgba(59, 42, 26, 0.25);
  --header-bg: linear-gradient(180deg, #3b2a1a, #2c1f13);
  --header-ink: #f3e5c5;
  --header-ink-soft: #cdb68f;

  --sea: #c4d0bd;
  --sea-line: rgba(70, 95, 90, 0.25);
  --land: #efe2c0;
  --land-hover: #e4cf9c;
  --border-line: #8a6a45;
  --coast: #4d3622;
  --coast-halo: rgba(70, 105, 110, 0.28);
  --graticule: rgba(122, 90, 53, 0.28);
  --label: #4d3622;
  --label-halo: rgba(239, 226, 192, 0.85);
  --owned-opacity: 0.62;
  --owned-hover-opacity: 0.8;
  --reachable: #8b2e1a;
  --free: #3f7a2a;
  --planned: #8b2e1a;
  --selected: #2c1f13;
  --sea-link: rgba(77, 54, 34, 0.55);
  --crown-halo: rgba(246, 237, 216, 0.9);
  --crown-halo-stroke: #4d3622;
  --crown-outline: #2c1f13;
  --marker-stroke: #4d3622;
}

.theme-digital {
  --font-ui: "Consolas", "Cascadia Mono", "Lucida Console", "Courier New", monospace;
  --font-display: "Consolas", "Cascadia Mono", "Lucida Console", monospace;
  --bg: #010608;
  --bg-elevated: #04141a;
  --panel: rgba(3, 16, 20, 0.94);
  --panel-border: #11524d;
  --ink: #a6fff4;
  --ink-soft: #4fc2b6;
  --ink-faint: #2b7a72;
  --accent: #20e3d2;
  --accent-ink: #00110f;
  --accent-2: #ffd23f;
  --ok: #52ff8f;
  --danger: #ff4d5e;
  --warning-bg: rgba(255, 210, 63, 0.12);
  --focus: #ffd23f;
  --radius: 2px;
  --shadow: 0 0 0 1px rgba(32, 227, 210, 0.35), 0 0 24px rgba(32, 227, 210, 0.15);
  --header-bg: linear-gradient(180deg, #03141a, #010608);
  --header-ink: #a6fff4;
  --header-ink-soft: #4fc2b6;

  --sea: #01080b;
  --sea-line: rgba(32, 227, 210, 0.06);
  --land: #05181d;
  --land-hover: #0b3940;
  --border-line: rgba(32, 227, 210, 0.45);
  --coast: #20e3d2;
  --coast-halo: rgba(32, 227, 210, 0.1);
  --graticule: rgba(32, 227, 210, 0.1);
  --label: #7ff5e8;
  --label-halo: rgba(1, 6, 8, 0.85);
  --owned-opacity: 0.38;
  --owned-hover-opacity: 0.6;
  --reachable: #ffd23f;
  --free: #52ff8f;
  --planned: #ffd23f;
  --selected: #ffffff;
  --sea-link: rgba(32, 227, 210, 0.4);
  --crown-halo: rgba(1, 6, 8, 0.85);
  --crown-halo-stroke: #20e3d2;
  --crown-outline: #ffffff;
  --marker-stroke: #20e3d2;
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.theme-digital body { letter-spacing: 0.02em; }

a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 0.5em; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.theme-antique h2, .theme-antique h3 { font-variant: small-caps; letter-spacing: 0.03em; }
.theme-digital h2, .theme-digital h3 { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.95rem; }
p { margin: 0 0 0.75em; }
small, .muted { color: var(--ink-soft); }
.muted { font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px;
}
.skip-link:focus { left: 8px; top: 8px; }

.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* ---------- Buttons ---------- */
button, .btn-primary, .btn-ghost, .btn-danger, .btn-icon {
  font: inherit; color: inherit; cursor: pointer;
}
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border-radius: var(--radius); border: 1px solid transparent;
  text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; border-color: var(--panel-border); color: var(--ink); }
.btn-ghost:hover { background: rgba(127, 127, 127, 0.12); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius); border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--ink);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.theme-digital .btn-primary, .theme-digital .btn-ghost, .theme-digital .btn-danger { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.theme-digital .btn-primary { box-shadow: 0 0 12px rgba(32, 227, 210, 0.45); }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: var(--header-bg); color: var(--header-ink);
  border-bottom: 2px solid var(--accent-2);
}
.theme-digital .topbar { border-bottom: 1px solid var(--accent); box-shadow: 0 0 18px rgba(32, 227, 210, 0.25); }
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.brand-icon { width: 26px; height: 26px; fill: var(--accent-2); }
.brand-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-antique .brand-name { font-variant: small-caps; letter-spacing: 0.05em; }
.theme-digital .brand-name { text-transform: uppercase; letter-spacing: 0.25em; font-size: 1.1rem; text-shadow: 0 0 10px rgba(32, 227, 210, 0.7); }

.topnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .btn-ghost { color: var(--header-ink); border-color: transparent; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); }
.topbar .btn-icon { background: transparent; color: var(--header-ink); border-color: rgba(255, 255, 255, 0.2); }
.menu-toggle { display: none !important; }

.segmented { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: var(--radius); overflow: hidden; }
.segmented button { background: transparent; border: 0; color: var(--header-ink-soft); padding: 5px 10px; min-height: 32px; font-size: 0.85rem; }
.segmented button[aria-pressed="true"] { background: var(--accent-2); color: #1d140b; font-weight: 700; }
.theme-digital .segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.account { display: flex; align-items: center; gap: 6px; }
.wallet-button { font-variant-numeric: tabular-nums; font-weight: 600; }
.wallet-button .icon { fill: var(--accent-2); }
.notif-button { position: relative; }
.badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}
.swatch { width: 14px; height: 14px; flex: none; }
.swatch rect { fill: var(--ink-faint); }
.swatch-lg { width: 42px; height: 42px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; min-height: 0; }
.map-wrap { position: relative; overflow: hidden; min-height: 320px; background: var(--sea); }
.sidebar {
  overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-elevated); border-left: 1px solid var(--panel-border);
}
.theme-antique .sidebar { background: linear-gradient(90deg, rgba(110, 87, 65, 0.12), transparent 14px), var(--bg-elevated); }

.footer {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: center;
  padding: 6px 16px; font-size: 0.82rem; color: var(--ink-soft);
  border-top: 1px solid var(--panel-border); background: var(--bg-elevated);
}
.footer a, .footer .link-button { color: var(--ink-soft); }

/* ---------- Karte ---------- */
.map { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.map .sphere { fill: var(--sea); }
.map .sphere-pattern { pointer-events: none; }
.theme-digital .map .sphere-pattern { display: none; }
.map .graticule { fill: none; stroke: var(--graticule); stroke-width: 0.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.theme-digital .map .graticule { stroke-dasharray: 2 4; }
.map .coast-halo { fill: none; stroke: var(--coast-halo); stroke-width: 7; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.theme-digital .map .coast-halo { stroke-width: 5; }

.map .country { cursor: pointer; transition: fill-opacity 0.15s, fill 0.15s; }
.map .country:not(.owned) { fill: var(--land); }
.map .country:not(.owned):hover { fill: var(--land-hover); }
.map .country.owned { fill-opacity: var(--owned-opacity); }
.map .country.owned:hover { fill-opacity: var(--owned-hover-opacity); }
.theme-antique .map .country { stroke: none; }
.theme-digital .map .country.owned { stroke-width: 1; stroke-opacity: 0.9; vector-effect: non-scaling-stroke; }

.map .borders { fill: none; stroke: var(--border-line); stroke-width: 0.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.theme-antique .map .borders { stroke-dasharray: 3 1.5; }
.map .coastline { fill: none; stroke: var(--coast); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.theme-antique .map .coast-digital,
.theme-digital .map .coast-antique { display: none; }
.map.is-zooming .coastline,
.map.no-filter .coastline { filter: none; }

.map .sea-link { fill: none; stroke: var(--sea-link); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.map .sea-link.active { stroke: var(--planned); stroke-width: 2; stroke-dasharray: 5 3; }

.map .hl { fill: none; pointer-events: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map .hl-reachable { stroke: var(--reachable); stroke-width: 1.6; stroke-dasharray: 4 3; stroke-opacity: 0.85; }
.map .hl-free { stroke: var(--free); stroke-width: 2; fill: var(--free); fill-opacity: 0.22; }
.map .tiny-marker.free { stroke: var(--free); stroke-width: 3; }
.map .crown.protected .crown-halo { stroke: var(--free); stroke-width: 2.2; stroke-dasharray: 3 2; }
.map .hl-planned { stroke: var(--planned); stroke-width: 2.6; fill: var(--planned); fill-opacity: 0.18; }
.map .hl-invalid { stroke: var(--danger); stroke-width: 2.6; stroke-dasharray: 2 2; }
.map .hl-selected { stroke: var(--selected); stroke-width: 2.4; }
.map .hl-mine { stroke: var(--selected); stroke-width: 1.2; stroke-opacity: 0.6; }
@media (prefers-reduced-motion: no-preference) {
  .map .hl-planned { animation: pulse 1.6s ease-in-out infinite; }
}
@keyframes pulse { 50% { stroke-opacity: 0.45; fill-opacity: 0.05; } }

.map .label {
  fill: var(--label); stroke: var(--label-halo); stroke-width: 3px; paint-order: stroke; stroke-linejoin: round;
  text-anchor: middle; dominant-baseline: middle; pointer-events: none; display: none;
}
.map .label.show { display: inline; }
.theme-antique .map .label { font-family: var(--font-display); font-style: italic; letter-spacing: 0.08em; }
.theme-digital .map .label { font-family: var(--font-ui); text-transform: uppercase; letter-spacing: 0.15em; }
.map.is-zooming .labels { display: none; }

.map .tiny-marker { cursor: pointer; stroke: var(--marker-stroke); vector-effect: non-scaling-stroke; stroke-width: 1; }
.map .tiny-marker:not(.owned) { fill: var(--land); }
.map .tiny-marker:hover { stroke-width: 2; }
.map .tiny-marker.reachable { stroke: var(--reachable); stroke-width: 2; stroke-dasharray: 2 2; }
.map .tiny-marker.planned { stroke: var(--planned); stroke-width: 3; }
.map .tiny-marker.selected { stroke: var(--selected); stroke-width: 3; }

.map .crown { cursor: pointer; }
.map .crown-halo { fill: var(--crown-halo); stroke: var(--crown-halo-stroke); stroke-width: 1; }
.map .crown-icon { stroke-width: 1.3; stroke-linejoin: round; }
.theme-antique .map .crown-icon { stroke: var(--crown-outline); }
.theme-digital .map .crown-icon { fill-opacity: 0.35; stroke-width: 1.6; }
.map .crown.mine .crown-halo { stroke: var(--accent-2); stroke-width: 2; }
.map .crown:hover .crown-halo { stroke-width: 2.5; }

.map .plan-badge circle { fill: var(--planned); stroke: var(--crown-halo); stroke-width: 1.5; }
.map .plan-badge text { fill: var(--accent-ink); font: 700 11px var(--font-ui); text-anchor: middle; dominant-baseline: central; }
.theme-antique .map .plan-badge text { fill: #fff6e6; }
.map .plan-badge.invalid circle { fill: var(--danger); }

/* Overlays auf der Karte */
.map-texture { position: absolute; inset: 0; pointer-events: none; }
.theme-antique .map-texture {
  background-image: radial-gradient(ellipse at center, transparent 55%, rgba(80, 50, 20, 0.35) 100%), url("../img/paper.svg");
  background-size: 100% 100%, 600px 600px;
  mix-blend-mode: multiply; opacity: 0.75;
}
.theme-digital .map-texture {
  background-image:
    repeating-linear-gradient(0deg, rgba(32, 227, 210, 0.05) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.75) 100%);
}
.compass { position: absolute; left: 14px; bottom: 14px; width: 92px; height: 92px; pointer-events: none; opacity: 0.85; }
.compass .c-ring { fill: none; stroke: var(--coast); stroke-width: 1.2; }
.compass .c-ring-inner { stroke-dasharray: 2 2; }
.compass .c-dark { fill: var(--coast); }
.compass .c-light { fill: var(--land); stroke: var(--coast); stroke-width: 0.8; }
.compass .c-text { fill: var(--coast); font: 700 11px var(--font-display); text-anchor: middle; }
.theme-digital .compass { opacity: 0.5; }

.zoom-controls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoom-controls .btn-icon { box-shadow: var(--shadow); }

.map-status {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  max-width: calc(100% - 200px); padding: 4px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.map-status:empty { display: none; }
.map-banner {
  position: absolute; left: 50%; top: 50px; transform: translateX(-50%); z-index: 5;
  max-width: calc(100% - 24px); padding: 8px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); font-weight: 600; text-align: center;
}
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--sea); color: var(--ink-soft); font-size: 1.1rem; }

/* ---------- Seitenleiste ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.theme-antique .panel { box-shadow: inset 0 0 0 3px rgba(184, 154, 106, 0.18); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 10px; }
.hint { font-size: 0.88rem; color: var(--ink-soft); }
.empty { color: var(--ink-faint); font-style: italic; font-size: 0.9rem; margin: 6px 0; }
.warning { background: var(--warning-bg); border-left: 3px solid var(--accent-2); padding: 6px 10px; font-size: 0.88rem; }
.notice { background: var(--warning-bg); border: 1px dashed var(--accent-2); padding: 8px 10px; font-size: 0.88rem; }
.notice-free, .panel .notice { border-color: var(--free); }
.price-list li.highlight { color: var(--free); font-weight: 700; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: 0.92rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.owner-link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 6px; }
.crown-inline { width: 15px; height: 15px; fill: var(--accent-2); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0; padding: 0; list-style: none; }
.chips li button {
  font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--panel-border);
  background: transparent; color: var(--ink); cursor: pointer;
}
.chips li button.sea { border-style: dashed; }
.chips li button.mine { border-color: var(--accent); color: var(--accent); }
.price-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.price-list li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--panel-border); padding: 3px 0; }
.price { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.cooldown { font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
.cooldown.ready { color: var(--ok); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.88rem; cursor: pointer; margin: 6px 0; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.turn-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; counter-reset: step; }
.turn-list li {
  display: grid; grid-template-columns: 24px 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--panel-border); border-radius: var(--radius); background: var(--bg-elevated);
}
.turn-list li.invalid { border-color: var(--danger); }
.turn-list .step { width: 22px; height: 22px; border-radius: 50%; background: var(--planned); color: var(--accent-ink); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.theme-antique .turn-list .step { color: #fff6e6; }
.turn-list li.invalid .step { background: var(--danger); }
.turn-list .what { min-width: 0; }
.turn-list .what strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-list .what small { display: block; font-size: 0.78rem; }
.turn-list .btn-icon { width: 28px; height: 28px; }
.turn-list .btn-icon .icon { width: 14px; height: 14px; }
.turn-sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.turn-sum dt { color: var(--ink-soft); }
.turn-sum dd { margin: 0; text-align: right; font-weight: 600; }
.turn-sum dd:first-of-type { font-size: 1.15rem; color: var(--accent); }
.turn-sum dd.negative { color: var(--danger); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 340px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 12px 1fr; gap: 8px; align-items: start; padding: 5px 2px; border-bottom: 1px dotted var(--panel-border); font-size: 0.86rem; }
.feed li.unread { font-weight: 600; }
.feed .dot { width: 10px; height: 10px; margin-top: 5px; }
.feed time { display: block; color: var(--ink-faint); font-size: 0.75rem; }
.feed-item { display: block; width: 100%; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.feed-item:hover > span > span:first-child, .feed-item:focus-visible > span > span:first-child { text-decoration: underline; }
#dlg-notifications .feed { max-height: none; }

/* ---------- Dialoge & Formulare ---------- */
.dialog {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--panel-border); border-radius: calc(var(--radius) + 2px);
  background: var(--bg-elevated); color: var(--ink); box-shadow: var(--shadow);
}
.dialog-wide { width: min(720px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(20, 12, 4, 0.55); }
.theme-digital .dialog::backdrop { background: rgba(0, 10, 12, 0.75); }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--panel-border); position: sticky; top: 0; background: var(--bg-elevated); z-index: 1;
}
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 14px 16px 18px; }
.dialog > .form, .dialog > .tab-panel { padding: 14px 16px 18px; }
.tab-panel .form + .form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--panel-border); }

.form { display: grid; gap: 10px; }
.form label:not(.check) { display: grid; gap: 4px; font-size: 0.9rem; }
.form label > span { font-weight: 600; }
.form fieldset { border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 8px 10px 10px; margin: 0; }
.form legend { padding: 0 4px; font-weight: 600; font-size: 0.9rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--panel-border); background: var(--panel);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.form-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; margin: 0; }
.form-note { font-size: 0.88rem; margin: 0; text-align: center; }
.form-links { font-size: 0.85rem; margin: -4px 0 0; }
.counter { float: right; font-variant-numeric: tabular-nums; }
.danger-zone { border: 1px solid var(--danger); border-radius: var(--radius); padding: 12px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.danger-zone h3 { color: var(--danger); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 42px; padding: 6px 8px;
  border: 1px solid var(--panel-border); border-radius: var(--radius); background: var(--panel); font-weight: 600; font-size: 0.9rem;
}
.choice input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.choice span { flex-direction: column; gap: 2px; }
.choice .bonus { color: var(--free); font-size: 0.78rem; font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--focus); }
.balance-big { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 1.05rem; }
.balance-big strong { font-size: 1.5rem; color: var(--accent); font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 2px; padding: 8px 16px 0; border-bottom: 1px solid var(--panel-border); }
.tabs button { background: none; border: 1px solid transparent; border-bottom: 0; padding: 8px 14px; border-radius: var(--radius) var(--radius) 0 0; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { border-color: var(--panel-border); background: var(--panel); color: var(--ink); font-weight: 700; margin-bottom: -1px; }

.profile-card { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.profile-card strong { font-size: 1.15rem; }
.profile-card p { margin: 2px 0 0; }
.player-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.player-head .crown-badge { width: 48px; height: 48px; }
.player-head strong { font-size: 1.25rem; display: block; }
.player-info { white-space: pre-line; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--panel-border); vertical-align: middle; }
.table th { font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .pos { color: var(--ok); }
.table .neg { color: var(--danger); }
.table tr.me td { background: rgba(127, 127, 127, 0.12); font-weight: 700; }
.player-cell { display: inline-flex; align-items: center; gap: 6px; }

/* Spielanleitung */
.guide section { margin-bottom: 18px; }
.guide h3 { color: var(--accent); }
.guide ul { padding-left: 1.2em; margin: 0 0 0.75em; }
.guide .example { border: 1px solid var(--panel-border); border-left: 4px solid var(--accent-2); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; background: var(--panel); }
.guide .example h4 { margin: 0 0 6px; font-size: 0.95rem; }
.guide table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.guide td, .guide th { padding: 4px 6px; border-bottom: 1px dotted var(--panel-border); text-align: left; }
.guide td.num, .guide th.num { text-align: right; font-variant-numeric: tabular-nums; }
.guide tr.total td { font-weight: 700; border-top: 2px solid var(--ink-soft); border-bottom: 0; }

/* Meldungen */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px; border-radius: var(--radius); background: var(--panel); color: var(--ink);
  border: 1px solid var(--panel-border); border-left: 4px solid var(--accent); box-shadow: var(--shadow); font-size: 0.92rem;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.2s ease-out; }
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Admin-Bereich ---------- */
.admin-page { grid-template-rows: auto 1fr; }
.admin { padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
.admin-tabs { padding: 0; margin-bottom: 14px; flex-wrap: wrap; }
.admin-panel { display: grid; gap: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 200px; }
.toolbar [aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.stat-label { color: var(--ink-soft); font-size: 0.85rem; }
.stat-value { font-size: 1.4rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td, .table tr.clickable:focus-visible td { background: rgba(127, 127, 127, 0.12); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.inline-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input.inline-input { width: 170px; padding: 6px 8px; }
#user-detail h2 { display: flex; align-items: center; gap: 8px; }

/* ---------- Rechtstexte ---------- */
.legal-page { grid-template-rows: auto 1fr auto; }
.legal { padding: 24px 16px 40px; max-width: 820px; width: 100%; margin: 0 auto; }
.legal h1 { font-size: 1.6rem; }
.legal h2 { margin-top: 1.4em; }
.legal .placeholder { background: var(--warning-bg); border: 1px dashed var(--accent-2); padding: 10px 12px; }
.legal-toc ol { columns: 2; column-gap: 24px; padding-left: 1.4em; margin: 0 0 1em; font-size: 0.92rem; }
.legal-box { border: 1px solid var(--panel-border); border-left: 4px solid var(--accent-2); border-radius: var(--radius); background: var(--panel); padding: 12px 16px; margin: 12px 0; }
.legal-box h3 { margin-top: 0; }
.legal-box h4 { margin: 1em 0 0.4em; }
@media (max-width: 600px) { .legal-toc ol { columns: 1; } }

/* ---------- Mobil ---------- */
@media (max-width: 1100px) {
  .topnav > .btn-ghost span { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr) 330px; }
}

@media (max-width: 860px) {
  html, body { height: auto; }
  body { grid-template-rows: auto auto auto; }
  .layout { min-height: auto; }
  .menu-toggle { display: inline-flex !important; }
  .topbar { flex-wrap: wrap; padding: 8px 16px; }
  .topnav {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 0 4px;
  }
  .topnav.open { display: flex; }
  .topnav > .btn-ghost span { display: inline; }
  .topnav .segmented { align-self: flex-start; }
  .account { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .map-wrap { height: 62vh; height: 62dvh; }
  .sidebar { border-left: 0; border-top: 1px solid var(--panel-border); overflow: visible; }
  .compass { width: 64px; height: 64px; }
  .map-status { max-width: calc(100% - 140px); bottom: 10px; }
  .toasts { right: 16px; left: 16px; width: auto; }
}

@media (max-width: 420px) {
  .brand-name { font-size: 1.1rem; }
  .compass { display: none; }
  .map-status { left: 12px; transform: none; max-width: calc(100% - 70px); }
}

/* ---------- Zeitalter, Regionen, Befestigung, Rückeroberung, Aufträge, Erfolge ---------- */
.season-bar {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 6;
  max-width: calc(100% - 24px); padding: 5px 14px; border-radius: 999px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  font: 600 0.85rem var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.season-bar:hover { border-color: var(--accent); }
.season-bar.landnahme { border-color: var(--free); color: var(--free); }
.season-bar.pause { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.map .hl-region { stroke: var(--accent-2); stroke-width: 1.4; stroke-dasharray: 1 3; stroke-linecap: round; stroke-opacity: 0.95; }
.map .fort-badge { pointer-events: none; }
.map .fort-badge circle { fill: var(--crown-halo); stroke: var(--crown-halo-stroke); stroke-width: 1; }
.map .fort-badge.level-3 circle { stroke-width: 2.2; }
.map .fort-badge use { stroke: var(--crown-outline); stroke-width: 0.6; }
.map .fort-badge .fort-level { fill: var(--ink); font: 700 8px var(--font-ui); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: var(--crown-halo); stroke-width: 2px; }
.icon.fort-inline { width: 1em; height: 1em; vertical-align: -0.12em; }
.region-united { color: var(--accent); font-weight: 600; }

.panel h2 .icon { width: 1em; height: 1em; vertical-align: -0.12em; }
.panel-revenge { border-color: var(--accent); }
.revenge-list, .mission-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.revenge-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; border-bottom: 1px dotted var(--panel-border); padding: 4px 0; }
.revenge-list li small { grid-column: 1; }
.revenge-list li .btn-small { grid-column: 2; grid-row: 1 / span 2; }
.btn-small { padding: 4px 10px; font-size: 0.85rem; }

.mission-list li { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; padding: 6px 0; border-bottom: 1px dotted var(--panel-border); font-size: 0.88rem; }
.mission-list .mission-text { grid-column: 1 / -1; }
.mission-list .mission-reward { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-soft); }
.mission-list progress { width: 100%; height: 8px; accent-color: var(--accent); }
.mission-list li.done .mission-text { color: var(--ok); font-weight: 600; }
.mission-list .done-icon { width: 1em; height: 1em; vertical-align: -0.15em; margin-right: 4px; fill: var(--ok); }
.vouchers { margin: 8px 0 0; font-size: 0.85rem; color: var(--free); font-weight: 600; }
.small { font-size: 0.8rem; }

.region-group { margin: 0 0 14px; }
.region-group h3 { margin: 0 0 6px; font-size: 1rem; }
.region-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.region-list li { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 0 10px; padding: 4px 0; border-bottom: 1px dotted var(--panel-border); font-size: 0.88rem; }
.region-list li small { grid-column: 1; }
.region-list li > span { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; }
.region-list li.united .link-button { font-weight: 700; }
.region-holder { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

.hall-season { margin: 0 0 16px; }
.hall-season h3 { margin: 0 0 6px; font-size: 1rem; }
.hall-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.hall-list li { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dotted var(--panel-border); }
.hall-list li.podium { font-weight: 700; }
.hall-list li.rank-1 .hall-rank { color: var(--accent-2); }
.hall-rank { font-family: var(--font-display); }

.player-title { display: block; color: var(--accent); font-style: italic; font-size: 0.9rem; }
.achievement-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.achievement-list li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--panel-border); border-radius: var(--radius); font-size: 0.86rem; }
.achievement-list li small { display: block; }
.achievement-list li.locked { opacity: 0.45; filter: grayscale(1); }
.achievement-icon { width: 26px; height: 26px; fill: var(--accent-2); }
.achievement-list .count { color: var(--accent); font-weight: 700; }
.feed li.ev-region_united, .feed li.ev-continent_united, .feed li.ev-season_end, .feed li.ev-season_start { font-weight: 600; }
.kv dd.dd-stack { flex-direction: column; align-items: flex-start; gap: 1px; }
.region-list .link-button { justify-self: start; text-align: left; }
@media (max-width: 720px) {
  .map-banner { top: 46px; padding: 6px 10px; font-size: 0.78rem; font-weight: 600; }
  .season-bar { font-size: 0.75rem; padding: 4px 10px; }
  .hall-list li { grid-template-columns: 56px 1fr; }
  .hall-list li small { grid-column: 2; }
}
