/* Tagesrätsel – eigenes Aussehen: warmes Papier, Tinte, Türkis/Bernstein */
:root {
  --bg: #f6f2ea;
  --karte: #fffdf8;
  --karte2: #f1ebe0;
  --text: #1f2230;
  --muted: #6c6a74;
  --linie: #e3dccf;
  --akzent: #4b3fb8;
  --akzent-text: #fff;
  --ich: #4b3fb8;
  --du: #c2416c;
  --treffer: #0e8a86;
  --drin: #df8a2c;
  --nix: #8f8a82;
  --leer: #ece5d8;
  --gut: #1e8a4c;
  --schlecht: #c8372d;
  --schatten: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --r: 16px;
  --unten: calc(64px + env(safe-area-inset-bottom));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151b;
    --karte: #211f28;
    --karte2: #2a2833;
    --text: #ecebf2;
    --muted: #a3a0ad;
    --linie: #37343f;
    --akzent: #8f84ff;
    --akzent-text: #15131d;
    --ich: #8f84ff;
    --du: #f07ba0;
    --treffer: #17a39e;
    --drin: #e2953e;
    --nix: #57545c;
    --leer: #2c2a33;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: var(--unten);
  -webkit-tap-highlight-color: transparent;
}
body.im-spiel { padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--akzent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.klein { font-size: .86rem; }

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linie);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text); font-size: 1.1rem; flex: none;
}
.icon-btn:active { background: var(--karte2); }
.sync { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nix); }
.sync[data-state="live"] .dot { background: var(--gut); }
.sync[data-state="off"] .dot { background: var(--schlecht); }
.sync[data-state="demo"] .dot { background: var(--drin); }

.banner { margin: 10px 16px 0; padding: 10px 14px; border-radius: 12px; font-size: .9rem; }
.banner.demo { background: color-mix(in srgb, var(--drin) 20%, var(--karte)); }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }
.ansicht > h2 { font-size: 1.05rem; margin: 18px 4px 8px; }
.karte {
  background: var(--karte); border-radius: var(--r); box-shadow: var(--schatten);
  padding: 16px; margin-bottom: 12px;
}

/* ---------- Anmeldung ---------- */
.login { display: grid; place-items: center; padding: 40px 16px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; }
.login h2 { margin: 4px 0 0; }
.login label { display: grid; gap: 4px; text-align: left; font-size: .9rem; }
input[type=email], input[type=password], input[type=text], input[type=time] {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--linie); background: var(--karte);
}
input[type=time] { width: auto; }
.fehler { color: var(--schlecht); margin: 0; font-size: .9rem; }

.btn {
  border: 1px solid var(--linie); background: var(--karte); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: .95rem;
}
.btn:active { transform: scale(.98); }
.btn.primaer { background: var(--akzent); color: var(--akzent-text); border-color: transparent; }
.btn.gefahr { color: var(--schlecht); }
.btn.klein { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; }
.knoepfe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Heute ---------- */
.tageskopf { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 4px 12px; gap: 8px; }
.tageskopf h2 { margin: 0; font-size: 1.25rem; }
.duell {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center;
}
.duell .person { display: grid; gap: 2px; }
.duell .name { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duell .zahl { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.duell .ich .zahl { color: var(--ich); }
.duell .du .zahl { color: var(--du); }
.duell .mitte { font-size: .8rem; color: var(--muted); }
.serien { display: flex; justify-content: center; gap: 14px; margin-top: 10px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }

.spielkarte { display: grid; grid-template-columns: 48px 1fr; gap: 4px 14px; align-items: center; cursor: pointer; }
.spielkarte:active { transform: scale(.995); }
.spielkarte .symbol { grid-row: span 2; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.15rem; }
.symbol.wort { background: var(--treffer); }
.symbol.sudoku { background: var(--akzent); }
.symbol.quiz { background: var(--drin); }
.spielkarte h3 { margin: 0; font-size: 1.08rem; }
.spielkarte .unter { font-size: .86rem; color: var(--muted); }
.spielkarte .stand { grid-column: 1 / -1; display: grid; gap: 6px; margin-top: 10px; }
.standzeile { display: flex; align-items: center; gap: 8px; font-size: .9rem; min-height: 28px; }
.standzeile .wer { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.standzeile .wer.ich { background: var(--ich); }
.standzeile .wer.du { background: var(--du); }
.standzeile .was { flex: 1; min-width: 0; }
.standzeile .p { font-weight: 700; font-variant-numeric: tabular-nums; }
.mini { display: inline-grid; grid-template-columns: repeat(5, 7px); gap: 2px; vertical-align: middle; margin-left: 4px; }
.mini i { width: 7px; height: 7px; border-radius: 2px; background: var(--nix); }
.mini i.t { background: var(--treffer); }
.mini i.d { background: var(--drin); }
.pille { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; background: var(--karte2); color: var(--muted); }
.pille.ok { background: color-mix(in srgb, var(--gut) 16%, var(--karte)); color: var(--gut); }

/* ---------- Unten-Navigation ---------- */
.unten {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--karte) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--linie);
}
.unten button {
  flex: 1; max-width: 140px; border: 0; background: transparent; display: grid; justify-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 14px; color: var(--muted); font-size: .75rem; font-weight: 600;
}
.unten svg { width: 24px; height: 24px; }
.unten button[aria-current="page"] { color: var(--akzent); background: color-mix(in srgb, var(--akzent) 12%, transparent); }

/* ---------- Vergleich ---------- */
.wochenkopf { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.wochenkopf h2 { margin: 0; font-size: 1.05rem; text-align: center; flex: 1; }
table.woche { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.woche th, table.woche td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--linie); }
table.woche th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.woche td:first-child, table.woche th:first-child { text-align: left; }
table.woche tr.heute td { font-weight: 700; }
table.woche tfoot td { border-bottom: 0; font-weight: 800; font-size: 1.05rem; }
td .sieg { display: inline-block; min-width: 2.2em; padding: 1px 6px; border-radius: 8px; }
td.ich .sieg.ja { background: color-mix(in srgb, var(--ich) 18%, transparent); }
td.du .sieg.ja { background: color-mix(in srgb, var(--du) 18%, transparent); }
.kopfname.ich { color: var(--ich); }
.kopfname.du { color: var(--du); }
.spielsummen { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px 12px; font-variant-numeric: tabular-nums; align-items: center; }
.spielsummen .r { text-align: right; }
.balken { height: 8px; border-radius: 4px; background: var(--leer); overflow: hidden; }
.balken i { display: block; height: 100%; border-radius: 4px; }
.serientab { width: 100%; border-collapse: collapse; }
.serientab td, .serientab th { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--linie); font-variant-numeric: tabular-nums; }
.serientab th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.serientab td:first-child { text-align: left; }
.verteilung { display: grid; grid-template-columns: 18px 1fr; gap: 4px 8px; align-items: center; font-size: .82rem; }
.verteilung .zeile2 { display: grid; gap: 2px; }
.verteilung .bal { height: 9px; border-radius: 3px; min-width: 2px; }
.verteilung .bal.ich { background: var(--ich); }
.verteilung .bal.du { background: var(--du); }

/* ---------- Archiv ---------- */
.archivliste { list-style: none; margin: 0; padding: 0; }
.archivliste li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 12px 14px; background: var(--karte); border-radius: 14px; margin-bottom: 8px; box-shadow: var(--schatten); cursor: pointer;
}
.archivliste .d { font-weight: 600; }
.archivliste .s { font-size: .82rem; color: var(--muted); }
.archivliste .pp { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.4em; text-align: right; }
.pp.ich { color: var(--ich); }
.pp.du { color: var(--du); }
.tagzeile { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.tagzeile .symbol { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; }
.tagzeile .info { font-size: .88rem; display: grid; gap: 2px; }

/* ---------- Dialoge ---------- */
dialog.sheet {
  border: 0; padding: 0 16px 24px; width: min(560px, 100%); max-height: 92dvh; margin: auto auto 0;
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text); overflow: auto;
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog::backdrop { background: rgba(10, 8, 20, .45); }
.sheet-kopf { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; background: var(--bg); z-index: 1; }
.sheet-kopf h2 { margin: 0; font-size: 1.15rem; }
.block { background: var(--karte); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; }
.block h3 { margin: 0 0 6px; font-size: 1rem; }
.zeile { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.schalter { display: flex; gap: 8px; align-items: center; }
.schalter input { width: 20px; height: 20px; accent-color: var(--akzent); }
.status { margin: 0; font-weight: 600; }
.infos { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: .92rem; }
.regel { display: block; margin: 4px 0; font-size: .85rem; }
i.f { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: #fff; font-style: normal; font-weight: 800; font-size: .75rem; vertical-align: middle; }
i.f.treffer { background: var(--treffer); }
i.f.drin { background: var(--drin); }
i.f.nix { background: var(--nix); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--unten) + 12px); z-index: 50;
  display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; box-shadow: var(--schatten); font-size: .92rem;
}
body.im-spiel .toast { bottom: auto; top: calc(70px + env(safe-area-inset-top)); }
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 700; text-decoration: underline; }

/* ===================================================================
   Spiele
   =================================================================== */
.spiel { padding-top: 0; }
.spielkopf { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 2px 10px; font-size: .88rem; color: var(--muted); min-height: 28px; }
.spielkopf .uebung { background: color-mix(in srgb, var(--drin) 22%, var(--karte)); color: var(--text); padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.ergebnis { text-align: center; }
.ergebnis h3 { margin: 0 0 4px; font-size: 1.2rem; }
.ergebnis .gross { font-size: 2.2rem; font-weight: 800; color: var(--akzent); line-height: 1.2; }
.vergleichzeile { display: flex; justify-content: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; font-size: .9rem; }

/* ---------- Fünfer ---------- */
.fuenfer { display: flex; flex-direction: column; min-height: calc(100dvh - 76px - env(safe-area-inset-top)); }
.raster5 { display: grid; gap: 7px; margin: 4px auto 12px; width: min(100%, 330px); }
.reihe { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.reihe.wackeln { animation: wackeln .4s; }
@keyframes wackeln { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.feld {
  aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center;
  font-size: clamp(1.4rem, 7vw, 1.9rem); font-weight: 800; text-transform: uppercase;
  background: var(--karte); box-shadow: inset 0 0 0 2px var(--linie);
}
.feld.voll { box-shadow: inset 0 0 0 2px var(--muted); animation: plopp .12s; }
@keyframes plopp { 50% { transform: scale(1.07); } }
.feld.t, .feld.d, .feld.n { color: #fff; box-shadow: none; }
.reihe.neu .feld { animation: auf .35s both; }
.feld.t { background: var(--treffer); border-radius: 50%; }
.feld.d { background: var(--drin); border-radius: 14px 4px 14px 4px; }
.feld.n { background: var(--nix); }
.reihe .feld:nth-child(2) { animation-delay: .07s; }
.reihe .feld:nth-child(3) { animation-delay: .14s; }
.reihe .feld:nth-child(4) { animation-delay: .21s; }
.reihe .feld:nth-child(5) { animation-delay: .28s; }
@keyframes auf { from { transform: scale(.6) rotate(-8deg); opacity: .3; } to { transform: none; opacity: 1; } }
.tastatur { margin-top: auto; display: grid; gap: 6px; padding-bottom: 6px; user-select: none; }
.tastenreihe { display: flex; gap: 4px; justify-content: center; }
.taste {
  flex: 1; max-width: 44px; height: 54px; border: 0; border-radius: 10px; background: var(--karte2);
  font-weight: 700; font-size: 1.02rem; padding: 0; touch-action: manipulation; box-shadow: 0 1px 0 var(--linie);
}
.taste.breit { max-width: 64px; flex: 1.5; font-size: .8rem; }
.taste:active { filter: brightness(.9); }
.taste.t { background: var(--treffer); color: #fff; }
.taste.d { background: var(--drin); color: #fff; }
.taste.n { background: var(--nix); color: #fff; opacity: .55; }

/* ---------- Sudoku ---------- */
.sudoku-wrap { display: grid; gap: 12px; }
.sgitter {
  display: grid; grid-template-columns: repeat(9, 1fr); width: min(100%, 460px); margin: 0 auto; aspect-ratio: 1;
  background: var(--karte); border: 2.5px solid var(--text); border-radius: 10px; overflow: hidden; user-select: none;
}
.zelle {
  position: relative; display: grid; place-items: center; border-right: 1px solid var(--linie); border-bottom: 1px solid var(--linie);
  font-size: clamp(1.1rem, 5.6vw, 1.7rem); font-variant-numeric: tabular-nums; color: var(--akzent); cursor: pointer;
}
.zelle:nth-child(9n) { border-right: 0; }
.zelle.r3 { border-right: 2px solid var(--text); }
.zelle.u3 { border-bottom: 2px solid var(--text); }
.zelle.vorgabe { color: var(--text); font-weight: 700; }
.zelle.bezug { background: color-mix(in srgb, var(--akzent) 7%, transparent); }
.zelle.gleich { background: color-mix(in srgb, var(--akzent) 20%, transparent); }
.zelle.aktiv { background: color-mix(in srgb, var(--akzent) 30%, transparent); }
.zelle.falsch { color: var(--schlecht); }
.zelle.konflikt::after { content: ""; position: absolute; inset: 3px; border-radius: 6px; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--schlecht) 60%, transparent); }
.notizen { position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr); font-size: clamp(.5rem, 2.3vw, .7rem); color: var(--muted); line-height: 1; }
.notizen span { display: grid; place-items: center; }
.notizen span.hl { color: var(--akzent); font-weight: 800; }
.sleiste { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.wbtn { border: 1px solid var(--linie); background: var(--karte); border-radius: 12px; padding: 8px 12px; font-size: .85rem; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.wbtn.an { background: var(--akzent); color: var(--akzent-text); border-color: transparent; }
.ziffern { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; width: min(100%, 460px); margin: 0 auto; }
.ziffer { height: 56px; border: 0; border-radius: 12px; background: var(--karte2); font-size: 1.35rem; font-weight: 700; display: grid; place-items: center; line-height: 1; padding: 0; touch-action: manipulation; }
.ziffer small { display: block; font-size: .62rem; color: var(--muted); font-weight: 600; }
.ziffer.fertig { opacity: .35; }
.ziffer:active { filter: brightness(.9); }
.uhr { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }

/* ---------- Quiz ---------- */
.quiz { display: grid; gap: 12px; }
.fortschritt { display: flex; gap: 4px; }
.fortschritt i { flex: 1; height: 6px; border-radius: 3px; background: var(--leer); }
.fortschritt i.r { background: var(--gut); }
.fortschritt i.f { background: var(--schlecht); }
.fortschritt i.jetzt { background: var(--akzent); }
.kategorie { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--drin); }
.frage { font-size: 1.18rem; font-weight: 700; margin: 4px 0 0; line-height: 1.35; }
.antworten { display: grid; gap: 8px; }
.antwort {
  text-align: left; border: 2px solid var(--linie); background: var(--karte); border-radius: 14px; padding: 13px 14px;
  font-size: 1rem; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
}
.antwort .bst { width: 26px; height: 26px; border-radius: 8px; background: var(--karte2); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.antwort.richtig { border-color: var(--gut); background: color-mix(in srgb, var(--gut) 12%, var(--karte)); }
.antwort.falsch { border-color: var(--schlecht); background: color-mix(in srgb, var(--schlecht) 10%, var(--karte)); }
.antwort:disabled { cursor: default; color: var(--text); }
.antwort .wer2 { display: flex; gap: 3px; }
.antwort .wer2 i { width: 10px; height: 10px; border-radius: 50%; }
.antwort .wer2 i.ich { background: var(--ich); }
.antwort .wer2 i.du { background: var(--du); }
.erklaerung { background: var(--karte2); border-radius: 14px; padding: 12px 14px; font-size: .93rem; }
.erklaerung p { margin: 0 0 6px; }
.quelle { font-size: .85rem; }
.hinweisbox { text-align: center; padding: 28px 16px; }
.hinweisbox .gross { font-size: 2.4rem; }
.rueckblick { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rueckblick li { background: var(--karte); border-radius: 12px; padding: 10px 12px; font-size: .9rem; box-shadow: var(--schatten); cursor: pointer; }
.rueckblick .kopf { display: flex; gap: 8px; align-items: baseline; }
.rueckblick .zeichen { font-weight: 800; }
.zeichen.ok { color: var(--gut); }
.zeichen.nok { color: var(--schlecht); }
.lade { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--linie); border-top-color: var(--akzent); border-radius: 50%; animation: dreh 1s linear infinite; vertical-align: middle; }
@keyframes dreh { to { transform: rotate(360deg); } }

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