/* WortWerk – Stylesheet
 * Eigene Identität: warmes Papier + Tinte, Akzent in tiefem Indigo,
 * Feedback-Farben Grün/Gelb/Grau. Mobile-first, Light/Dark via Tokens.
 */

:root {
  --bg: #f6f3ec;
  --flaeche: #ffffff;
  --tinte: #23262e;
  --tinte-2: #6b6e78;
  --akzent: #4338ca;
  --akzent-tinte: #ffffff;
  --rand: #d8d3c6;
  --kachel-rand: #c6c0b2;
  --kachel-rand-aktiv: #8f8a7c;
  --richtig: #3a9e5f;
  --enthalten: #d9a514;
  --fehlt: #787c86;
  --feedback-tinte: #ffffff;
  --taste-bg: #e6e1d5;
  --taste-tinte: #23262e;
  --toast-bg: #23262e;
  --toast-tinte: #f6f3ec;
  --schatten: 0 12px 32px rgba(35, 38, 46, 0.16);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a21;
    --flaeche: #1f232c;
    --tinte: #e8e6df;
    --tinte-2: #9a9daa;
    --akzent: #8b85f0;
    --akzent-tinte: #14161c;
    --rand: #333846;
    --kachel-rand: #3b4150;
    --kachel-rand-aktiv: #6a7184;
    --richtig: #3f9e63;
    --enthalten: #c99a1b;
    --fehlt: #444a58;
    --feedback-tinte: #f4f3ee;
    --taste-bg: #3a4050;
    --taste-tinte: #e8e6df;
    --toast-bg: #e8e6df;
    --toast-tinte: #171a21;
    --schatten: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--tinte);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ===================== Header ===================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--rand);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-name {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.brand-name em {
  font-style: normal;
  color: var(--akzent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  color: var(--tinte);
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--kachel-rand-aktiv); }

/* ===================== Buttons ===================== */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  color: var(--tinte);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-tinte);
}

.btn-ghost { background: transparent; }

.btn-small { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.link-button {
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: var(--tinte-2);
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem;
}

/* ===================== Spielfeld ===================== */

#main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.raetsel-nummer {
  font-size: 0.85rem;
  color: var(--tinte-2);
}

.grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: min(88vw, 340px);
}

.reihe {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.kachel {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 7vw, 2rem);
  font-weight: 800;
  text-transform: uppercase;
  border: 2px solid var(--kachel-rand);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--tinte);
  user-select: none;
}

.kachel.gefuellt {
  border-color: var(--kachel-rand-aktiv);
  animation: kachel-pop 0.12s ease;
}

@keyframes kachel-pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.kachel.enthuellt {
  animation: kachel-flip 0.55s ease both;
  border-color: transparent;
  color: var(--feedback-tinte);
}

.kachel.enthuellt.sofort { animation: none; }

.zustand-richtig { background: var(--richtig); }
.zustand-enthalten { background: var(--enthalten); }
.zustand-fehlt { background: var(--fehlt); }

@keyframes kachel-flip {
  0% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.reihe.schuetteln { animation: schuetteln 0.5s ease; }

@keyframes schuetteln {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .kachel.gefuellt,
  .kachel.enthuellt,
  .reihe.schuetteln { animation: none !important; }
}

/* ===================== Tastatur ===================== */

.tastatur {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 0.4rem;
}

.tasten-reihe {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.taste {
  flex: 1;
  max-width: 44px;
  height: 52px;
  border: none;
  border-radius: 6px;
  background: var(--taste-bg);
  color: var(--taste-tinte);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}

.taste:active { transform: translateY(1px); }

.taste-breit {
  flex: 1.6;
  max-width: 72px;
  font-size: 0.75rem;
}

.taste.zustand-richtig { background: var(--richtig); color: var(--feedback-tinte); }
.taste.zustand-enthalten { background: var(--enthalten); color: var(--feedback-tinte); }
.taste.zustand-fehlt { background: var(--fehlt); color: var(--feedback-tinte); opacity: 0.85; }

/* ===================== Toast ===================== */

.toast-wrap {
  position: fixed;
  top: 4.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-tinte);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  box-shadow: var(--schatten);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.toast-weg { opacity: 0; }

/* ===================== Anzeige & Footer ===================== */

.ad-slot {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 56px;
  border: 1px dashed var(--rand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tinte-2);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 0.6rem 0.9rem 0.9rem;
  color: var(--tinte-2);
  font-size: 0.85rem;
}

/* ===================== Modals ===================== */

.modal {
  border: none;
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--tinte);
  box-shadow: var(--schatten);
  padding: 1.3rem 1.4rem;
  width: min(92vw, 26rem);
  margin: auto;
}

.modal::backdrop { background: rgba(10, 12, 18, 0.55); }

.modal h3 { margin-bottom: 0.7rem; font-size: 1.2rem; }

.modal p { margin-bottom: 0.7rem; line-height: 1.5; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.todo-note {
  font-size: 0.8rem;
  color: var(--tinte-2);
  border-left: 3px solid var(--enthalten);
  padding-left: 0.6rem;
}

.premium-list {
  margin: 0 0 0.7rem 1.1rem;
  line-height: 1.6;
}

.premium-price { font-size: 1.05rem; }

/* Hilfe-Beispiele */
.hilfe-beispiel p {
  font-size: 0.9rem;
  margin: 0.35rem 0 0.8rem;
  color: var(--tinte-2);
}

.hilfe-reihe { display: flex; gap: 4px; }

.kachel.mini {
  width: 2.2rem;
  height: 2.2rem;
  aspect-ratio: auto;
  font-size: 1.1rem;
  flex: none;
}

/* Lernen & Übungsmodus */
.uebung-badge {
  display: inline-block;
  background: var(--akzent);
  color: var(--akzent-tinte);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  margin-right: 0.4rem;
  vertical-align: 0.05em;
}

.uebung-leiste {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.uebung-leiste[hidden] { display: none; }

.tipp-karte {
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.6rem;
}

.tipp-karte h4 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.tipp-karte p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--tinte-2);
  line-height: 1.45;
}

/* Einstellungen */
.schalter-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.schalter-zeile small { color: var(--tinte-2); line-height: 1.4; }

.schalter-zeile input {
  width: 2.6rem;
  height: 1.4rem;
  accent-color: var(--akzent);
  flex: none;
}

/* Statistik */
.stat-zeile {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.stat-wert b { display: block; font-size: 1.5rem; }

.stat-wert span { font-size: 0.72rem; color: var(--tinte-2); }

.verteilung { display: flex; flex-direction: column; gap: 5px; }

.verteilung-zeile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.verteilung-nr { width: 1rem; text-align: right; font-weight: 700; }

.balken-spur { flex: 1; }

.balken {
  background: var(--fehlt);
  color: var(--feedback-tinte);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-align: right;
  min-width: 1.4rem;
}

.balken-aktiv { background: var(--richtig); }

/* Countdown */
.countdown-box {
  margin-top: 1rem;
  text-align: center;
}

.countdown-label {
  display: block;
  font-size: 0.8rem;
  color: var(--tinte-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.countdown {
  font-size: 1.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ===================== Kleine Screens ===================== */

@media (max-width: 360px) {
  .taste { height: 46px; }
  .brand-name { font-size: 1.05rem; }
}
