/* Brettspiele – Handy zuerst, dezente Farben, hell/dunkel */
:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --text: #1d1f1c;
  --muted: #6b6f68;
  --line: #e4e1d9;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #dcefec;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --l-perfekt: #1f9254; --l-perfekt-t: #ffffff;
  --l-gut: #cdebd5; --l-gut-t: #14532d;
  --l-geht: #f2eacb; --l-geht-t: #5b4a0b;
  --l-nichtempfohlen: #f5dcd6; --l-nichtempfohlen-t: #7f1d1d;
  --l-unmoeglich: transparent; --l-unmoeglich-t: #a3a69f;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614;
    --card: #1e211f;
    --text: #ecebe6;
    --muted: #9a9e97;
    --line: #2f3330;
    --accent: #3fb5a8;
    --accent-text: #0b1f1d;
    --accent-soft: #1b3532;
    --danger: #f2877b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --l-perfekt: #2c9d61; --l-perfekt-t: #ffffff;
    --l-gut: #22422f; --l-gut-t: #bfe8cb;
    --l-geht: #423b20; --l-geht-t: #eee2b0;
    --l-nichtempfohlen: #4a2723; --l-nichtempfohlen-t: #f2c2bb;
    --l-unmoeglich-t: #5f645e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--accent); }

/* ---------- Anmelden ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 340px; display: grid; gap: 14px; text-align: center; }
.login-icon { margin: 0 auto; border-radius: 18px; }
.login h1 { font-size: 26px; margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--muted); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.err { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 15px; }

/* ---------- Eingaben & Knöpfe ---------- */
.input, .login input[type=password], textarea.input, select.input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  min-height: 46px;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus, .login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
input[type=search] { -webkit-appearance: none; appearance: none; }
input[type=search]::-webkit-search-cancel-button { display: none; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; flex: none; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link { color: var(--accent); font-weight: 600; padding: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Reiter ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; min-width: 0; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg .fill { fill: currentColor; stroke: none; }
.tabs button.active { color: var(--accent); font-weight: 600; }
main { padding-top: var(--safe-t); padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); min-height: 100dvh; }
.view { max-width: 760px; margin: 0 auto; }

/* Am PC: Reiter oben */
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  .tabs { position: sticky; top: 0; bottom: auto; height: 56px; padding: 0; border-top: 0; border-bottom: 1px solid var(--line);
    display: flex; justify-content: center; gap: 8px; }
  .tabs button { flex-direction: row; font-size: 15px; padding: 0 18px; gap: 8px; }
  .tabs svg { width: 20px; height: 20px; }
  main { padding-bottom: 32px; padding-top: 0; }
  .head { top: 56px; }
}

/* ---------- Kopfzeile einer Ansicht ---------- */
.head {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: 14px 16px 10px;
}
.head-row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.head h1 { font-size: 24px; flex: 1; min-width: 0; }
.count { color: var(--muted); font-size: 15px; font-weight: 500; }
.tools { display: flex; gap: 8px; margin-top: 10px; }
.search { position: relative; flex: 1; min-width: 0; }
.search .input { padding-left: 38px; padding-right: 38px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; pointer-events: none; }
.search .clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; color: var(--muted); font-size: 20px; }
.tool-btn { position: relative; flex: none; width: 46px; height: 46px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; display: grid; place-items: center; }
.tool-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; min-height: 64px;
  background: var(--bg); width: 100%; text-align: left;
}
.row + .row, .list > li + li > .row { border-top: 1px solid var(--line); }
.row:active { background: var(--accent-soft); }
.row .txt { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .meta { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.dim .thumb, .row.dim .name { opacity: .55; }
.rating { flex: none; min-width: 32px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--accent-soft); color: var(--accent); padding: 0 6px; }
.thumb { flex: none; width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--line); }
.ph { display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 18px; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); z-index: 6;
  width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-text);
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) { .fab { bottom: 24px; right: calc(50% - 380px); } }

/* ---------- Seiten (Details, Formular, Suche) ---------- */
.page {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.page-inner { max-width: 760px; margin: 0 auto; min-height: 100%; padding-bottom: calc(24px + var(--safe-b)); }
.page-head {
  position: sticky; top: 0; z-index: 3; background: var(--bg);
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + var(--safe-t)) 8px 6px;
  min-height: calc(56px + var(--safe-t));
}
.page-head h2 { flex: 1; min-width: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-body { padding: 4px 16px 16px; }

/* Detailseite */
.cover-big { width: 100%; max-height: 340px; object-fit: contain; border-radius: 14px; background: var(--card); }
.cover-ph { width: 100%; height: 160px; border-radius: 14px; background: var(--card); display: grid; place-items: center; font-size: 56px; font-weight: 700; color: var(--line); }
.title { font-size: 24px; margin: 16px 0 2px; }
.sub { color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.fact { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.fact b { display: block; font-size: 18px; }
.fact span { color: var(--muted); font-size: 13px; }
.section { margin: 20px 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notes { white-space: pre-wrap; background: var(--card); padding: 12px; border-radius: 12px; }
.tagline { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.note-off { display: inline-block; margin-top: 8px; font-size: 14px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 3px 8px; }
.bgg-link { display: inline-block; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* Spielerzahl-Kästchen */
.players { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.pl {
  height: 42px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; border: 1px solid transparent; user-select: none;
}
.pl.perfekt { background: var(--l-perfekt); color: var(--l-perfekt-t); }
.pl.gut { background: var(--l-gut); color: var(--l-gut-t); }
.pl.geht { background: var(--l-geht); color: var(--l-geht-t); }
.pl.nichtempfohlen { background: var(--l-nichtempfohlen); color: var(--l-nichtempfohlen-t); }
.pl.unmoeglich { background: var(--l-unmoeglich); color: var(--l-unmoeglich-t); border: 1px dashed var(--line); text-decoration: line-through; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend i, .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; }
.dot.perfekt, .legend i.perfekt { background: var(--l-perfekt); }
.dot.gut, .legend i.gut { background: var(--l-gut); border: 1px solid var(--l-gut-t); }
.dot.geht, .legend i.geht { background: var(--l-geht); border: 1px solid var(--l-geht-t); }
.dot.nichtempfohlen, .legend i.nichtempfohlen { background: var(--l-nichtempfohlen); border: 1px solid var(--l-nichtempfohlen-t); }
.legend i.unmoeglich { border: 1px dashed var(--muted); }

/* ---------- Formular ---------- */
.field { margin: 18px 0; }
.field > label, .field > .label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-weight: 400; font-size: 13px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .field { margin: 0; }
.cover-edit { display: flex; gap: 14px; align-items: center; }
.cover-edit .thumb { width: 88px; height: 88px; border-radius: 12px; }
.cover-edit .btns { display: grid; gap: 8px; flex: 1; }
.alt-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.alt-names button { font-size: 14px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); }
.with-unit { position: relative; }
.with-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.save-bar {
  position: sticky; bottom: 0; z-index: 3;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}

/* Segmente (eine Auswahl) und Chips (mehrere) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.seg button {
  min-height: 44px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  font-size: 15px; padding: 0 2px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg.tight { gap: 2px; }
.seg.tight button { padding: 0; font-size: 15px; }
.seg button.on, .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 15px; }
.chip.add { border-style: dashed; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid2 .chip { border-radius: 12px; min-height: 46px; }
.seg-note { margin-top: 6px; font-size: 13px; color: var(--muted); min-height: 1.2em; }

/* Schalter */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- BGG-Suche ---------- */
.searchbar { display: flex; gap: 8px; padding: 0 16px 8px; }
.searchbar .input { flex: 1; min-width: 0; }
.result .meta .exp { color: var(--muted); }
.result .have { color: var(--accent); font-size: 13px; font-weight: 600; }
.powered { display: block; text-align: center; font-size: 12px; color: var(--muted); padding: 16px; text-decoration: none; }
.powered b { color: var(--text); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top 30 ---------- */
.top { list-style: none; margin: 0; padding: 0; }
.top li { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 12px; min-height: 60px; background: var(--bg); border-top: 1px solid var(--line); }
.top li:first-child { border-top: 0; }
.place { flex: none; width: 38px; height: 38px; border-radius: 10px; font-weight: 800; font-size: 17px; color: var(--muted); display: grid; place-items: center; }
.place:active { background: var(--accent-soft); }
.top:not(.bench) li:nth-child(-n+3) .place { color: var(--accent); }
#samList { padding-bottom: 72px; }
.top .thumb { width: 44px; height: 44px; }
.top .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.grip { flex: none; width: 48px; height: 48px; display: grid; place-items: center; color: var(--muted); touch-action: none; cursor: grab; }
.grip svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.top li.dragging { position: fixed; z-index: 30; box-shadow: var(--shadow); border-radius: 12px; border: 0; background: var(--card); pointer-events: none; }
.top li.placeholder { background: var(--accent-soft); border: 2px dashed var(--accent); border-radius: 12px; }
body.dragging, body.dragging * { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.bench-head { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 16px 4px; }
.bench li { opacity: .85; }
.bench .place { font-size: 13px; font-weight: 600; }
.add-row { padding: 12px 16px; }

/* ---------- Spieleabend ---------- */
.plan { padding: 0 16px; }
.plan .field { margin: 14px 0; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; }
.stepper button { width: 60px; height: 60px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); font-size: 30px; font-weight: 400; line-height: 1; }
.stepper button:disabled { opacity: .35; }
.stepper output { min-width: 72px; text-align: center; font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: -4px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 16px 6px; border-top: 1px solid var(--line); margin-top: 18px; }
.results-head h2 { font-size: 18px; }
.card-row .lvl { flex: none; display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }

/* Würfel-Ergebnis */
.roll { text-align: center; }
.roll img, .roll .cover-ph { margin: 0 auto 12px; max-height: 260px; width: auto; max-width: 100%; border-radius: 14px; }
.roll .cover-ph { width: 100%; }
.roll h3 { font-size: 22px; margin-bottom: 4px; }
.roll.spin h3 { opacity: .5; }

/* ---------- Mehr ---------- */
.box { background: var(--card); border-radius: 14px; margin: 0 16px 12px; padding: 4px 16px; }
.box-title { padding: 16px 16px 6px; margin: 8px 0 0; }
.box .line { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; border-top: 1px solid var(--line); }
.box .line:first-child { border-top: 0; }
.box .line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.line-btn { width: 100%; text-align: left; }
a.btn { text-decoration: none; color: var(--text); }
.jump { flex: none; min-height: 34px; padding: 0 12px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px; }
.box form { display: grid; gap: 10px; padding: 12px 0; }
.updates { list-style: none; margin: 0; padding: 8px 0; font-size: 14px; }
.updates li { padding: 6px 0; }
.updates b { font-weight: 600; }
.version { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 16px 24px; }

/* ---------- Modal / Blatt von unten ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); animation: fade .15s; }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(16px + var(--safe-b));
  animation: up .18s ease-out;
}
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 18px; padding-bottom: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h3 { font-size: 18px; margin-bottom: 12px; }
.sheet .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.menu { display: grid; }
.menu button { text-align: left; min-height: 52px; padding: 0 4px; border-top: 1px solid var(--line); font-size: 17px; }
.menu button:first-child { border-top: 0; }
.menu button.danger { color: var(--danger); }
.pick-list { margin: 8px -16px 0; max-height: 60dvh; overflow-y: auto; }

/* ---------- Hinweis unten ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 14px);
  max-width: calc(100% - 32px); width: max-content;
  background: #2b2f2c; color: #f2f2ee; border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); font-size: 15px;
}
.toast button { color: #7fd8cd; font-weight: 700; padding: 4px 0; }
body.locked .toast { bottom: calc(var(--safe-b) + 84px); }

@media (max-width: 340px) {
  .head h1 { font-size: 22px; }
  .row { gap: 10px; padding: 8px 12px; }
  .page-body, .plan { padding-left: 12px; padding-right: 12px; }
  .seg button { font-size: 14px; }
  .chip { padding: 0 11px; }
  .pl { height: 38px; font-size: 14px; }
  .box { margin-left: 12px; margin-right: 12px; }
}
