/* Kartenturm – Stil „Palast bei Nacht“: Nachtblau + Gold. */
:root {
  --nacht: #0b1026; --nacht2: #141a3a; --nacht3: #1d2550; --gold: #ffc83d; --gold2: #b88a1c;
  --tinte: #ece8f7; --leise: #9aa0c8; --rand: rgba(255, 200, 61, .35);
  --grau: #9a9aa6; --blau: #3d7bff; --lila: #a24cff; --goldkarte: #ffc83d;
  --gruen: #33e07a; --gelb: #f0c929; --rot: #e8484f;
  --oben: env(safe-area-inset-top, 0px); --unten: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--nacht); color: var(--tinte); overflow: hidden; overscroll-behavior: none;
  font: 16px/1.4 -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 600; color: var(--gold); }
#app { position: fixed; inset: 0; background: radial-gradient(120% 80% at 50% 30%, #1a2152 0, var(--nacht) 70%); }
.laden { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--leise); font-family: Georgia, serif; }

/* ---------- Netz-Bildschirm ---------- */
.netz-bs { position: absolute; inset: 0; display: flex; flex-direction: column; }
.kopf { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(var(--oben) + 8px) 8px 8px;
  background: linear-gradient(#0b1026 60%, rgba(11, 16, 38, 0)); z-index: 5; position: relative; }
.staub { flex: none; display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, .07);
  border: 1px solid var(--rand); font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; font-size: 15px; }
.kopf .knopfreihe { display: flex; flex: 1; gap: 5px; justify-content: flex-end; min-width: 0; }
.kopfknopf { flex: 0 1 auto; padding: 7px 9px; border-radius: 10px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .06);
  font-size: 13px; font-weight: 600; color: var(--tinte); white-space: nowrap; }
.kopfknopf:active { background: rgba(255, 200, 61, .25); }
.netz-box { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.netz-wurzel { position: absolute; inset: 0; }
.netz-wurzel canvas { display: block; }
.netz-fehler { padding: 30px; text-align: center; color: var(--leise); }
.netz-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.netz-label { position: absolute; left: 0; top: 0; font: 700 12px Georgia, serif; color: #fff; text-shadow: 0 0 4px #000, 0 0 8px #000; display: none; will-change: transform; }
.netz-label.fertig { color: var(--gruen); }
.netz-hinweis { position: absolute; left: 0; right: 0; bottom: calc(var(--unten) + 10px); text-align: center; font-size: 12px; color: var(--leise); pointer-events: none; text-shadow: 0 0 6px #000; }

/* ---------- Seiten (Türme, Album, …) ---------- */
.seite { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: radial-gradient(120% 60% at 50% 0, #1a2152 0, var(--nacht) 75%); animation: einblenden .18s ease-out; }
@keyframes einblenden { from { opacity: 0; transform: translateY(10px); } }
.seite-kopf { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(var(--oben) + 8px) 12px 10px; border-bottom: 1px solid var(--rand); }
.seite-kopf h2 { flex: 1; font-size: 20px; }
.zurueck { padding: 7px 12px; border-radius: 10px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .06); font-weight: 600; font-size: 14px; }
.seite-inhalt { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(var(--unten) + 24px); -webkit-user-select: text; user-select: text; }
.seite-inhalt h3 { font-size: 17px; margin: 18px 0 8px; }
.seite-inhalt h3:first-child { margin-top: 2px; }
.leise { color: var(--leise); font-size: 13px; }
.gold { color: var(--gold); }

/* ---------- Fenster (Bottom Sheet) ---------- */
.fenster-bg { position: absolute; inset: 0; z-index: 40; background: rgba(4, 6, 18, .62); display: flex; align-items: flex-end; justify-content: center; animation: einblenden .15s ease-out; }
.fenster-bg.mitte { align-items: center; }
.fenster { width: min(100%, 520px); max-height: 92%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: linear-gradient(#1a2152, #11173a); border: 1px solid var(--rand);
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(var(--unten) + 16px); box-shadow: 0 -10px 40px rgba(0, 0, 0, .6); }
.mitte .fenster { border-radius: 20px; padding-bottom: 16px; margin: 0 12px; }
.fenster h2 { font-size: 21px; }
.fenster .zu { float: right; border: 0; background: rgba(255, 255, 255, .1); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; line-height: 1; }

/* ---------- Knöpfe, Chips ---------- */
.knopf { display: block; width: 100%; padding: 13px 16px; border-radius: 14px; border: 0; font-weight: 700; font-size: 17px; color: #1a1200;
  background: linear-gradient(#ffd96a, var(--gold) 55%, var(--gold2)); box-shadow: 0 4px 14px rgba(255, 200, 61, .25); margin-top: 12px; }
.knopf:disabled { opacity: .4; box-shadow: none; }
.knopf:active:not(:disabled) { transform: scale(.98); }
.knopf2 { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .07); font-weight: 600; font-size: 14px; }
.knopf2:disabled { opacity: .35; }
.knopf2.akt { background: rgba(255, 200, 61, .22); border-color: var(--gold); color: var(--gold); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .06); font-weight: 700; font-size: 14px; min-width: 52px; text-align: center; }
.chip.akt { background: var(--gold); color: #1a1200; border-color: var(--gold); }
.chip:disabled { opacity: .35; }
.reihe { display: flex; gap: 10px; align-items: center; }
.reihe.zwischen { justify-content: space-between; }

/* ---------- Kartenbild ---------- */
.kbild { position: relative; aspect-ratio: 5 / 7; border-radius: 12px; overflow: hidden; background: #000; border: 3px solid var(--rc, var(--grau)); box-shadow: 0 0 18px -4px var(--rc, var(--grau)); }
.kbild.r0 { --rc: var(--grau); } .kbild.r1 { --rc: var(--blau); } .kbild.r2 { --rc: var(--lila); } .kbild.r3 { --rc: var(--goldkarte); }
.kbild img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.kbild.verdeckt img { filter: blur(16px) brightness(.55) saturate(.7); transform: scale(1.15); }
.kbild .schloss { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font: 700 56px Georgia, serif; color: rgba(255, 255, 255, .8); text-shadow: 0 0 14px #000; }
.kbild.verdeckt .schloss { display: flex; }
.kbild.gross { width: min(62vw, 300px); margin: 6px auto 0; }
.vorschau-kopf { display: flex; gap: 14px; }
.vorschau-kopf .kbild { width: 38%; flex: none; }
.vorschau-text { flex: 1; min-width: 0; }
.vorschau-text h2 { font-size: 22px; line-height: 1.15; }
.plakette { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid currentColor; margin: 6px 6px 0 0; }
.farbbalken { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 6px 0; border: 1px solid rgba(255, 255, 255, .2); }
.farbbalken i { display: block; height: 100%; }
.info-zeile { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 3px 0; }
.indikator { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 700; display: flex; align-items: center; gap: 10px; border: 1px solid; }
.indikator::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; flex: none; }
.indikator.gruen { color: var(--gruen); background: rgba(51, 224, 122, .1); }
.indikator.gelb { color: var(--gelb); background: rgba(240, 201, 41, .1); }
.indikator.rot { color: var(--rot); background: rgba(232, 72, 79, .1); }
.indikator.neutral { color: var(--leise); background: rgba(255, 255, 255, .05); }
.hinweis { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px dashed var(--rand); color: var(--leise); font-size: 13px; margin-top: 10px; }

/* ---------- Level / Belohnung ---------- */
.level-voll { position: absolute; inset: 0; z-index: 30; background: #000; }
.beute { text-align: center; }
.beute h2 { font-size: 24px; margin-bottom: 4px; }
.beute .gewinn { margin: 10px 0 0; font-size: 15px; }
.beute .gewinn b { color: var(--gold); }
.beute .neu { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 200, 61, .18); color: var(--gold); font-weight: 700; border: 1px solid var(--gold); }

/* ---------- Türme ---------- */
.turm { border: 1px solid var(--rand); border-radius: 16px; padding: 10px; margin-bottom: 12px; background: rgba(255, 255, 255, .04); }
.turm.gesperrt { opacity: .5; }
.turm-kopf { display: flex; gap: 10px; align-items: center; }
.turm-kopf .kbild { width: 62px; flex: none; border-width: 2px; }
.turm-kopf .t { flex: 1; min-width: 0; }
.turm-kopf .t b { display: block; font-size: 16px; }
.platznr { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #1a1200; font-weight: 800; display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; }
.platznr.aus { background: rgba(255, 255, 255, .15); color: var(--leise); }
.pfeile { display: flex; flex-direction: column; gap: 4px; }
.pfeile button { width: 34px; height: 24px; border-radius: 8px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .07); line-height: 1; padding: 0; }
.pfeile button:disabled { opacity: .25; }
.kplaetze { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.kplatz { width: 46px; aspect-ratio: 5 / 7; border-radius: 8px; border: 2px dashed var(--rand); background: rgba(255, 255, 255, .04); position: relative; padding: 0; overflow: hidden; font-size: 22px; color: var(--leise); }
.kplatz.voll { border-style: solid; border-color: var(--rc); }
.kplatz img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kplatz.r1 { --rc: var(--blau); } .kplatz.r2 { --rc: var(--lila); }
.kplatz .passt { position: absolute; right: 1px; bottom: 1px; font-size: 9px; background: var(--gold); color: #1a1200; border-radius: 4px; padding: 0 3px; font-weight: 800; }
.boni { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--leise); }
.zeile { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .1); margin-bottom: 8px; background: rgba(255, 255, 255, .04); width: 100%; text-align: left; }
.zeile .kbild { width: 44px; flex: none; border-width: 2px; }
.zeile .t { flex: 1; min-width: 0; font-size: 14px; }
.zeile .t b { display: block; font-size: 15px; }
.zeile.passt { border-color: var(--gold); }

/* ---------- Album ---------- */
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.raster .kachel { padding: 0; border: 0; background: none; text-align: center; }
.raster .kbild { border-width: 2px; border-radius: 8px; }
.raster .kachel span { display: block; font-size: 10.5px; margin-top: 2px; color: var(--leise); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stufenbilder { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.stufenbilder .kbild { width: 30%; border-width: 2px; padding: 0; }
.vollbild { position: absolute; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center; }
.vollbild img { max-width: 100%; max-height: 100%; object-fit: contain; }
.vollbild .x { position: absolute; top: calc(var(--oben) + 10px); right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .2); font-size: 20px; color: #fff; }

/* ---------- Erfolge, Werkstatt ---------- */
.kachelzahl { text-align: center; padding: 14px; border-radius: 16px; border: 1px solid var(--rand); background: rgba(255, 255, 255, .05); margin-bottom: 10px; }
.kachelzahl b { display: block; font: 700 38px Georgia, serif; color: var(--gold); }
.balken { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 4px 0 2px; }
.balken i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.stufe-zeile { padding: 8px 10px; border-radius: 12px; margin-bottom: 6px; border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.stufe-zeile.ok { border-color: var(--gruen); color: var(--gruen); }
.stufe-zeile.jetzt { border-color: var(--gold); }
.upgrade { border: 1px solid var(--rand); border-radius: 16px; padding: 12px; margin-bottom: 10px; background: rgba(255, 255, 255, .04); }
.upgrade b { font-size: 16px; }
.upgrade .knopf { margin-top: 8px; padding: 10px; font-size: 15px; }

/* ---------- Einstellungen / Toast ---------- */
.einst { margin-bottom: 14px; padding: 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; background: rgba(255, 255, 255, .04); }
.einst p { margin: 4px 0 8px; }
.einst input[type=file] { display: none; }
.einst label.knopf2 { display: inline-block; }
#toast { position: fixed; left: 50%; bottom: calc(var(--unten) + 70px); transform: translateX(-50%); z-index: 100; max-width: 88vw; padding: 10px 16px; border-radius: 14px; background: rgba(20, 26, 58, .96);
  border: 1px solid var(--gold); color: var(--tinte); font-size: 14px; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .6); pointer-events: none; }
#toast[hidden] { display: none; }
