:root {
  color-scheme: dark;
  --bg: #0B1222;
  --surface: #121D35;
  --surface-2: #1B2A4A;
  --line: #26375A;
  --text: #EEF1F6;
  --muted: #95A3BB;
  --gold: #E9B44C;
  --red: #E0475B;
  --green: #4CC38A;
  --lino: #E9B44C;
  --hiller: #6EC3F0;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.num, td, .big { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ Kopf & Navigation */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(11, 18, 34, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top img { width: 34px; height: 34px; border-radius: 9px; }
.top .brand { font-weight: 900; letter-spacing: .06em; font-size: 15px; text-transform: uppercase; }
.top .brand span { color: var(--gold); }
.top .who { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.top .who button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 10px; font: inherit; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center;
  background: rgba(18, 29, 53, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs a {
  flex: 1; max-width: 160px; text-align: center; text-decoration: none;
  padding: 9px 4px 10px; font-size: 11px; color: var(--muted); font-weight: 600;
}
.tabs a svg { display: block; margin: 0 auto 3px; width: 22px; height: 22px; }
.tabs a.on { color: var(--gold); }

/* ------------------------------------------------ Grundbausteine */
h1 { font-size: 22px; margin: 4px 0 14px; letter-spacing: -.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.basis { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.basis::before { content: "Basis: "; font-weight: 600; }
.lino { color: var(--lino); }
.hiller { color: var(--hiller); }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.frames { border-color: var(--gold); color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.flash { padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }
.flash.error { background: rgba(224, 71, 91, .15); border: 1px solid var(--red); }
.flash.ok { background: rgba(76, 195, 138, .12); border: 1px solid var(--green); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 16px; font: 600 15px/1 system-ui, sans-serif; text-decoration: none; cursor: pointer; background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--gold); color: #1A1406; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }

/* ------------------------------------------------ Duell-Kopf */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 6px; text-align: center; }
.duel .name { font-weight: 800; letter-spacing: .05em; text-transform: uppercase; font-size: 13px; }
.duel .big { font-size: 44px; font-weight: 900; line-height: 1; margin-top: 4px; }
.duel .vs { color: var(--muted); font-weight: 800; padding-bottom: 8px; }
.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; margin: 14px 0 6px; background: var(--line); }
.bar .h { background: var(--hiller); }
.bar .l { background: var(--lino); }
.kv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; margin-top: 12px; font-size: 15px; }
.kv .k { text-align: center; color: var(--muted); font-size: 12px; align-self: center; }
.kv .h { text-align: left; }
.kv .l { text-align: right; }
.lead { text-align: center; font-size: 13px; margin-top: 12px; color: var(--muted); }
.lead b { color: var(--text); }

/* ------------------------------------------------ Filter */
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters select { flex: 1; }
select, input, textarea {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: 16px system-ui, sans-serif;
}
textarea { min-height: 70px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ------------------------------------------------ Abend-Liste */
.evening { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 12px 14px; }
.evening + .evening { border-top: 1px solid var(--line); }
.evening .date { width: 64px; flex: none; }
.evening .date b { display: block; font-size: 15px; }
.evening .date span { font-size: 12px; color: var(--muted); }
.evening .mid { flex: 1; min-width: 0; }
.evening .score { font-weight: 800; font-size: 17px; white-space: nowrap; }
.evening .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.evening .crown { font-size: 12px; font-weight: 700; text-align: right; width: 54px; flex: none; }
.list { padding: 0; overflow: hidden; }

/* ------------------------------------------------ Tabellen */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: right; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.tbl td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ------------------------------------------------ Rekorde / Kacheln */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile .t { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.tile .v { font-size: 26px; font-weight: 900; margin-top: 6px; }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile a { text-decoration: none; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.pair > div { min-width: 0; }

/* ------------------------------------------------ Frame-Ansicht (wie Ausdruck) */
.sheet { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.sheet table { border-collapse: collapse; min-width: 640px; width: 100%; background: #F6F3EC; color: #1B1B1B; border-radius: 6px; overflow: hidden; }
.sheet td { border: 1px solid #5B5B5B; text-align: center; padding: 0; font-variant-numeric: tabular-nums; }
.sheet .pn { text-align: left; padding: 4px 8px; font-weight: 700; font-size: 13px; width: 64px; }
.sheet .pn.won { background: #F2DFAE; }
.sheet .fr { width: 52px; }
.sheet .marks { display: flex; justify-content: flex-end; border-bottom: 1px solid #8A8A8A; height: 22px; }
.sheet .marks span { width: 18px; border-left: 1px solid #8A8A8A; font-size: 13px; line-height: 22px; }
.sheet .cum { font-size: 15px; line-height: 26px; }
.sheet .tot { font-size: 22px; font-weight: 800; width: 62px; }
.sheet .hd td { font-size: 10px; color: #555; border-top: 0; }
.sheet .x { font-weight: 800; }

/* ------------------------------------------------ Formular Einzelspiele */
.gamerow { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin-bottom: 10px; background: var(--surface); }
.gamerow .gh { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.gamerow .gh input { width: 92px; padding: 6px 8px; }
.gamerow .gh button { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; }
.pl { display: grid; grid-template-columns: 64px 78px 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.pl input { padding: 8px 10px; }
.pl .frames { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin: 6px 0 10px; }
.seg label { flex: 1; margin: 0; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 9px; font-size: 14px; color: var(--muted); font-weight: 600; }
.seg input:checked + span { background: var(--bg); color: var(--text); }

/* ------------------------------------------------ Diagramm */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ------------------------------------------------ Login */
.login { max-width: 380px; margin: 40px auto; text-align: center; }
.login img { width: 120px; height: 120px; border-radius: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.login form { text-align: left; margin-top: 24px; }

@media (min-width: 640px) {
  .duel .big { font-size: 56px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}

.tbl td.stack span { display: block; line-height: 1.25; }
@media (max-width: 420px) { .tbl { font-size: 13px; } .tbl td, .tbl th { padding: 7px 4px; } }

/* ------------------------------------------------ Upload & Prüfansicht */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin: 0 0 12px;
  padding: 34px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; }
.drop svg { width: 44px; height: 44px; color: var(--gold); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status { margin-bottom: 12px; font-size: 14px; }
.status.good { border-color: var(--green); background: rgba(76, 195, 138, .1); }
.status.warn { border-color: var(--red); background: rgba(224, 71, 91, .1); }
.warnbox { border-color: var(--gold); margin-top: 14px; font-size: 14px; }
.photo summary { cursor: pointer; font-weight: 600; }
.photo img { width: 100%; margin-top: 10px; border-radius: 8px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; margin: 6px 0 0; }
.check input { width: auto; }
.game { margin-bottom: 18px; }
.gh2 { margin-bottom: 6px; }
.tiny { width: 52px; padding: 6px 8px; font-size: 14px; }
.tiny.wide { width: 86px; }
.sheet table.edit { min-width: 700px; }
.sheet .edit .fr { width: 56px; padding: 3px 2px; }
.sheet .edit .mk { width: 100%; padding: 4px 2px; text-align: center; font: 700 15px ui-monospace, Menlo, monospace;
  background: #fff; color: #111; border: 1px solid #bbb; border-radius: 4px; }
.sheet .edit .calc { font-size: 15px; font-weight: 700; margin-top: 3px; }
.sheet .edit .prt { font-size: 11px; color: #777; min-height: 13px; }
.sheet .edit .bad { background: #F9D3D8; }
.sheet .edit .bad .mk { border-color: var(--red); }
.sheet .edit .big2 { font-size: 20px; }
.sheet .edit .mapped { font-weight: 500; color: #666; }
.issue { color: var(--red); margin-top: 4px; }

/* ------------------------------------------------ Selfies */
.selfie { display: block; position: relative; margin-top: 14px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.selfie img { display: block; width: 100%; max-height: 70vh; object-fit: cover; }
.selfie .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 14px 10px; font-size: 13px; font-weight: 600;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; }
.evening .thumb { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--line); }
.drop.small-drop { padding: 14px; flex-direction: row; justify-content: center; border-width: 1px; }

/* ------------------------------------------------ Upload-Feedback */
.drop.chosen { border-style: solid; border-color: var(--green); }
.drop img#prev { max-width: 100%; max-height: 220px; border-radius: 10px; }
.drop .sprev { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.evening .thumb.sq { border-radius: 8px; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(6, 10, 20, .82); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay[hidden] { display: none; }
.ovbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pbar { width: 100%; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.pbar div { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.pbar div.busy { width: 100% !important; background: linear-gradient(90deg, var(--gold) 0 40%, #f6d58e 50%, var(--gold) 60% 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ------------------------------------------------ UHU */
.uhubar { background: rgba(224, 71, 91, .12); border: 1px solid var(--red); border-radius: 12px; padding: 9px 12px; font-size: 13.5px; margin-top: 10px; }
.uhutile .v { font-size: 26px; }
.uhuline { font-size: 13px; color: var(--muted); padding: 3px 0 3px 12px; border-left: 2px solid var(--line); margin: 4px 0 0 2px; }
.sheet .tot.uhu { background: #F9D3D8; position: relative; }
.sheet .owl { font-size: 13px; position: absolute; top: 1px; right: 3px; }
.flash.uhu { background: rgba(233, 180, 76, .15); border: 1px solid var(--gold); font-weight: 600; }
.mind { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .75; line-height: 1; margin-bottom: 2px; }
.uhutile .row { align-items: flex-end; }
.uhutile .v.lino { text-align: right; }
