/* Malins skattjakt – stil
   Du behöver inte ändra något här för att byta frågor eller texter;
   det görs i config.js. */

@font-face {
  font-family: "Lilita One";
  src: url("fonts/lilita-one-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("fonts/nunito-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1a1020;
  --night: #2b1b4a;
  --night-2: #3b2768;
  --cream: #fff4dc;
  --cream-2: #f3dfb4;
  --orange: #ff7a1a;
  --yellow: #ffd23f;
  --teal: #1fc8b4;
  --pink: #ff4f8b;
  --green: #3fd16b;
  --red: #ff4545;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;            /* allt scrollar inuti #stage – inga sidoscroll vid effekter */
  overscroll-behavior: none;
}
body {
  background: #120a20;
  color: var(--ink);
  font-family: var(--body);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.prewrap { white-space: pre-line; }

/* ---------- Världen & bakgrund ---------- */

#world {
  position: fixed;
  inset: 0;
  overflow: hidden;
  transform-origin: 50% 50%;
}

#bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--night);
}
#bg::before {                    /* solstrålar */
  content: "";
  position: absolute;
  left: 50%; top: 32%;
  width: 260vmax; height: 260vmax;
  margin: -130vmax 0 0 -130vmax;
  background: repeating-conic-gradient(from 0deg, var(--night-2) 0deg 10deg, var(--night) 10deg 20deg);
  animation: rays 90s linear infinite;
}
#bg::after {                     /* rasterprickar + vinjett */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 30%, transparent 0 35%, rgba(10, 4, 20, .65) 100%),
    radial-gradient(rgba(255, 255, 255, .07) 1.5px, transparent 1.6px) 0 0 / 14px 14px;
}
@keyframes rays { to { transform: rotate(360deg); } }

#stage {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 16px);
}
body.busy #stage { pointer-events: none; }

.screen {
  display: none;
  width: 100%;
  max-width: 460px;
  min-height: 100%;
  margin: 0 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 18px;
}
.screen.active {
  display: flex;
  animation: screen-in .5s var(--bounce) both;
}
@keyframes screen-in {
  from { opacity: 0; transform: scale(.85) rotate(-2deg); }
  to   { opacity: 1; transform: none; }
}

/* Låga skärmar (små telefoner): krymp maskot och rubrik lite */
@media (max-height: 640px) {
  .screen { gap: 12px; }
  .mascot-start { width: 96px; }
  .mascot-fail { width: 84px; }
  .mega-title { font-size: clamp(2.2rem, 12vw, 3.2rem); }
  .panel { padding: 22px 16px 18px; }
  .btn-big { min-height: 60px; font-size: 1.5rem; }
}

/* ---------- Typografi ---------- */

.mega-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 14vw, 4.3rem);
  line-height: .95;
  text-align: center;
  color: var(--yellow);
  -webkit-text-stroke: .13em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .09em 0 var(--ink), .05em .11em 0 var(--ink);
  letter-spacing: .01em;
  transform: rotate(-3deg);
}
.mega-title .ch {
  display: inline-block;
  animation: wave 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 70ms);
}
.mega-title .word { display: inline-block; white-space: nowrap; }
@keyframes wave {
  0%, 60%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-.12em) rotate(-4deg); }
  40% { transform: translateY(.03em) rotate(3deg); }
}

.kicker {
  margin: 0 0 8px;
  text-align: center;
}
.kicker span {
  display: inline-block;
  padding: 5px 14px 6px;
  font-family: var(--display);
  font-size: 1.05rem;
  color: #fff;
  background: var(--pink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(2deg);
}

/* ---------- Dialogpanel ---------- */

.panel {
  position: relative;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 20px;
  padding: 26px 20px 22px;
  box-shadow:
    inset 0 0 0 4px var(--cream),
    inset 0 0 0 7px var(--orange),
    0 7px 0 var(--ink),
    0 14px 24px rgba(0, 0, 0, .35);
}
.panel-text {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
  text-align: center;
}
.nametag {
  position: absolute;
  top: -19px;
  left: 14px;
  padding: 3px 14px 5px;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: .03em;
  color: #fff;
  background: var(--orange);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
  transform: rotate(-3deg);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
}
.nametag-gold { background: var(--yellow); }
.nametag-red  { background: var(--red); }
.panel-next {
  position: absolute;
  right: 14px;
  bottom: 6px;
  font-size: .8rem;
  color: var(--orange);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ---------- Knappar ---------- */

button { font: inherit; color: inherit; }

.btn-big {
  display: block;
  width: 100%;
  min-height: 68px;
  padding: 12px 20px 14px;
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: .02em;
  color: #fff;
  background: var(--orange);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 7px 0 var(--ink), inset 0 -6px 0 rgba(0, 0, 0, .18), inset 0 4px 0 rgba(255, 255, 255, .35);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  cursor: pointer;
  touch-action: manipulation;
  animation: nudge 2.2s ease-in-out infinite;
  transition: transform .08s, box-shadow .08s;
}
.btn-big:active { transform: translateY(5px) !important; box-shadow: 0 2px 0 var(--ink); animation: none; }
@keyframes nudge {
  0%, 70%, 100% { transform: none; }
  78% { transform: rotate(-2deg) scale(1.04); }
  86% { transform: rotate(2deg) scale(1.04); }
  94% { transform: rotate(-1deg); }
}
.btn-small {
  align-self: center;
  min-height: 48px;
  padding: 8px 20px;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.btn-small:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

button:focus-visible {
  outline: 4px solid var(--teal);
  outline-offset: 4px;
}

/* ---------- Maskoten ---------- */

.mascot-wrap { display: flex; justify-content: center; }
.mascot { display: block; width: 100%; height: auto; overflow: visible; }
.mascot-start { width: 150px; align-self: center; animation: hop 1.4s var(--bounce) infinite; }
.mascot-fail  { width: 120px; align-self: center; animation: sulk 2.6s ease-in-out infinite; }
.mascot .eyes { transform-box: fill-box; transform-origin: center; animation: eyeblink 4s infinite; }
@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.1, .88); }
  45% { transform: translateY(-22px) scale(.95, 1.06); }
  75% { transform: translateY(0) scale(1.08, .92); }
}
@keyframes sulk {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg) translateY(4px); }
}
@keyframes eyeblink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}

/* ---------- Startsidan ---------- */

.start-top { padding-top: 6px; }
.panel-intro .panel-text { font-size: 1.12rem; }

/* ---------- Frågesidan ---------- */

#screen-quiz { gap: 14px; }
.quiz-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.progress-pill {
  margin: 0;
  padding: 4px 18px 6px;
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-2deg);
}
.dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.dots li {
  width: 16px; height: 16px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  transition: transform .3s var(--bounce), background .2s;
}
.dots li.now  { background: var(--yellow); transform: scale(1.3); }
.dots li.ok   { background: var(--green); }
.dots li.miss { background: var(--red); }

.q-area {
  position: relative;
  padding-top: 22px;
  margin-top: 4px;
}
.mascot-quiz {
  position: absolute;
  right: -2px;
  top: -16px;
  width: 78px;
  z-index: 2;
  transform: rotate(8deg);
}
.mascot-quiz.jump { animation: jump .8s var(--bounce); }
.mascot-quiz.gasp { animation: gasp .7s ease-out; }
@keyframes jump {
  0% { transform: rotate(8deg); }
  35% { transform: translateY(-34px) rotate(-12deg) scale(1.15); }
  70% { transform: translateY(0) rotate(8deg) scale(1.12, .88); }
  100% { transform: rotate(8deg); }
}
@keyframes gasp {
  0% { transform: rotate(8deg); }
  20% { transform: scale(1.3) rotate(-6deg); }
  100% { transform: rotate(8deg); }
}

.panel-question {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 18px 26px;
}
.panel-question.enter { animation: panel-in .55s var(--bounce) both; }
@keyframes panel-in {
  0% { transform: scale(.6) rotate(-4deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.q-text {
  margin: 0;
  font-family: var(--body);
  font-weight: 900;
  font-size: clamp(1.25rem, 5.6vw, 1.5rem);
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}
#q-text .c { opacity: 0; }
#q-text .c.on { opacity: 1; }

.answers {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 8px;
}
.answer {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 70px;
  padding: 8px 16px 8px 10px;
  text-align: left;
  font-family: var(--body);
  font-weight: 900;
  font-size: 1.2rem;
  line-height: 1.2;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s, box-shadow .08s, background .15s, opacity .2s;
  overflow-wrap: anywhere;
}
.answers.enter .answer { animation: answer-in .5s var(--bounce) both; }
.answers.enter .answer:nth-child(1) { animation-delay: .12s; }
.answers.enter .answer:nth-child(2) { animation-delay: .2s; }
.answers.enter .answer:nth-child(3) { animation-delay: .28s; }
@keyframes answer-in {
  from { opacity: 0; transform: translateX(-40px) rotate(-3deg); }
  to   { opacity: 1; transform: none; }
}
.answer:not(:disabled):active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
@media (hover: hover) {
  .answer:not(:disabled):hover { background: var(--cream); transform: translateY(-2px) rotate(-.6deg); }
}
.answer:disabled { cursor: default; }
.answers.locked .answer:not(.is-correct):not(.is-wrong) { opacity: .45; }
.badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  font-family: var(--display);
  font-size: 1.75rem;
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2);
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
}
.b1 { background: var(--teal); }
.bx { background: var(--pink); }
.b2 { background: var(--orange); }
.answer-text { flex: 1; }

.answer.is-correct {
  background: var(--green);
  animation: boing .6s var(--bounce) both !important;
}
.answer.is-wrong {
  background: var(--red);
  color: #fff;
  animation: nope .45s ease-in-out both !important;
}
@keyframes boing {
  0% { transform: scale(1); }
  40% { transform: scale(1.08, .9); }
  70% { transform: scale(.97, 1.05); }
  100% { transform: scale(1.03); }
}
@keyframes nope {
  0%, 100% { transform: none; }
  20% { transform: translateX(-10px) rotate(-2deg); }
  40% { transform: translateX(10px) rotate(2deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- Vinst ---------- */

.win-title { color: var(--yellow); }
.win-figure {
  margin: 0;
  align-self: center;
  width: min(100%, 340px);
  padding: 10px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 8px 0 var(--ink), 0 0 0 10px rgba(255, 210, 63, .35), 0 0 60px 10px rgba(255, 210, 63, .45);
  transform: rotate(-2deg);
  animation: figure-in .8s var(--bounce) .15s both;
}
.win-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 46dvh;
  object-fit: contain;
  border-radius: 8px;
}
@keyframes figure-in {
  from { transform: scale(0) rotate(-30deg); }
  to   { transform: rotate(-2deg); }
}
.panel-win .panel-text { font-size: 1.15rem; }

/* ---------- Nästan ---------- */

.fail-title {
  color: var(--pink);
  animation: wobble 1.8s ease-in-out infinite;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(3deg) scale(1.05); }
}
.score-big {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 2.6rem;
  color: #fff;
  -webkit-text-stroke: .14em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
}
.score-big small { font-size: .55em; }

/* ---------- Fel i config ---------- */

.err-title { margin: 0 0 10px; font-family: var(--display); font-weight: 400; font-size: 1.6rem; }
#err-list { margin: 0 0 12px; padding-left: 1.2em; line-height: 1.4; }
#err-list li { margin-bottom: 6px; }
.err-hint { margin: 0; font-weight: 700; }
code { background: var(--cream-2); padding: 1px 5px; border-radius: 4px; }
.noscript { position: fixed; inset: auto 16px 16px; z-index: 300; padding: 16px; background: var(--cream); border: 4px solid var(--ink); border-radius: 16px; }

/* =====================================================================
   EFFEKTER
   ===================================================================== */

#fx {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: hidden;
}

/* --- Rätt svar: stämpel --- */
.stamp {
  position: absolute;
  left: 50%; top: 42%;
  width: 270px; height: 270px;
  margin: -135px 0 0 -135px;
  display: grid;
  place-items: center;
  animation: stamp 1.15s var(--bounce) both;
}
.stamp::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--yellow);
  clip-path: polygon(50% 0, 59% 25%, 85% 12%, 74% 38%, 100% 44%, 76% 59%, 92% 84%, 64% 75%, 55% 100%, 44% 76%, 17% 90%, 26% 62%, 0 52%, 25% 39%, 10% 13%, 38% 24%);
  filter: drop-shadow(0 0 0 var(--ink));
  animation: spin-slow 3s linear infinite;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: 16px;
  background: var(--orange);
  clip-path: polygon(50% 0, 59% 25%, 85% 12%, 74% 38%, 100% 44%, 76% 59%, 92% 84%, 64% 75%, 55% 100%, 44% 76%, 17% 90%, 26% 62%, 0 52%, 25% 39%, 10% 13%, 38% 24%);
  animation: spin-slow 3s linear infinite reverse;
}
.stamp-text {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: var(--display);
  color: #fff;
  -webkit-text-stroke: 9px var(--ink);
  paint-order: stroke fill;
  transform: rotate(-8deg);
  line-height: .9;
}
.stamp-text b { display: block; font-weight: 400; font-size: 4.2rem; }
.stamp-text i { display: block; font-style: normal; font-size: 1.5rem; margin-top: 4px; color: var(--yellow); -webkit-text-stroke-width: 6px; }
@keyframes stamp {
  0%   { transform: scale(3) rotate(25deg); opacity: 0; }
  25%  { transform: scale(.9) rotate(-4deg); opacity: 1; }
  38%  { transform: scale(1.05) rotate(2deg); }
  80%  { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(.4) rotate(0); opacity: 0; }
}
@keyframes spin-slow { to { transform: rotate(360deg); } }
.spark {
  position: absolute;
  left: 50%; top: 42%;
  width: 22px; height: 22px;
  margin: -11px;
  background: var(--c, var(--yellow));
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark .9s ease-out both;
}
@keyframes spark {
  from { transform: translate(0, 0) scale(.3) rotate(0); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(1.4) rotate(180deg); opacity: 0; }
}

/* --- Bildtext/pratbubbla för fel svar --- */
.fx-caption {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-t) + 18%);
  max-width: calc(100vw - 32px);
  padding: 10px 22px 12px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  line-height: 1;
  white-space: nowrap;
  color: #fff;
  background: var(--red);
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink);
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  transform: translateX(-50%) rotate(-5deg);
  animation: caption 2.2s var(--bounce) both;
}
.fx-caption.bottom { top: auto; bottom: calc(var(--safe-b) + 14%); }
@keyframes caption {
  0%   { transform: translateX(-50%) scale(0) rotate(-25deg); }
  15%  { transform: translateX(-50%) scale(1.1) rotate(-5deg); }
  22%  { transform: translateX(-50%) scale(1) rotate(-5deg); }
  85%  { transform: translateX(-50%) scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(.6) rotate(-3deg); opacity: 0; }
}

/* 1. Snurr */
body.fx-spin #world { animation: fx-spin 2.2s cubic-bezier(.6, 0, .3, 1) both; }
@keyframes fx-spin {
  0%   { transform: none; }
  45%  { transform: rotate(540deg) scale(.45); }
  80%  { transform: rotate(720deg) scale(1.05); }
  100% { transform: rotate(720deg) scale(1); }
}

/* 2. Jordbävning */
body.fx-shake #world { animation: fx-shake 1.9s linear both; }
@keyframes fx-shake {
  0%, 100% { transform: none; }
  5%  { transform: translate(-14px, 6px) rotate(-3deg); }
  10% { transform: translate(16px, -8px) rotate(3deg); }
  15% { transform: translate(-18px, -4px) rotate(-2deg); }
  20% { transform: translate(14px, 10px) rotate(4deg); }
  25% { transform: translate(-10px, -12px) rotate(-4deg); }
  30% { transform: translate(18px, 4px) rotate(2deg); }
  35% { transform: translate(-16px, 8px) rotate(-3deg); }
  40% { transform: translate(12px, -10px) rotate(3deg); }
  45% { transform: translate(-14px, 2px) rotate(-2deg); }
  50% { transform: translate(10px, 8px) rotate(2deg); }
  60% { transform: translate(-8px, -6px) rotate(-1deg); }
  70% { transform: translate(6px, 4px) rotate(1deg); }
  80% { transform: translate(-4px, -2px); }
  90% { transform: translate(2px, 2px); }
}

/* 3. Färgkaos (inverterade färger) */
body.fx-invert #world { animation: fx-invert 2.2s steps(1, end) both; }
@keyframes fx-invert {
  0%   { filter: invert(1); }
  12%  { filter: invert(1) hue-rotate(90deg); }
  24%  { filter: invert(1) hue-rotate(180deg); }
  36%  { filter: invert(1) hue-rotate(270deg) saturate(3); }
  48%  { filter: invert(0) hue-rotate(180deg) saturate(4); }
  60%  { filter: invert(1) hue-rotate(45deg); }
  72%  { filter: invert(1) hue-rotate(135deg) contrast(1.4); }
  86%  { filter: invert(1); }
  100% { filter: none; }
}

/* 4. Upp och ned */
body.fx-flip #world { animation: fx-flip 2.3s var(--bounce) both; }
@keyframes fx-flip {
  0%   { transform: none; }
  18%  { transform: rotate(180deg); }
  30%  { transform: rotate(170deg) scale(.95); }
  42%  { transform: rotate(186deg); }
  70%  { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}

/* 5. Smälter */
body.fx-melt #world { animation: fx-melt 2.4s ease-in-out both; transform-origin: 50% 0; }
@keyframes fx-melt {
  0%   { transform: none; filter: none; }
  45%  { transform: scale(1, 1.35) skewX(6deg); filter: blur(2px) saturate(1.6); }
  65%  { transform: scale(1.05, 1.5) skewX(-5deg); filter: blur(3px) hue-rotate(40deg); }
  82%  { transform: scale(1, .9); filter: none; }
  92%  { transform: scale(1, 1.04); }
  100% { transform: none; filter: none; }
}
.drip {
  position: absolute;
  top: -10px;
  width: var(--w, 40px);
  height: var(--h, 40vh);
  left: var(--x, 0);
  background: var(--c, var(--pink));
  border: 4px solid var(--ink);
  border-top: none;
  border-radius: 0 0 999px 999px;
  transform-origin: 50% 0;
  animation: drip 2.4s cubic-bezier(.5, 0, .4, 1) var(--d, 0s) both;
}
@keyframes drip {
  0%   { transform: scaleY(0); }
  55%  { transform: scaleY(1); }
  75%  { transform: scaleY(1.05); }
  100% { transform: scaleY(0); }
}

/* 6. Platt som en pannkaka */
body.fx-squash #world { animation: fx-squash 2.1s both; transform-origin: 50% 100%; }
@keyframes fx-squash {
  0%   { transform: none; animation-timing-function: cubic-bezier(.6, 0, 1, .6); }
  18%  { transform: scale(1.4, .06); }
  55%  { transform: scale(1.4, .06); animation-timing-function: cubic-bezier(.2, 1.8, .4, 1); }
  75%  { transform: scale(.9, 1.15); }
  88%  { transform: scale(1.04, .96); }
  100% { transform: none; }
}

/* 7. Fiskregn */
.rain-item {
  position: absolute;
  top: -120px;
  left: var(--x);
  width: var(--s, 70px);
  height: auto;
  animation: rain var(--t, 1.6s) cubic-bezier(.4, 0, .9, .6) var(--d, 0s) both;
}
@keyframes rain {
  from { transform: translateY(0) rotate(var(--r0, 0deg)); }
  to   { transform: translateY(calc(100vh + 260px)) rotate(var(--r1, 360deg)); }
}

/* 8. Älgen rullar förbi */
.alg {
  position: absolute;
  top: 38%;
  left: 100%;
  width: min(85vw, 380px);
  height: auto;
  animation: alg 2.4s linear both;
}
@keyframes alg {
  0%   { transform: translate(0, 0) rotate(0); }
  20%  { transform: translate(-45vw, -16px) rotate(-6deg); }
  30%  { transform: translate(-60vw, 0) rotate(3deg); }
  40%  { transform: translate(-75vw, -16px) rotate(-4deg); }
  50%  { transform: translate(-90vw, 0) rotate(4deg); }
  60%  { transform: translate(-105vw, -16px) rotate(-3deg); }
  100% { transform: translate(calc(-100vw - 110%), -30px) rotate(-8deg); }
}

/* 9. Gummikycklingen */
.kyckling {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(72vw, 300px);
  height: auto;
  margin-left: calc(min(72vw, 300px) / -2);
  transform-origin: 50% 100%;
  animation: kyckling 2.3s both;
}
@keyframes kyckling {
  0%   { transform: translateY(105%) rotate(0); animation-timing-function: cubic-bezier(.2, 1.6, .5, 1); }
  20%  { transform: translateY(8%) rotate(-4deg); }
  28%  { transform: translateY(8%) rotate(6deg) scale(1.08); }
  36%  { transform: translateY(8%) rotate(-6deg) scale(1.12); }
  44%  { transform: translateY(8%) rotate(6deg) scale(1.08); }
  52%  { transform: translateY(8%) rotate(-5deg) scale(1.12); }
  60%  { transform: translateY(8%) rotate(5deg) scale(1.08); }
  75%  { transform: translateY(8%) rotate(0) scale(1); animation-timing-function: cubic-bezier(.6, -0.6, .8, .3); }
  100% { transform: translateY(110%) rotate(0); }
}
body.fx-kyckling #world { animation: dim 2.3s both; }
@keyframes dim {
  0%, 100% { filter: none; }
  15%, 80% { filter: brightness(.55) saturate(.6); }
}

/* --- Seger: stor fanfar --- */
.victory-burst {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  animation: vb-fade 3.4s both;
}
.victory-burst::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 220vmax; height: 220vmax;
  margin: -110vmax 0 0 -110vmax;
  background: repeating-conic-gradient(rgba(255, 210, 63, .85) 0 9deg, rgba(255, 122, 26, .85) 9deg 18deg);
  animation: spin-slow 6s linear infinite;
}
.victory-text {
  position: relative;
  text-align: center;
  font-family: var(--display);
  color: #fff;
  line-height: .9;
  -webkit-text-stroke: .16em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .08em 0 var(--ink);
  font-size: clamp(3rem, 17vw, 5.5rem);
  transform: rotate(-6deg);
  animation: vt-in 1s var(--bounce) both, vt-pulse .5s ease-in-out 1s 4 alternate;
  padding: 0 12px;
}
.victory-text small { display: block; font-size: .42em; color: var(--yellow); margin-top: .3em; }
@keyframes vt-in {
  0%   { transform: scale(0) rotate(-200deg); }
  100% { transform: scale(1) rotate(-6deg); }
}
@keyframes vt-pulse {
  from { transform: scale(1) rotate(-6deg); }
  to   { transform: scale(1.1) rotate(-3deg); }
}
@keyframes vb-fade {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  85%  { opacity: 1; }
  100% { opacity: 0; }
}
body.fx-victory #world { animation: v-shake .5s ease-out .1s both; }
@keyframes v-shake {
  0%, 100% { transform: none; }
  20% { transform: scale(1.06) rotate(-1deg); }
  40% { transform: scale(.97) rotate(1deg); }
  60% { transform: scale(1.02); }
}
.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* =====================================================================
   MINDRE RÖRELSE (prefers-reduced-motion)
   Våldsamma effekter byts mot lugna tonings-/färgeffekter.
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  #bg::before,
  .mega-title .ch,
  .btn-big,
  .mascot-start,
  .mascot-fail,
  .fail-title,
  .stamp::before,
  .stamp::after,
  .victory-burst::before,
  .panel-next { animation: none !important; }

  .screen.active,
  .panel-question.enter,
  .answers.enter .answer,
  .win-figure { animation: rm-fade .35s ease-out both !important; }
  .win-figure { transform: rotate(-2deg); }
  .mascot-quiz.jump, .mascot-quiz.gasp { animation: none; }
  .answer.is-correct, .answer.is-wrong { animation: none !important; }

  .stamp, .fx-caption, .victory-text { animation: rm-fade-inout 1.1s ease-in-out both !important; }
  .fx-caption { animation-duration: 2.2s !important; }
  .victory-text { animation-duration: 3.2s !important; }
  .spark { display: none; }

  body.fx-spin #world   { animation: rm-tint 2.2s ease-in-out both; }
  body.fx-shake #world  { animation: rm-redpulse 1.9s ease-in-out both; }
  body.fx-invert #world { animation: rm-invert 2.2s ease-in-out both; }
  body.fx-flip #world   { animation: rm-dim 2.3s ease-in-out both; }
  body.fx-melt #world   { animation: rm-blur 2.4s ease-in-out both; }
  body.fx-squash #world { animation: rm-gray 2.1s ease-in-out both; }
  body.fx-victory #world { animation: none; }

  .drip, .rain-item, .alg, .kyckling { animation: rm-fade-inout 2.2s ease-in-out both !important; }
  .rain-item { top: var(--y, 30%); }
  .alg { left: 50%; margin-left: calc(min(85vw, 380px) / -2); }
  .kyckling { transform: none; }
}
@keyframes rm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rm-fade-inout { 0%, 100% { opacity: 0; } 20%, 80% { opacity: 1; } }
@keyframes rm-tint { 0%, 100% { filter: none; } 30%, 70% { filter: sepia(1) hue-rotate(250deg) saturate(2); } }
@keyframes rm-redpulse { 0%, 100% { filter: none; } 30%, 70% { filter: sepia(1) hue-rotate(-40deg) saturate(3); } }
@keyframes rm-invert { 0%, 100% { filter: none; } 30%, 70% { filter: invert(1); } }
@keyframes rm-dim { 0%, 100% { opacity: 1; } 30%, 70% { opacity: .25; } }
@keyframes rm-blur { 0%, 100% { filter: none; } 30%, 70% { filter: blur(4px); } }
@keyframes rm-gray { 0%, 100% { filter: none; } 30%, 70% { filter: grayscale(1) contrast(.7); } }
