/* =========================================================
   Pokémon Rechnen – Stylesheet
   ========================================================= */
:root {
  --yellow: #ffcb05;
  --blue: #2a75bb;
  --blue-dark: #1d4f86;
  --red: #e3350d;
  --green: #2fa84f;
  --purple: #7b3fc4;
  --white: #ffffff;
  --ink: #1f2a44;
  --muted: #5b6784;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: #1b3a5c;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- Hintergrund ---------- */
#bg {
  position: fixed; inset: -40px;
  background: url("../img/titel.webp") center / cover no-repeat;
  filter: blur(14px) brightness(0.85);
  transform: scale(1.05);
  z-index: 0;
}

.screen {
  position: fixed; inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
}
.screen.active { display: flex; }

/* ---------- Startbildschirm ---------- */
#splash { justify-content: center; background: rgba(0, 0, 0, 0.25); padding: 16px; }
#splash img {
  max-width: 100%; max-height: calc(100% - 110px);
  object-fit: contain;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.loader {
  width: min(520px, 80vw);
  height: 26px;
  margin-top: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  border: 3px solid var(--white);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.loader-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--yellow), #ffe066, var(--yellow));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.loader-text { color: var(--white); margin-top: 10px; font-size: 20px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }

/* ---------- Kopfleiste ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
#topbar.show { display: flex; }
.home-btn {
  width: 56px; height: 56px; flex: none;
  border-radius: 16px;
  border: 3px solid var(--white);
  background: var(--red);
  color: var(--white);
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.home-btn:hover { transform: scale(1.08); }
.home-btn svg { width: 30px; height: 30px; }
.home-btn.hidden { visibility: hidden; }
.pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 3px solid var(--white);
  border-radius: 999px;
  padding: 6px 18px;
  box-shadow: var(--shadow);
  font-size: 24px; font-weight: 700;
}
.spacer { flex: 1; }
.level-pill { flex-direction: column; align-items: stretch; gap: 2px; border-radius: 20px; min-width: 170px; }
.level-pill .lvl { font-size: 22px; line-height: 1.1; color: var(--blue-dark); }
.lvl-bar { height: 10px; background: #dbe4f0; border-radius: 99px; overflow: hidden; }
.lvl-bar div { height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width 0.4s; }
.lvl-sub { font-size: 13px; font-weight: 600; color: var(--muted); }

.balls-pill { gap: 16px; padding: 6px 16px 6px 10px; }
.hud-ball { display: flex; align-items: center; gap: 6px; }
.hud-ball img { width: 32px; height: 32px; flex: none; }
.hud-ball span { min-width: 1.2ch; }
.bump { animation: bump 0.45s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }

/* ---------- Dashboard ---------- */
#dashboard { justify-content: safe center; gap: 22px; padding: 90px 16px 16px; overflow-y: auto; }
#dashboard .logo {
  width: min(460px, 80vw);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  border-radius: 14px;
  aspect-ratio: 16 / 7;
  object-fit: cover; object-position: 50% 18%;
}
.menu-btn {
  width: min(420px, 88vw);
  padding: 18px 24px;
  font-size: 28px; font-weight: 700;
  color: var(--white);
  border: 4px solid var(--white);
  border-radius: 24px;
  box-shadow: var(--shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.18);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  transition: transform 0.15s;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}
.menu-btn:hover { transform: translateY(-3px) scale(1.03); }
.menu-btn:active { transform: scale(0.97); }
.menu-btn .ico { font-size: 34px; }
.btn-play { background: var(--green); }
.btn-shop { background: var(--blue); }
.btn-dex  { background: var(--red); }

/* ---------- Aufgabenbereich wählen ---------- */
#modes { justify-content: safe center; gap: 18px; padding: 90px 16px 16px; overflow-y: auto; }
.modes-title {
  margin: 0; color: var(--white); font-size: 32px;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}
.mode-card {
  width: min(520px, 100%);
  display: flex; align-items: center; gap: 18px;
  text-align: left;
  padding: 16px 20px;
  background: var(--card);
  border: 4px solid var(--white);
  border-radius: 26px;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform 0.15s, border-color 0.15s;
}
.mode-card:hover { transform: translateY(-3px) scale(1.02); border-color: var(--yellow); }
.mode-card.last { border-color: var(--yellow); }
.mode-icon {
  flex: none;
  width: 78px; height: 78px;
  border-radius: 20px;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700; color: var(--white);
}
.mode-mul .mode-icon  { background: var(--red); }
.mode-div .mode-icon  { background: #2b2b2b; color: #ffd21f; }
.mode-rest .mode-icon { background: var(--purple); }
.mode-body { flex: 1; min-width: 0; }
.mode-name { font-size: 24px; font-weight: 700; line-height: 1.15; }
.mode-name, .mode-example, .lock-info { display: block; }
.mode-example { font-size: 16px; color: var(--muted); margin: 2px 0 6px; }
.reward { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 18px; font-weight: 700; }
.reward .lbl { font-weight: 600; color: var(--muted); font-size: 15px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f1f4f9; border-radius: 999px; padding: 2px 10px 2px 4px;
  font-weight: 700;
}
.chip img { width: 22px; height: 22px; }
.mode-card.locked { cursor: not-allowed; background: rgba(230, 233, 240, 0.92); }
.mode-card.locked:hover { transform: none; border-color: var(--white); }
.mode-card.locked .mode-icon, .mode-card.locked .reward { filter: grayscale(1); opacity: 0.5; }
.mode-card.locked .mode-name { color: #7d8598; }
.lock-info { font-size: 16px; font-weight: 700; color: var(--red); margin-top: 6px; }

/* ---------- Spiel ---------- */
#game { justify-content: safe center; padding: 90px 16px 16px; overflow-y: auto; }
.game-card {
  background: var(--card);
  border: 5px solid var(--white);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 16px 22px 24px;
  width: min(500px, 100%);
  text-align: center;
}
.mode-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 999px;
  background: #eef2f8; color: var(--blue-dark);
  font-size: 16px; font-weight: 700;
  padding: 6px 14px;
  margin-bottom: 10px;
}
.mode-chip:hover { background: #e1e8f3; }
.task {
  font-size: clamp(40px, 11vw, 68px);
  font-weight: 700;
  color: var(--blue-dark);
  line-height: 1.15;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.task.small { font-size: clamp(34px, 9vw, 58px); }
.rest-label { font-size: 0.55em; color: var(--muted); }
.answer-box {
  min-width: 2.2ch;
  padding: 0 10px;
  border-radius: 18px;
  background: #fff7d1;
  border: 4px dashed var(--yellow);
  color: var(--ink);
  cursor: pointer;
}
.answer-box.empty { color: #c7b46a; }
.answer-box.active { border-style: solid; box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.35); }
.answer-box.right { background: #d9f7e0; border: 4px solid var(--green); color: var(--green); box-shadow: none; }
.answer-box.wrong { background: #ffe1d9; border: 4px solid var(--red); color: var(--red); box-shadow: none; }
.hint { font-size: 15px; color: var(--muted); margin-top: 6px; min-height: 0; }
.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.feedback { min-height: 32px; margin: 8px 0 12px; font-size: 22px; font-weight: 600; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  font-size: 32px; font-weight: 700;
  padding: 12px 0;
  border-radius: 18px;
  border: none;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 5px 0 #c9d3e3, 0 6px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.08s;
}
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9d3e3; }
.key.del { background: #ffe9a8; box-shadow: 0 5px 0 #e3c35a; }
.key.ok { background: var(--green); color: var(--white); box-shadow: 0 5px 0 #1f7a37; }

/* ---------- Shop & Pokédex ---------- */
#shop, #dex { padding: 90px 16px 16px; }
.panel {
  width: min(1100px, 100%);
  flex: 1; min-height: 0;
  background: var(--card);
  border: 5px solid var(--white);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-head { padding: 16px 22px 8px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 30px; color: var(--blue-dark); }
.panel-head p { margin: 0; font-size: 18px; color: var(--muted); }
.grid {
  flex: 1; overflow-y: auto;
  padding: 10px 18px 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  align-content: start;
}
.pkm {
  background: var(--white);
  border: 3px solid #e3e9f3;
  border-radius: 20px;
  padding: 8px 8px 10px;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
  position: relative;
}
.pkm img.art { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.pkm .nr { font-size: 13px; color: #8a94ad; font-weight: 600; }
.pkm .name { font-size: 17px; font-weight: 700; line-height: 1.15; min-height: 1.15em; overflow-wrap: anywhere; }
.cost { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; font-size: 16px; }
.cost .chip { background: #fff3c4; }
.cost .chip.short { background: #ffe1d9; color: var(--red); }
.pkm.can { cursor: pointer; border-color: var(--yellow); }
.pkm.can:hover { transform: translateY(-4px) scale(1.03); }
.pkm.locked { background: #eef0f4; }
.pkm.locked img.art, .pkm.locked .name, .pkm.locked .nr { filter: grayscale(1); opacity: 0.4; }
.pkm.locked .chip { filter: grayscale(1); opacity: 0.75; }
.pkm.owned { border-color: var(--green); }
.owned-tag {
  margin-top: 6px; display: inline-block;
  background: #d9f7e0; color: var(--green);
  border-radius: 999px; padding: 2px 12px;
  font-size: 16px; font-weight: 700;
}
.pkm.dexcard { cursor: pointer; }
.pkm.dexcard:hover { transform: translateY(-4px) scale(1.03); }
.empty-msg { grid-column: 1 / -1; text-align: center; font-size: 22px; color: var(--muted); padding: 40px 10px; }

/* ---------- Fliegende Bälle ---------- */
.flyball {
  position: fixed; left: 0; top: 0; z-index: 50;
  width: 90px; height: 90px;
  pointer-events: none;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

/* ---------- Dialoge ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 25, 50, 0.55);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.overlay.show { display: flex; }
.dialog {
  background: var(--white);
  border: 5px solid var(--yellow);
  border-radius: 30px;
  padding: 26px 28px;
  width: min(460px, 100%);
  max-height: 100%; overflow-y: auto;
  text-align: center;
  box-shadow: var(--shadow);
  animation: popin 0.4s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes popin { from { transform: scale(0.5); opacity: 0; } }
.dialog h3 { margin: 0 0 8px; font-size: 34px; color: var(--blue-dark); }
.dialog p { margin: 0 0 18px; font-size: 22px; }
.dialog img.art { width: 200px; height: 200px; object-fit: contain; }
.dialog .cost { justify-content: center; margin: -6px 0 18px; font-size: 20px; }
.dialog .cost .chip img { width: 26px; height: 26px; }
.unlock { background: #f3ebff; color: var(--purple); border-radius: 16px; padding: 10px; font-weight: 700; }
.unlock .reward { justify-content: center; margin-top: 6px; color: var(--ink); }
.dialog .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.dbtn {
  font-size: 22px; font-weight: 700;
  padding: 12px 26px;
  border-radius: 18px;
  border: none; color: var(--white);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2);
}
.dbtn.yes { background: var(--green); }
.dbtn.no { background: #8a94ad; }
.dbtn.go { background: var(--blue); }

#confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- Kleine Bildschirme ---------- */
@media (max-width: 600px) {
  #topbar { gap: 8px; padding: 10px; }
  .home-btn { width: 46px; height: 46px; border-radius: 14px; }
  .home-btn svg { width: 24px; height: 24px; }
  .pill { font-size: 17px; padding: 4px 10px; }
  .level-pill { min-width: 92px; }
  .level-pill .lvl { font-size: 16px; }
  .lvl-sub { display: none; }
  .balls-pill { gap: 8px; padding: 4px 10px 4px 6px; }
  .hud-ball { gap: 3px; }
  .hud-ball img { width: 22px; height: 22px; }
  .menu-btn { font-size: 23px; padding: 14px 18px; }
  .mode-card { gap: 12px; padding: 12px 14px; }
  .mode-icon { width: 58px; height: 58px; font-size: 22px; border-radius: 16px; }
  .mode-name { font-size: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 8px 8px 16px; }
  .pkm { padding: 6px 4px 8px; border-radius: 16px; }
  .cost .chip { padding: 1px 6px 1px 2px; }
  .owned-tag { font-size: 13px; padding: 2px 8px; }
  .pkm .name { font-size: 15px; }
  .cost { font-size: 14px; }
  .chip img { width: 18px; height: 18px; }
  .key { font-size: 28px; padding: 10px 0; }
}

/* ---------- Niedrige Bildschirme (z. B. Handy quer) ---------- */
@media (max-height: 640px) {
  #dashboard .logo { display: none; }
  #dashboard { gap: 14px; }
  .menu-btn { padding: 10px 18px; font-size: 22px; }
  #game, #modes, #shop, #dex, #dashboard { padding-top: 78px; }
  .game-card { padding: 10px 16px 14px; }
  .task { font-size: 40px; }
  .feedback { min-height: 24px; margin: 4px 0 8px; font-size: 18px; }
  .key { font-size: 24px; padding: 6px 0; }
  .keypad { gap: 7px; }
}
