/* =========================================================
   Thermikdoku – Kawaii-Stil
   Dicke Navy-Konturen + harte Sticker-Schatten wie bei den Figuren
   ========================================================= */
:root {
  color-scheme: light;
  --ink: #2b3a55;
  --ink-soft: #5d6b86;
  --line: 3px solid var(--ink);
  --pop: 0 5px 0 var(--ink);
  --pop-sm: 0 3px 0 var(--ink);
  --thin: rgba(43, 58, 85, 0.14);
  --sky-top: #6cc3f7;
  --sky-mid: #a9dcfb;
  --sky-bot: #e4f6ff;
  --card: #ffffff;
  --cream: #fff9ef;
  --red: #ff5a4e;
  --red-dark: #e0392d;
  --yellow: #ffd23f;
  --yellow-dark: #f2b705;
  --pink: #ff8fc7;
  --good: #36c97a;
  --bad: #ff4d6d;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sky-mid); color: var(--ink);
  font-family: var(--font); font-weight: 700;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { display: block; }
img { -webkit-user-drag: none; user-select: none; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Himmel ---------- */
.sky {
  position: fixed; inset: 0; overflow: hidden; z-index: 0;
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 246, 200, .7), transparent 40%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bot) 100%);
}
.sky-dots {
  position: absolute; inset: 0; opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .9) 1.2px, transparent 1.6px);
  background-size: 26px 26px;
  animation: dots 40s linear infinite;
}
@keyframes dots { to { background-position: 260px 520px; } }

.sun { position: absolute; top: calc(var(--safe-t) + 26px); right: 6%; width: 96px; height: 96px; }
.sun .rays { transform-origin: 50px 50px; animation: spin 24s linear infinite; }
.sun .face { animation: sunBob 4s ease-in-out infinite; transform-origin: 50px 50px; }
@keyframes sunBob { 50% { transform: translateY(2px) scale(1.04); } }
@keyframes spin { to { transform: rotate(360deg); } }

.cloud {
  position: absolute; left: -200px; width: 130px;
  animation: drift linear infinite;
}
.cloud img { width: 100%; display: block; animation: cloudBob 5s ease-in-out infinite; }
.cloud.c1 { top: 13%; animation-duration: 75s; animation-delay: -12s; }
.cloud.c2 { top: 33%; width: 90px; animation-duration: 95s; animation-delay: -60s; opacity: .9; }
.cloud.c3 { top: 56%; width: 150px; animation-duration: 120s; animation-delay: -35s; opacity: .8; }
.cloud.c4 { top: 74%; width: 70px; animation-duration: 85s; animation-delay: -50s; opacity: .75; }
.cloud.c2 img { animation-delay: -1.5s; } .cloud.c3 img { animation-delay: -3s; }
@keyframes drift { from { left: -200px; } to { left: calc(100% + 200px); } }
@keyframes cloudBob { 50% { transform: translateY(-6px) scale(1.03, .97); } }

.sky-glider { position: absolute; top: 18%; left: -25%; width: 74px; animation: skyGlide 40s linear infinite; }
.sky-glider img { width: 100%; animation: skyBob 5s ease-in-out infinite; }
@keyframes skyGlide { 0% { left: -25%; top: 24%; } 50% { top: 10%; } 100% { left: 125%; top: 22%; } }
@keyframes skyBob { 50% { transform: translateY(-14px) rotate(8deg); } }

.hills { position: absolute; bottom: -2px; left: 0; width: 100%; height: 20vh; min-height: 110px; }

/* ---------- Screens ---------- */
#app { position: fixed; inset: 0; z-index: 1; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 12px);
  opacity: 0; pointer-events: none; visibility: hidden;
  transform: translateY(30px) scale(.97);
  transition: opacity .3s ease, transform .5s cubic-bezier(.2, 1.4, .4, 1), visibility 0s .3s;
}
.screen.active {
  opacity: 1; pointer-events: auto; visibility: visible; transform: none;
  transition: opacity .3s ease, transform .5s cubic-bezier(.2, 1.4, .4, 1), visibility 0s;
}
.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; flex-shrink: 0; }
.topbar h2 { margin: 0; font-size: 22px; flex: 1; text-align: center; font-weight: 900; }
.topbar .spacer { width: 46px; }

/* ---------- Sticker-Bausteine ---------- */
.icon-btn {
  width: 46px; height: 46px; border-radius: 16px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--card); border: var(--line); box-shadow: var(--pop-sm);
  transition: transform .12s, box-shadow .12s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }

.btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 10px 20px;
  border-radius: 22px; text-align: center;
  background: var(--card); color: var(--ink);
  border: var(--line); box-shadow: var(--pop);
  transition: transform .1s, box-shadow .1s;
}
.btn::after {
  content: ""; position: absolute; left: 10%; right: 10%; top: 4px; height: 22%;
  border-radius: 20px; background: rgba(255, 255, 255, .3); pointer-events: none;
}
.btn:active { transform: translateY(5px); box-shadow: 0 0 0 var(--ink); }
.btn > span { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; }
.btn-big { font-size: 21px; font-weight: 900; letter-spacing: .2px; }
.btn-small { font-size: 13px; font-weight: 700; opacity: .85; }
.btn-ico { width: 28px; height: 28px; flex-shrink: 0; position: relative; z-index: 1; }
.btn-primary { background: linear-gradient(180deg, #ff7b6e, var(--red)); color: #fff; text-shadow: 0 2px 0 rgba(43, 58, 85, .35); }
.btn-sun { background: linear-gradient(180deg, #ffe37a, var(--yellow)); color: var(--ink); }
.btn-sun .btn-ico { animation: spin 10s linear infinite; }
.btn-light { background: var(--card); }
.btn.done-today .btn-small::after { content: " ✓"; }
.link-btn { margin-top: 6px; font-size: 14px; color: var(--ink-soft); text-decoration: underline; padding: 8px; }

.jelly { animation: jelly .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes jelly {
  0% { transform: scale(1, 1); }
  25% { transform: scale(1.12, .88); }
  50% { transform: scale(.94, 1.06); }
  75% { transform: scale(1.03, .97); }
  100% { transform: scale(1, 1); }
}

/* ---------- Home ---------- */
#screen-home { justify-content: space-between; align-items: center; }
.home-top { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.rank {
  flex: 1; max-width: 230px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: var(--line); box-shadow: var(--pop-sm);
  border-radius: 18px; padding: 5px 10px 5px 5px; text-align: left;
}
.rank-lvl {
  width: 34px; height: 34px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 16px; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, #a78bfa, #7c4dff); border: 2.5px solid var(--ink);
  text-shadow: 0 2px 0 rgba(43, 58, 85, .4);
}
.rank-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rank-name { font-size: 12.5px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp-bar { position: relative; height: 10px; border-radius: 6px; background: #e8eef7; border: 2px solid var(--ink); overflow: hidden; }
.xp-bar i {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #ffd23f, #ff8fc7, #7c4dff, #ffd23f); background-size: 200% 100%;
  animation: xpShine 2.5s linear infinite;
  transition: width .6s cubic-bezier(.2, .9, .3, 1);
}
@keyframes xpShine { to { background-position: -200% 0; } }

.home-hero { text-align: center; display: flex; flex-direction: column; align-items: center; }
.logo-glider { width: min(40vw, 170px, 21vh); aspect-ratio: 1; animation: logoIn 1.1s cubic-bezier(.2, 1.3, .4, 1) both; cursor: pointer; }
.logo-glider img { width: 100%; height: 100%; animation: bob 3.6s ease-in-out infinite; }
.logo-glider.loop img { animation: loop 1s cubic-bezier(.4, 0, .2, 1); }
@keyframes loop {
  0% { transform: none; }
  30% { transform: translateY(-30px) rotate(-30deg) scale(1.1); }
  60% { transform: translateY(-10px) rotate(-330deg) scale(1.15); }
  100% { transform: rotate(-360deg); }
}
@keyframes logoIn {
  0% { transform: translate(-80vw, -30vh) rotate(-35deg) scale(.4); opacity: 0; }
  65% { transform: translate(3vw, 2vh) rotate(8deg) scale(1.05); opacity: 1; }
  100% { transform: none; }
}
.title {
  margin: 4px 0 0; font-size: clamp(40px, 12vw, 60px); font-weight: 900; letter-spacing: -1px; line-height: 1;
  color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 var(--ink));
  display: flex;
}
.title span { display: inline-block; animation: letterIn .6s cubic-bezier(.2, 1.6, .4, 1) both, letterBob 3s ease-in-out infinite; }
.title span.y { color: var(--yellow); }
@keyframes letterIn { from { opacity: 0; transform: translateY(-40px) scale(.3) rotate(-20deg); } }
@keyframes letterBob { 0%, 80%, 100% { transform: none; } 88% { transform: translateY(-7px) rotate(-4deg); } }
.subtitle {
  margin: 12px 0 0; font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1.35;
  background: rgba(255, 255, 255, .85); border: 2.5px solid var(--ink); border-radius: 16px; padding: 6px 14px;
  animation: popIn .5s .9s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.5); } }

.home-play { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px; }
.home-label {
  margin: 0; font-size: 15px; font-weight: 900; color: #fff; text-align: center;
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
  animation: popIn .5s .8s both;
}
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-card {
  --tone: #36c97a; --tone-soft: #dcf7e7;
  position: relative; text-align: left;
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px 12px 11px; border-radius: 22px;
  background: linear-gradient(170deg, #fff 45%, var(--tone-soft));
  border: var(--line); box-shadow: var(--pop);
  animation: cardIn .6s cubic-bezier(.2, 1.5, .4, 1) both;
  animation-delay: calc(.8s + var(--k) * .09s);
  transition: transform .1s, box-shadow .1s;
}
.diff-card:active { transform: translateY(5px); box-shadow: 0 0 0 var(--ink); }
.diff-card.wiggle { animation: wiggle .7s ease; }
@keyframes cardIn { from { opacity: 0; transform: translateY(50px) scale(.7) rotate(-6deg); } }
@keyframes wiggle { 20% { transform: rotate(-4deg) scale(1.04); } 40% { transform: rotate(3deg); } 60% { transform: rotate(-2deg); } 80% { transform: rotate(1deg); } }
.diff-mittel { --tone: #3d8bff; --tone-soft: #dce9ff; }
.diff-schwer { --tone: #ff8a1f; --tone-soft: #ffe8d1; }
.diff-experte { --tone: #8a4dff; --tone-soft: #ebe0ff; }
.diff-icons { display: flex; margin: -2px 0 0 -3px; height: 30px; }
.diff-icons img { width: 30px; height: 30px; }
.diff-icons img.off { filter: grayscale(1) brightness(1.15); opacity: .3; }
.diff-name { font-size: 21px; font-weight: 900; color: var(--tone); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; letter-spacing: .3px; }
.diff-size { font-size: 12px; font-weight: 800; }
.diff-info { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.badge {
  position: absolute; top: -11px; right: 8px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 900;
  padding: 3px 9px; border-radius: 12px; border: 2.5px solid var(--ink);
  animation: badgePulse 1.4s ease-in-out infinite;
}
@keyframes badgePulse { 50% { transform: scale(1.12) rotate(-4deg); } }
.home-play .btn { animation: cardIn .6s 1.2s cubic-bezier(.2, 1.5, .4, 1) both; min-height: 58px; }
.streak { display: inline-block; margin-left: 4px; animation: flame 1s ease-in-out infinite alternate; }
@keyframes flame { to { transform: scale(1.25) rotate(8deg); } }
.app-footer {
  text-align: center; font-size: 12px; font-weight: 800; color: #fff; line-height: 1.35;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
}
.app-footer p { margin: 0; }
.app-footer a, .app-footer button { color: #fff; font-weight: 900; text-decoration: underline; text-underline-offset: 2px; }
.app-footer-legal { display: flex; gap: 6px; justify-content: center; margin-top: 2px !important; }
.app-footer-legal button { padding: 2px 4px; }
.app-footer .heart { display: inline-block; margin: 0 2px; -webkit-text-stroke: 0; animation: heartbeat 1.4s ease-in-out infinite; }
@keyframes heartbeat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.3); } 30% { transform: scale(1.1); } 45% { transform: scale(1.25); } }
.settings-legal { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.settings-legal a, .settings-legal button { color: var(--ink-soft); text-decoration: underline; font-weight: 800; }

.legal-card { max-height: calc(100dvh - 40px - var(--safe-t) - var(--safe-b)); }
.legal {
  overflow-y: auto; text-align: left; font-size: 14px; line-height: 1.5; font-weight: 600;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; padding: 4px 14px 10px;
  touch-action: pan-y; -webkit-user-select: text; user-select: text;
}
.legal h3 { margin: 12px 0 4px; font-size: 15px; font-weight: 900; }
.legal p { margin: 6px 0; }
.legal ul { margin: 6px 0; padding-left: 20px; }
.legal a { color: #3d6fd6; }
.legal strong { font-weight: 900; }
.legal-meta { color: var(--ink-soft); font-size: 12.5px; }
@media (max-height: 720px) {
  .subtitle { display: none; }
  .diff-card { padding: 8px 11px; }
  .diff-icons, .diff-icons img { height: 24px; width: auto; }
}

/* ---------- Spiel ---------- */
.game-title { flex: 1; text-align: center; line-height: 1.1; }
.game-title h2 { font-size: 21px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.game-title small {
  display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 800;
  background: rgba(255, 255, 255, .9); border: 2px solid var(--ink); border-radius: 10px; padding: 1px 8px;
}
.timer {
  min-width: 66px; text-align: center; font-weight: 900; font-variant-numeric: tabular-nums;
  background: var(--card); border: var(--line); box-shadow: var(--pop-sm);
  padding: 9px 8px; border-radius: 16px; font-size: 15px;
}

.rule-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 0; flex-shrink: 0; }
.chip {
  display: grid; place-items: center; text-align: center;
  min-height: 50px; padding: 5px 6px; border-radius: 16px;
  background: rgba(255, 255, 255, .92); border: 2.5px solid var(--ink); box-shadow: var(--pop-sm);
  font-size: 12px; font-weight: 800; line-height: 1.2;
  animation: cardIn .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
.chip:nth-child(2) { animation-delay: .08s; } .chip:nth-child(3) { animation-delay: .16s; }
.chip b { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 1px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); font-size: 11px; font-weight: 900; vertical-align: 1px; }
.chip.alert { animation: chipAlert .6s ease; background: #ffd6de; }
@keyframes chipAlert { 15% { transform: rotate(-5deg) scale(1.1); } 35% { transform: rotate(4deg) scale(1.1); } 55% { transform: rotate(-3deg) scale(1.05); } 75% { transform: rotate(2deg); } }
.progress { display: flex; justify-content: center; gap: 2px; margin: 6px 0 0; min-height: 34px; }
.progress .pg { width: 34px; height: 34px; position: relative; }
.progress .pg img { width: 100%; height: 100%; filter: grayscale(1) brightness(1.3); opacity: .35; transition: filter .3s, opacity .3s; }
.progress .pg.on img { filter: none; opacity: 1; }
.progress .pg.on { animation: pgPop .55s cubic-bezier(.2, 1.8, .4, 1); }
.progress .pg.bad { animation: shake .4s; }
.progress.full .pg { animation: pgDance .6s ease calc(var(--k) * 60ms) 2; }
@keyframes pgPop { 0% { transform: scale(.2) translateY(14px); } 60% { transform: scale(1.45) rotate(-10deg); } }
@keyframes pgDance { 50% { transform: translateY(-10px) rotate(8deg); } }

.board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; }
.board {
  --n: 5; --thick: 3px;
  width: min(100%, 560px, calc(100vh - 360px - var(--safe-t) - var(--safe-b)));
  width: min(100%, 560px, calc(100dvh - 360px - var(--safe-t) - var(--safe-b)));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  border: 4px solid var(--ink); border-radius: 20px; overflow: hidden;
  background: #fff;
  box-shadow: 0 7px 0 var(--ink), 0 18px 34px rgba(43, 58, 85, .22);
  touch-action: none; container-type: inline-size;
}
.board.enter { animation: boardIn .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes boardIn { from { opacity: 0; transform: scale(.7) rotate(-4deg); } }
.board.won { animation: boardWon 1s ease; }
@keyframes boardWon { 25% { transform: scale(1.06) rotate(1deg); } 50% { transform: scale(.97) rotate(-1deg); } 75% { transform: scale(1.02); } }
.board.quake { animation: quake .35s; }
@keyframes quake { 20% { transform: translate(-5px, 2px) rotate(-.6deg); } 40% { transform: translate(5px, -2px) rotate(.6deg); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }

.cell {
  position: relative; background: var(--rc);
  border: 0 solid var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(43, 58, 85, .06);
}
.cell::before { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity .15s; pointer-events: none; }
.cell.press::before { opacity: .45; transition: none; }

.cell .x { width: 40%; height: 40%; pointer-events: none; animation: xIn .3s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes xIn { from { transform: scale(0) rotate(-120deg); opacity: 0; } }
.cell.auto:not(.has-x):not(.has-g)::after {
  content: ""; width: 16%; height: 16%; border-radius: 50%;
  background: rgba(43, 58, 85, .25); animation: xIn .25s ease;
}

.g-wrap { position: absolute; inset: 1%; animation: drop .65s cubic-bezier(.2, 1.3, .4, 1) both; pointer-events: none; z-index: 1; }
.g-wrap.noanim { animation: none; }
.g-bob { width: 100%; height: 100%; animation: bob 3.2s ease-in-out infinite; animation-delay: var(--bd, 0s); }
.g-bob img { width: 100%; height: 100%; display: block; }
.g-wrap.leave { animation: leave .3s ease-in forwards; }
.g-wrap.happy .g-bob { animation: happyHop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes happyHop { 40% { transform: translateY(-18%) rotate(-10deg) scale(1.1); } 70% { transform: translateY(2%) rotate(5deg) scale(.96, 1.04); } }
@keyframes drop {
  0% { transform: translateY(-170%) rotate(-30deg) scale(.4); opacity: 0; }
  50% { transform: translateY(6%) rotate(10deg) scale(1.12, .9); opacity: 1; }
  68% { transform: translateY(-6%) rotate(-6deg) scale(.95, 1.06); }
  84% { transform: rotate(2deg) scale(1.02, .98); }
  100% { transform: none; }
}
@keyframes leave { 30% { transform: scale(1.15); } to { transform: translateY(-70%) scale(.1) rotate(40deg); opacity: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5%) rotate(3deg); } }

.cell.conflict { background-image: repeating-linear-gradient(45deg, rgba(255, 77, 109, .4) 0 5px, transparent 5px 11px); }
.cell.conflict .g-bob { animation: wobble .45s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(-12deg) translateX(-3%); } 50% { transform: rotate(12deg) translateX(3%); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

.cell.flash::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 70%);
  animation: flash .55s ease-out both; animation-delay: var(--d, 0s);
}
@keyframes flash { 0% { opacity: 0; transform: scale(.3); } 40% { opacity: 1; } 100% { opacity: 0; transform: scale(1.2); } }

.cell.hint { z-index: 2; }
.cell.hint::after {
  content: ""; position: absolute; inset: 6%; border-radius: 26%; pointer-events: none;
  border: 3px solid #fff; box-shadow: 0 0 0 3px var(--red), 0 0 18px 5px rgba(255, 90, 78, .7);
  animation: hintPulse .7s ease-in-out infinite alternate;
}
.cell.hint-soft::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 2px rgba(255, 90, 78, .85);
  animation: hintSoft .7s ease-in-out infinite alternate;
}
@keyframes hintPulse { from { transform: scale(.84); } to { transform: scale(1); } }
@keyframes hintSoft { from { opacity: .45; } to { opacity: 1; } }

.cell.wave { animation: wave .7s ease both; animation-delay: var(--d, 0s); }
@keyframes wave { 40% { filter: brightness(1.3) saturate(1.4); transform: scale(1.1); z-index: 3; } }

/* Partikel & Popups */
.puff { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.puff i {
  position: absolute; left: 50%; top: 62%; width: 24%; height: 24%; border-radius: 50%;
  background: #fff; border: 2px solid rgba(43, 58, 85, .25); opacity: 0;
  animation: puff .65s ease-out forwards;
}
@keyframes puff {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(.3); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--px)), calc(-50% + var(--py))) scale(1.5); }
}
.spark {
  position: fixed; width: var(--s, 14px); height: var(--s, 14px); pointer-events: none; z-index: 26;
  animation: spark var(--t, .8s) cubic-bezier(.2, .8, .3, 1) forwards;
}
.spark svg { width: 100%; height: 100%; fill: var(--c, #ffd23f); stroke: var(--ink); stroke-width: 2.5px; stroke-linejoin: round; paint-order: stroke; overflow: visible; }
@keyframes spark {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--r, 180deg)); opacity: 0; }
}
.popup {
  position: fixed; z-index: 27; pointer-events: none; white-space: nowrap;
  font-size: var(--fs, 22px); font-weight: 900; color: var(--c, #fff);
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  animation: popup 1.1s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes popup {
  0% { transform: translate(-50%, -20%) scale(.2) rotate(-12deg); opacity: 0; }
  25% { transform: translate(-50%, -80%) scale(1.25) rotate(4deg); opacity: 1; }
  45% { transform: translate(-50%, -90%) scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -170%) scale(.9); opacity: 0; }
}

.loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px;
  font-weight: 900; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.loading.show { opacity: 1; }
.loading img { width: 84px; height: 84px; animation: circle 1.6s linear infinite; }
@keyframes circle { from { transform: rotate(0) translateX(26px) rotate(0); } to { transform: rotate(360deg) translateX(26px) rotate(-360deg); } }

.tools { display: flex; justify-content: center; gap: 12px; margin-top: 16px; flex-shrink: 0; }
.tool {
  position: relative; overflow: hidden;
  flex: 1; max-width: 120px; height: 66px; border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--card); font-weight: 900; font-size: 13px;
  border: var(--line); box-shadow: var(--pop);
  transition: transform .1s, box-shadow .1s;
}
.tool::after { content: ""; position: absolute; left: 14%; right: 14%; top: 4px; height: 26%; border-radius: 20px; background: rgba(255, 255, 255, .5); }
.tool svg { width: 26px; height: 26px; }
.tool:active { transform: translateY(5px); box-shadow: 0 0 0 var(--ink); }
.tool-hint { background: linear-gradient(180deg, #ffe37a, var(--yellow)); }
.tool.spin svg { animation: spinBack .5s ease; }
@keyframes spinBack { to { transform: rotate(-360deg); } }
.tool.wiggle svg { animation: wiggleIco .5s ease; }
@keyframes wiggleIco { 25% { transform: rotate(-20deg) scale(1.3); } 75% { transform: rotate(15deg) scale(1.3); } }

/* Combo-Anzeige */
.combo {
  position: absolute; top: 0; left: 50%; z-index: 4; pointer-events: none;
  transform: translate(-50%, -30%) scale(.5); opacity: 0;
  background: linear-gradient(180deg, #ffe37a, var(--yellow));
  border: var(--line); box-shadow: var(--pop-sm); border-radius: 16px; padding: 2px 12px;
  font-size: 15px; font-weight: 900; white-space: nowrap;
  transition: opacity .25s, transform .35s cubic-bezier(.2, 1.6, .4, 1);
}
.combo.show { opacity: 1; transform: translate(-50%, -60%) scale(1); }
.combo.bump { animation: jelly .45s; }

/* ---------- Hilfe ---------- */
.help-scroll { flex: 1; overflow-y: auto; margin: 0 -16px; padding: 6px 16px 24px; touch-action: pan-y; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.help-scroll > * { width: 100%; max-width: 440px; flex-shrink: 0; }
.help-example { width: min(46vw, 180px, 21vh) !important; }
.board.mini { width: 100%; pointer-events: none; }
.help-chips { margin: 0; }
.controls-card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  background: var(--card); border: var(--line); box-shadow: var(--pop); border-radius: 20px;
}
.ctl { display: grid; grid-template-columns: 44px auto 1fr; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.ctl b { font-weight: 900; }
.ctl-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: #b6f3c2; border: 2.5px solid var(--ink); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .55);
}
.ctl-ico .x { width: 20px; height: 20px; }
.ctl-ico img { width: 38px; height: 38px; animation: bob 2.6s ease-in-out infinite; }
.ctl-ico.swipe { display: flex; gap: 0; justify-content: center; background: #9fe6ff; }
.ctl-ico.swipe .x { width: 12px; height: 12px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(43, 58, 85, .35);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal.show { opacity: 1; pointer-events: auto; }
.card {
  position: relative;
  width: 100%; max-width: 380px; background: var(--cream); border-radius: 28px; padding: 22px 18px 18px;
  display: flex; flex-direction: column; gap: 11px; align-items: stretch; text-align: center;
  border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink);
  transform: scale(.6) translateY(60px) rotate(-4deg); transition: transform .55s cubic-bezier(.2, 1.5, .4, 1);
}
.modal.show .card { transform: none; }
.card h2 { margin: 0; font-size: 27px; font-weight: 900; }

.win-card { padding-top: 6px; }
.win-glider { width: 132px; height: 132px; margin: -84px auto -6px; }
.win-glider img { width: 100%; height: 100%; }
.modal.show .win-glider img { animation: winDrop .9s cubic-bezier(.2, 1.5, .4, 1) both, bob 2.4s 1s ease-in-out infinite; }
@keyframes winDrop { 0% { transform: translateY(-120px) scale(.4) rotate(-30deg); opacity: 0; } 60% { transform: translateY(8px) scale(1.1, .92); opacity: 1; } 100% { transform: none; } }
.win-card h2 { color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; font-size: 30px; }
.modal.show .win-card h2 { animation: popIn .5s .25s cubic-bezier(.2, 1.8, .4, 1) both; }
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.win-stars .star { width: 54px; height: 54px; fill: #e4e7ef; stroke: var(--ink); stroke-width: 2px; stroke-linejoin: round; paint-order: stroke; overflow: visible; }
.win-stars .star.big { width: 74px; height: 74px; margin-bottom: 8px; }
.win-stars .star.on { fill: var(--yellow); animation: starPop .7s cubic-bezier(.2, 1.9, .4, 1); }
@keyframes starPop { 0% { transform: scale(0) rotate(-180deg); } 60% { transform: scale(1.45) rotate(15deg); } 100% { transform: none; } }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.win-stats div { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px 4px; display: flex; flex-direction: column; }
.win-stats small { font-size: 11px; color: var(--ink-soft); font-weight: 800; }
.win-stats b { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.win-xp { background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.win-xp-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 900; }
.win-xp-head b { color: #7c4dff; font-size: 17px; font-variant-numeric: tabular-nums; }
.win-xp .xp-bar { height: 14px; border-radius: 8px; }
.win-xp small { font-size: 11px; color: var(--ink-soft); text-align: left; }
.win-record:empty { display: none; }
.win-record {
  position: absolute; top: 52px; right: -12px; margin: 0; z-index: 2;
  background: var(--red); color: #fff; border: 3px solid var(--ink); border-radius: 12px;
  padding: 4px 10px; font-size: 13px; font-weight: 900; transform: rotate(12deg);
  animation: stamp .5s 1.6s cubic-bezier(.2, 1.8, .4, 1) both;
}
@keyframes stamp { from { opacity: 0; transform: rotate(12deg) scale(3); } }

/* Rang-Aufstieg */
.rankup { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; opacity: 0; overflow: hidden; }
.rankup.show { opacity: 1; pointer-events: auto; animation: fadeIn .2s; }
.rankup::before {
  content: ""; position: absolute; inset: -60%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 210, 63, .55) 0 10deg, rgba(255, 255, 255, .15) 10deg 20deg);
  animation: spin 14s linear infinite;
}
.rankup::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, transparent 20%, rgba(43, 58, 85, .55) 75%); }
.rankup-card {
  position: relative; z-index: 1; text-align: center; padding: 16px 26px 20px; margin: 20px;
  background: var(--cream); border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink); border-radius: 28px;
}
.rankup.show .rankup-card { animation: rankIn .8s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes rankIn { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } }
.rankup-card small { font-size: 14px; font-weight: 900; color: var(--ink-soft); letter-spacing: 1.5px; text-transform: uppercase; }
.rankup-card h2 { margin: 2px 0 4px; font-size: 32px; font-weight: 900; color: var(--yellow); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.rankup-card img { width: 120px; height: 120px; animation: bob 1.6s ease-in-out infinite; }
.rankup-card .lvl { font-size: 17px; font-weight: 900; }
.rankup-card p { margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 2px dashed rgba(43, 58, 85, .15); text-align: left; font-weight: 900; font-size: 17px; }
.toggle small { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.toggle input { display: none; }
.toggle i { width: 56px; height: 34px; border-radius: 18px; background: #d6dde8; border: 3px solid var(--ink); position: relative; flex-shrink: 0; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2.5px solid var(--ink); box-sizing: border-box; transition: transform .3s cubic-bezier(.2, 1.6, .4, 1); }
.toggle input:checked + i { background: var(--good); }
.toggle input:checked + i::after { transform: translateX(22px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 100px); z-index: 30;
  transform: translate(-50%, 40px) scale(.8); opacity: 0;
  max-width: calc(100% - 32px); width: max-content;
  background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: 18px;
  border: var(--line); box-shadow: var(--pop-sm);
  font-weight: 800; font-size: 15px; text-align: center; line-height: 1.3;
  transition: transform .4s cubic-bezier(.2, 1.6, .4, 1), opacity .25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
.toast.bad { background: #ffe1e6; }
.toast.good { background: #dff8ea; }

/* ---------- Effekte ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.flashscreen { position: fixed; inset: 0; background: #fff; z-index: 24; pointer-events: none; animation: flashOut .5s ease-out forwards; }
@keyframes flashOut { from { opacity: .85; } to { opacity: 0; } }
.fly { position: fixed; will-change: transform; animation: liftoff 1.7s cubic-bezier(.45, 0, .6, .4) forwards; animation-delay: var(--ld, 0s); }
.fly img { width: 100%; height: 100%; }
@keyframes liftoff {
  0% { transform: none; }
  18% { transform: translateY(18%) scale(1.15, .85); }
  30% { transform: translateY(-10%) scale(.95, 1.1) rotate(-8deg); }
  100% { transform: translate(var(--lx), -115vh) rotate(var(--lr)) scale(1.6); }
}
.confetti { position: fixed; top: -50px; will-change: transform; animation: fall var(--dur, 4s) linear forwards; animation-delay: var(--dl, 0s); }
.confetti > div { width: 100%; height: 100%; animation: sway 1.3s ease-in-out infinite alternate; }
.confetti img { width: 100%; height: 100%; }
.confetti.piece > div { border-radius: 4px; background: var(--col); border: 2px solid var(--ink); }
.confetti.star svg { width: 100%; height: 100%; fill: var(--col); stroke: var(--ink); stroke-width: 2.5px; paint-order: stroke; overflow: visible; }
@keyframes fall { to { transform: translateY(calc(100vh + 100px)) rotate(var(--rot, 180deg)); } }
@keyframes sway { from { transform: translateX(-20px) rotate(-15deg); } to { transform: translateX(20px) rotate(15deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) { .screen { padding-left: 32px; padding-right: 32px; } }

.legal-card .legal { flex: 1; min-height: 0; }

/* Ko-fi */
.app-footer-legal { flex-wrap: wrap; }
.app-footer-legal a { color: #fff; }
.kofi-link { display: inline-block; margin-top: 6px; }
.kofi-note {
  display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none; color: var(--ink);
  background: #fff3d6; border: 2.5px solid var(--ink); border-radius: 16px; padding: 8px 12px;
  font-size: 12.5px; font-weight: 700; line-height: 1.35;
}
.kofi-note[hidden] { display: none; }
.kofi-note b { font-weight: 900; font-size: 13.5px; }
.kofi-cup { font-size: 28px; animation: bob 2.4s ease-in-out infinite; }
.modal.show .kofi-note:not([hidden]) { animation: popIn .5s 2.2s cubic-bezier(.2, 1.6, .4, 1) both; }
