/* =========================================================
   Nathan der Weise – Escape Room
   ---------------------------------------------------------
   Visuelles Konzept: "Kerzenbeleuchtetes Studierzimmer in
   Jerusalem, 1192". Warmes, dunkles Tinten-/Pergament-
   Farbschema mit Safran-Gold als Leitfarbe und Lapis-Blau
   als Zweitakzent. Modern, ruhig, lesbar – kein Kostümkitsch.
   Eine einzige globale Stylesheet-Datei, kein Build-Step.
   ========================================================= */

:root {
  /* --- Oberflächen: warme Tinte bei Kerzenlicht ------------------ */
  --bg:            #15110c;
  --bg-elevated:   #1f1812;
  --bg-elevated-2: #281f16;
  --bg-hover:      #34281b;
  --border:        #3c2f21;
  --border-soft:   #2c2218;

  /* --- Schrift: Tinte auf Pergament ----------------------------- */
  --text:        #f1e7d6;
  --text-muted:  #bdac93;
  --text-faint:  #867660;

  /* --- Safran / Gold – Leitakzent ------------------------------- */
  --accent:        #d8a24a;
  --accent-strong: #f1c66c;
  --accent-soft:   rgba(216, 162, 74, 0.14);
  --accent-border: rgba(216, 162, 74, 0.38);
  --accent-ink:    #20170a; /* dunkle Schrift auf Gold-Flächen */

  /* --- Lapislazuli – Zweitakzent (Links, Sekundär-Buttons) ------ */
  --lapis:        #6ea2c4;
  --lapis-strong: #9ac8e4;
  --lapis-soft:   rgba(110, 162, 196, 0.14);
  --lapis-border: rgba(110, 162, 196, 0.38);

  /* --- Rückmeldungen -------------------------------------------- */
  --success:      #82b676;
  --success-soft: rgba(130, 182, 118, 0.15);
  --error:        #d8745f;
  --error-soft:   rgba(216, 116, 95, 0.15);

  /* --- Typografie ----------------------------------------------- */
  --font-sans:  "Outfit", "Century Gothic", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Spectral", Georgia, "Times New Roman", serif;

  /* --- Abstände (4px-Raster) ------------------------------------ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* --- Radien --------------------------------------------------- */
  --radius:     14px;
  --radius-sm:  9px;
  --radius-lg:  20px;
  --radius-pill: 999px;

  /* --- Schatten (warm getönt, geschichtet) ---------------------- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 12px 30px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.72), 0 8px 18px rgba(0, 0, 0, 0.4);

  /* --- Bewegung ------------------------------------------------- */
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  /* Kerzenlicht aus den Ecken + feine Pergamentkörnung (selbsthaltend) */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E"),
    radial-gradient(1100px 760px at 12% -8%, rgba(216, 162, 74, 0.08), transparent 58%),
    radial-gradient(960px 700px at 102% 4%, rgba(110, 162, 196, 0.06), transparent 55%),
    linear-gradient(180deg, #1a140d 0%, var(--bg) 60%);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 0 0 0.5em;
  letter-spacing: 0.005em;
  line-height: 1.2;
  color: var(--text);
}

a {
  color: var(--lapis-strong);
  text-decoration: none;
  text-underline-offset: 3px;
}
a:hover { text-decoration: underline; }

p { margin: 0 0 0.75em; }

strong { color: #fbf3e4; font-weight: 600; }

::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* Schlanke, themengetreue Scrollbalken */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); background-clip: padding-box; }

/* Einheitliche, gut sichtbare Fokus-Markierung (Tastatur):
   klarer Gold-Ring mit Abstand statt diffusem Schimmer. */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  box-shadow: none;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------
   Layout-Helfer
   --------------------------------------------------------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }

/* ---------------------------------------------------------
   Marke / Kopfzeile
   --------------------------------------------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.brand .lamp {
  font-size: 1.7em;
  line-height: 1;
  filter: drop-shadow(0 2px 10px rgba(216, 162, 74, 0.45));
  animation: lamp-flicker 5s ease-in-out infinite;
}
@keyframes lamp-flicker {
  0%, 100% { filter: drop-shadow(0 2px 10px rgba(216, 162, 74, 0.45)); }
  45%      { filter: drop-shadow(0 2px 14px rgba(216, 162, 74, 0.7)); }
  60%      { filter: drop-shadow(0 2px 8px rgba(216, 162, 74, 0.35)); }
}
.brand h1 {
  font-size: 1.5em;
  margin: 0;
  background: linear-gradient(135deg, var(--accent-strong) 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .subtitle {
  color: var(--text-muted);
  font-size: 0.86em;
  margin-top: 3px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------
   Paneele / Karten
   --------------------------------------------------------- */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 120px),
    var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.panel + .panel { margin-top: var(--space-4); }
.panel h2, .panel h3 {
  color: var(--accent-strong);
  letter-spacing: 0.01em;
}
.panel > h2:first-child,
.panel > h3:first-child { margin-top: 0; }

.card {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.excerpt-box {
  background:
    linear-gradient(180deg, rgba(216, 162, 74, 0.04), transparent),
    var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
  font-family: var(--font-serif);
  font-size: 1.02em;
  line-height: 1.65;
  white-space: pre-line;
}
.excerpt-box mark,
.book-text mark {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 3px;
  padding: 0 3px;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-4);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.02), transparent 70%),
    var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.chat-bubble {
  max-width: 85%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  line-height: 1.45;
  font-size: 0.95em;
  box-shadow: var(--shadow-sm);
}
.chat-bubble.chat-npc {
  align-self: flex-start;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 3px;
}
.chat-bubble.chat-npc strong { color: var(--accent-strong); }
.chat-bubble.chat-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(110, 162, 196, 0.2), var(--lapis-soft));
  border: 1px solid var(--lapis-border);
  color: var(--text);
  border-bottom-right-radius: 3px;
}

/* ---------------------------------------------------------
   Formulare
   --------------------------------------------------------- */
label {
  display: block;
  font-size: 0.82em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="search"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1em;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
input[type="text"]::placeholder,
input[type="search"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder { color: var(--text-faint); }

input[type="text"]:hover,
input[type="search"]:hover,
input[type="password"]:hover,
textarea:hover,
select:hover { border-color: var(--accent-border); }

input[type="text"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

/* Eigene, "designte" Auswahl-Pfeile statt Browser-Standard */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23bdac93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
select option { background: var(--bg-elevated); color: var(--text); }

.field { margin-bottom: var(--space-4); }

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.94em;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.08s ease, background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition), filter var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
/* Hover = sanftes Umfärben in Gold-Ton (statt Aufhellen ins Bräunliche) */
.btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
/* Deaktiviert/Ladezustand: flach, voll deckend, kein Schimmer (sonst wird
   das Gold halbtransparent über dem dunklen Grund matschig-braun). */
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: var(--accent-ink);
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover {
  filter: brightness(1.05);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 8px 20px -10px rgba(241, 198, 108, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Sekundär = Lapis-getönt (z.B. "Lektüre öffnen", "Beitreten") */
.btn-secondary {
  background: var(--lapis-soft);
  border-color: var(--lapis-border);
  color: var(--lapis-strong);
}
.btn-secondary:hover {
  background: rgba(110, 162, 196, 0.22);
  border-color: var(--lapis);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: rgba(255, 255, 255, 0.04); }

/* Destruktiv = Terrakotta (z.B. "Spiel verlassen") */
.btn-danger {
  background: var(--error-soft);
  border-color: var(--error);
  color: var(--error);
}
.btn-danger:hover {
  background: rgba(216, 116, 95, 0.24);
  border-color: var(--error);
  color: #f0a392;
}

.btn-sm { padding: 7px 13px; font-size: 0.84em; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------
   Lobby
   --------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* Hero / Einstieg */
.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-5);
  padding: var(--space-8) var(--space-6);
  background:
    radial-gradient(900px 440px at 86% -45%, rgba(216, 162, 74, 0.16), transparent 60%),
    radial-gradient(680px 380px at -5% 125%, rgba(110, 162, 196, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 55%),
    var(--bg-elevated);
}
/* Dezente, große Lampe als Dekor in der Hero-Ecke */
.hero::after {
  content: "🏮";
  position: absolute;
  top: -18px; right: 26px;
  font-size: 9em;
  opacity: 0.07;
  transform: rotate(8deg);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 700px; }
.hero-eyebrow {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-strong);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  padding: 4px 13px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-4);
}
.hero-title {
  font-size: clamp(2em, 4.8vw, 3.1em);
  line-height: 1.07;
  margin: 0 0 var(--space-3);
  background: linear-gradient(135deg, var(--accent-strong) 12%, var(--accent) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead {
  font-size: 1.08em;
  color: var(--text-muted);
  max-width: 58ch;
  margin: 0 0 var(--space-6);
}
.hero-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
}
.hero-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.hero-step-icon { font-size: 1.5em; line-height: 1.15; }
.hero-step strong {
  display: block;
  font-family: var(--font-serif);
  color: var(--text);
  margin-bottom: 2px;
}
.hero-step .small { display: block; line-height: 1.35; }
@media (max-width: 640px) {
  .hero { padding: var(--space-6) var(--space-5); }
  .hero::after { font-size: 6em; }
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  align-items: start;
}
/* Beide Spalten oben bündig – nicht durch ".panel + .panel" versetzen */
.lobby-grid .panel { margin-top: 0; }
@media (max-width: 800px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

.game-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 360px; overflow-y: auto; padding-right: var(--space-1); }
.game-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}
.game-list-item:hover {
  border-color: var(--accent-border);
  transform: translateX(2px);
  background: var(--bg-hover);
}
.game-list-item .team-name { font-weight: 600; font-family: var(--font-serif); font-size: 1.05em; }
.game-list-item .meta { color: var(--text-muted); font-size: 0.84em; margin-top: 2px; }
.game-list-item .meta strong { color: var(--accent-strong); letter-spacing: 0.06em; }
.empty-hint {
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-6) var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.012);
  font-size: 0.92em;
}

/* ---------------------------------------------------------
   Spielfenster-Layout
   --------------------------------------------------------- */
.game-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-4);
  height: 100vh;
  padding: var(--space-4);
}
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; height: auto; }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
  padding-right: var(--space-1);
}
.sidebar .panel { padding: var(--space-4); }

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9em;
}
.status-row:last-child { border-bottom: none; }
.status-row .label { color: var(--text-muted); }
.status-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

#status-code { letter-spacing: 0.12em; color: var(--accent-strong); }
#timer { font-variant-numeric: tabular-nums; }
#timer.warning { color: var(--error); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: var(--space-2);
}
.inventory-item {
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(216, 162, 74, 0.08), transparent 70%),
    var(--bg-elevated-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-1);
  text-align: center;
  font-size: 1.6em;
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.inventory-item:hover {
  border-color: var(--accent-border);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.inventory-item .item-label {
  display: block;
  font-size: 0.32em;
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.2;
  font-weight: 600;
}
.inventory-empty { color: var(--text-faint); font-size: 0.85em; font-style: italic; }

.item-modal-icon {
  font-size: 3.2em;
  text-align: center;
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

/* ---------------------------------------------------------
   Karte
   --------------------------------------------------------- */
.map-wrapper {
  position: relative;
  line-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.map-image {
  width: 100%;
  display: block;
}
/* Kleine, kräftige Pin-Punkte. Farben so gewählt, dass sie sich klar vom
   gelb-sandfarbenen Kartenhintergrund abheben; weißer Ring zur Trennung. */
.map-marker {
  position: absolute;
  width: 2.6%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-sizing: border-box;
  transition: box-shadow var(--transition), background var(--transition);
}
.map-marker.locked {
  background: #313a477a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 1px 5px rgba(0, 0, 0, 0.5);
}
.map-marker.done {
  background: #1f9d578a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92), 0 1px 5px rgba(0, 0, 0, 0.45);
}
.map-marker.current {
  background: #2f7fd18a;
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(47, 127, 209, 0.35), 0 0 12px rgba(47, 127, 209, 0.85);
  animation: map-pulse 1.6s ease-in-out infinite;
}
@keyframes map-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(47, 127, 209, 0.3), 0 0 8px rgba(47, 127, 209, 0.6); }
  50%      { box-shadow: 0 0 0 2px #fff, 0 0 0 8px rgba(47, 127, 209, 0.12), 0 0 18px rgba(47, 127, 209, 0.95); }
}

.code-digits { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.code-digit {
  width: 34px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent-border);
  background:
    linear-gradient(180deg, rgba(241, 198, 108, 0.12), var(--accent-soft));
  color: var(--accent-strong);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ---------------------------------------------------------
   Szene / Hotspots
   --------------------------------------------------------- */
.scene-wrapper {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.scene-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}
.scene-header h2 { margin: 0; font-size: 1.15em; color: var(--accent-strong); }

.scene-svg-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}
.scene-svg-container svg {
  width: 100%;
  height: auto;
  max-height: 70vh;
  border-radius: var(--radius-sm);
}

.hotspot {
  cursor: pointer;
}
.hotspot .hotspot-shape {
  fill: rgba(255, 255, 255, 0);
  stroke: rgba(241, 198, 108, 0);
  stroke-width: 2;
  transition: fill 0.18s ease, stroke 0.18s ease;
  vector-effect: non-scaling-stroke;
}
/* Dezenter Dauerhinweis: ungelöste, freie Hotspots leicht andeuten */
.hotspot:not(.solved):not(.locked) .hotspot-shape {
  stroke: rgba(241, 198, 108, 0.28);
  stroke-dasharray: 7 6;
  animation: hotspot-breathe 3.4s ease-in-out infinite;
}
@keyframes hotspot-breathe {
  0%, 100% { stroke-opacity: 0.5; }
  50%      { stroke-opacity: 1; }
}
.hotspot:not(.locked):hover .hotspot-shape {
  fill: rgba(241, 198, 108, 0.22);
  stroke: rgba(241, 198, 108, 0.95);
  stroke-dasharray: none;
}
.hotspot.solved .hotspot-shape {
  fill: rgba(130, 182, 118, 0.14);
  stroke: rgba(130, 182, 118, 0);
}
.hotspot.solved:hover .hotspot-shape {
  stroke: rgba(130, 182, 118, 0.85);
}
.hotspot.locked {
  cursor: not-allowed;
}
.hotspot.locked .hotspot-shape {
  fill: rgba(8, 6, 4, 0.28);
  stroke: rgba(8, 6, 4, 0);
}
.hotspot.locked:hover .hotspot-shape {
  stroke: rgba(8, 6, 4, 0.45);
}

.hotspot-label-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.18), transparent);
}
.hotspot-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), background var(--transition), color var(--transition);
}
.hotspot-chip:hover { border-color: var(--accent-border); transform: translateY(-2px); color: var(--accent-strong); }
.hotspot-chip.solved {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}
.hotspot-chip.solved:hover { color: var(--success); }
.hotspot-chip.locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.hotspot-chip.locked:hover { transform: none; border-color: var(--border); color: inherit; }

/* ---------------------------------------------------------
   Modal (Rätsel, Buch, etc.)
   --------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.66);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-5);
  animation: backdrop-in 0.18s ease;
}
.modal-backdrop.hidden { display: none; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 160px),
    var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.modal-wide { max-width: 900px; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(216, 162, 74, 0.06), transparent);
}
.modal-header h3 { margin: 0; color: var(--accent-strong); font-size: 1.2em; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5em;
  cursor: pointer;
  line-height: 1;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
}
.modal-body ul { margin: 0.4em 0 0.6em; padding-left: 1.25em; }
.modal-body li { margin-bottom: 0.3em; }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.18);
}

/* ---------------------------------------------------------
   Rätsel-UI
   --------------------------------------------------------- */
.option-list { display: flex; flex-direction: column; gap: var(--space-2); }
.option-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-elevated-2);
  transition: border-color var(--transition), background var(--transition), transform 0.08s ease;
}
.option-item::before {
  content: "";
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.option-item:hover { border-color: var(--accent-border); background: var(--bg-hover); }
.option-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.option-item.selected::before {
  border-color: var(--accent);
  background: radial-gradient(circle at center, var(--accent-strong) 38%, transparent 42%);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 600px) {
  .matching-grid { grid-template-columns: 1fr; }
}
.matching-col h4 { font-size: 0.78em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-sans); }
.matching-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated-2);
  margin-bottom: var(--space-2);
  font-size: 0.92em;
}
.matching-item select { margin-top: var(--space-2); }

.code-hints-list { margin: var(--space-3) 0; }
.code-hints-table { width: 100%; border-collapse: collapse; margin-top: var(--space-1); }
.code-hints-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.95em;
}
.code-hints-table tr:last-child td { border-bottom: none; }
.code-hints-table td.code-digit-cell { width: 1%; text-align: right; }
.code-hints-table .code-digit { margin-left: auto; }

.code-input-row { display: flex; gap: var(--space-2); justify-content: center; margin: var(--space-5) 0; }
.code-input-row input {
  width: 52px; height: 60px;
  text-align: center;
  font-size: 1.7em;
  font-weight: 700;
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.feedback-box {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.92em;
  line-height: 1.5;
}
.feedback-box.correct { background: var(--success-soft); border: 1px solid var(--success); color: var(--success); }
.feedback-box.incorrect { background: var(--error-soft); border: 1px solid var(--error); color: var(--error); }
.feedback-box.error { background: var(--error-soft); border: 1px solid var(--error); color: var(--text); }
.feedback-box.hidden { display: none; }
.hidden { display: none !important; }

.hint-area .card {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.book-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.84em;
  margin-top: var(--space-1);
}

/* ---------------------------------------------------------
   Lektüre / Buch-Fenster
   --------------------------------------------------------- */
.book-toc {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.book-toc button {
  font-size: 0.8em;
  padding: 6px 11px;
}
.book-text {
  font-family: var(--font-serif);
  font-size: 1.06em;
  white-space: pre-wrap;
  line-height: 1.75;
  background:
    linear-gradient(180deg, rgba(216, 162, 74, 0.03), transparent 120px),
    var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-5) var(--space-5);
  max-height: 50vh;
  overflow-y: auto;
}
.book-text mark {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 3px;
  padding: 0 3px;
}

/* ---------------------------------------------------------
   Bestenliste
   --------------------------------------------------------- */
table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
table.leaderboard th, table.leaderboard td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
}
table.leaderboard th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.74em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
table.leaderboard tbody tr { transition: background var(--transition); }
table.leaderboard tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
table.leaderboard tbody td { font-variant-numeric: tabular-nums; }
table.leaderboard tbody td:nth-child(2) { font-variant-numeric: normal; font-weight: 600; font-family: var(--font-serif); }
/* Gold/Silber/Bronze für die ersten drei Ränge */
table.leaderboard tbody tr:nth-child(1) td:first-child { color: var(--accent-strong); font-weight: 700; }
table.leaderboard tbody tr:nth-child(2) td:first-child { color: #cfd2d6; font-weight: 700; }
table.leaderboard tbody tr:nth-child(3) td:first-child { color: #c9885a; font-weight: 700; }

/* ---------------------------------------------------------
   Toast-Benachrichtigungen
   --------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
    var(--bg-elevated-2);
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  box-shadow: var(--shadow);
  font-size: 0.9em;
  line-height: 1.45;
  animation: toast-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------------------------------------------------------
   Sonstiges
   --------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.74em;
  font-weight: 700;
  letter-spacing: 0.03em;
}
hr.divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: var(--space-4) 0;
}
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
   Barrierefreiheit: Bewegung reduzieren
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
