:root {
  --bg: #15161a;
  --bg-2: #1d1f26;
  --bg-3: #262932;
  --line: #32353f;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --accent: #e60012;        /* Nintendo-Rot */
  --accent-2: #4f8cff;
  --green: #3ecf8e;
  --amber: #f5a623;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 400; }
.search-wrap { flex: 1; }
#search {
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--accent-2); }
.actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--bg-3); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger { color: #ff6b6b; }
.btn.danger.ghost:hover { background: rgba(255,107,107,.12); }

/* Stats */
.stats {
  display: flex;
  gap: 12px;
  padding: 16px 20px 0;
  flex-wrap: wrap;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 92px;
  cursor: pointer;
  transition: border-color .08s ease;
}
.stat:hover { border-color: var(--muted); }
.stat.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat.active .num { color: var(--accent); }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; }

/* Filters */
.filters {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.filters select {
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
  min-width: 150px;
}
.filters label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  padding-bottom: 8px;
}

/* Tabs (Status-Schnellfilter) */
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 6px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { background: var(--bg-3); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.toggle.active { background: gold; border-color: gold; color: #2a2400; }
.tab-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 4px 20px 40px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .08s ease, border-color .08s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent-2); }
.card .cover {
  aspect-ratio: 1 / 1;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.card .cover img { width: 100%; height: 100%; object-fit: cover; }
.card .cover .placeholder { font-size: 40px; opacity: .25; }
.card .badges {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(2px);
}
.badge.status-playing { background: var(--amber); color: #1a1a1a; }
.badge.status-done { background: var(--green); color: #0d2c1d; }
.badge.status-abandoned { background: #6b6f7a; }
.badge.hundred { background: gold; color: #2a2400; }
.card .cover .pin {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: .55;
  filter: grayscale(1);
  transition: opacity .1s ease, background .1s ease;
}
.card:hover .cover .pin { opacity: .9; }
.card .cover .pin:hover { opacity: 1; background: rgba(0, 0, 0, .8); }
.card .cover .pin.on { background: var(--accent-2); opacity: 1; filter: none; }

.card .cover .rating-badge {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0, 0, 0, .72);
  color: gold;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 6px;
}

.card .info { padding: 10px 12px 12px; }
.card .title { font-weight: 600; line-height: 1.25; margin-bottom: 3px; }
.card .meta { color: var(--muted); font-size: 12px; }
.card .progress {
  margin-top: 9px;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-3);
  overflow: hidden;
}
.card .progress > span { display: block; height: 100%; background: var(--accent-2); }
.card .plays { margin-top: 6px; font-size: 11px; color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.modal-body { display: flex; gap: 22px; padding: 26px; }
.modal-cover { width: 220px; flex-shrink: 0; }
.modal-cover img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--bg-3);
  display: block;
  margin-bottom: 10px;
}
.modal-cover .btn.small { display: block; width: 100%; margin-bottom: 6px; }
.modal-fields {
  flex: 1;
  min-width: 0; /* erlaubt Schrumpfen statt Überlaufen */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: start;
}
.modal-fields label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.modal-fields input,
.modal-fields select,
.modal-fields textarea { max-width: 100%; }
.modal-fields .full { grid-column: 1 / -1; }
.modal-fields label.checkbox.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.modal-fields input[type="text"],
.modal-fields input[type="date"],
.modal-fields input[type="number"],
.modal-fields select,
.modal-fields textarea {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.modal-fields input:focus, .modal-fields select:focus, .modal-fields textarea:focus {
  outline: none; border-color: var(--accent-2);
}
.hint { color: var(--muted); font-weight: 400; }
.family-members { font-size: 11px; margin-top: 2px; }

/* Stern-Bewertung (1–10) */
.rating-field { display: flex; flex-direction: column; gap: 5px; }
.field-cap { font-size: 12px; color: var(--muted); }
.stars-row { display: flex; align-items: center; gap: 8px; }
.stars { display: flex; }
.stars .star {
  font-size: 19px; line-height: 1; cursor: pointer; color: var(--line);
  transition: color .05s ease;
}
.stars .star:hover { transform: scale(1.08); }
.stars .star.on { color: gold; }
.stars-num { color: var(--muted); font-size: 13px; min-width: 34px; }
.stars-clear {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px;
}
.stars-clear:hover { color: #ff6b6b; }

.completions { background: var(--bg-3); border-radius: 10px; padding: 12px 14px; }
.completions-head { display: flex; justify-content: space-between; align-items: center; color: var(--text); font-size: 13px; margin-bottom: 8px; }
.add-date { display: flex; gap: 6px; }
.add-date input { background: var(--bg-2) !important; }
.completions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.completions-list li {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 13px;
}
.completions-list button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px;
}
.completions-list button:hover { color: #ff6b6b; }
.completions-list .none { color: var(--muted); border: none; background: none; padding: 4px 0; }

/* Akkordeon (Durchläufe) */
.accordion { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg-3); }
.accordion-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 6px; }
.acc-toggle {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 5px 8px; border-radius: 7px;
}
.acc-toggle:hover { background: var(--bg-2); }
.acc-caret { transition: transform .12s ease; display: inline-block; color: var(--muted); }
.accordion.open .acc-caret { transform: rotate(90deg); }
.acc-count {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); font-weight: 400;
}
.acc-spacer { flex: 1; }
.accordion-body { display: none; padding: 0 12px 12px; }
.accordion.open .accordion-body { display: block; }

/* Editierbare Durchlauf-Zeilen */
.completions-list.runs { flex-direction: column; gap: 6px; }
.completions-list.runs li.run {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; font-size: 13px;
}
.completions-list.runs li.run input {
  padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text); font-size: 13px; font-family: inherit;
  min-width: 0;
}
.completions-list.runs li.run input:focus { outline: none; border-color: var(--accent-2); }
.completions-list.runs li.run input[type="date"] { width: 134px; flex-shrink: 0; }
.completions-list.runs li.run input[type="number"] { width: 60px; flex-shrink: 0; }
.completions-list.runs li.run .run-note { flex: 1 1 110px; }
.completions-list.runs li.run .run-100 {
  display: flex; align-items: center; gap: 4px; color: var(--text); white-space: nowrap;
}
.run-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
.run-del:hover { color: #ff6b6b; }

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 26px;
  border-top: 1px solid var(--line);
}
.modal-footer .spacer { flex: 1; }

/* Jahresrückblick ("Wrapped") */
.recap-card { width: min(720px, 100%); padding: 26px; }
.recap-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.recap-title { margin: 0; font-size: 20px; }
.recap-title span { color: var(--accent); }
.recap-empty { color: var(--muted); text-align: center; padding: 40px 10px; line-height: 1.7; }

.recap-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.recap-tile {
  background: linear-gradient(150deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  text-align: center;
}
.recap-tile .rt-num { font-size: 30px; font-weight: 800; color: var(--accent-2); line-height: 1.1; }
.recap-tile .rt-lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }
.recap-tile.gold .rt-num { color: gold; }

.recap-fav {
  margin-top: 14px;
  background: linear-gradient(135deg, rgba(230,0,18,.18), rgba(79,140,255,.18));
  border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center;
}
.recap-fav .rf-label { color: var(--muted); font-size: 13px; }
.recap-fav .rf-name { font-size: 26px; font-weight: 800; margin: 4px 0; }
.recap-fav .rf-sub { color: var(--muted); font-size: 13px; }

.recap-months { margin-top: 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.recap-months .rm-title { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.recap-months .rm-title b { color: var(--text); }
.rm-chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; }
.rm-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 5px; }
.rm-bar { width: 100%; min-height: 2px; background: var(--accent-2); border-radius: 4px 4px 0 0; transition: height .2s ease; }
.rm-bar.peak { background: var(--accent); }
.rm-lbl { color: var(--muted); font-size: 10px; }

.recap-highlights { margin-top: 14px; display: grid; gap: 8px; }
.rh { display: flex; align-items: center; gap: 12px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rh-ic { font-size: 22px; }
.rh-h { color: var(--muted); font-size: 12px; }
.rh-v { font-weight: 600; }

/* Statistik-Tabelle */
.stats-card { width: min(940px, 100%); padding: 26px; }
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stats-title { margin: 0; font-size: 18px; }
.stats-year-lbl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.stats-year-lbl select {
  padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text); font-size: 14px;
}
.stats-table-wrap { overflow: auto; max-height: 70vh; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th, .stats-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stats-table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg-2); }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table tbody tr:hover { background: var(--bg-3); }
.stats-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
.stats-table .bar { display: inline-block; height: 6px; background: var(--accent-2); border-radius: 3px; vertical-align: middle; }

/* ===== Web/PWA-Ergänzungen ===================================================== */
body { padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }
.topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }

/* Große Listen: Karten außerhalb des Sichtbereichs nicht layouten/zeichnen */
.card { content-visibility: auto; contain-intrinsic-size: auto 300px; }

/* Login */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card input {
  padding: 11px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text); font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--accent-2); }
.login-err { color: #ff6b6b; min-height: 1.2em; font-size: 13px; }

/* Offline-Hinweis */
.offline { background: var(--amber); color: #1a1a1a; text-align: center; font-weight: 600; font-size: 13px; padding: 6px 12px; }

/* Menü */
.actions { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 230px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); display: flex; flex-direction: column;
}
.menu button {
  background: none; border: none; color: var(--text); text-align: left; font-size: 14px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.menu button:hover { background: var(--bg-3); }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: calc(100% - 32px); font-size: 14px;
}

/* Systemfamilien */
.families-card { width: min(720px, 100%); padding: 26px; }
.families-card > .hint { margin: 6px 0 16px; font-size: 13px; line-height: 1.5; }
.families-list { display: flex; flex-direction: column; gap: 12px; }
.family { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.family-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.family-head input {
  flex: 1; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font-size: 14px; font-weight: 600;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--muted); font-size: 12px; cursor: pointer;
}
.chip.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.families-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.families-actions .spacer { flex: 1; }

/* ===== Smartphone ============================================================== */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .brand { font-size: 16px; }
  .brand-name, #year-label { display: none; }
  .search-wrap { flex: 1 1 0; min-width: 0; }
  #search { font-size: 16px; } /* verhindert Auto-Zoom auf iOS */
  .lbl-long { display: none; }

  .stats { gap: 8px; padding: 12px 12px 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .stat { min-width: 84px; padding: 8px 12px; flex-shrink: 0; }
  .stat .num { font-size: 18px; }

  .filters { gap: 8px; padding: 12px; flex-wrap: nowrap; }
  .filters label { flex: 1; min-width: 0; }
  .filters select { min-width: 0; width: 100%; font-size: 16px; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 4px 12px 32px; }
  .card:hover { transform: none; }
  .card .cover .pin { opacity: .8; }
  .card .info { padding: 8px 10px 10px; }
  .card .title { font-size: 14px; }

  /* Dialoge als Vollbild-Sheet */
  .modal { padding: 0; align-items: stretch; }
  .modal-card, .stats-card, .recap-card, .families-card {
    width: 100%; max-height: none; height: 100%; border-radius: 0; border: none;
    padding-top: env(safe-area-inset-top);
  }
  .stats-card, .recap-card, .families-card { padding: calc(18px + env(safe-area-inset-top)) 16px 24px; }
  .modal-close { top: calc(10px + env(safe-area-inset-top)); }
  .modal-body { flex-direction: column; padding: 18px 16px; gap: 16px; }
  .modal-cover { width: 100%; display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; align-items: start; }
  .modal-cover img { grid-row: span 3; margin: 0; }
  .modal-cover { padding-right: 40px; } /* Platz für das ✕ */
  .modal-fields { grid-template-columns: 1fr; }
  .modal-fields input, .modal-fields select, .modal-fields textarea { font-size: 16px !important; }
  .stars .star { font-size: 24px; }
  .modal-footer {
    position: sticky; bottom: 0; background: var(--bg-2);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .stats-head, .recap-head { flex-wrap: wrap; padding-right: 40px; }
  .stats-table-wrap { max-height: none; }
  .stats-table { font-size: 13px; }
  .stats-table th, .stats-table td { padding: 7px 8px; }
}

/* ===== v2: Stoppuhr, Jahresziel, Würfel, Heatmap, Käufe ======================== */
.badge.running { background: var(--accent); color: #fff; }
.card.running { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Jahresziel in der Kachel */
.goal-of { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .goal-bar, .goal-bar { margin-top: 6px; height: 4px; border-radius: 3px; background: var(--bg-3); overflow: hidden; }
.goal-bar > span { display: block; height: 100%; background: var(--green); }

/* Timer-Button im Dialog */
.modal-cover .timer-btn { margin-top: 6px; background: var(--green); color: #0d2c1d; }
.modal-cover .timer-btn.running { background: var(--accent); color: #fff; }
.acc-sum { font-size: 12px; }

/* Laufender Timer (unten) */
.timerbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 24px));
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--accent); border-radius: 14px;
  padding: 8px 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.timerbar.paused { border-color: var(--amber); }
.timerbar img { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--bg-3); flex-shrink: 0; }
.tb-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  background: none; border: none; color: var(--text); cursor: pointer; padding: 0; text-align: left;
}
.tb-title { font-weight: 600; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-time { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; color: var(--accent); }
.timerbar.paused .tb-time { color: var(--amber); }
.tb-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text); font-size: 17px; cursor: pointer; flex-shrink: 0;
}
.tb-btn:hover { filter: brightness(1.2); }
.tb-btn.stop { background: var(--accent); border-color: var(--accent); color: #fff; }
body.timer-on .grid { padding-bottom: 110px; }
body.timer-on .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

/* Stopp-Dialog */
.stop-card, .pick-card { width: min(480px, 100%); padding: 26px; }
.stop-game { display: flex; gap: 12px; align-items: center; margin: 14px 0; }
.stop-game img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.stop-warn { background: rgba(245,166,35,.15); border: 1px solid var(--amber); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.stop-fields, .settings-row, .pick-filters { display: flex; gap: 12px; flex-wrap: wrap; }
.stop-fields label, .settings-row label, .pick-filters label {
  display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); flex: 1; min-width: 90px;
}
.stop-fields input, .settings-row input, .pick-filters select {
  padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--text); font-size: 14px; font-family: inherit;
}
.stop-actions, .pick-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.stop-actions .spacer, .pick-actions .spacer { flex: 1; }

/* Einstellungen */
.settings-row { margin: 16px 0 6px; }
.settings-h { font-size: 15px; margin: 20px 0 4px; }

/* Würfel */
.pick-filters { margin-top: 14px; }
.pick-result { margin-top: 16px; min-height: 150px; display: flex; align-items: center; justify-content: center; }
.pick-empty { font-size: 64px; opacity: .25; }
.pick-card-inner { display: flex; gap: 14px; align-items: center; width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.pick-card-inner.final { border-color: var(--accent-2); animation: pick-pop .25s ease; }
.pick-card-inner img, .pick-card-inner .placeholder { width: 120px; height: 120px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--bg-2); display: flex; align-items: center; justify-content: center; font-size: 36px; }
.pick-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pick-title { font-size: 17px; font-weight: 700; }
.pick-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
@keyframes pick-pop { from { transform: scale(.94); } to { transform: scale(1); } }

/* Heatmap im Rückblick */
.heatmap-box { margin-top: 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.heatmap-box .rm-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.heatmap-box .rm-title b { color: var(--text); }
.heatmap-scroll { overflow-x: auto; padding-bottom: 4px; }
/* Spalten passen sich der Breite an; auf sehr schmalen Displays wird gescrollt */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, auto); grid-auto-columns: minmax(7px, 1fr); gap: 2px; min-width: 100%; }
.hm-cell { display: block; aspect-ratio: 1; border-radius: 2px; background: var(--bg-2); }
.hm-legend .hm-cell { width: 10px; }
.hm-cell.out { visibility: hidden; }
.hm-cell.l1 { background: rgba(79,140,255,.35); }
.hm-cell.l2 { background: rgba(79,140,255,.6); }
.hm-cell.l3 { background: rgba(79,140,255,.85); }
.hm-cell.l4 { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: 11px; color: var(--muted); margin-top: 8px; }
.hm-legend .hm-cell { margin: 0 1px; display: inline-block; }

/* Statistik-Zusatz */
.stats-extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.extra-card { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.extra-h { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.extra-big { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.extra-card .hint { font-size: 12px; line-height: 1.5; }
.mini-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.mini-table td { padding: 4px 0; border-top: 1px solid var(--line); }
.mini-table td:not(:first-child) { text-align: right; }
.mini-table tr.hl td { color: var(--accent-2); font-weight: 700; }

@media (max-width: 700px) {
  .stop-card, .pick-card { padding: calc(18px + env(safe-area-inset-top)) 16px 24px; }
  .stop-fields input, .settings-row input, .pick-filters select { font-size: 16px; }
  .pick-card-inner img, .pick-card-inner .placeholder { width: 96px; height: 96px; }
  .timerbar { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

.recap-tile .rt-num { white-space: nowrap; font-size: clamp(22px, 3.2vw, 30px); }

/* Eingabefelder nebeneinander stehender Labels auf gleicher Höhe halten,
   auch wenn eine Beschriftung umbricht */
.modal-fields { align-items: end; }
.modal-fields .full, .modal-fields .checkbox.inline { align-self: start; }

/* ===== v3: Käufe ============================================================= */
/* Zustand: Neu = Akzentblau, Gebraucht = Bernstein (CVD-geprüft auf --bg-2),
   ohne Angabe = neutrales Grau */
:root { --c-new: #4f8cff; --c-used: #c97a1a; --c-none: #5b606c; }
.c-new { background: var(--c-new); }
.c-used { background: var(--c-used); }
.c-none { background: var(--c-none); }

.buy-body { display: flex; flex-direction: column; gap: 14px; }
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; }
.kpi { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi-lbl { color: var(--muted); font-size: 12px; }
.kpi-val { font-size: 22px; font-weight: 700; margin-top: 4px; white-space: nowrap; }
.kpi.hero .kpi-val { font-size: 34px; }

.chart-box { background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.chart-h { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; margin: 10px 0 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.split-bar { display: flex; gap: 2px; height: 14px; }
.split-bar .seg { min-width: 4px; flex-basis: 0; }
.split-bar .seg:first-child { border-radius: 4px 0 0 4px; }
.split-bar .seg:last-child { border-radius: 0 4px 4px 0; }
.split-bar .seg:only-child { border-radius: 4px; }

/* Säulen (Jahre / Monate) */
.cols { display: flex; align-items: stretch; gap: 6px; height: 190px; margin-top: 6px; border-bottom: 1px solid var(--line); }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; cursor: default; }
.col-cap { height: 18px; font-size: 11px; color: var(--text); white-space: nowrap; }
.col-stack { flex: 1; width: 100%; max-width: 24px; display: flex; flex-direction: column-reverse; gap: 2px; }
.col-stack .seg { display: block; width: 100%; flex-shrink: 0; }
.col-stack .seg:last-child { border-radius: 4px 4px 0 0; }
.col:hover .col-stack .seg { filter: brightness(1.15); }
.col-lbl { font-size: 11px; color: var(--muted); padding-top: 6px; height: 22px; white-space: nowrap; }
.cols { padding-bottom: 0; }
.cols .col-lbl { transform: translateY(1px); }
.small-note { font-size: 12px; margin-top: 8px; }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); }

/* Horizontale Balken (Systeme) */
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; }
.hbar-track span { display: block; height: 100%; min-width: 3px; background: var(--c-new); border-radius: 0 4px 4px 0; }
.hbar:hover .hbar-track span { filter: brightness(1.15); }
.hbar-val { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Tooltip */
.chart-tip {
  position: fixed; z-index: 200; pointer-events: none; white-space: pre-line;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: 0 8px 20px rgba(0,0,0,.45); max-width: 260px;
}

.buy-data { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.buy-data .spacer { flex: 1; }

/* CSV-Vorschau */
.csv-body { margin-top: 12px; }
.csv-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.csv-chip { background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.csv-chip.ok { border-color: var(--green); }
.csv-chip.warn { border-color: var(--amber); }
.csv-issues { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.csv-issues summary { cursor: pointer; font-weight: 600; }
.csv-table td { white-space: normal; }
.csv-table td:not(:first-child), .csv-table th:not(:first-child) { text-align: left; }

@media (max-width: 700px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi.hero .kpi-val { font-size: 28px; }
  .cols { gap: 3px; height: 160px; }
  .cols.months .col-lbl { font-size: 10px; }
  .hbar { grid-template-columns: 1fr auto; }
  .hbar-name { grid-column: 1 / -1; }
}

.lg { flex-wrap: wrap; }
.csv-table b, .csv-table .hint { white-space: nowrap; }
