@import url("fonts/fonts.css");

/* Gleiche Gestaltung wie zMittag: hell und ruhig, weisse Karten, Navy als einziger Akzent. */
:root {
  --bg: #F5F6F8; --card: #FFFFFF; --line: #ECEEF3; --edge: #E1E4EB; --track: #E9EBF0; --hover: #F1F3F7;
  --text: #14161F; --muted: #5E6372; --ink: #1F1A8F; --accent: #1F1A8F; --on-accent: #FFFFFF;
  --cyan: #00D4FF; --float: #14161F;
  --good: #1B7F4B; --good-bg: #E5F5EC; --bad: #B3261E; --bad-bg: #FCEBEA;
  --badge-bg: #DDF5FC; --badge-ink: #005F7A;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 0 0 1px #ECEEF3;
  --font: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
/* Dunkel: per Schalter (data-theme="dark") oder, bei «wie System», wenn das System dunkel ist. Standard ist hell. */
:root[data-theme="dark"] {
    --bg: #0E0F14; --card: #171922; --line: #262935; --edge: #30343F; --track: #22252F; --hover: #1F222D;
    --text: #E9EAF0; --muted: #A3A7B6; --ink: #A9B1FF; --accent: #4A4FE0; --on-accent: #FFFFFF;
    --float: #2C3040;
    --good: #6FD08C; --good-bg: #13291D; --bad: #FF8A80; --bad-bg: #331A1A;
    --badge-bg: #0F3442; --badge-ink: #7FE0F7;
    --shadow: 0 0 0 1px #262935;
    color-scheme: dark;
  }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0E0F14; --card: #171922; --line: #262935; --edge: #30343F; --track: #22252F; --hover: #1F222D;
    --text: #E9EAF0; --muted: #A3A7B6; --ink: #A9B1FF; --accent: #4A4FE0; --on-accent: #FFFFFF;
    --float: #2C3040;
    --good: #6FD08C; --good-bg: #13291D; --bad: #FF8A80; --bad-bg: #331A1A;
    --badge-bg: #0F3442; --badge-ink: #7FE0F7;
    --shadow: 0 0 0 1px #262935;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-size: 17px; line-height: 1.55; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input, textarea { font-family: var(--font); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
p { color: var(--muted); }
a { color: var(--ink); }
.muted { color: var(--muted); font-size: 15px; }
.small { font-size: 14px; font-weight: 400; }
.label { font: 700 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.num, .score { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Kopfzeile ---------- */
header.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); padding: env(safe-area-inset-top, 0px) 16px 0; }
.top .bar { max-width: 560px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 900; font-stretch: 120%; font-size: 20px; color: var(--text); display: inline-flex; align-items: baseline; white-space: nowrap; }
.brand span { color: var(--ink); }
.brand i { width: 6px; height: 6px; border-radius: 50%; background: #00B8E0; margin-left: 3px; }
.top .title { flex: 1; min-width: 0; font-weight: 800; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { width: 40px; height: 40px; padding: 0; border-radius: 10px; border: 1px solid var(--edge); background: var(--card); color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.iconbtn .ico { width: 18px; height: 18px; stroke-width: 2.2; }

#offline { position: sticky; top: 0; z-index: 11; text-align: center; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px; background: var(--badge-bg); color: var(--badge-ink); }

main { max-width: 560px; margin: 0 auto; padding: 24px 16px max(40px, env(safe-area-inset-bottom)); }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
h2 { margin: 32px 0 12px; }
h2.label { display: block; }

/* ---------- Knöpfe ---------- */
button, .btn {
  font: 700 16px var(--font); color: var(--text); cursor: pointer; text-align: center; text-decoration: none;
  background: var(--card); border: 1px solid var(--edge); border-radius: 10px;
  padding: 0 18px; min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, border-color .15s;
}
button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.primary:hover { background: var(--accent); filter: brightness(1.1); }
.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.ghost:hover { background: transparent; color: var(--text); }
.link { background: none; border: 0; min-height: 0; padding: 0; color: var(--ink); font-weight: 600; }
.link:hover { background: none; text-decoration: underline; }
.block { display: flex; width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; }
.stack { display: grid; gap: 10px; }

/* ---------- Karten und Listen ---------- */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; }
.hello { margin: 4px 0 22px; }
.hello p { margin-top: 6px; }
.modes { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.mode { flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: 10px; padding: 18px; min-height: 140px;
  border: 0; border-radius: 16px; box-shadow: var(--shadow); background: var(--card); }
.mode .ico { width: 22px; height: 22px; color: var(--ink); }
.mode b { font-size: 18px; font-weight: 800; line-height: 1.25; }
.mode small { font: 400 15px/1.4 var(--font); color: var(--muted); }

.list { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; justify-content: flex-start;
  padding: 14px 16px; min-height: 64px; border: 0; border-radius: 0; border-top: 1px solid var(--line); background: transparent; font: 600 17px/1.35 var(--font); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .sub { display: block; font: 400 15px/1.4 var(--font); color: var(--muted); margin-top: 3px; }
.item .chev { color: var(--muted); width: 16px; height: 16px; }
.badge { font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px;
  background: var(--track); color: var(--muted); white-space: nowrap; }
.badge.hot { background: var(--badge-bg); color: var(--badge-ink); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.cats { display: grid; grid-template-columns: 1fr 1fr; }
.cats .item { border-top: 1px solid var(--line); }
.cats .item:nth-child(even) { border-left: 1px solid var(--line); }
.cats .item:nth-child(-n+2) { border-top: 0; }

/* ---------- Frage ---------- */
.progress { display: flex; gap: 4px; margin-bottom: 18px; }
.progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--track); }
.progress i.good { background: var(--good); }
.progress i.bad { background: var(--bad); }
.progress i.now { background: var(--ink); }
.meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.question { font-size: 24px; font-weight: 800; line-height: 1.35; margin: 12px 0 22px; letter-spacing: -.01em; }
.answers { display: grid; gap: 10px; }
.answers button { justify-content: flex-start; text-align: left; font: 600 18px/1.35 var(--font); min-height: 60px; padding: 14px 18px; border-radius: 12px; }
.answers button.correct { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.answers button.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.answers button.dim, .answers button.dim:disabled { opacity: .5; }
.answers button:disabled { opacity: 1; cursor: default; }
.feedback { margin-top: 16px; font-size: 18px; font-weight: 700; min-height: 1.5em; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.after { margin-top: 12px; display: grid; gap: 10px; }

/* ---------- Ergebnis und Duell ---------- */
.score { font-size: 40px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 8px; }
.vs .name { font-weight: 700; margin-top: 6px; }
.rounds { display: grid; gap: 0; margin-top: 14px; border-top: 1px solid var(--line); }
.round { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.round:last-child { border-bottom: 0; }
.round .mid { font-size: 15px; color: var(--muted); text-align: center; min-width: 110px; }
.round .mid b { color: var(--text); font-weight: 600; }
.dots { display: flex; gap: 5px; }
.dots.right { justify-content: flex-end; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--track); }
.dots i.good { background: var(--good); }
.dots i.bad { background: var(--bad); }
.dots i.hidden { background: repeating-linear-gradient(45deg, var(--edge), var(--edge) 2px, transparent 2px, transparent 4px); }

/* ---------- Statistik ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 4px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { vertical-align: middle; font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td:first-child { font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; width: 28%; }
td.num b { font-size: 17px; }
/* Statistik: eigene Quote pro Fach, die andere Person klein darunter. */
.statsum { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.statsum > div + div { border-left: 1px solid var(--line); padding-left: 16px; }
.statsum .score { font-size: 34px; margin: 8px 0 6px; }
.statlist { padding: 4px 16px; }
.statrow { padding: 14px 0; border-top: 1px solid var(--line); }
.statrow:first-child { border-top: 0; }
.statline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.statname { font-weight: 700; font-size: 17px; }
.statpct { font: 700 18px var(--mono); }
.statrow .meter { max-width: none; height: 8px; border-radius: 4px; margin: 8px 0 6px; }
.statopp { font-size: 14px; color: var(--muted); }
.statrow.unplayed .statname, .statrow.unplayed .statpct { color: var(--muted); }
.meter { height: 4px; border-radius: 2px; background: var(--track); margin: 6px 0 0 auto; overflow: hidden; max-width: 90px; }
.meter i { display: block; height: 100%; background: var(--accent); }

/* ---------- Bottom Sheet ---------- */
dialog { border: 0; padding: 0; width: min(560px, 100%); max-width: 100%; margin: auto auto 0; background: var(--card); color: var(--text);
  border-radius: 20px 20px 0 0; max-height: 88vh; }
dialog::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--edge); margin: 8px auto 0; }
dialog::backdrop { background: rgba(10, 12, 20, .4); }
#sheet-body { padding: 14px 18px max(20px, env(safe-area-inset-bottom)); display: grid; gap: 12px; overflow: auto; max-height: calc(88vh - 12px); }
#sheet-body h2 { margin: 0; font-size: 22px; font-weight: 800; }
.source { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--edge); text-decoration: none; color: var(--text); }
.source .grow { flex: 1; min-width: 0; }
.source b { display: block; font-size: 17px; }
.source span { display: block; font-size: 14px; color: var(--muted); word-break: break-all; }
.source .ico { color: var(--muted); width: 16px; height: 16px; }
.choices { display: grid; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; }
.choices label { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-weight: 600; border-top: 1px solid var(--line); }
.choices label:first-child { border-top: 0; }
.choices input { width: 18px; height: 18px; accent-color: var(--accent); }
textarea, input[type="text"], input[type="email"], input[type="password"] {
  font: 400 17px var(--font); color: var(--text); background: var(--card); border: 1px solid var(--edge); border-radius: 10px; padding: 12px 14px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
.field { display: grid; gap: 6px; }
.error { color: var(--bad); font-size: 15px; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--float); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 16px; max-width: calc(100% - 32px); }
.empty { text-align: center; padding: 22px 16px; color: var(--muted); border: 1px dashed var(--edge); border-radius: 16px; }

/* ---------- Anmeldung ---------- */
.login { min-height: calc(100vh - 80px); display: grid; align-content: center; gap: 18px; }
.login .logo { display: flex; align-items: center; gap: 12px; }
.login .logo img { width: 48px; height: 48px; border-radius: 12px; }
.login .brand { font-size: 26px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ================= Design A: «Klar» ================= */
.card { border-radius: 18px; }
.list { border-radius: 18px; }
.item { min-height: 72px; padding: 16px 18px; }
.item .num { font-weight: 700; }

/* Startseite: was als Nächstes zu tun ist, steht zuoberst. */
.hero { margin: 4px 0 8px; padding: 20px; display: grid; gap: 4px; }
.hero-row { all: unset; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 2px; }
.hero-row b { font-size: 19px; font-weight: 700; }
.hero .score { font-size: 30px; }
.hero .primary { margin-top: 14px; min-height: 54px; font-size: 17px; border-radius: 12px; }
.segs { display: flex; gap: 6px; margin: 14px 0 8px; }
.segs i { flex: 1; height: 6px; border-radius: 3px; background: var(--track); }
.segs i.d { background: var(--accent); }
.segs i.c { background: var(--cyan); }

/* Frage: Antworten mit Buchstaben, Feedback-Karte mit beiden Quellen. */
.answers button { gap: 14px; min-height: 62px; padding: 10px 16px; border-radius: 14px; }
.answers .key { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  font: 700 13px var(--mono); background: var(--track); color: var(--muted); }
.answers .grow { flex: 1; min-width: 0; }
.answers .tag { font: 700 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.answers button.correct, .answers button.wrong { border-width: 2px; }
.answers button.correct .key { background: var(--good); color: #fff; }
.answers button.wrong .key { background: var(--bad); color: #fff; }
.card.feedback { margin-top: 18px; padding: 16px 18px; min-height: 0; font-size: 17px; font-weight: 400; }
.feedback .srcline { margin-top: 8px; font-size: 14px; color: var(--muted); }
.srcline a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--edge); }
.feedback .verdict { font-size: 20px; font-weight: 800; }
.feedback .verdict.good { color: var(--good); }
.feedback .verdict.bad { color: var(--bad); }
.feedback p { color: var(--text); margin-top: 2px; }
.srcs { margin-top: 12px; }
.src { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); }
.src .grow { flex: 1; min-width: 0; }
.src .n { font: 700 13px var(--mono); color: var(--muted); width: 18px; flex: none; }
.src b { display: block; font-weight: 600; color: var(--ink); line-height: 1.3; }
.src small { display: block; font: 13px var(--mono); color: var(--muted); margin-top: 2px; }
.src .ico { color: var(--muted); width: 16px; height: 16px; }
#sheet-body .srcs { margin-top: 0; }
.after { margin-top: 18px; gap: 4px; }
.after .primary { min-height: 54px; font-size: 17px; border-radius: 12px; }
.after .ghost { gap: 8px; font-weight: 600; }

/* Duell: Anzeigetafel und Runden als Tabelle. Falsch = leerer Ring, verdeckt = grau. */
.board { padding: 22px 20px 18px; text-align: center; }
.board .vs { align-items: end; }
.board .score { font-size: 44px; }
.board .colon { color: var(--muted); font-size: 32px; padding-bottom: 34px; }
.board .name { font-size: 18px; }
.rounds { margin-top: 14px; border-top: 0; padding: 0; overflow: hidden; }
.rd { display: grid; grid-template-columns: 20px 1fr 52px 52px; align-items: center; gap: 10px; padding: 0 18px; min-height: 60px; border-top: 1px solid var(--line); }
.rd.head { min-height: 0; padding-top: 14px; padding-bottom: 8px; border-top: 0; }
.rd.head span:nth-child(n+3) { text-align: center; }
.rd .no { font: 700 14px var(--mono); color: var(--muted); }
.rd .f { font-weight: 600; font-size: 17px; line-height: 1.3; }
.rd .f small { display: block; color: var(--muted); font-size: 14px; font-weight: 400; }
.rd.now { background: var(--hover); }
.rd.open .f { color: var(--muted); font-weight: 400; }
.rd .dots, .legend .dots { justify-content: center; }
.dots i { width: 12px; height: 12px; }
.rd .dots { gap: 4px; }
.dots i.bad { background: transparent; box-shadow: inset 0 0 0 2.5px var(--bad); }
.dots i.hidden { background: var(--muted); opacity: .45; }
.legend { display: flex; gap: 18px; justify-content: center; color: var(--muted); font-size: 14px; margin-top: 12px; }
.legend > span { display: inline-flex; gap: 6px; align-items: center; }
