:root {
  --bg: #1f2430;
  --bg-2: #2b3040;
  --panel: #2f3547;
  --text: #f1f3f8;
  --muted: #a9b0c3;
  --accent: #ffd60a;
  --accent-2: #2f7eb3;
  --danger: #b3362f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Startbildschirm ---------- */

#screen-start {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 24px) calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 24px) calc(var(--safe-left) + 20px);
}

.start-inner { max-width: 520px; margin: 0 auto; width: 100%; }

h1 {
  margin: 0 0 8px;
  font-size: 2.4rem;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #ffd60a, #d27e10 40%, #2f7eb3 70%, #581c69);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 24px 0 8px; }

.tagline { color: var(--muted); line-height: 1.45; margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.status { min-height: 1.4em; color: var(--accent); font-size: 0.9rem; }

.level-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.level-list li { display: flex; gap: 8px; }

/* Kachelansicht der Mosaike */
.level-list.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.level-list.tiles li { display: block; position: relative; min-width: 0; }
.level-tile {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 10px;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.level-tile:active { background: var(--bg-2); }
.level-tile .level-name { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-tile .level-sub { font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-thumb {
  position: relative;
  aspect-ratio: 1;
  margin-bottom: 6px;
  border-radius: 10px;
  background: var(--thumb-bg, var(--bg-2));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tile-thumb img { max-width: 90%; max-height: 90%; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35)); animation: fade 0.3s ease-out; }
@keyframes fade { from { opacity: 0; } }
.tile-wait {
  width: 26px; height: 26px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.tile-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: #1f2430;
  font-size: 0.68rem;
  font-weight: 800;
}
.level-list.tiles .del-btn { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; font-size: 1rem; background: rgba(31,36,48,0.85); }
.level-list.tiles .del-btn.armed { width: auto; background: var(--danger); font-size: 0.8rem; }

.level-btn {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-height: 56px;
}
.level-btn:active { background: var(--bg-2); }
.level-name { font-weight: 600; font-size: 1.05rem; }
.level-sub { color: var(--muted); font-size: 0.85rem; }

.theme-list { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  flex: 1 1 60px;
  min-width: 60px;
}
.theme-btn.selected { border-color: var(--accent); color: var(--text); }
.theme-swatch { width: 100%; height: 40px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15); }

.file-btn {
  display: block;
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px dashed #4a5168;
  text-align: center;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.file-btn input { display: none; }
.file-btn:active { background: var(--bg-2); }

.icon-btn {
  width: 42px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: var(--panel);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: var(--bg-2); }
.icon-btn.active { background: var(--accent); color: #1f2430; }
.del-btn { align-self: center; }
.del-btn.armed { width: auto; padding: 0 14px; background: var(--danger); font-size: 0.9rem; font-weight: 700; }

/* ---------- Spiel ---------- */

#screen-game { background: var(--bg); }

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 8px) 8px calc(var(--safe-left) + 8px);
  background: #1f2430; /* deckend statt backdrop-filter: die Leiste liegt nicht über dem Spielfeld,
                          der Weichzeichner kostete bei jedem Uhr-Update nur Rechenzeit */
  z-index: 2;
}
.hud-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; min-width: 0; }
.hud-time { font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 700; letter-spacing: 0.02em; }
.hud-progress { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.hud .icon-btn { width: 38px; height: 38px; font-size: 1.1rem; }
#btn-select { font-variant-numeric: tabular-nums; font-size: 0.95rem; font-weight: 700; }

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #2c3242 0%, #1c2029 100%);
  touch-action: none;
}
#stage > canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  display: block;
}
#c-drag { cursor: grab; }
#c-drag.blower { cursor: crosshair; }
#c-drag.blower.pan { cursor: grab; }
#btn-blower svg { display: block; }
/* fünf Buttons im HUD: auf schmalen Handys etwas kompakter, damit Zeit und Fortschritt lesbar bleiben */
@media (max-width: 420px) {
  .hud { gap: 4px; }
  .hud .icon-btn { width: 34px; }
  .hud-progress { font-size: 0.7rem; }
}

/* Laubbläser: Umschalter Pusten | Saugen oben rechts im Spielfeld */
.blower-mode {
  position: absolute;
  top: 8px;
  right: calc(var(--safe-right) + 8px);
  z-index: 3;
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: rgba(20, 24, 32, 0.88);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.blower-mode button {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 72px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.blower-mode button[aria-pressed="true"] { background: #aae1ff; color: #1f2430; }
.blower-mode button[data-mode="suck"][aria-pressed="true"] { background: #ffd60a; }
/* Auswahl-Leiste: gleicher Stil, Plus/Minus/Leeren schmal; Plus/Minus nur mit Rahmen aktiv */
.select-tools button[data-act="add"], .select-tools button[data-act="remove"], .select-tools button[data-act="clear"] { min-width: 38px; padding: 0 8px; font-size: 1.05rem; }
.select-tools button[data-act="frame"][aria-pressed="true"] { background: #3ee0ff; }
.select-tools button[data-act="remove"][aria-pressed="true"] { background: #ff6b6b; }
.select-tools button:disabled { opacity: 0.35; cursor: default; }
.select-count { align-self: center; padding: 0 6px 0 4px; font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.select-count.full { color: #ffd60a; }
#c-drag.marquee { cursor: crosshair; }
/* Gemeinsamer Vorrat: Restzeit mit Füllbalken; im Abklingen nur dieser Teil gedämpft mit Wartezeit –
   die Moduswahl bleibt farbig, damit das Umschalten auch während der Abklingzeit sichtbar ist */
.air-tank {
  position: relative;
  min-width: 52px;
  padding: 0 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.air-tank small { font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.air-tank::after {
  content: '';
  position: absolute;
  left: 8px;
  bottom: 5px;
  height: 3px;
  width: calc((100% - 16px) * var(--fill, 1));
  border-radius: 2px;
  background: #aae1ff;
}
.blower-mode.cooling .air-tank { color: #8a90a2; }
.blower-mode.cooling .air-tank::after { background: #8a90a2; }
/* Gekachelte Ebenen (s. js/tiles.js): Container wird nur per Transform bewegt */
#stage .layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
#stage .tiles {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
#stage .tiles canvas { display: block; }

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: rgba(31, 36, 48, 0.85);
  z-index: 3;
}
.spinner {
  width: 36px; height: 36px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 18, 26, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 4;
}
.card {
  background: var(--panel);
  border-radius: 20px;
  padding: 28px 24px;
  width: min(100%, 360px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: pop 0.35s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }
.card h2 { margin: 0 0 6px; color: var(--accent); font-size: 1.6rem; text-transform: none; letter-spacing: 0; }
.done-time { font-size: 2.6rem; font-weight: 800; margin: 4px 0; font-variant-numeric: tabular-nums; }
.done-best { color: var(--muted); margin: 0 0 20px; }
.row { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  min-height: 48px;
}
.btn.primary { background: var(--accent); color: #1f2430; }
.btn:active { filter: brightness(0.9); }

/* ---------- Ansichten-Panel ---------- */

.panel {
  position: absolute;
  top: calc(var(--safe-top) + 58px);
  right: calc(var(--safe-right) + 8px);
  z-index: 3;
  width: min(calc(100% - 16px), 320px);
  background: rgba(47, 53, 71, 0.97);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: pop 0.2s cubic-bezier(.2,.9,.3,1.2);
}
.panel-btn {
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.panel-btn:active { filter: brightness(0.9); }
.panel-btn.add { border: 2px dashed #4a5168; background: transparent; }
.panel-btn.add:disabled { opacity: 0.4; cursor: default; }
.panel-hint { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.view-list { display: flex; flex-direction: column; gap: 6px; }
.view-list:empty { display: none; }
.view-row { display: flex; gap: 6px; }
.view-row .panel-btn { flex: 1; }
.view-row .icon-btn { width: 44px; height: 44px; background: var(--bg-2); }
.view-row .icon-btn.armed { background: var(--danger); font-size: 0.8rem; font-weight: 700; width: auto; padding: 0 10px; }

/* ---------- Einstellungen ---------- */

.card.prefs { text-align: left; max-height: calc(100% - 16px); overflow-y: auto; }
.card.prefs h2 { text-align: center; margin-bottom: 4px; }
.card.prefs .theme-list { display: grid; grid-template-columns: repeat(5, 1fr); }
.card.prefs .theme-btn { min-width: 0; padding: 5px; font-size: 0.72rem; }
.card.prefs .theme-swatch { height: 34px; }
.card.prefs h3 { margin: 16px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.card.prefs .row { margin-top: 20px; }
/* Segment-Auswahl (Reibung) */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  -webkit-appearance: none;
  appearance: none;
  min-height: 40px;
  padding: 6px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--bg-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.prefs-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.btn.wide { width: 100%; display: block; text-align: center; }
.btn.danger { background: var(--danger); }
.btn.danger.armed { background: #d24a41; }
.done-stats { color: var(--text); margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.hud-progress .hud-touches::before { content: ' · '; }

/* ---------- Vorschau: Startkarte und Minimap ---------- */

.card.intro h2 { margin-bottom: 12px; }
.intro-img {
  display: block;
  margin: 0 auto 12px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.minimap {
  position: absolute;
  z-index: 2;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.25);
  touch-action: none;
  cursor: pointer;
}
.minimap.overview { box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 0 2px #ffd60a; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  max-width: calc(100% - 24px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(20, 24, 32, 0.92);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.toast.tool { border: 2px solid #3ee0ff; }

/* ---------- Power-up-Leiste ---------- */

.pu-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px calc(var(--safe-right) + 8px) calc(var(--safe-bottom) + 6px) calc(var(--safe-left) + 8px);
  background: rgba(31, 36, 48, 0.92);
  z-index: 2;
}
.pu-points {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pu-points.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 40% { transform: scale(1.15); } }
.pu-list { flex: 1; display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.pu-list::-webkit-scrollbar { display: none; }
.pu-list:empty::before { content: 'Sammle ★ und schalte im Menü unter „Skilltree“ Hilfen frei.'; color: var(--muted); font-size: 0.8rem; align-self: center; }
.pu-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 44px;
  max-width: 60px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.pu-btn small { font-size: 0.62rem; color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.pu-btn:disabled { opacity: 0.45; cursor: default; }
.pu-btn.active { background: #3ee0ff; color: #1f2430; }
.pu-btn.active small { color: #1f2430; }
.pu-btn .pu-boost {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #3ee0ff;
}
.pu-btn.active .pu-boost { color: #1f2430; }

/* ---------- Skilltree ---------- */

.overlay.fixed { position: fixed; z-index: 10; }
.card.skills { text-align: left; width: min(100%, 640px); max-height: calc(100% - 16px); overflow-y: auto; }
.card.skills h2 { text-align: center; }
.skills-points { text-align: center; margin: 0 0 8px; font-size: 1.3rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
/* Skilltree als Kacheln: drei nebeneinander, auf dem Handy zwei */
.skills-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.skill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 8px;
  border-radius: 14px;
  background: var(--bg-2);
  text-align: center;
}
.skill-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.skill-name { font-weight: 700; font-size: 0.85rem; line-height: 1.15; }
.skill-desc { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.3; }
.skill-use { margin: 0; color: var(--accent); font-size: 0.68rem; font-weight: 700; }
.skill-row { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: auto; padding-top: 6px; }
.skill-row + .skill-row { margin-top: 4px; border-top: 1px solid #4a5168; }
.skill-part { font-size: 0.72rem; font-weight: 700; }
.skill-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
.skill-dots span { width: 7px; height: 7px; border-radius: 50%; background: #4a5168; }
.skill-dots span.owned { background: var(--accent); }
.skill-effect { font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.skill .btn { width: 100%; min-height: 36px; padding: 6px 4px; font-size: 0.85rem; }
.skill .btn:disabled { opacity: 0.5; cursor: default; }
/* Handy: zwei Kacheln nebeneinander, weniger Rand */
@media (max-width: 520px) {
  #overlay-skills { padding: 10px; }
  .card.skills { padding: 18px 12px; }
  .skills-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .skill { padding: 8px 6px; }
}
.skills-btn .level-sub { color: var(--accent); font-weight: 700; }
.skills-reset { margin-top: 16px; }
.skills-reset:disabled { opacity: 0.4; cursor: default; }
.card.skills .row { margin-top: 10px; }
.done-points { color: var(--accent); font-weight: 700; margin: 0 0 6px; }

/* ---------- Statistik ---------- */

/* (i) auf der Level-Kachel: oben rechts (oben links sitzt „Angefangen“, bei eigenen Leveln rückt es
   neben den Papierkorb) */
.level-list.tiles .info-btn {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 0.95rem; font-weight: 800; font-style: italic; font-family: Georgia, serif;
  background: rgba(31,36,48,0.85);
}
.level-list.tiles li:has(.del-btn) .info-btn { right: 52px; top: 14px; }

/* Kennzahlen (Abschlusskarte und Statistik-Seite) */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 10px 0 6px; }
.metric { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--bg-2); min-width: 0; }
.metric-value { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.done-notes { margin: 0 0 10px; color: var(--muted); font-size: 0.78rem; }
.done-notes:empty { display: none; }

#screen-stats { background: var(--bg); }
.hud-spacer { width: 38px; flex: 0 0 auto; }
.stats-title { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stats-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 24px) calc(var(--safe-left) + 16px); }
.stats-body { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.stats-card { background: var(--panel); border-radius: 16px; padding: 14px; }
.stats-card h3 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stats-head { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; column-gap: 12px; }
.stats-head h3 { grid-column: 1 / -1; }
.stats-thumb { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: var(--bg-2); }
.stats-facts { margin: 0; align-self: center; font-size: 0.88rem; line-height: 1.4; }
.stats-time { margin: 0; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats-empty, .stats-hint { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.stats-summary { margin: 0 0 8px; font-size: 0.88rem; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.stats-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 4px 6px; border-bottom: 1px solid #4a5168; }
.stats-table td { padding: 5px 4px; border-bottom: 1px solid rgba(74,81,104,0.4); }

/* Fortschrittskurve: eine Linie (Akzentfarbe), Fehlversuche als Striche; Raster zurückhaltend */
.curve-box { position: relative; margin-top: 10px; }
.curve { display: block; width: 100%; height: auto; touch-action: pan-y; }
.curve-grid { stroke: #3a4054; stroke-width: 1; }
.curve-label { fill: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.curve-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.curve-area { fill: var(--accent); opacity: 0.12; }
.curve-miss line { stroke: #ff6b6b; stroke-width: 1.5; }
.curve-cross { stroke: var(--text); stroke-width: 1; opacity: 0.5; }
.curve-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.curve-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%);
  padding: 5px 8px; border-radius: 8px; background: rgba(20,24,32,0.95);
  font-size: 0.75rem; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.curve-legend { display: flex; gap: 14px; margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.curve-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { width: 14px; height: 2px; background: var(--accent); display: inline-block; }
.lg-miss { width: 2px; height: 10px; background: #ff6b6b; display: inline-block; }
