/* =====================================================================
   Stammtisch – Design (iOS-Stil, optimiert für iPhone 13 und neuer)
   Breiten: 375 pt (13 mini) · 390/393 pt (13–16) · 428–440 pt (Plus/Pro Max)
   ===================================================================== */

:root {
  --bg: #f2f2f7;                       /* iOS „grouped background“ */
  --card: #ffffff;
  --card-2: #f7f7fa;
  --fill: rgba(118, 118, 128, .12);    /* Eingabefelder, getönte Flächen */
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, .14);
  --accent: #1a7f4b;
  --accent-2: #26a465;
  --accent-tint: rgba(26, 127, 75, .12);
  --on-accent: #ffffff;
  --gold: #d4a017;
  --good: #1f8a4c;
  --bad: #d92d20;
  --bad-tint: rgba(217, 45, 32, .10);
  --good-tint: rgba(31, 138, 76, .10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --radius: 18px;
  --radius-sm: 12px;
  --bar-bg: rgba(249, 249, 251, .82);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #232326;
    --fill: rgba(118, 118, 128, .24);
    --text: #f2f2f7;
    --muted: #98989f;
    --line: rgba(84, 84, 88, .55);
    --accent: #30c26f;
    --accent-2: #2aa862;
    --accent-tint: rgba(48, 194, 111, .16);
    --on-accent: #04140b;
    --good: #34d07a;
    --bad: #ff6b5e;
    --bad-tint: rgba(255, 107, 94, .15);
    --good-tint: rgba(52, 208, 122, .14);
    --shadow: none;
    --bar-bg: rgba(22, 22, 24, .78);
  }
}

/* ---------- Grundlagen ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* oben KEIN Safe-Area-Padding – das übernimmt der Header (sonst doppelter Abstand unter Dynamic Island) */
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 20px; font-weight: 700; margin: 2px 0 10px; letter-spacing: -.015em; }
.view > h2 { font-size: 30px; line-height: 1.15; margin: 6px 2px 12px; letter-spacing: -.02em; }
.card h2 { font-size: 18px; }
h3.yearhead { margin: 20px 4px 6px; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
p { margin: 6px 0; }
a { color: var(--accent); }
code { font: 13px ui-monospace, "SF Mono", Menlo, monospace; background: var(--fill); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.block { display: block; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.dim { opacity: .5; }
a, button, .chip, .btn, input, select, label { touch-action: manipulation; }
button, .btn, .chip, .nav a { -webkit-user-select: none; user-select: none; }

/* ---------- Kopfzeile (durchscheinend) ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
}
.sync { font-size: 13px; color: var(--muted); white-space: nowrap; }

.view { padding: 8px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left)); max-width: 680px; margin: 0 auto; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.card.hero {
  background: linear-gradient(150deg, var(--accent-tint), transparent 70%), var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.hero.is-cancelled { background: linear-gradient(150deg, var(--bad-tint), transparent 70%), var(--card); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.kicker { text-transform: uppercase; font-size: 12px; font-weight: 600; letter-spacing: .07em; color: var(--muted); }
.big { font-size: 26px; font-weight: 700; margin: 2px 0; letter-spacing: -.02em; }
.line { margin: 8px 0; }
.link { display: block; color: inherit; text-decoration: none; }
.link:active { transform: scale(.99); }
details summary { cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--accent); }
details summary::-webkit-details-marker { color: var(--muted); }
.bad-box { background: var(--bad); color: #fff; font-weight: 600; box-shadow: none; }
.good-box { background: var(--good); color: #fff; font-weight: 600; box-shadow: none; }
.card.bad { background: var(--bad-tint); color: var(--bad); box-shadow: none; font-weight: 600; }

/* ---------- Tasten ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; margin: 6px 0; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; width: 100%;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active, .chip:active, .nav-btn:active, .big-btn:active { transform: scale(.96); opacity: .85; }
.btn.ghost { background: var(--accent-tint); color: var(--accent); }
.btn.danger { background: var(--bad-tint); color: var(--bad); }
.btn.small-btn, .small-btn { min-height: 44px; width: auto; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn.whatsapp { background: #25d366; color: #052e16; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions .btn { flex: 1 1 auto; margin: 0; }
.actions.sticky { position: sticky; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 4; }
.actions.sticky .btn { box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }

.chip {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--accent-tint); color: var(--accent); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .12s ease;
}
.chip.on { background: var(--fill); color: var(--muted); }
.chip.danger-chip { background: var(--bad-tint); color: var(--bad); }

.nav-btn {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; border: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-tint); color: var(--accent); font-size: 26px; line-height: 1; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
.nav-btn:disabled { opacity: .3; cursor: default; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--fill); color: var(--text); }
.badge.good { background: var(--good-tint); color: var(--good); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }

/* ---------- Formulare ---------- */
.form { display: grid; gap: 12px; }
.form h2 { margin-top: 8px; }
.form.card h2:first-child { margin-top: 0; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; font-weight: 400; }
input, select {
  font: inherit; font-size: 17px; color: var(--text);
  background: var(--fill); border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 14px; min-height: 48px; width: 100%; min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select { -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus { outline: none; border-color: var(--accent); background-color: var(--card); }
input::placeholder { color: var(--muted); opacity: .7; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 24px; padding: 0; accent-color: var(--accent); flex: 0 0 auto; }
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; }
input.invalid { border-color: var(--bad); background-color: var(--bad-tint); }
input.valid { border-color: var(--good); }
[data-hint]:empty { display: none; }
.form-error { font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.filters label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.search { position: relative; display: block; margin: 4px 0 6px; }
.search span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; pointer-events: none; }
.search input { padding-left: 42px; border-radius: 999px; }
.file-btn { cursor: pointer; }

/* ---------- Listen ---------- */
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: .5px solid var(--line); }
.item:last-of-type { border-bottom: 0; }
.item .grow, .grow { flex: 1; min-width: 0; }
.item label.check { white-space: nowrap; }
.item-btn { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.subhead { font-size: 15px; font-weight: 600; margin: 16px 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meeting .row-between { margin-bottom: 4px; }

/* ---------- Startseite ---------- */
.pager { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pager-mid { flex: 1; text-align: center; min-width: 0; }
.hero label { margin-top: 10px; }
.attend-list { display: grid; background: var(--card-2); border-radius: 14px; padding: 2px 12px; }
.attend-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: .5px solid var(--line); }
.attend-row:last-child { border-bottom: 0; }
.attend-row .grow { flex: 1; }
.attend-row.is-absent .grow { color: var(--muted); }
.attend-row .chip { min-width: 100px; }
.attend-row.is-absent .chip { background: var(--bad-tint); color: var(--bad); }

/* ---------- Spieltag ---------- */
.pick { margin: 4px 0 10px; font-weight: 600; }
.players { display: grid; gap: 12px; margin-top: 8px; }
.pad { background: var(--card); border-radius: var(--radius); padding: 14px 12px; box-shadow: var(--shadow); }
.pad.is-absent { opacity: .65; background: var(--card-2); box-shadow: none; }
.pad-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.pname { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ctr { background: var(--card-2); border-radius: 14px; padding: 8px; }
.ctr span { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; margin-bottom: 4px; }
.ctr-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.cnt { font-size: 26px; min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }
.big-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--fill); color: var(--text); font-size: 28px; font-weight: 600; cursor: pointer;
  transition: transform .1s ease;
}
.big-btn.plus { background: var(--accent); color: var(--on-accent); }

/* ---------- Rankings ---------- */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: .5px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row .pos {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rank-row.is-best .pos { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold); }
.rank-row.is-best .rn { font-weight: 700; }
.rank-row .rn { flex: 1; min-width: 0; }
.rank-row b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sym { font-size: 20px; margin-left: 4px; }

/* ---------- Abrechnung ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 8px; text-align: left; border-bottom: .5px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--card-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: .5px solid var(--line); border-bottom: 0; }
.paidbox { width: 26px; height: 26px; }
.card.unpaid { box-shadow: inset 4px 0 0 var(--bad), var(--shadow); }
.card.paid-all { box-shadow: inset 4px 0 0 var(--good), var(--shadow); }
.cash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cash-hero details { margin-top: 10px; }
.cash-hero details .row-between { padding: 6px 0; border-bottom: .5px solid var(--line); }

/* ---------- Daten: Umschalter ---------- */
.switcher { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.switcher-mid { flex: 1; text-align: center; min-width: 0; }
.switcher-mid b { display: block; font-size: 20px; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: inline-flex; gap: 6px; margin-top: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--fill); transition: width .2s ease; }
.dots i.on { width: 18px; border-radius: 4px; background: var(--accent); }
.player-item { border-bottom: .5px solid var(--line); }
.player-item:last-of-type { border-bottom: 0; }
.player-item .item { border-bottom: 0; }
.form.sub { padding: 4px 0 16px; }

/* ---------- Historie / Sicherungen ---------- */
.hist { padding-top: 4px; }
.hist .yearhead { margin: 14px 0 4px; }
.hist .yearhead:first-child { margin-top: 2px; }
.hist-row { padding: 10px 0; border-bottom: .5px solid var(--line); overflow-wrap: anywhere; }
.hist-row:last-child { border-bottom: 0; }
.hist-meta { display: flex; justify-content: space-between; gap: 8px; }
.backup-row { display: grid; gap: 8px; padding: 12px 0; border-bottom: .5px solid var(--line); }
.backup-row:last-of-type { border-bottom: 0; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.backup-actions .chip { min-height: 38px; padding: 0 12px; font-size: 14px; }

/* ---------- Untere Leiste (durchscheinend) ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.nav[hidden] { display: none; }
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 54px; padding: 6px 2px 4px; min-width: 0;
  font-size: 10.5px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.nav a span { font-size: 22px; line-height: 1.1; filter: grayscale(1); opacity: .6; transition: filter .15s, opacity .15s; }
.nav a.on { color: var(--accent); font-weight: 700; }
.nav a.on span { filter: none; opacity: 1; }

/* ---------- Hinweisfenster ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  background: var(--card); color: var(--text); width: 100%; max-width: 620px; max-height: 85dvh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.sheet ol { padding-left: 22px; }
.sheet li { margin: 10px 0; }

.login { max-width: 420px; margin: 28px auto; }

/* ---------- Breitere iPhones (Plus/Pro Max ab 428 pt) und größer ---------- */
@media (min-width: 420px) {
  .big-btn { width: 58px; height: 58px; font-size: 30px; }
  .cnt { min-width: 40px; font-size: 28px; }
  .nav a { font-size: 11px; }
}
@media (min-width: 680px) {
  .nav { left: 50%; transform: translateX(-50%); max-width: 680px; border-radius: 20px 20px 0 0; border-left: .5px solid var(--line); border-right: .5px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
