:root {
  --bg: #fff8f1;
  --bg2: #ffeef5;
  --card: #ffffff;
  --ink: #3b3355;
  --muted: #8a82a3;
  --line: #eee4f3;
  --der: #4c84f0;
  --die: #ea5a83;
  --das: #23a874;
  --accent: #ff9b45;
  --ok: #23a874;
  --bad: #ea5a83;
  --shadow: 0 6px 20px rgba(80, 50, 120, 0.1);
  --r: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Nunito, ui-rounded, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg2), var(--bg) 380px);
  background-color: var(--bg);
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-weight: 900; margin: 18px 0 12px; }
h3 { font-weight: 800; }
.small { font-size: 0.82rem; color: var(--muted); }
.center { text-align: center; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 248, 241, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 900; font-size: 1.25rem; }
.brand small { display: block; font-weight: 700; font-size: 0.75rem; color: var(--muted); }
.wallet { text-align: right; }
.treats { font-weight: 900; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rate { color: var(--muted); font-weight: 700; font-size: 0.8rem; }
.boost {
  flex-basis: 100%; position: relative; height: 22px; border-radius: 99px;
  background: #f3e8f7; overflow: hidden; font-size: 0.78rem; font-weight: 800;
}
.boost-fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, #ffc2d8, #ff7eab); transition: width 0.3s;
}
.boost span { position: relative; display: block; text-align: center; line-height: 22px; }

/* Wiese */
.meadow {
  position: relative; height: 150px;
  margin: 12px auto 0; width: calc(100% - 32px); max-width: 868px;
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
  background: linear-gradient(180deg, #c4ecff 0, #e3f6ff 40%, #a6df8f 40%, #86cf6f 100%);
}
.sun { position: absolute; top: 6px; right: 14px; font-size: 30px; }
.cloud { position: absolute; font-size: 28px; opacity: 0.9; animation: drift 40s linear infinite; }
.cloud.c1 { top: 4px; left: -10%; }
.cloud.c2 { top: 20px; left: -10%; animation-delay: -22s; font-size: 22px; }
@keyframes drift { to { left: 110%; } }
.meadow-empty {
  position: absolute; inset: 40% 0 0; display: grid; place-items: center;
  font-weight: 800; color: #2d5a25; text-align: center; padding: 0 16px;
}
.meadow-empty[hidden] { display: none; }
.mpet {
  position: absolute; border: 0; background: none; padding: 0;
  font-size: 36px; line-height: 1; transform: translateX(-50%);
  transition: left 2.4s ease-in-out, top 2.4s ease-in-out;
}
.mpet .bob { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.mpet.happy .bob { animation: hop 0.5s ease; }
@keyframes hop { 40% { transform: translateY(-18px) scale(1.15); } 100% { transform: none; } }
.mpet.r-epic .bob { filter: drop-shadow(0 0 5px rgba(178, 108, 240, 0.8)); }
.mpet.r-legendary .bob { filter: drop-shadow(0 0 7px rgba(255, 200, 0, 0.95)); }
.mpet .lvl {
  position: absolute; right: -8px; bottom: -2px; font-size: 11px; font-weight: 900;
  background: #fff; border-radius: 99px; padding: 0 5px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.mpet .lvl:empty { display: none; }

/* Tabs */
.tabs { display: flex; gap: 6px; max-width: 900px; margin: 12px auto 0; padding: 0 16px; }
.tab {
  flex: 1; border: 0; background: #fff; border-radius: 14px; padding: 10px 6px;
  font-weight: 800; box-shadow: var(--shadow); white-space: nowrap; position: relative;
}
.tab.active { background: var(--ink); color: #fff; }
.dot { position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.dot[hidden] { display: none; }
main { max-width: 900px; margin: 0 auto; padding: 16px 16px 64px; }

/* Lernen */
.modes { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.modes button {
  border: 2px solid var(--line); background: #fff; border-radius: 99px;
  padding: 6px 14px; font-weight: 800; font-size: 0.9rem;
}
.modes button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.modes button:disabled { opacity: 0.5; cursor: not-allowed; }
.card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 22px 20px; text-align: center; max-width: 560px; margin: 0 auto;
}
.q-question { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; }
.q-emoji { font-size: 60px; line-height: 1.2; margin: 6px 0; }
.q-prompt { font-size: 2rem; font-weight: 900; overflow-wrap: anywhere; }
.blank { color: #cfc6dc; letter-spacing: 0.08em; }
.q-sub { color: var(--muted); font-style: italic; min-height: 1.4em; margin-top: 2px; }
.choices { display: grid; gap: 10px; margin-top: 18px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices.four { grid-template-columns: 1fr 1fr; }
.choice {
  position: relative; border: 2px solid var(--line); background: #fff; border-radius: 16px;
  padding: 14px 10px; font-weight: 800; font-size: 1.1rem; transition: transform 0.08s, background 0.2s;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); border-color: #d9cde6; }
.choice kbd { position: absolute; top: 4px; left: 8px; font: 700 0.65rem Nunito, sans-serif; color: var(--muted); }
.art-btn { font-size: 1.45rem; color: #fff; border: 0; }
.art-btn kbd { color: rgba(255, 255, 255, 0.8); }
.art-btn.art-der { background: var(--der); }
.art-btn.art-die { background: var(--die); }
.art-btn.art-das { background: var(--das); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.correct):not(.wrong) { opacity: 0.35; }
.choice.correct { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 0 0 4px rgba(35, 168, 116, 0.25); }
.choice.wrong { background: #9b93ad; border-color: #9b93ad; color: #fff; text-decoration: line-through; }
.choice.correct span, .choice.wrong span, .choice.correct kbd, .choice.wrong kbd { color: #fff; }
span.art-der { color: var(--der); font-weight: 900; }
span.art-die { color: var(--die); font-weight: 900; }
span.art-das { color: var(--das); font-weight: 900; }
.feedback { margin-top: 14px; display: none; cursor: pointer; }
.feedback.show { display: block; }
.fb-title { font-weight: 900; font-size: 1.1rem; }
.fb-title.ok { color: var(--ok); }
.fb-title.bad { color: var(--bad); }
.fb-word { margin-top: 4px; font-size: 1.05rem; }
.fb-note { margin-top: 8px; background: #fff4e3; border-radius: 12px; padding: 8px 12px; font-size: 0.92rem; text-align: left; }
.btn { margin-top: 14px; border: 0; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 22px; font-weight: 800; }
.btn[hidden] { display: none; }
.streak { text-align: center; margin-top: 12px; color: var(--muted); font-weight: 700; }
.streak b { color: var(--accent); }
.shake { animation: shake 0.35s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

/* Eier und Verbesserungen */
.eggs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.egg-card { background: #fff; border-radius: var(--r); padding: 18px; text-align: center; box-shadow: var(--shadow); }
.egg-card h3 { margin: 6px 0 2px; }
.egg-card.locked { opacity: 0.6; }
.egg-big { font-size: 56px; display: inline-block; animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } 95% { transform: rotate(-4deg); } }
.gold { filter: sepia(1) saturate(5) hue-rotate(-12deg) brightness(1.05) drop-shadow(0 0 8px #ffd34d); }
.odds { font-size: 0.8rem; color: var(--muted); margin: 4px 0 12px; }
.buy {
  border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 800;
  background: var(--accent); color: #fff; min-width: 120px; white-space: nowrap;
}
.buy:disabled { background: #ebe4ee; color: #a59cb5; cursor: not-allowed; }
.upgrades { display: flex; flex-direction: column; gap: 10px; }
.up { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.up-icon { font-size: 32px; }
.up-body { flex: 1; min-width: 0; }
.up-body h3 { margin: 0; font-size: 1rem; }
.up-body p { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.lvl-tag { font-size: 0.75rem; color: var(--muted); font-weight: 700; }

/* Tiere */
.count { font-size: 1rem; color: var(--muted); }
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pet-card { background: #fff; border-radius: var(--r); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); border-top: 5px solid var(--rc); }
.r-common { --rc: #b8b3c4; }
.r-rare { --rc: #4fa3f7; }
.r-epic { --rc: #b26cf0; }
.r-legendary { --rc: #f0ac00; }
.pet-emoji { font-size: 48px; line-height: 1.2; }
.sil { filter: brightness(0); opacity: 0.15; }
.pet-name { font-weight: 800; }
.pet-nick { color: var(--muted); font-size: 0.85rem; }
.pet-stats { font-size: 0.8rem; margin-top: 4px; font-weight: 700; }
.pet-rar { font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--rc); margin-top: 4px; }

/* Wörter */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: #fff; border-radius: var(--r); padding: 12px; text-align: center; box-shadow: var(--shadow); font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.stat b { display: block; font-size: 1.5rem; font-weight: 900; color: var(--ink); }
.legend { margin-top: 12px; }
.pack { background: #fff; border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.pack-head { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.pack-head::-webkit-details-marker { display: none; }
.pack-head h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.pack-icon { font-size: 1.5rem; }
.pack-num { font-weight: 800; color: var(--muted); font-size: 0.85rem; }
.badge { font-size: 0.75rem; font-weight: 800; background: #fff3c4; border-radius: 99px; padding: 2px 8px; }
.pack.locked { opacity: 0.65; }
.pack.locked .pack-head { cursor: default; }
.pack.locked p { margin: 6px 0 0; }
.bar { position: relative; height: 8px; border-radius: 99px; background: #f1eaf5; margin: 10px 0; overflow: hidden; }
.bar div { position: absolute; inset: 0 auto 0 0; transition: width 0.4s; }
.bar-solid { background: #cdbbf3; }
.bar-master { background: #7c5cd6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.85rem; padding: 4px 10px; border-radius: 99px; background: #f7f3fa;
  font-weight: 700; display: inline-flex; gap: 6px; align-items: center; border-left: 4px solid var(--ac);
}
.art-bg-der { --ac: var(--der); }
.art-bg-die { --ac: var(--die); }
.art-bg-das { --ac: var(--das); }
.chip.unseen { opacity: 0.5; }
.dots { font-size: 0.55rem; letter-spacing: 1px; color: #7c5cd6; }
.danger { background: none; border: 2px solid var(--bad); color: var(--bad); border-radius: 12px; padding: 8px 14px; font-weight: 800; margin-top: 24px; }

/* Dialog */
.modal-bg { position: fixed; inset: 0; background: rgba(40, 25, 60, 0.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-bg[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 24px; padding: 24px; max-width: 400px; width: 100%;
  text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); overflow: hidden;
}
.modal h2 { margin: 6px 0 8px; }
.big-emoji { font-size: 64px; }
.hatch { position: relative; padding-top: 8px; }
.egg-anim { font-size: 96px; display: inline-block; animation: shakeEgg 0.45s ease-in-out infinite; }
.egg-anim.gold { animation: shakeEgg 0.45s ease-in-out infinite; }
@keyframes shakeEgg { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
.pet-pop { position: relative; font-size: 96px; line-height: 1.1; animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1); } }
.burst {
  position: absolute; left: 50%; top: 64px; width: 240px; height: 240px; margin: -120px 0 0 -120px;
  border-radius: 50%; background: radial-gradient(circle, var(--rc) 0, transparent 65%); opacity: 0.45;
}
.rar-label { position: relative; font-weight: 900; color: var(--rc); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; }
.pet-title { font-size: 1.2rem; font-weight: 800; }

/* Toasts und schwebender Text */
.toasts {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(420px, calc(100% - 32px));
}
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); animation: toastIn 0.3s; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }
.float {
  position: fixed; pointer-events: none; font-weight: 900; color: var(--accent); z-index: 70;
  transform: translate(-50%, -50%); animation: floatUp 1s ease-out forwards; text-shadow: 0 1px 0 #fff;
}
@keyframes floatUp { to { transform: translate(-50%, -260%); opacity: 0; } }

@media (max-width: 520px) {
  .choices.four { grid-template-columns: 1fr; }
  .q-prompt { font-size: 1.6rem; }
  .tab { font-size: 0.82rem; padding: 9px 2px; }
  .up { flex-wrap: wrap; }
  .up .buy { width: 100%; }
}

@media (hover: none) {
  .kbd-tip, .choice kbd { display: none; }
}

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