/* Wortblüte – Gestaltung. Keine externen Schriften, nur System-Fonts. */

:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #26231e;
  --muted: #7a7365;
  --accent: #5f7d3a;
  --accent-ink: #ffffff;
  --petal: #fffdf8;
  --petal-ink: #26231e;
  --center: #5f7d3a;
  --center-ink: #ffffff;
  --line: #e0d7c4;
  --ok: #3c7a3c;
  --err: #b3402f;
  --chip: #efe7d6;
  --shadow: 0 2px 6px rgba(60, 50, 30, 0.14);
}

html[data-theme='dark'] {
  --bg: #181b15;
  --card: #232721;
  --ink: #e9e5d9;
  --muted: #9a958a;
  --accent: #8fb56a;
  --accent-ink: #141711;
  --petal: #2b3028;
  --petal-ink: #e9e5d9;
  --center: #8fb56a;
  --center-ink: #141711;
  --line: #3a4036;
  --ok: #8cc98c;
  --err: #e08a7a;
  --chip: #31362d;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.loading {
  height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1rem;
}

#app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) 14px max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
}

/* ---------- Kopfzeile ---------- */
header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 6px;
  padding: 2px 0 6px;
}

.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }

.spacer { flex: 1; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); }

.iconbtn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Status ---------- */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 2px 4px;
  white-space: nowrap;
}

#score { color: var(--ink); font-weight: 700; font-size: 0.95rem; }

.rankbar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

#rankfill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

#rankname { font-weight: 600; color: var(--ink); }

/* ---------- Rückmeldung und Eingabe ---------- */
.message {
  min-height: 1.35em;
  text-align: center;
  font-size: 0.92rem;
  color: var(--muted);
}

.message.ok { color: var(--ok); font-weight: 600; }
.message.err { color: var(--err); font-weight: 600; }

.typed {
  min-height: 2.3rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.25rem, 6vw, 1.8rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  user-select: none;
}

.typed span { cursor: pointer; padding: 0 1px; }
.typed span:hover { color: var(--accent); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake { animation: shake 0.3s; }

/* ---------- Blüte ---------- */
main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 0;
  container-type: size;
}

.flower {
  position: relative;
  width: min(100%, 100cqh);
  aspect-ratio: 1;
  container-type: size;
}

.cell {
  position: absolute;
  translate: -50% -50%;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--petal);
  color: var(--petal-ink);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 8cqw;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.cell:hover { filter: brightness(0.96); }
.cell:active { transform: scale(0.93); }

.cell.petal { width: 30%; height: 30%; }

.cell.center {
  width: 36%;
  height: 36%;
  background: var(--center);
  color: var(--center-ink);
  border-color: transparent;
  font-size: 11cqw;
  z-index: 2;
}

.flower.ended .cell { cursor: default; opacity: 0.55; }
.flower.ended .cell:active { transform: none; }

/* ---------- Aktionsknöpfe ---------- */
.actions {
  display: flex;
  gap: 8px;
  padding: 6px 0 2px;
}

.actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.actions button:active { transform: scale(0.97); }

/* ---------- Dialoge ---------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  max-width: min(560px, 94vw);
  max-height: 82dvh;
  overflow: auto;
  padding: 16px 18px 18px;
  margin: auto;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.dlg-head h2 { font-size: 1.05rem; }

.dlg-actions { display: flex; gap: 8px; margin-top: 14px; }

.dlg-actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px;
  font-weight: 600;
  cursor: pointer;
}

.dlg-actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.hint-remaining { font-size: 0.9rem; margin-bottom: 10px; }

dialog h3 { font-size: 0.85rem; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }

.tablewrap { overflow-x: auto; }

#hintTable { border-collapse: collapse; font-size: 0.78rem; width: 100%; }

#hintTable th, #hintTable td {
  border: 1px solid var(--line);
  padding: 3px 7px;
  text-align: center;
}

#hintTable th { color: var(--muted); font-weight: 600; }
#hintTable td.zero { color: var(--muted); opacity: 0.35; }
#hintTable td.center-mark { font-weight: 700; color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.85rem;
  background: var(--chip);
  text-transform: uppercase;
}

.chip.found { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.pang::after { content: ' ✱'; }
.chip .lang { font-size: 0.62rem; opacity: 0.75; margin-left: 4px; text-transform: none; }

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.legend .chip { font-size: 0.7rem; padding: 2px 6px; }

.solve-group { margin-bottom: 12px; }
.solve-group h4 { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
