/* STV Spreitenbach – Statistik-App */
:root {
  --blue: #1a3a7a; --blue-l: #2952a3; --blue-d: #0f2654; --accent: #4a90d9;
  --bg: #eef2f9; --card: #ffffff; --text: #1e293b; --muted: #64748b; --line: rgba(0,0,0,.09);
  --chip: rgba(0,0,0,.04); --green: #10b981; --red: #ef4444; --amber: #f59e0b; --purple: #8b5cf6;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b111d; --card: #151d2e; --text: #e2e8f0; --muted: #94a3b8; --line: rgba(255,255,255,.09);
    --chip: rgba(255,255,255,.06); --accent: #6aa7ea; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b111d; --card: #151d2e; --text: #e2e8f0; --muted: #94a3b8; --line: rgba(255,255,255,.09);
  --chip: rgba(255,255,255,.06); --accent: #6aa7ea; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.4; min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
body.no-nav { padding-bottom: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 48px; gap: 8px; }
.boot div { font-size: 18px; font-weight: 800; } .boot small { font-size: 13px; color: var(--muted); }

/* Header */
.hdr {
  position: sticky; top: 0; z-index: 50; color: #fff;
  background: linear-gradient(135deg, var(--blue-d), var(--blue));
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.hdr .logo { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.3); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.hdr .ttl { flex: 1; min-width: 0; }
.hdr .ttl b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr .ttl small { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; opacity: .75; }
.hdr .back { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; }
.sync { font-size: 12px; padding: 5px 9px; border-radius: 20px; background: rgba(255,255,255,.14); white-space: nowrap; border: 0; color: #fff; }
.sync.warn { background: var(--amber); color: #1e293b; font-weight: 700; }

/* Bottom nav */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav button { flex: 1; border: 0; background: none; padding: 9px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.nav button span { font-size: 21px; line-height: 1; }
.nav button.on { color: var(--accent); }

.wrap { max-width: 960px; margin: 0 auto; padding: 14px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.sec { font-size: 12px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 11px; }
.center { text-align: center; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic { font-size: 44px; margin-bottom: 10px; }

/* Buttons */
.btn { border: 0; border-radius: 11px; padding: 12px 18px; font-weight: 700; background: linear-gradient(135deg, var(--blue), var(--blue-l)); color: #fff; }
.btn.sec2 { background: var(--chip); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(239,68,68,.14); color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 6px 0; }

/* Chips / Segmented */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--chip); border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.on.pp { background: var(--green); border-color: var(--green); }
.chip.on.bp { background: var(--purple); border-color: var(--purple); }

/* Forms */
label.lbl { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 14px 0 6px; }
input.in, select.in, textarea.in { width: 100%; padding: 12px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); outline: none; font-size: 16px; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--accent); }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 1em; }

/* Auth */
.auth { max-width: 380px; margin: 0 auto; padding: 48px 20px; }
.auth .big { font-size: 56px; text-align: center; }
.auth h1 { text-align: center; margin: 6px 0 2px; font-size: 22px; }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* Stats tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.tile { background: var(--chip); border-radius: 12px; padding: 12px; text-align: center; }
.tile b { display: block; font-size: 24px; color: var(--accent); line-height: 1.1; }
.tile span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tile i { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--card); }
.tbl th.sorted { color: var(--accent); }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl td.name { font-weight: 700; white-space: normal; min-width: 120px; }
.tbl tr.inactive td { opacity: .55; }

/* Player list */
.plist .pl { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--chip); margin-bottom: 7px; border: 0; width: 100%; text-align: left; }
.num { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--blue), var(--blue-l)); color: #fff; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; font-size: 15px; }
.num.gk { background: linear-gradient(135deg, #b45309, var(--amber)); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--chip); color: var(--muted); margin-right: 4px; }
.badge.g { background: rgba(16,185,129,.15); color: var(--green); }
.badge.r { background: rgba(239,68,68,.15); color: var(--red); }
.badge.a { background: rgba(245,158,11,.18); color: #b45309; }
.badge.p { background: rgba(139,92,246,.15); color: var(--purple); }
.badge.b { background: rgba(74,144,217,.15); color: var(--accent); }

/* Game list */
.gm { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); margin-bottom: 8px; width: 100%; text-align: left; }
.gm .res { font-size: 20px; font-weight: 800; min-width: 64px; text-align: center; border-radius: 10px; padding: 6px 4px; background: var(--chip); }
.gm .res.w { background: rgba(16,185,129,.15); color: var(--green); }
.gm .res.l { background: rgba(239,68,68,.12); color: var(--red); }
.gm .res.d { background: rgba(245,158,11,.15); color: #b45309; }

/* Game screen */
.score { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px 12px; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, var(--blue-d), var(--blue-l)); margin-bottom: 12px; }
.score .t { flex: 1; text-align: center; font-weight: 700; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.score .n { font-size: 44px; font-weight: 900; letter-spacing: 2px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.act { border: 0; border-radius: 16px; padding: 20px 10px; font-size: 17px; font-weight: 800; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.act span { font-size: 28px; }
.act.goal { background: linear-gradient(135deg, #059669, #10b981); }
.act.against { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.act.pen { background: linear-gradient(135deg, #b45309, #f59e0b); }
.act.opp { background: linear-gradient(135deg, #475569, #64748b); }
.ev { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px; background: var(--chip); margin-bottom: 6px; width: 100%; border: 0; text-align: left; }
.ev .sc { font-weight: 800; min-width: 44px; text-align: center; font-size: 15px; }
.ev .ic { font-size: 20px; }

/* Picker grid (Spieler-Knöpfe) */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 7px; }
.pbtn { border: 2px solid var(--line); background: var(--chip); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; justify-content: center; }
.pbtn b { font-size: 19px; line-height: 1.1; }
.pbtn small { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 3px; }
.pbtn.on { border-color: var(--blue-l); background: rgba(41,82,163,.18); }
.pbtn.on.multi { border-color: var(--green); background: rgba(16,185,129,.16); }
.pbtn.none small { font-size: 12px; }
.pbtn.gk b { color: #b45309; }

/* Sheet (Modal von unten) */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
.sheet .foot { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--card); padding: 12px 0 calc(4px + env(safe-area-inset-bottom)); margin-top: 16px; display: flex; gap: 8px; border-top: 1px solid var(--line); }

#toast { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 300; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: .95; }
.season-sel { width: auto; flex: 1 1 140px; min-width: 140px; }
