:root {
  --bg: #ffffff;
  --ink: #111111;
  --ink-soft: #4a4a4a;
  --line: #d8d8d8;
  --line-soft: #ebebeb;
  --accent: #f3c641;
  --accent-soft: #fde7a3;
  --pill-bg: #1c1c1c;
  --pill-fg: #ffffff;
  --pill-light-bg: #f0f0f0;
  --pill-light-fg: #111111;
  --error: #c8453a;
  --success: #2e8b57;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: linear-gradient(160deg, #fff8df 0%, #ffe7a8 60%, #f3c641 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  overscroll-behavior-y: none;
  touch-action: manipulation;        /* deaktiviert iOS Double-Tap-Zoom */
}

body {
  user-select: none;
  -webkit-user-select: none;
}

/* Tap-Targets: ebenfalls Double-Tap-Zoom unterdrücken */
button, .petal-group, svg { touch-action: manipulation; }

.app {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

/* Iconbtn (used by shuffle button) ----------------------- */
.iconbtn {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.12s;
}
.iconbtn:active { background: var(--line-soft); }

/* Score-Zeile -------------------------------------------- */
.scoreline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(env(safe-area-inset-top), 14px) 18px 2px;
  font-size: 13px;
  color: var(--ink-soft);
}
.helpbtn {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.12s, transform 0.08s;
}
.helpbtn:active { background: var(--line-soft); transform: scale(0.94); }
.lvl { font-weight: 600; color: var(--ink); }
.lvldots {
  flex: 1;
  display: flex;
  gap: 5px;
  align-items: center;
}
.lvldots .dot {
  flex: 0 0 auto;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line);
}
.lvldots .dot.on { background: var(--accent); }
.scoreval { font-weight: 600; color: var(--ink); }

/* Wortanzeige -------------------------------------------- */
.wordbox {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 16px 0;
}
.word {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}
.word .center { color: var(--accent); }
.word.valid { color: var(--success); }
.word.valid .center { color: var(--success); }
.word-hint {
  display: inline-block;
  margin-left: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--success);
  opacity: 0.65;
  vertical-align: middle;
}
.word.shake { animation: shake 0.32s ease; }
.caret {
  display: inline-block;
  width: 2px; height: 28px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* Blume -------------------------------------------------- */
.flowerwrap {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
}
#flower {
  width: 92%;
  max-width: 420px;
  max-height: 50vh;
  height: auto;
}
.petal-shape {
  fill: #ffffff;
  stroke: #c9c9c9;
  stroke-width: 2.4;
  stroke-linejoin: round;
}
.petal-shape.center {
  fill: var(--accent);
  stroke: var(--accent);
}
.petal-letter {
  font-family: -apple-system, "Inter", Helvetica, Arial, sans-serif;
  font-weight: 800;
  font-size: 64px;
  text-anchor: middle;
  dominant-baseline: central;
  fill: #111;
  pointer-events: none;
}
.petal-group {
  cursor: pointer;
  transition: transform 0.12s ease;
}
.petal-group:active .petal-shape { fill: #f5f5f5; }
.petal-group.center-group:active .petal-shape { fill: #efb735; }
.petal-group.used .petal-letter { opacity: 0.28; }
.petal-group.used .petal-shape  { opacity: 0.85; }
.petal-group.tap-anim { animation: tap 0.18s ease; }
.petal-group.hint-flash .petal-shape { animation: hintflash 1.4s ease; }
@keyframes hintflash {
  0%, 100% { fill: #ffffff; stroke: #c9c9c9; }
  20%, 60% { fill: #fde7a3; stroke: #f3c641; stroke-width: 4; }
}
.petal-group.center-group.hint-flash .petal-shape { animation: hintflashCenter 1.4s ease; }
@keyframes hintflashCenter {
  0%, 100% { fill: var(--accent); stroke: var(--accent); }
  20%, 60% { fill: #fff2c1; stroke: #b88600; stroke-width: 5; }
}
@keyframes tap {
  0% { transform: scale(1); }
  50% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

/* Aktions-Buttons --------------------------------------- */
.actions {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  gap: 12px;
  padding: 2px 16px 4px;
  align-items: center;
}
.pill {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
  font-family: inherit;
}
.pill:active { transform: scale(0.97); }
.pill-dark { background: var(--pill-bg); color: var(--pill-fg); }
.pill-light { background: var(--pill-light-bg); color: var(--pill-light-fg); }
.pill.wide { width: 100%; }
.iconbtn.shuffle { width: 48px; height: 48px; margin: 0 auto; }

.giveup {
  text-align: center;
  padding: 4px 16px 8px;
}
.linkbtn {
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 16px;
}
.linkbtn:active { color: var(--ink-soft); }

/* Wortliste --------------------------------------------- */
.foundbox {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--line-soft);
  padding: 10px 16px 24px;
  background: transparent;
}
.foundhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-bottom: 6px;
}
.counter { color: var(--ink); }
.foundlist {
  flex: 1 1 0;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 1px 10px;
  overflow: auto;
}
.foundlist li {
  font-size: 14px;
  line-height: 1.2;
  padding: 1px 0;
  color: var(--ink);
  text-transform: capitalize;
  display: flex; justify-content: space-between; align-items: baseline; gap: 4px;
}
.foundlist li.pangram { color: #b88600; font-weight: 700; }
.foundlist li .pts { color: var(--ink-soft); font-size: 11px; opacity: 0.7; }

/* Modal ------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20,20,20,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px 22px 18px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-card h2 { margin: 0 0 8px; font-size: 19px; }
.modal-card p { margin: 0 0 18px; color: var(--ink-soft); font-size: 15px; }
.modal-actions {
  display: flex; gap: 10px;
}
.modal-actions .pill { flex: 1; padding: 13px 14px; }

.loadingcard { max-width: 320px; text-align: center; padding: 26px 22px 24px; }
.loadingcard h2 { margin: 14px 0 6px; }
.loadingcard p  { margin: 0; }
.spinner {
  width: 38px; height: 38px;
  margin: 0 auto;
  border: 3px solid var(--line-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.endcard { max-width: 460px; }
.endstats {
  text-align: center;
  font-size: 17px;
  margin: 8px 0 16px;
  display: grid; gap: 6px;
}
.endlevel { color: #b88600; font-weight: 700; font-size: 18px; }
.endwords {
  background: #fafafa;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 14px;
  max-height: 40vh;
  overflow: auto;
}
.endwords summary {
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.endwords ul {
  list-style: none;
  padding: 6px 0 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 2px 10px;
}
.endwords li {
  font-size: 14px;
  padding: 2px 0;
  text-transform: capitalize;
}
.endwords li.found { color: #2e8b57; font-weight: 700; }
.endwords li.pangram { color: #b88600; font-weight: 700; }

/* Toast ------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%; bottom: 30%;
  transform: translateX(-50%);
  background: rgba(28,28,28,0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toastpop 1.4s ease forwards;
}
.toast.hidden { display: none; }
.toast.success { background: rgba(46,139,87,0.96); }
.toast.error   { background: rgba(200,69,58,0.96); }
.toast.gold    { background: rgba(184,134,0,0.96); }
@keyframes toastpop {
  0%   { opacity: 0; transform: translate(-50%, 8px); }
  15%  { opacity: 1; transform: translate(-50%, 0); }
  80%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* Datenschutz-Banner ----------------------------------- */
.privacy-banner {
  position: fixed;
  inset: 0;
  background: rgba(20,20,20,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  padding: 0;
  animation: privacy-fade 0.18s ease-out;
}
.privacy-banner.hidden { display: none; }
.privacy-card {
  background: #fff;
  width: 100%;
  max-width: 540px;
  border-radius: 18px 18px 0 0;
  padding: 20px 22px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  animation: privacy-slide 0.22s ease-out;
}
.privacy-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
}
.privacy-card p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}
.privacy-card strong { color: var(--ink); font-weight: 700; }
.privacy-details {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.privacy-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  user-select: none;
}
.privacy-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.5;
}
.privacy-details li { margin-bottom: 6px; }
.privacy-details em { font-style: normal; font-weight: 600; color: var(--ink); }
.privacy-actions { display: flex; }
.privacy-actions .pill { padding: 13px 14px; }

@keyframes privacy-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes privacy-slide {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
