:root {
  color-scheme: dark;
  --bg: #101216; --bg2: #171b21; --bg3: #1f242c; --text: #e9ebef; --dim: #9aa3ad;
  --gold: #c9a227; --gold2: #e6c55a; --rot: #b5293c; --gruen: #3f9a4f; --tuerkis: #54d3d0; --blau: #3b7fa6;
  --panel: rgba(16, 18, 22, 0.92); --rand: rgba(255, 255, 255, 0.10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Schrift selbst gehostet (keine Google-Anfragen), SIL Open Font License -> fonts/OFL.txt */
@font-face { font-family: 'Grenze Gotisch'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/grenze-gotisch-latin.woff2) format('woff2'); }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#spiel { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#gl, #text { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#text { pointer-events: none; }

/* Kopfleiste */
#oben { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: linear-gradient(rgba(10,12,16,0.92), rgba(10,12,16,0.55) 75%, rgba(10,12,16,0)); z-index: 5; }
.werte { display: flex; gap: 5px; flex: 1; justify-content: center; flex-wrap: wrap; }
.wert { background: rgba(0,0,0,0.45); border: 1px solid var(--rand); border-radius: 999px; padding: 3px 9px; font-size: 14px; white-space: nowrap; }
.wert b { font-variant-numeric: tabular-nums; }
.wert.warn { border-color: #e0763a; color: #ffb38a; }
.wert.puls { animation: puls 0.5s; }
@keyframes puls { 50% { transform: scale(1.15); background: rgba(201,162,39,0.45); } }
.rund { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rand); background: rgba(0,0,0,0.5); font-size: 17px; flex: none; }
.rund.tempo { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rund.an { background: linear-gradient(#2f7a3c, #235d2d); border-color: rgba(120,220,140,0.6); }
#naechste #b-upgrade-jetzt { width: 100%; margin: 6px 0 4px; animation: upgradeHinweis 1.6s ease-in-out infinite; }
@keyframes upgradeHinweis { 50% { box-shadow: 0 0 0 4px rgba(230,197,90,0.35); } }
@media (prefers-reduced-motion: reduce) { #naechste #b-upgrade-jetzt { animation: none; } }
.einfuehrung { background: rgba(201,162,39,0.14); border: 1px solid rgba(230,197,90,0.45); border-radius: 10px; padding: 9px 11px; margin: 4px 0 10px; font-size: 14px; }
#pause-schild { position: absolute; left: 50%; top: calc(98px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 6;
  background: rgba(10,12,16,0.82); border: 1px solid rgba(230,197,90,0.55); color: var(--gold2); border-radius: 999px; padding: 7px 16px;
  font-weight: 700; font-size: 14px; white-space: nowrap; }
.knopf { border: 1px solid var(--rand); background: var(--bg3); border-radius: 12px; padding: 9px 14px; font-weight: 600; }
.knopf:active { transform: translateY(1px); }
.knopf.gold { background: linear-gradient(#3a2f10, #2a220c); border-color: rgba(201,162,39,0.6); color: var(--gold2); position: relative; }
.knopf.gruen { background: linear-gradient(#2f7a3c, #235d2d); border-color: rgba(120,220,140,0.45); }
.knopf.rot { background: linear-gradient(#7c2130, #5c1723); border-color: rgba(255,120,120,0.4); }
.knopf:disabled { opacity: 0.45; filter: grayscale(0.6); cursor: default; }
#b-stadtrat { padding: 7px 10px; flex: none; }
#b-stadtrat i { position: absolute; top: -6px; right: -6px; background: var(--rot); color: #fff; font-style: normal; font-size: 12px;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; border: 2px solid var(--bg); animation: puls 1.2s infinite; }
@media (max-width: 520px) { #b-stadtrat span { display: none; } .wert { padding: 3px 7px; font-size: 13px; } }

/* Naechste Welle */
#naechste { position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5; background: var(--panel);
  border: 1px solid var(--rand); border-radius: 14px; padding: 8px 10px; min-width: 190px; max-width: 280px; }
#naechste .titel { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#naechste-name { font-weight: 700; margin: 1px 0 4px; }
#naechste-gegner { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.gtag { font-size: 12px; background: rgba(255,255,255,0.07); border-radius: 8px; padding: 2px 6px; white-space: nowrap; }
.gtag.neu { background: rgba(181,41,60,0.35); border: 1px solid rgba(255,120,120,0.45); }
.gtag.boss { background: rgba(181,41,60,0.6); font-weight: 700; }
#b-los { width: 100%; }

/* Kontext-Panel */
#panel { position: absolute; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 6; background: var(--panel);
  border: 1px solid var(--rand); border-radius: 16px; padding: 10px; max-width: 640px; margin: 0 auto; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: rein 0.16s ease-out; }
@keyframes rein { from { transform: translateY(14px); opacity: 0; } }
#panel .kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#panel h3 { margin: 0; font-size: 16px; flex: 1; }
.x { border: 0; background: rgba(255,255,255,0.08); width: 32px; height: 32px; border-radius: 50%; font-size: 15px; flex: none; }
.turmwahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.tw { border: 1px solid var(--rand); background: var(--bg2); border-radius: 12px; padding: 6px 4px 7px; text-align: center; position: relative; }
.tw img { width: 56px; height: 64px; object-fit: contain; display: block; margin: 0 auto 2px; }
.tw .n { font-weight: 700; font-size: 13px; }
.tw .k { font-size: 12px; color: var(--gold2); }
.tw.aktiv { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.tw.nein { opacity: 0.45; }
.tw .gesperrt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; background: rgba(0,0,0,0.55); border-radius: 12px; padding: 4px; }
.beschr { font-size: 13px; color: var(--dim); margin: 8px 2px 2px; min-height: 18px; }
.reihe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.reihe .knopf { flex: 1; }
.werteliste { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--dim); }
.werteliste b { color: var(--text); }
.richtungen { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.richtung { border: 1px solid rgba(201,162,39,0.45); background: linear-gradient(#262014, #1a170f); border-radius: 12px; padding: 8px; text-align: left; }
.richtung b { display: block; color: var(--gold2); }
.richtung small { display: block; color: var(--dim); font-size: 12px; margin: 3px 0 5px; }
.richtung .k { font-size: 13px; }
.modus { display: flex; gap: 4px; margin-top: 8px; }
.modus button { flex: 1; font-size: 12px; padding: 5px; border-radius: 8px; border: 1px solid var(--rand); background: var(--bg2); }
.modus button.an { border-color: var(--tuerkis); color: var(--tuerkis); }

/* Overlays */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; background: rgba(6,8,10,0.72);
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); overflow: auto; }
.karte { background: var(--bg2); border: 1px solid var(--rand); border-radius: 18px; padding: 16px; width: min(560px, 100%); min-width: 0; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.karte.breit { width: min(1180px, 100%); max-height: calc(100% - 10px); overflow-y: auto; overflow-x: hidden; }
.karte .kopf { display: flex; align-items: center; gap: 10px; }
.karte h2 { margin: 0; font-size: 20px; flex: 1; }
.klein { font-size: 13px; color: var(--dim); }
.spalte { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.fuss { font-size: 11px; color: var(--dim); margin: 12px 0 0; text-align: center; }

/* Start */
#start { background: radial-gradient(ellipse at 50% 30%, rgba(30,40,55,0.55), rgba(6,8,10,0.92)); }
.karte.start { text-align: center; }
.overlay { touch-action: pan-y; }
.beta-tag { display: inline-block; vertical-align: super; margin-left: 8px; padding: 2px 7px; border-radius: 8px; font: 700 12px/1.2 system-ui, sans-serif;
  letter-spacing: 0.06em; text-transform: uppercase; color: #1b1210; background: var(--gold2); text-shadow: none; }
.merken-zeile { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: center; margin: 10px 0 2px; padding: 8px 10px;
  border: 1px dashed rgba(230,197,90,0.35); border-radius: 10px; font-size: 13px; color: var(--dim); }
.merken-zeile.an { border-style: solid; color: #9fd89f; }
p.links { margin: 6px 0 0; font-size: 12.5px; color: var(--dim); }
p.links a { color: var(--gold2); text-decoration: none; white-space: nowrap; }
p.links a:hover, p.links a:focus-visible { text-decoration: underline; }
.logo { font: 800 46px/1 "Grenze Gotisch", Georgia, "Times New Roman", serif; letter-spacing: 0.02em; color: var(--gold2); text-shadow: 0 2px 0 #000, 0 0 30px rgba(201,162,39,0.25); }
.logo small { display: block; font: 700 12px/1.6 system-ui, sans-serif; letter-spacing: 0.35em; color: var(--tuerkis); }
.unterzeile { margin: 6px 0 14px; color: var(--dim); }
#staedte { display: grid; gap: 8px; text-align: left; }
.stadt { display: flex; gap: 10px; align-items: center; border: 1px solid var(--rand); background: var(--bg3); border-radius: 14px; padding: 8px; width: 100%; min-width: 0; text-align: left; }
.stadt .t { min-width: 0; }
.stadt img { width: 120px; height: 80px; object-fit: cover; border-radius: 9px; flex: none; background: #222; }
.stadt .t { flex: 1; }
.stadt .t b { display: block; font-size: 16px; }
.stadt .t small { color: var(--dim); }
.stadt.bald { opacity: 0.6; }
.stadt .bald-tag { font-size: 11px; border: 1px dashed var(--dim); border-radius: 999px; padding: 2px 8px; color: var(--dim); white-space: nowrap; }
.stadt .nr { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: rgba(201,162,39,0.18); border: 1px solid rgba(201,162,39,0.55); color: var(--gold2); }
.stadt.finale { border-color: rgba(230,110,70,0.55); background: linear-gradient(90deg, rgba(120,40,30,0.35), var(--bg3) 60%); }
.stadt .t b em { font-style: normal; font-size: 11px; font-weight: 700; color: #ffb38a; border: 1px solid rgba(255,140,100,0.6); border-radius: 999px; padding: 1px 7px; margin-left: 4px; vertical-align: 2px; }
.stadt .t .ok { display: block; font-style: normal; font-size: 12px; color: #8fe0a0; margin-top: 2px; }
.kampagne-hinweis { font-size: 12px; color: var(--dim); margin: 2px 4px 0; text-align: center; }
.reise-zeile { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: rgba(201,162,39,0.10);
  border: 1px solid rgba(230,197,90,0.35); border-radius: 12px; padding: 8px 10px; font-size: 14px; }
.knopf.klein { padding: 6px 10px; font-size: 12px; }
.stadt .t .gesperrt { display: block; font-style: normal; font-size: 12px; color: var(--dim); margin-top: 2px; }
.stadt.zu { opacity: 0.62; cursor: default; }
.stadt.zu img { filter: grayscale(0.75) brightness(0.8); }
.stadt .zu-knopf { background: transparent; border-style: dashed; color: var(--dim); box-shadow: none; }
.ende-merken { margin: 2px 0 8px; font-size: 13px; color: var(--dim); }
.ende-merken .knopf { margin-left: 4px; }
.teilen-knopf { margin-top: 0; border-color: rgba(230,197,90,0.65); color: var(--gold2); }
/* Anleitung erster Turm (1.2): empfohlener Turm + Bauen-Knopf pulsieren */
.anleitung { animation: anleitung 1.1s ease-in-out infinite; }
@keyframes anleitung { 50% { box-shadow: 0 0 0 4px rgba(255,215,90,0.85), 0 0 18px rgba(255,215,90,0.55); } }
/* schmale Handys (320-420 px): kleineres Bild, Knopf als eigene Zeile darunter - steht NACH den Grundregeln, sonst wirkt sie nicht */
@media (max-width: 420px) {
  .stadt { flex-wrap: wrap; row-gap: 6px; }
  .stadt img { width: 76px; height: 52px; }
  .stadt .t { flex: 1 1 110px; }
  .stadt > .knopf, .stadt > .bald-tag { flex: 1 0 100%; text-align: center; padding: 7px 10px; }
  .stadt > .zu-knopf { display: none; }          /* Schloss steht schon in der Textzeile - spart eine Zeile je gesperrter Stadt */
}
.breit-knopf { display: block; width: 100%; margin: 10px 0 8px; font-size: 16px; }
.abspann { text-align: center; max-width: 560px; }
.abspann .ab-kopf { font-size: 44px; line-height: 1; margin-bottom: 4px; animation: ab-leuchten 1.6s ease-in-out infinite alternate; }
.abspann h2 { color: var(--gold2); font-size: 26px; margin: 4px 0 8px; }
@keyframes ab-leuchten { from { transform: scale(1); filter: drop-shadow(0 0 4px rgba(255,210,90,0.4)); } to { transform: scale(1.08); filter: drop-shadow(0 0 14px rgba(255,210,90,0.9)); } }
#ab-staedte { display: grid; gap: 6px; margin: 12px 0; text-align: left; }
.ab-stadt { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 4px 10px; align-items: center; background: var(--bg3);
  border: 1px solid rgba(230,197,90,0.3); border-radius: 10px; padding: 7px 10px; font-size: 14px; }
.ab-stadt small { grid-column: 2; color: var(--dim); font-size: 12px; margin-top: -4px; }
.ab-stadt .nr { grid-row: span 2; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(201,162,39,0.25); font-weight: 800; }
.ab-stadt span:nth-of-type(2), .ab-stadt span:nth-of-type(3) { grid-row: span 2; font-weight: 700; white-space: nowrap; }
.ab-stadt.offen { opacity: 0.55; }
#ab-summe { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 2px 18px; margin: 6px 0; }
#ab-summe span { grid-row: 1; color: var(--dim); font-size: 12px; } #ab-summe b { grid-row: 2; font-size: 20px; color: var(--gold2); }
.ab-dank { margin-top: 10px; }
.wert i { font-style: normal; opacity: 0.75; }
@media (max-width: 420px) { .stadt .nr { width: 20px; height: 20px; font-size: 12px; } .stadt { gap: 7px; } }
.anleitung { text-align: left; margin-top: 12px; font-size: 14px; }
.anleitung summary { cursor: pointer; color: var(--gold2); font-weight: 600; }
.anleitung ul { padding-left: 18px; margin: 8px 0 0; }
.anleitung li { margin-bottom: 4px; }

/* Stadtrat */
#sr-punkte { color: var(--gold2); font-weight: 700; white-space: nowrap; }
#sr-baum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
@media (max-width: 760px) { #sr-baum { grid-template-columns: minmax(0, 1fr); } }
.strang { background: var(--bg); border-radius: 14px; padding: 8px; border-top: 3px solid var(--sf, var(--gold)); }
.strang h3 { margin: 2px 4px 8px; font-size: 16px; }
.stufe { display: flex; gap: 6px; margin-bottom: 6px; position: relative; min-width: 0; }
.stufe .kosten { position: absolute; left: -2px; top: -7px; font-size: 10px; background: var(--bg3); border-radius: 6px; padding: 0 5px; color: var(--gold2); border: 1px solid var(--rand); z-index: 1; }
.knoten { flex: 1 1 0; min-width: 0; text-align: left; border: 1px solid var(--rand); background: var(--bg3); border-radius: 10px; padding: 7px 8px; font-size: 13px; min-height: 64px;
  overflow-wrap: anywhere; hyphens: auto; }
.knoten b { display: block; font-size: 14px; }
.knoten small { color: var(--dim); font-size: 12px; }
.knoten.gekauft { border-color: var(--sf); background: color-mix(in srgb, var(--sf) 22%, var(--bg3)); }
.knoten.gekauft b::after { content: " ✓"; color: var(--sf); }
.knoten.frei { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.knoten.gesperrt { opacity: 0.35; text-decoration: line-through; }
.knoten.vorstufe, .knoten.zu_teuer { opacity: 0.6; }
.oder { align-self: center; font-size: 11px; color: var(--dim); flex: none; }

/* Banner, Hinweis, Laden */
#banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 8; text-align: center; pointer-events: none;
  font: 800 32px/1.1 "Grenze Gotisch", Georgia, serif; color: #fff; text-shadow: 0 3px 12px rgba(0,0,0,0.8); animation: banner 2.6s forwards; white-space: nowrap; }
#banner small { display: block; font: 600 14px/1.4 system-ui, sans-serif; color: var(--gold2); letter-spacing: 0.15em; text-transform: uppercase; }
#banner.boss { color: #ff8a7a; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.96); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
#hinweis { position: absolute; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 7; background: var(--panel);
  border: 1px solid var(--rand); border-radius: 18px; padding: 6px 14px; font-size: 14px; pointer-events: none;
  width: max-content; max-width: calc(100vw - 24px); text-align: center; }          /* 1.2: lange Hinweise umbrechen statt am Handy abschneiden */
#laden { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); }
#laden .ring { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.12); border-top-color: var(--gold); animation: dreh 0.9s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }
#drehen { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 4; background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
#ende-werte { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
#ende-werte b { text-align: right; }

/* Demo 0.2: Warnkarte neue Wege/Gegner, Zustand, Wege-Zeile */
#warnung { position: absolute; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 9; display: flex; justify-content: center; pointer-events: none; }
#warnung .w-karte { pointer-events: auto; background: var(--panel); border: 2px solid rgba(230, 90, 60, 0.85); border-radius: 16px; padding: 12px; width: min(560px, 100%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(230, 90, 60, 0.15); animation: rein 0.2s ease-out; }
.w-kopf { font: 800 20px/1.1 "Grenze Gotisch", Georgia, serif; color: #ff9a7a; margin-bottom: 8px; }
.w-zeile { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; font-size: 14px; }
.w-icon { font-size: 20px; line-height: 1; flex: none; }
#naechste-wege { font-size: 12px; color: var(--dim); margin: -2px 0 7px; }
#naechste-wege .wneu { color: #ff9a7a; font-weight: 700; }
.zustand { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); margin-bottom: 8px; }
.zustand b { color: var(--text); font-variant-numeric: tabular-nums; }
.zbalken { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; }
.zbalken i { display: block; height: 100%; }
