/* Kaiserthermen Trier 3D – Mobile First
   Gestaltung angelehnt an das Erscheinungsbild von trier-info.de:
   Aubergine #450C34, Weiss/Hellgrau, Source Sans, Versal-Ueberschriften mit weiter Laufweite. */
:root {
  --brand: #450c34;
  --brand-dark: #320824;
  --brand-soft: #f3ebf0;
  --accent: #e73452;
  --ink: #111;
  --text: #2b2b2b;
  --muted: #6b6a6a;
  --line: #d9d9d9;
  --surface: #fff;
  --surface-2: #efefef;
  --radius: 4px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --bar-h: 56px;
  --font: 'Source Sans 3', 'Source Sans Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --peek: 240px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ------------------------------------------------------------ Kopfzeile (Aubergine-Balken) */
.topbar {
  position: absolute; inset: 0 0 auto 0; z-index: 40;
  height: calc(var(--bar-h) + var(--safe-t));
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--safe-t) 8px 0 4px;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: #fff; line-height: 1; }
.brand-city { font-size: 26px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-name { font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.9; white-space: nowrap; }
@media (max-width: 380px) { .brand-name { letter-spacing: 0.1em; } }
.top-left { display: flex; align-items: center; gap: 2px; min-width: 0; }
.top-left .icon-btn { flex: none; }
/* Startbildschirm (z 50) liegt ueber der Kopfzeile: Zurueck-Pfeil trotzdem erreichbar, uebrige Icons bleiben dort inaktiv */
.is-intro .topbar { z-index: 51; }
.is-intro .top-actions { pointer-events: none; }
/* Schmale Handys: Zurueck-Pfeil + Titel + drei Icons passen nur, wenn Stadt und Szenenname uebereinander stehen */
@media (max-width: 479px) {
  .brand { flex-direction: column; align-items: flex-start; gap: 3px; }
  .brand-city { font-size: 20px; }
  .brand-name { font-size: 11px; white-space: nowrap; }
}
.top-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: none; color: #fff;
  display: grid; place-items: center; border-radius: var(--radius);
}
.icon-btn:active { background: rgba(255, 255, 255, 0.12); }

/* ------------------------------------------------------------ Epochen-Tag (haengt am Balken) */
.era-badge {
  position: absolute; z-index: 35; left: 16px; top: calc(var(--bar-h) + var(--safe-t));
  display: flex; flex-direction: column; pointer-events: none;
  padding: 7px 14px 9px; border-radius: 0 0 5px 5px;
  background: var(--brand); color: #fff;
  box-shadow: 0 6px 18px rgba(50, 8, 36, 0.25);
  transition: opacity 0.4s;
}
.era-year { font-size: 22px; font-weight: 700; line-height: 1.05; letter-spacing: 0.06em; text-transform: uppercase; }
.era-label { font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; margin-top: 2px; opacity: 0.85; }
.era-badge.swap > * { animation: badge-in 0.5s var(--ease); }
@keyframes badge-in { from { opacity: 0; transform: translateY(-6px); } }

/* ------------------------------------------------------------ Hotspot-Pins */
#pins { position: absolute; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.pin {
  position: absolute; left: 0; top: 0;
  width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0;
  display: grid; place-items: center;
  background: none; border: 0; pointer-events: auto;
  transition: opacity 0.3s;
}
.pin span {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff;
  background: var(--brand); box-shadow: 0 0 0 2.5px #fff, 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s var(--ease), background 0.2s;
}
.pin::before {
  content: ''; position: absolute; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; animation: pulse 2.6s infinite; opacity: 0;
}
.pin.is-active span { background: var(--accent); transform: scale(1.18); }
.pin.is-occluded { opacity: 0.45; }
.pin.is-occluded::before { animation: none; }
.pin.is-hidden { opacity: 0; pointer-events: none; }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.9); opacity: 0; } }

.gesture-hint {
  position: absolute; z-index: 12; left: 50%; bottom: calc(var(--peek) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: var(--radius);
  background: rgba(50, 8, 36, 0.88); color: #fff;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.5s;
}
.gesture-hint.show { opacity: 1; }
.gesture-hint svg { animation: swipe 1.8s infinite var(--ease); }
@keyframes swipe { 0%, 100% { transform: translateX(-5px); } 50% { transform: translateX(5px); } }

/* ------------------------------------------------------------ Bottom Sheet */
.sheet {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(100dvh - var(--bar-h) - var(--safe-t) - 8px);
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  transform: translateY(calc(100% - var(--peek) - var(--safe-b)));
  transition: transform 0.45s var(--ease);
  will-change: transform;
}
.sheet.dragging { transition: none; }
.is-intro .sheet { transform: translateY(100%); }
.sheet-grab { flex: none; touch-action: none; padding-top: 8px; cursor: grab; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #c9c9c9; margin: 0 auto 4px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tab {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 48px; padding: 0 4px;
  border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: none;
  font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.tab svg { width: 18px; height: 18px; }
.tab[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }

.panels { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 0 calc(28px + var(--safe-b)); }
.panel { padding: 0 16px; }

/* Ueberschriften im Stil von trier-info.de */
h2, h3 { color: var(--ink); text-transform: uppercase; font-weight: 700; }
.era-card h2, .spot-head h2, .visit-hero h2 {
  margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: 0.12em; text-wrap: balance;
}
.kicker { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand); }

/* ------------------------------------------------------------ Zeitreise */
.timeline {
  list-style: none; margin: 0 -16px; padding: 14px 16px 4px;
  display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.timeline::-webkit-scrollbar { display: none; }
.timeline li { flex: none; scroll-snap-align: center; }
.tl-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 84px; padding: 8px 12px 9px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  text-align: left; transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.tl-year { font-weight: 700; font-size: 19px; line-height: 1; letter-spacing: 0.04em; color: var(--ink); }
.tl-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 5px; white-space: nowrap; }
.tl-btn[aria-current='step'] { background: var(--brand); border-color: var(--brand); }
.tl-btn[aria-current='step'] .tl-year, .tl-btn[aria-current='step'] .tl-label { color: #fff; }
.tl-btn.roman::after {
  content: 'RÖM.'; position: absolute; top: 7px; right: 7px;
  font-size: 8.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent);
}
.tl-btn[aria-current='step'].roman::after { color: #ffc2cd; }

.era-card { padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 10px; }
.era-text p { margin: 10px 0 0; font-size: 16px; line-height: 1.6; letter-spacing: 0.01em; color: var(--text); max-width: 62ch; }
.era-card.swap > *, .spot-detail.swap > * { animation: card-in 0.5s var(--ease) both; }
.era-card.swap > :nth-child(2) { animation-delay: 0.04s; }
.era-card.swap > :nth-child(3) { animation-delay: 0.08s; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } }

.facts { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.facts li {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 10px; border-radius: var(--radius);
  background: var(--brand-soft); color: var(--brand);
}
.era-cta { margin-top: 18px; }

.era-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 8px; }
.round-btn {
  width: 48px; height: 48px; flex: none; border-radius: var(--radius);
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand);
}
.round-btn:disabled { opacity: 0.35; cursor: default; }
.round-btn:not(:disabled):active { background: var(--brand-soft); }

.spots-teaser {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 6px 0 10px; padding: 12px;
  border: 0; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); text-align: left;
}
.spots-teaser > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; gap: 1px; }
.spots-teaser strong { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }
.spots-teaser small { font-size: 13px; color: var(--muted); }
.spots-dots { display: flex; }
.spots-dots i {
  width: 24px; height: 24px; margin-left: -6px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-style: normal; font-weight: 700; font-size: 11px; box-shadow: 0 0 0 2px var(--brand-soft);
}
.spots-dots i:first-child { margin-left: 0; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--radius);
  font-weight: 700; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-link { background: none; color: #fff; text-decoration: underline; text-underline-offset: 4px; letter-spacing: 0.08em; }
.btn-lg { min-height: 54px; font-size: 15px; padding: 0 28px; }
#era-play { flex: 1; }
.btn-text {
  min-height: 44px; border: 0; background: none; color: var(--brand);
  font-weight: 700; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: underline; text-underline-offset: 4px;
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ Entdecken */
.panel-intro { margin: 16px 0 6px; font-size: 15px; color: var(--muted); line-height: 1.5; }
.spot-list { list-style: none; margin: 0; padding: 0; }
.spot-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
}
.spot-list li:last-child .spot-item { border-bottom: 0; }
.spot-num {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; background: var(--brand); color: #fff;
}
.spot-item .t { display: flex; flex-direction: column; flex: 1; gap: 2px; }
.spot-item strong { font-size: 15px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }
.spot-item small { font-size: 14px; color: var(--muted); }
.spot-item.unavailable { opacity: 0.45; }
.spot-item > svg { color: var(--brand); }

.spot-detail { padding-top: 10px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px 0 4px; margin-left: -6px;
  border: 0; background: none; color: var(--brand);
  font-weight: 700; font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase;
}
.spot-head { display: flex; align-items: center; gap: 12px; margin-top: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.spot-nav { margin-top: 20px; }

/* ------------------------------------------------------------ Besuchen */
.visit-hero { padding: 18px 0 4px; }
.visit-hero p:not(.kicker) { margin: 10px 0 0; font-size: 16px; line-height: 1.55; }
.visit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 16px; }
.visit-actions .btn { padding: 0 10px; letter-spacing: 0.05em; font-size: 13px; gap: 6px; }
.info-card { background: var(--surface-2); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.info-card h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0.14em; padding-bottom: 8px; border-bottom: 1px solid #cfcfcf; }
.info-card p { margin: 0; font-size: 15px; line-height: 1.55; }
.info-card .note { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.info-card.feature { background: var(--brand); color: #fff; }
.info-card.feature h3 { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.info-card.feature .kicker { color: #f5c7d6; }
.info-card.feature .btn { margin-top: 14px; background: #fff; color: var(--brand); border-color: #fff; }
.info-table { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; font-size: 15px; }
.info-table dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.disclaimer { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 14px 2px 0; }
.disclaimer a { color: inherit; }

/* ------------------------------------------------------------ Intro */
.intro {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: flex-end;
  background: linear-gradient(to bottom, rgba(50, 8, 36, 0) 25%, rgba(50, 8, 36, 0.55) 52%, rgba(50, 8, 36, 0.94) 78%, var(--brand-dark) 100%);
  color: #fff;
  transition: opacity 0.8s var(--ease), visibility 0.8s;
}
.intro.hide { opacity: 0; visibility: hidden; }
.intro-inner { width: 100%; padding: 24px 24px calc(28px + var(--safe-b)); max-width: 560px; }
.intro .kicker { color: #f5c7d6; }
.intro h1 {
  margin: 0; font-weight: 700; text-transform: uppercase;
  font-size: clamp(40px, 12.5vw, 76px); line-height: 0.98; letter-spacing: 0.1em;
}
.intro-sub { margin: 14px 0 22px; font-size: 18px; font-weight: 300; line-height: 1.45; letter-spacing: 0.02em; max-width: 30ch; }
.progress { height: 3px; background: rgba(255, 255, 255, 0.2); overflow: hidden; margin-bottom: 20px; transition: opacity 0.4s; }
.progress span { display: block; height: 100%; width: 0; background: #fff; transition: width 0.25s; }
.progress.done { opacity: 0; }
.intro-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.intro .btn-primary { background: #fff; color: var(--brand); }
#btn-start .label-ready, #btn-start:not(:disabled) .label-loading { display: none; }
#btn-start:not(:disabled) .label-ready { display: inline; }
.is-intro .era-badge { opacity: 0; }

/* ------------------------------------------------------------ Grafik-Einstellungen */
.settings {
  position: absolute; z-index: 45; right: 8px; top: calc(var(--bar-h) + var(--safe-t) + 8px);
  width: min(320px, calc(100% - 16px)); padding: 14px;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  animation: card-in 0.25s var(--ease);
}
.settings h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.14em; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--brand); border-radius: var(--radius); overflow: hidden; }
.seg button {
  min-height: 40px; border: 0; border-left: 1px solid var(--brand); background: var(--surface); color: var(--brand);
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-checked='true'] { background: var(--brand); color: #fff; }
.settings-note { margin: 10px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* ------------------------------------------------------------ Guide: Ferox, Dialog im Videospiel-Stil */
.portrait { position: relative; aspect-ratio: 3 / 4; }
.portrait img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 10px 18px rgba(20, 5, 15, 0.45));
  transform-origin: 50% 100%; animation: idle 4.5s ease-in-out infinite;
}
@keyframes idle { 50% { transform: translateY(-2px) scale(1.008); } }
.portrait.talking img { animation: talk-bob 0.7s ease-in-out infinite; }
@keyframes talk-bob { 50% { transform: translateY(-3px) rotate(-0.4deg); } }
.portrait.pose-point img { rotate: 2deg; translate: 6px 0; transition: rotate 0.6s var(--ease), translate 0.6s var(--ease); }
.portrait img.enter { animation: outfit-in 0.7s var(--ease) both; }
.portrait img.leave { animation: outfit-out 0.5s ease both; }
@keyframes outfit-in { from { opacity: 0; filter: brightness(3) blur(6px); transform: translateY(10px) scale(0.97); } }
@keyframes outfit-out { to { opacity: 0; filter: brightness(3) blur(6px); } }
/* Zeitsprung: kurzer goldener Lichtring hinter der Figur */
.portrait::before {
  content: ''; position: absolute; left: 50%; bottom: 18%; width: 120%; aspect-ratio: 1; translate: -50% 0;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 220, 140, 0.9) 0%, rgba(240, 180, 80, 0.35) 35%, transparent 65%);
}
.portrait.warp::before { animation: warp 0.9s ease-out; }
@keyframes warp { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.3); } }

/* Epochen-Themes fuer Dialogbox und Jahres-Uebergang (gesetzt ueber #app[data-era]) */
#app {
  --d-bg: linear-gradient(180deg, rgba(70, 22, 14, 0.96), rgba(36, 10, 6, 0.97));
  --d-inner: rgba(36, 10, 6, 0.95);
  --d-frame: #c8913a;
  --d-frame-l: #f0c76a;
  --d-text: #f8efe3;
  --d-muted: rgba(248, 239, 227, 0.62);
  --d-accent: #f0c76a;
  --d-name-bg: linear-gradient(180deg, #f3cf78, #b98232);
  --d-name-ink: #2a0e08;
  --d-name-font: 'Cinzel', Georgia, serif;
  --d-name-size: 19px;
  --d-name-case: uppercase;
  --d-text-font: var(--font);
  --d-text-size: 17px;
  --d-glow: none;
  --d-radius: 6px;
}
/* um 200: Badebetrieb – Wasserblau der Becken, Gold der Mosaiken */
#app[data-era='bad'] {
  --d-bg: linear-gradient(180deg, rgba(10, 70, 86, 0.96), rgba(6, 38, 50, 0.97));
  --d-inner: rgba(6, 38, 50, 0.95);
  --d-frame: #d4b05c; --d-frame-l: #f6dc8e; --d-accent: #f6dc8e;
  --d-name-bg: linear-gradient(180deg, #f6e1a0, #c7993e); --d-name-ink: #062a36;
}
/* 5. Jh.: Zuflucht in den Ruinen – Rauchgrau, gedecktes Ocker */
#app[data-era='spaet'] {
  --d-bg: linear-gradient(180deg, rgba(58, 54, 48, 0.97), rgba(30, 28, 25, 0.97));
  --d-inner: rgba(30, 28, 25, 0.95);
  --d-frame: #a88a5a; --d-frame-l: #d6bb86; --d-accent: #e0c690;
  --d-name-bg: #cdb17c; --d-name-ink: #2a2218;
  --d-radius: 3px;
}
/* um 170: Baustelle – Ziegelrot und Kalk, Kapitalis */
#app[data-era='bau'] {
  --d-bg: linear-gradient(180deg, rgba(92, 42, 26, 0.97), rgba(52, 24, 14, 0.97));
  --d-inner: rgba(52, 24, 14, 0.95);
  --d-frame: #d8cbb0; --d-frame-l: #f4ecda; --d-accent: #f0dcb0;
  --d-name-bg: #e8dcc2; --d-name-ink: #4a1e10;
  --d-radius: 2px;
}
/* um 1150: Pergament einer Handschrift, rote Rubrik */
#app[data-era='burg'] {
  --d-bg: linear-gradient(180deg, rgba(245, 233, 206, 0.98), rgba(229, 211, 170, 0.98));
  --d-inner: rgba(229, 211, 170, 0.9);
  --d-frame: #6b4a2a; --d-frame-l: #a0331f; --d-text: #3b2a17; --d-muted: rgba(59, 42, 23, 0.6); --d-accent: #9b2a1a;
  --d-name-bg: #9b2a1a; --d-name-ink: #f6e9cf;
  --d-name-font: 'Uncial Antiqua', Georgia, serif; --d-name-case: none; --d-name-size: 20px;
  --d-text-font: 'EB Garamond', Georgia, serif; --d-text-size: 19px;
  --d-radius: 2px;
}
/* um 1620: Kupferstich (Wiltheim, Merian) – helles Papier, schwarze Tinte, feiner Doppelrahmen */
#app[data-era='steinbruch'] {
  --d-bg: linear-gradient(180deg, rgba(246, 241, 228, 0.98), rgba(232, 224, 204, 0.98));
  --d-inner: rgba(246, 241, 228, 0.95);
  --d-frame: #2a2622; --d-frame-l: #2a2622; --d-text: #1f1b17; --d-muted: rgba(31, 27, 23, 0.6); --d-accent: #3a3027;
  --d-name-bg: #2a2622; --d-name-ink: #f4eedf;
  --d-name-font: 'EB Garamond', Georgia, serif; --d-name-case: none; --d-name-size: 21px;
  --d-text-font: 'EB Garamond', Georgia, serif; --d-text-size: 19px;
  --d-radius: 0;
}
#app[data-era='steinbruch'] .dialog { box-shadow: inset 0 0 0 4px var(--d-inner), inset 0 0 0 5px #2a2622, 0 14px 40px rgba(0, 0, 0, 0.4); }
/* ab 1816: Grabungstagebuch – vergilbtes Papier, Tinte, doppelter Rahmen, Antiqua */
#app[data-era='grabung'] {
  --d-bg: linear-gradient(180deg, rgba(244, 236, 214, 0.98), rgba(228, 215, 186, 0.98));
  --d-inner: rgba(244, 236, 214, 0.95);
  --d-frame: #5a4630; --d-frame-l: #5a4630; --d-text: #2e2418; --d-muted: rgba(46, 36, 24, 0.6); --d-accent: #7a4b22;
  --d-name-bg: #5a4630; --d-name-ink: #f6eedb;
  --d-name-font: 'Playfair Display', Georgia, serif; --d-name-case: none; --d-name-size: 21px;
  --d-text-font: 'EB Garamond', Georgia, serif; --d-text-size: 19px;
  --d-radius: 0;
}
#app[data-era='grabung'] .dialog { box-shadow: inset 0 0 0 4px var(--d-inner), inset 0 0 0 5px #5a4630, 0 14px 40px rgba(0, 0, 0, 0.4); }
#app[data-era='grabung'] .ew-label { color: #f0dcb4; }
#app[data-era='steinbruch'] .ew-label { color: #f4eedf; }
/* Heute: Trier-CI, hell und klar */
#app[data-era='heute'] {
  --d-bg: rgba(255, 255, 255, 0.97);
  --d-inner: rgba(255, 255, 255, 0.95);
  --d-frame: #450c34; --d-frame-l: #e73452; --d-text: #2b2b2b; --d-muted: #6b6a6a; --d-accent: #450c34;
  --d-name-bg: #450c34; --d-name-ink: #fff;
  --d-name-font: var(--font); --d-name-size: 18px;
  --d-radius: 6px;
}

.guide { position: absolute; z-index: 32; left: 0; right: 0; bottom: 0;
  padding: 0 8px calc(8px + var(--safe-b));
  transform: translateY(calc(100% + 280px)); visibility: hidden; pointer-events: none;
  transition: transform 0.6s var(--ease), visibility 0.6s, opacity 0.45s;
}
.is-tour .guide { transform: none; visibility: visible; }
/* Waehrend des Jahres-Uebergangs taucht der Dialog kurz ab */
.is-tour.is-warping .guide { transform: translateY(70px); opacity: 0; pointer-events: none; }
.is-tour.is-warping .guide * { pointer-events: none; }
.is-warping .era-warp.play { pointer-events: auto; cursor: pointer; }
.guide > .guide-avatar { position: absolute; z-index: 0; left: -6px; bottom: calc(100% - 64px); width: 210px; pointer-events: none; }

.dialog {
  position: relative; z-index: 1; pointer-events: auto; cursor: pointer; user-select: none;
  padding: 26px 16px 8px;
  border: 2px solid var(--d-frame); border-radius: var(--d-radius);
  background: var(--d-bg);
  box-shadow: inset 0 0 0 3px var(--d-inner), inset 0 0 0 4px color-mix(in srgb, var(--d-frame-l) 40%, transparent), 0 14px 40px rgba(0, 0, 0, 0.45), var(--d-glow);
  color: var(--d-text);
  transition: background 0.6s, color 0.6s, border-color 0.6s, border-radius 0.6s, box-shadow 0.6s;
}
/* Ecknieten */
.dialog::before, .dialog::after {
  content: ''; position: absolute; top: 6px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--d-frame-l); transition: background 0.6s;
}
.dialog::before { left: 6px; }
.dialog::after { right: 6px; }

.dialog-name {
  position: absolute; left: 14px; top: -17px;
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 18px 6px 14px;
  background: var(--d-name-bg); color: var(--d-name-ink);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.dialog-name span {
  font-family: var(--d-name-font); font-weight: 700; font-size: var(--d-name-size);
  letter-spacing: 0.08em; line-height: 1; text-transform: var(--d-name-case);
}
.dialog-name small { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.8; }
.dialog-close {
  position: absolute; right: 4px; top: 4px; width: 40px; height: 40px;
  display: grid; place-items: center; border: 0; border-radius: var(--radius); background: none; color: var(--d-muted);
}
.dialog-close:active { background: color-mix(in srgb, var(--d-text) 12%, transparent); }
.dialog-chapter {
  display: flex; flex-wrap: wrap; gap: 0 8px; margin: 0 36px 6px 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--d-accent);
}
.dialog-chapter b { color: var(--d-text); font-weight: 700; }
.dialog-chapter b::before { content: '—'; margin-right: 8px; color: var(--d-frame); }
.dialog-text {
  display: grid; margin: 0; font-family: var(--d-text-font); font-size: var(--d-text-size);
  line-height: 1.5; letter-spacing: 0.01em;
}
.say-ghost, .say-typed { grid-area: 1 / 1; }
.say-ghost { visibility: hidden; }
.dialog.swap .dialog-chapter { animation: card-in 0.45s var(--ease) both; }

/* Gesten-Hilfe in der Einleitung */
.dialog-gestures { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 2px; padding: 0; }
.dialog-gestures li {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; text-align: center;
  border: 1px solid color-mix(in srgb, var(--d-accent) 30%, transparent); border-radius: 6px;
  background: color-mix(in srgb, var(--d-accent) 7%, transparent);
}
.dialog-gestures svg { width: 40px; height: 40px; margin-bottom: 4px; stroke-width: 1.7; color: var(--d-accent); overflow: visible; }
.dialog-gestures .gi-btn { fill: currentColor; }
.dialog-gestures strong { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.dialog-gestures small { font-size: 12px; line-height: 1.3; color: var(--d-muted); }
.gi-swipe { animation: gi-swipe 2s ease-in-out infinite; }
@keyframes gi-swipe { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
.gi-pinch-a { animation: gi-pinch-a 1.8s ease-in-out infinite; }
.gi-pinch-b { animation: gi-pinch-b 1.8s ease-in-out infinite; }
@keyframes gi-pinch-a { 50% { transform: translate(-2.5px, 2.5px); } }
@keyframes gi-pinch-b { 50% { transform: translate(2.5px, -2.5px); } }
.gi-pan { animation: gi-pan 2.4s ease-in-out infinite; }
@keyframes gi-pan { 25% { transform: translate(-2px, -1px); } 75% { transform: translate(2px, 1px); } }
.gi-wheel { animation: gi-wheel 1.2s ease-in-out infinite; }
@keyframes gi-wheel { 50% { transform: translateY(2px); } }

.dialog-choices { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 2px; }
.choice {
  position: relative; min-height: 44px; padding: 0 12px 0 30px; text-align: left;
  border: 1px solid color-mix(in srgb, var(--d-frame-l) 40%, transparent); border-radius: 4px;
  background: color-mix(in srgb, var(--d-text) 5%, transparent);
  color: var(--d-text); font-size: 15px; font-weight: 600; letter-spacing: 0.04em;
  transition: background 0.2s, border-color 0.2s;
}
.choice::before { content: '▸'; position: absolute; left: 12px; color: var(--d-accent); transition: transform 0.2s; }
.choice:hover, .choice:focus-visible { background: color-mix(in srgb, var(--d-accent) 18%, transparent); border-color: var(--d-accent); }
.choice:hover::before, .choice:focus-visible::before { transform: translateX(3px); }
.choice:first-child { border-color: var(--d-accent); background: color-mix(in srgb, var(--d-accent) 14%, transparent); }

.dialog-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.dlg-btn {
  min-width: 40px; height: 36px; padding: 0 8px; display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--d-accent) 35%, transparent); border-radius: 4px; background: none; color: var(--d-accent);
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
}
.dlg-btn svg { width: 18px; height: 18px; }
.dlg-btn:disabled { opacity: 0.3; cursor: default; }
.dlg-auto[aria-pressed='true'] { background: var(--d-accent); border-color: var(--d-accent); color: var(--d-inner); }
.dialog-count { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; color: var(--d-muted); font-variant-numeric: tabular-nums; }
.dlg-next {
  margin-left: auto; min-height: 44px; padding: 0 6px 0 12px; display: flex; align-items: center; gap: 8px;
  border: 0; background: none; color: var(--d-text); font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.dlg-next i { width: 0; height: 0; border: 7px solid transparent; border-top: 9px solid var(--d-accent); border-bottom: 0; opacity: 0.35; }
.dialog.ready .dlg-next i { opacity: 1; animation: nudge 0.9s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }
.dialog.is-final .dlg-next, .dialog.is-final .dlg-auto { display: none; }
.dlg-menu { display: flex; gap: 6px; padding: 0 10px; }
.dlg-menu[aria-expanded='true'] { background: var(--d-accent); color: var(--d-inner); }
.dialog-pages { display: flex; gap: 4px; }
.dialog-pages i { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--d-text) 30%, transparent); }
.dialog-pages i.on { background: var(--d-accent); }

/* Kapitel-Menue: oeffnet sich ueber der Dialogbox, im Design der aktuellen Epoche */
.chapters {
  position: absolute; z-index: 3; right: 8px; bottom: calc(100% - 4px); width: min(320px, calc(100% - 16px));
  max-height: min(60vh, 460px); overflow-y: auto; pointer-events: auto;
  padding: 12px 10px 10px; border: 2px solid var(--d-frame); border-radius: var(--d-radius);
  background: var(--d-bg); color: var(--d-text);
  box-shadow: inset 0 0 0 3px var(--d-inner), 0 14px 40px rgba(0, 0, 0, 0.45);
  animation: card-in 0.25s var(--ease);
}
.chapters-title { margin: 0 4px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--d-accent); }
.chapter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.chapter {
  display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 42px; padding: 8px 10px; text-align: left;
  border: 1px solid transparent; border-radius: 4px; background: none; color: var(--d-text);
}
.chapter:hover, .chapter:focus-visible { background: color-mix(in srgb, var(--d-accent) 14%, transparent); }
.chapter[aria-current='step'] { border-color: var(--d-accent); background: color-mix(in srgb, var(--d-accent) 18%, transparent); }
.ch-year { flex: none; min-width: 7.5em; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--d-accent); }
.ch-name { font-size: 15px; font-weight: 600; }
.is-warping .chapters { display: none; }

/* ------------------------------------------------------------ Jahres-Uebergang */
.era-warp {
  position: absolute; z-index: 34; left: 0; right: 0; top: 40%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  translate: 0 -50%; pointer-events: none; text-align: center; color: #fff;
  padding: 0 20px; opacity: 0; visibility: hidden;
}
.era-warp::before {
  content: ''; position: absolute; inset: -50px -10%; z-index: -1;
  background: radial-gradient(closest-side, rgba(10, 4, 8, 0.55), transparent);
}
.ew-year {
  font-family: var(--d-name-font); font-weight: 700; line-height: 1;
  font-size: clamp(30px, 11vw, 104px); letter-spacing: 0.06em; text-transform: uppercase;
  max-width: 100%; text-wrap: balance;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.4);
  font-variant-numeric: tabular-nums;
}
.ew-label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--d-frame-l); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
#app[data-era='burg'] .ew-label { color: #f3e1b5; }
#app[data-era='heute'] .ew-label { color: #fff; }
.ew-line { width: min(260px, 60vw); height: 2px; background: linear-gradient(90deg, transparent, var(--d-frame-l), transparent); }
.era-warp.play { visibility: visible; animation: ew-show 3.6s var(--ease) both; }
.era-warp.play .ew-line { animation: ew-line 3.6s var(--ease) both; }
.era-warp.play .ew-year { animation: ew-year 3.6s var(--ease) both; }
@keyframes ew-show { 0% { opacity: 0; } 8%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ew-line { 0% { transform: scaleX(0); } 20%, 100% { transform: scaleX(1); } }
@keyframes ew-year {
  0% { transform: scale(0.86); filter: blur(10px); }
  20% { transform: scale(1); filter: blur(0); }
  100% { transform: scale(0.96); }
}

.is-tour .sheet { transform: translateY(100%); }
.is-tour .toast { bottom: calc(var(--dock-h, 300px) + var(--safe-b) + 16px); }
.is-tour .gesture-hint { bottom: auto; top: calc(var(--bar-h) + var(--safe-t) + 74px); }

/* Ferox im Intro */
.intro-guide { display: flex; align-items: flex-end; gap: 4px; margin: 0 0 18px -10px; }
.intro-guide .guide-avatar { width: 116px; flex: none; }
.intro-bubble {
  position: relative; margin: 0 0 28px; padding: 10px 14px; max-width: 30ch;
  border: 2px solid #c8913a; border-radius: 6px; background: rgba(26, 6, 20, 0.92); color: #f6eee6;
  font-size: 15px; line-height: 1.45;
}
.intro-bubble strong { font-family: 'Cinzel', Georgia, serif; color: #f0c76a; letter-spacing: 0.06em; }
@media (max-height: 740px) and (max-width: 959px) {
  .intro-sub { display: none; }
  .intro h1 { margin-bottom: 10px; }
}

/* ------------------------------------------------------------ Toast */
.toast {
  position: absolute; z-index: 60; left: 50%; bottom: calc(var(--peek) + var(--safe-b) + 16px);
  transform: translate(-50%, 0); visibility: hidden; opacity: 0; margin-bottom: -16px;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--radius);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: opacity 0.3s, visibility 0.3s, margin 0.4s var(--ease);
}
.toast.show { visibility: visible; opacity: 1; margin-bottom: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ Tablet / Desktop */
@media (min-width: 960px) {
  :root { --panel-w: 400px; --bar-h: 64px; }
  .topbar { padding: 0 16px 0 12px; }
  .brand-city { font-size: 30px; }
  .sheet {
    left: 16px; right: auto; top: calc(var(--bar-h) + 16px); bottom: 16px; height: auto; width: var(--panel-w);
    border-radius: var(--radius);
    transform: none;
  }
  .is-intro .sheet { transform: translateX(calc(-100% - 24px)); }
  .sheet-grab { cursor: default; padding-top: 4px; }
  .sheet-handle { display: none; }
  .era-badge { left: calc(var(--panel-w) + 40px); }
  .era-year { font-size: 28px; }
  .gesture-hint { left: calc(50% + 208px); bottom: 32px; }
  .toast { left: calc(50% + 208px); bottom: 32px; }
  .intro { align-items: center; background: linear-gradient(to right, rgba(50, 8, 36, 0.94) 0%, rgba(50, 8, 36, 0.75) 38%, rgba(50, 8, 36, 0) 72%); }
  .intro-inner { padding: 0 0 0 8vw; }
  .intro-actions { flex-direction: row; align-items: center; gap: 16px; }
  .intro-guide .guide-avatar { width: 150px; }
  .guide {
    left: 50%; right: auto; bottom: 24px; width: min(920px, calc(100% - 48px)); padding: 0 0 0 260px;
    transform: translate(-50%, calc(100% + 340px));
  }
  .is-tour .guide { transform: translate(-50%, 0); }
  .is-tour.is-warping .guide { transform: translate(-50%, 90px); }
  .guide > .guide-avatar { left: -30px; bottom: -24px; width: 360px; }
  .dialog { padding: 30px 26px 10px; min-height: 210px; }
  .dialog-text { font-size: 19px; }
  .is-tour .sheet { transform: translateX(calc(-100% - 24px)); }
  .is-tour .era-badge { left: 16px; }
  .is-tour .toast { bottom: calc(var(--dock-h, 260px) + 40px); left: 50%; }
  .is-tour .gesture-hint { left: 50%; }
  .no-sheet .era-badge { left: 16px; }
  .no-sheet .gesture-hint, .no-sheet .toast { left: 50%; }
}

/* Panel Zeitreise/Entdecken/Besuchen vorerst ausgeblendet (SHEET_ON in main.js) */
.no-sheet { --peek: 8px; }
.no-sheet .sheet { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 420px) {
  .dlg-menu span { display: none; }
  .dlg-menu { padding: 0 8px; }
  .dialog-foot { gap: 5px; }
}

/* ------------------------------------------------------------ Detailfenster (Eisenklammer) */
.detail-card {
  position: absolute; z-index: 33; right: 12px; top: calc(var(--bar-h) + var(--safe-t) + 12px);
  width: min(48vw, 280px); margin: 0; padding: 0 0 8px; overflow: hidden;
  border: 2px solid var(--d-frame); border-radius: var(--d-radius);
  background: var(--d-bg); color: var(--d-text);
  box-shadow: inset 0 0 0 3px var(--d-inner), 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: card-in 0.4s var(--ease);
}
.detail-card canvas { display: block; width: 100%; aspect-ratio: 4 / 3; touch-action: none; cursor: grab;
  background: radial-gradient(circle at 50% 38%, #5a4a3e, #241812 75%); }
.detail-card { background-color: #1e1410; }
.detail-card figcaption { display: flex; flex-direction: column; gap: 1px; padding: 2px 12px 0; }
.detail-card strong { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--d-accent); }
.detail-card span { font-size: 12px; color: var(--d-muted); }
.detail-close {
  position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius); background: rgba(0, 0, 0, 0.25); color: #fff;
}
.is-warping .detail-card { display: none; }
@media (min-width: 960px) {
  .detail-card { width: 320px; right: 24px; top: calc(var(--bar-h) + 24px); }
}
