/* ============================================================
   Kierrätyskissa — bright, playful "sticker" theme.
   Palette sampled from the park tug-of-war artwork:
   sky blue, grass green, sunny yellow, orange, red, teal.
   ============================================================ */

:root {
  /* core palette */
  --sky:        #bfe9fb;
  --sky-deep:   #7fc9e8;
  --grass:      #86cf4e;
  --grass-deep: #4ea32e;
  --sun:        #ffd23f;
  --orange:     #ff9442;
  --red:        #ff5d6c;
  --teal:       #2ec4b6;
  --blue:       #3d9be9;
  --purple:     #9b7ede;

  --ink:        #2c3e2a;      /* dark leafy green for text on light */
  --cloud:      #ffffff;

  --stroke:     3px solid #ffffff;          /* sticker outline */
  --shadow:     0 6px 0 rgba(0,0,0,.14), 0 10px 18px rgba(0,0,0,.18);
  --shadow-sm:  0 3px 0 rgba(0,0,0,.14), 0 6px 12px rgba(0,0,0,.16);

  font-family: "Fredoka", "Baloo 2", "Segoe UI Rounded", "Comic Sans MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* cheerful sky → grass backdrop behind any letterboxing */
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-deep) 55%, var(--grass) 100%);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app { width: 100%; height: 100%; }

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  border-radius: 18px;
  box-shadow: var(--shadow);
  touch-action: none;
  overflow: hidden;
}
/* Fullscreen play area on mobile: no rounded frame or shadow. */
.stage.cover { border-radius: 0; box-shadow: none; }
.stage.cover .level-tint,
.stage.cover .danger-vignette { border-radius: 0; }

/* The world that holds the artwork + game objects. The camera scales and
   translates this (from the top-left) to follow the cat when zoomed in. */
.world {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  background-size: cover;
  background-position: center;
  will-change: transform;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  cursor: pointer;
  border: var(--stroke);
  border-radius: 999px;
  padding: 14px 30px;
  font-family: inherit;
  font-size: clamp(17px, 4.5vw, 22px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, var(--grass) 0%, var(--grass-deep) 100%);
  text-shadow: 0 2px 0 rgba(0,0,0,.18);
  box-shadow: var(--shadow);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.07) saturate(1.05); }
.btn:active { transform: translateY(3px) scale(.97); box-shadow: var(--shadow-sm); }
.btn.secondary { background: linear-gradient(180deg, var(--blue) 0%, #2b7fc7 100%); }
.btn.accent    { background: linear-gradient(180deg, var(--orange) 0%, #ef6f2a 100%); }

/* ============================================================
   Overlays (menu / game over)
   ============================================================ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;   /* centred via auto margins; scrolls when tall */
  gap: clamp(10px, 2.2vh, 20px);
  text-align: center;
  padding: calc(clamp(14px, 3.5vh, 24px) + env(safe-area-inset-top, 0px)) 20px calc(clamp(14px, 3.5vh, 24px) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(127,201,232,.55), rgba(78,163,46,.55));
  backdrop-filter: blur(2px);
  animation: popIn .35s ease;
}
/* Centre the content block when it fits, but let it scroll from the top when it
   is taller than the screen (robust cross-browser flex centering + scroll). */
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 68px);
  font-weight: 700;
  color: #fff;
  /* multi-layer outline + drop for a fun cartoon title */
  text-shadow:
    -2px -2px 0 var(--grass-deep), 2px -2px 0 var(--grass-deep),
    -2px  2px 0 var(--grass-deep), 2px  2px 0 var(--grass-deep),
     0 8px 0 rgba(0,0,0,.18);
}
.overlay p {
  margin: 0;
  font-size: clamp(15px, 4vw, 21px);
  font-weight: 600;
  color: #fff;
  max-width: 30ch;
  text-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.overlay .mascot {
  width: auto;
  max-width: clamp(96px, 22vw, 200px);
  max-height: 26vh;                 /* never eats the whole short screen */
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.35));
  animation: bobble 2.4s ease-in-out infinite;
}

/* Shorter screens (landscape phones / small portraits): shrink the big bits. */
@media (max-height: 680px) {
  .overlay h1 { font-size: clamp(24px, 6vw, 40px); }
  .overlay .mascot { max-height: 20vh; }
  .star { font-size: clamp(30px, 8vw, 48px) !important; }
}

/* Narrow phones: keep the top HUD chips from crowding / overflowing. */
@media (max-width: 380px) {
  .hud { padding: 8px 8px; gap: 6px; }
  .chip { padding: 6px 10px; font-size: 13px; }
}

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  /* Keep the chips clear of a notch / rounded corner on mobile. */
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px calc(14px + env(safe-area-inset-left, 0px));
  pointer-events: none;
  z-index: 30;
}
/* Stacked variant: all meters in a tidy column in the top-left corner. */
.hud--stack {
  right: auto;                 /* hug the left edge instead of spanning */
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: auto;
}
.hud--stack .hud-row { display: flex; gap: 8px; }
.chip {
  font-family: inherit;
  border: var(--stroke);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 700;
  font-size: clamp(14px, 3.8vw, 19px);
  color: #fff;
  text-shadow: 0 2px 2px rgba(0,0,0,.25);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.chip--score    { background: linear-gradient(180deg, var(--sun), #f5b800); color: #5a3e00; text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.chip--progress { background: linear-gradient(180deg, var(--blue), #2b7fc7); }
.chip--lives    { background: linear-gradient(180deg, var(--red), #e23a4c); }
.chip--mute     { background: linear-gradient(180deg, var(--teal), #1fa99c); cursor: pointer; }
.chip--mute:active { transform: translateY(2px); }

/* ---- "Carrying" banner ---- */
.carry {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: linear-gradient(180deg, var(--sun), var(--orange));
  border: var(--stroke);
  color: #5a3e00;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: clamp(13px, 3.6vw, 18px);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 30;
}
.carry.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Phones (either orientation — the map is landscape, so a phone held sideways is
   WIDE; match on short height too so the rule still fires): the thumb covers the
   bottom, so pin the "carrying" banner to the very TOP-centre and push the chip
   stack (and the combo/power timers, see below) down to make room. */
@media (max-width: 640px), (max-height: 600px) {
  .carry {
    top: calc(12px + env(safe-area-inset-top, 0px));
    bottom: auto;
    transform: translateX(-50%) translateY(-10px);
    max-width: calc(100vw - 16px);
    white-space: normal;   /* wrap instead of overflowing off a narrow screen */
    text-align: center;
  }
  .carry.show { transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   Bins
   ============================================================ */
/* Bins are invisible drop zones — the player finds the correct one via the
   blinking hint ring (shown only while carrying the matching item) + arrow.
   Padding/border keep the original hit area; the visuals are transparent. */
.bin {
  position: absolute;
  transform: translate(-50%, -50%);
  /* Every delivery spot is the SAME size, independent of its (hidden) label —
     so no bin is easier to hit than another. Scales with the screen. */
  width: clamp(63px, 17.25vw, 97.5px);
  height: clamp(52.5px, 14.25vw, 82.5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 18px;
  border: 3px solid transparent;
  color: transparent;
  user-select: none;
  z-index: 10;
}
.bin .icon { font-size: clamp(22px, 6vw, 36px); line-height: 1; }
.bin .icon, .bin .bin-label { visibility: hidden; } /* keep size, hide visuals */

/* Hint ring: a circle that blinks on the bin the carried item belongs to. */
.bin-ring {
  position: absolute;
  left: 50%; top: 50%;
  width: 78px; height: 78px;
  margin: -39px 0 0 -39px;
  border-radius: 50%;
  border: 5px solid #fff;
  opacity: 0;
  pointer-events: none;
}
.bin.target .bin-ring { animation: ringBlink .7s ease-in-out infinite; }
@keyframes ringBlink {
  0%, 100% { opacity: .2; transform: scale(1);    box-shadow: 0 0 0 0 rgba(255,255,140,0); }
  50%      { opacity: 1;  transform: scale(1.14); box-shadow: 0 0 18px 5px rgba(255,255,140,.65); }
}

/* ============================================================
   Trash + cat
   ============================================================ */
.trash {
  position: absolute;
  transform: translate(-50%, -50%);
  width: var(--trash-size, 90px);
  height: var(--trash-size, 90px);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.45));
  z-index: 20;
}
.trash img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.trash.pickup { animation: pop .35s ease; }

.avatar {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 15;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,.45));
  will-change: left, top, transform;
}
/* Glow the player while a timed power-up is active. */
.avatar.pw-star   { filter: drop-shadow(0 5px 8px rgba(0,0,0,.45)) drop-shadow(0 0 10px #ffd23f); }
.avatar.pw-magnet { filter: drop-shadow(0 5px 8px rgba(0,0,0,.45)) drop-shadow(0 0 10px #59c1ff); }
.avatar.pw-star.pw-magnet { filter: drop-shadow(0 5px 8px rgba(0,0,0,.45)) drop-shadow(0 0 10px #ffd23f) drop-shadow(0 0 10px #59c1ff); }
.avatar.pw-clock  { filter: drop-shadow(0 5px 8px rgba(0,0,0,.45)) drop-shadow(0 0 10px #2ec4b6); }

/* ---- Collectible power-ups -------------------------------------------- */
.powerup {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 16;
  font-size: 30px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.4));
  animation: pwFloat 1.4s ease-in-out infinite;
}
.powerup img {                    /* image power-ups (e.g. 🧨 dynamite) */
  width: 52px; height: 52px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.powerup::after {                 /* soft halo so it reads as "collect me" */
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 150%; height: 150%; transform: translate(-50%, -50%);
  border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(255,255,255,.55), rgba(255,255,255,0) 70%);
  animation: pwHalo 1.4s ease-in-out infinite;
}
.powerup.leaving { animation: pwFloat 1.4s ease-in-out infinite, pwBlink .4s steps(2) infinite; }
@keyframes pwFloat { 0%,100% { transform: translate(-50%, -50%)      scale(1); } 50% { transform: translate(-50%, -60%) scale(1.08); } }
@keyframes pwHalo  { 0%,100% { opacity: .5; } 50% { opacity: .9; } }
@keyframes pwBlink { 0% { opacity: 1; } 100% { opacity: .35; } }

/* Trash mid-flight to the player's hand (pulled by the magnet). */
.trash.magnetized { filter: drop-shadow(0 0 8px #59c1ff); z-index: 14; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes pop   { 0%{transform:translate(-50%,-50%) scale(1)} 50%{transform:translate(-50%,-50%) scale(1.25)} 100%{transform:translate(-50%,-50%) scale(1)} }
@keyframes shake { 0%,100%{transform:translate(-50%,-50%) rotate(0)} 25%{transform:translate(-50%,-50%) rotate(-9deg)} 75%{transform:translate(-50%,-50%) rotate(9deg)} }
@keyframes targetPulse {
  0%,100% { transform: translate(-50%,-50%) scale(1);    box-shadow: 0 0 0 0 rgba(255,255,120,0), var(--shadow-sm); filter: brightness(1); }
  50%     { transform: translate(-50%,-50%) scale(1.13); box-shadow: 0 0 20px 7px rgba(255,221,90,.9), var(--shadow-sm); filter: brightness(1.25); }
}
@keyframes popIn  { 0%{opacity:0; transform:scale(.92)} 100%{opacity:1; transform:scale(1)} }
@keyframes bobble { 0%,100%{transform:translateY(0) rotate(-2deg)} 50%{transform:translateY(-10px) rotate(2deg)} }

/* ============================================================
   Pile meter + chip feedback
   ============================================================ */
.chip--pile { background: linear-gradient(180deg, #6b8e5a, #4e7a3a); }
.chip--pile.danger {
  background: linear-gradient(180deg, var(--red), #e23a4c);
  animation: pilePulse .5s ease-in-out infinite;
}
@keyframes pilePulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.12);} }

.chip.punch { animation: chipPunch .35s ease; }
@keyframes chipPunch { 0%{ transform: scale(1);} 40%{ transform: scale(1.28);} 100%{ transform: scale(1);} }

/* ============================================================
   Direction arrow (points the carried item toward its bin)
   ============================================================ */
.game-arrow {
  position: absolute;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity .15s ease;
}
.game-arrow::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 0; height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 21px solid #fff200;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 4px rgba(0,0,0,.55));
  animation: arrowPulse .6s ease-in-out infinite;
}
@keyframes arrowPulse {
  0%,100% { transform: translateY(-50%) translateX(0)   scale(1); }
  50%     { transform: translateY(-50%) translateX(7px) scale(1.12); }
}

/* ============================================================
   Effects (confetti, rings, floating text, fly-to-score, shake)
   ============================================================ */
.fx-confetti {
  position: absolute;
  width: 10px; height: 14px;
  border-radius: 2px;
  z-index: 24;
  pointer-events: none;
  animation: confettiFly .9s ease-out forwards;
}
@keyframes confettiFly {
  0%   { transform: translate(-50%,-50%) translate(0,0) rotate(0);                       opacity: 1; }
  100% { transform: translate(-50%,-50%) translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

.fx-ring {
  position: absolute;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border: 4px solid #fff200;
  border-radius: 50%;
  z-index: 24;
  pointer-events: none;
  animation: ringPop .6s ease-out forwards;
}
@keyframes ringPop { 0%{ transform: scale(.3); opacity:.9; } 100%{ transform: scale(2.6); opacity:0; } }

/* New-trash indicator: pulsing rings + a bouncing "!" badge at a spawn point. */
.fx-spawn { position: absolute; transform: translate(-50%, -50%); z-index: 23; pointer-events: none; }
.fx-spawn-ring {
  position: absolute; left: 0; top: 0;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 3px solid #ffd23f; border-radius: 50%;
  animation: fxSpawnRing 1.05s ease-out forwards;
}
.fx-spawn-ring--2 { border-color: #ff9442; animation-delay: .26s; }
@keyframes fxSpawnRing { 0%{ transform: scale(.3); opacity:.9; } 70%{ opacity:.45; } 100%{ transform: scale(4.4); opacity:0; } }
.fx-spawn-badge {
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #ffd23f; color: #4a3a00;
  font-weight: 800; font-size: 16px; line-height: 1;
  box-shadow: 0 3px 6px rgba(0,0,0,.35);
  animation: fxSpawnBadge 1.3s ease forwards;
}
@keyframes fxSpawnBadge {
  0%   { transform: translate(-50%, -90%)  scale(0); }
  15%  { transform: translate(-50%, -175%) scale(1.2); }
  32%  { transform: translate(-50%, -150%) scale(1); }
  80%  { transform: translate(-50%, -150%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(.9); opacity: 0; }
}

.fx-float {
  position: absolute;
  z-index: 26;
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.3), 0 0 8px rgba(0,0,0,.3);
  pointer-events: none;
  white-space: nowrap;
  animation: floatUp 1.6s ease-out forwards;
}
.fx-float.good  { color: #fff200; text-shadow: 0 2px 0 #c98a00, 0 0 10px rgba(255,242,0,.6); }
.fx-float.bad   { color: #ff5d6c; }
.fx-float.combo { color: #ff9442; font-size: 22px; }
@keyframes floatUp {
  0%   { transform: translate(-50%,-50%) translateY(0)    scale(.6); opacity: 0; }
  12%  { transform: translate(-50%,-50%) translateY(-6px) scale(1.1); opacity: 1; }
  75%  { transform: translate(-50%,-50%) translateY(-32px) scale(1);  opacity: 1; }
  100% { transform: translate(-50%,-50%) translateY(-54px) scale(1);  opacity: 0; }
}

.fx-screen { position: fixed; inset: 0; pointer-events: none; z-index: 2000; }
.fx-fly {
  position: absolute;
  transform: translate(-50%,-50%);
  font-weight: 800;
  font-size: 24px;
  color: #fff200;
  text-shadow: 0 2px 0 #c98a00, 0 0 10px rgba(255,242,0,.7);
  transition: transform .6s cubic-bezier(.4,-0.2,.2,1), opacity .6s ease-in;
}

.fx-shake { animation: fxShake .4s ease; }
@keyframes fxShake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-7px, 3px); }
  40% { transform: translate(7px, -3px); }
  60% { transform: translate(-5px, 2px); }
  80% { transform: translate(5px, -2px); }
}

/* ============================================================
   Combo badge + timer bar
   ============================================================ */
.combo {
  position: absolute;
  /* Clear the left HUD stack (score/progress/lives+pile) so it never overlaps —
     track the notch inset the HUD padding adds so the gap holds on any phone. */
  top: calc(192px + env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%) translateY(-8px) scale(.9);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
  z-index: 30;
}
.combo.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.combo-x {
  font-weight: 800;
  font-size: clamp(18px, 5vw, 26px);
  color: #ff9442;
  text-shadow: 0 2px 0 #b54e16, 0 0 10px rgba(255,148,66,.6);
}
.combo-bar {
  width: 120px; height: 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.3);
  border: 2px solid #fff;
  overflow: hidden;
}
.combo-bar > i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--sun), var(--red));
  transition: width .1s linear;
}

/* Active power-up timers: a badge with a draining bar per active power.
   Sit top-centre, just below the combo bar. */
.powers {
  position: absolute;
  top: calc(244px + env(safe-area-inset-top, 0px)); left: 50%;  /* below the combo bar, still top-centre */
  transform: translateX(-50%);
  display: flex; flex-direction: row; gap: 8px;
  z-index: 30; pointer-events: none;
}
.power {
  display: flex; align-items: center; gap: 7px;
  background: rgba(0,0,0,.42);
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  animation: popIn .18s ease;
}
.power-x { font-size: 20px; line-height: 1; }
.power-bar {
  width: 66px; height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
}
.power-bar > i { display: block; height: 100%; width: 100%; transition: width .12s linear; }
.power-star   .power-bar > i { background: linear-gradient(90deg, #ffe066, #ff9d2e); }
.power-magnet .power-bar > i { background: linear-gradient(90deg, #8fd7ff, #2f8fe0); }
.power-clock  .power-bar > i { background: linear-gradient(90deg, #7fe0d4, #22a597); }
.power.ending { animation: powerEnding .5s ease-in-out infinite; }
@keyframes powerEnding { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* Narrow (portrait) phones only: the full-width top banner covers the top-left
   chips, so drop the chip stack — and the combo/power timers below it. (Landscape
   is wide, so the centred banner clears the left chips and nothing moves.) Placed
   after the base rules so it wins. */
@media (max-width: 640px) {
  .hud--stack { padding-top: calc(96px + env(safe-area-inset-top, 0px)); }
  .combo  { top: calc(272px + env(safe-area-inset-top, 0px)); }
  .powers { top: calc(324px + env(safe-area-inset-top, 0px)); }
}

/* ============================================================
   Time-of-day tint + danger vignette
   ============================================================ */
.level-tint { position: absolute; inset: 0; border-radius: 18px; pointer-events: none; z-index: 23; }
.danger-vignette {
  position: absolute; inset: 0;
  border-radius: 18px;
  pointer-events: none;
  z-index: 29;
  opacity: 0;
  transition: opacity .25s ease;
}
.danger-vignette.on { opacity: 1; animation: dangerPulse .7s ease-in-out infinite; }
@keyframes dangerPulse {
  0%,100% { box-shadow: inset 0 0 50px 12px rgba(255,40,60,.35); }
  50%     { box-shadow: inset 0 0 85px 26px rgba(255,40,60,.62); }
}

/* Golden bonus item (double points). */
.trash.golden img { animation: goldGlow 1s ease-in-out infinite; }
@keyframes goldGlow {
  0%,100% { filter: drop-shadow(0 0 4px rgba(255,210,40,.7)); }
  50%     { filter: drop-shadow(0 0 13px rgba(255,210,40,1)); }
}

/* ============================================================
   Stars (game over)
   ============================================================ */
.star-row { display: flex; gap: 10px; justify-content: center; }
.star {
  font-size: clamp(40px, 11vw, 64px);
  line-height: 1;
  color: rgba(255,255,255,.35);
  text-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.star.on {
  color: var(--sun);
  text-shadow: 0 3px 0 #c98a00, 0 0 16px rgba(255,210,63,.85);
  animation: starPop .5s ease both;
}
@keyframes starPop {
  0%   { transform: scale(0) rotate(-30deg); }
  60%  { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ============================================================
   Rippee-themed start menu (matches rippee.fi — brand blue on white)
   ============================================================ */
:root {
  --rippee-blue:      #0090d8;
  --rippee-navy:      #004890;
  --rippee-blue-dark: #0072ad;
}
/* Bright, on-theme start menu (sky → grass with a sunny glow). */
.overlay.menu-rippee {
  background:
    radial-gradient(130% 90% at 50% -15%, rgba(255,210,63,.4), transparent 55%),
    linear-gradient(180deg, rgba(191,233,251,.96) 0%, rgba(206,236,214,.94) 52%, rgba(134,207,78,.92) 100%);
  backdrop-filter: blur(4px);
  gap: 13px;
}
.menu-rippee .rippee-brand {
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--rippee-navy);
  background: #fff;
  border: 3px solid var(--rippee-blue);
  border-radius: 999px;
  padding: 6px 20px;
  box-shadow: var(--shadow-sm);
  font-size: clamp(14px, 4vw, 20px);
}
/* Colourful cartoon title (white fill, green sticker outline). */
.overlay.menu-rippee h1 {
  color: #fff;
  font-size: clamp(26px, 6.6vw, 48px);
  max-width: 15ch;
  line-height: 1.05;
  text-shadow:
    -2px -2px 0 var(--grass-deep), 2px -2px 0 var(--grass-deep),
    -2px  2px 0 var(--grass-deep), 2px  2px 0 var(--grass-deep),
     0 6px 0 rgba(0,0,0,.16), 0 9px 14px rgba(0,0,0,.22);
}
.overlay.menu-rippee p { color: #2c3e2a; text-shadow: none; }
.overlay.menu-rippee .welcome { font-weight: 700; max-width: 32ch; color: var(--sun); text-shadow: 0 1px 2px rgba(0,0,0,.45); }
/* Stats as separate chips (clearer than one run-on line). */
.menu-stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.stat-chip {
  font-weight: 800; color: #5a3e00;
  background: linear-gradient(180deg, #fff3c9, #ffdf87);
  border: 2px solid #fff; border-radius: 999px;
  padding: 5px 15px; font-size: clamp(14px, 3.8vw, 18px);
  box-shadow: var(--shadow-sm);
}
.overlay.menu-rippee .menu-label { font-weight: 800; color: var(--sun); text-shadow: 0 1px 2px rgba(0,0,0,.45); opacity: 1; }
.menu-rippee .mascot { filter: drop-shadow(0 8px 10px rgba(0,72,144,.3)); }

/* Menu buttons — varied theme colours instead of all-blue. */
.btn-rippee { background: linear-gradient(180deg, var(--teal), #1f9e92) !important; }
.menu-actions .btn.secondary {
  background: linear-gradient(180deg, var(--sun), var(--orange));
  color: #5a3e00; text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
/* Level cards colour-coded by time of day (Aamu→Yö). */
.menu-rippee .level-btn { background: linear-gradient(180deg, var(--grass), var(--grass-deep)); }
.menu-rippee .level-1 { background: linear-gradient(180deg, #f9a825, #ef8a00); } /* Maanantai — gold */
.menu-rippee .level-2 { background: linear-gradient(180deg, #5fb84a, #3f9a3f); } /* Tiistai — green */
.menu-rippee .level-3 { background: linear-gradient(180deg, #2ec4b6, #1fa99c); } /* Keskiviikko — teal */
.menu-rippee .level-4 { background: linear-gradient(180deg, #9b7ede, #6f4fb0); } /* Torstai — purple */
.menu-rippee .level-5 { background: linear-gradient(180deg, #3d6ee9, #244e8f); } /* Perjantai — night blue */
.menu-rippee .level-btn.locked {
  background: linear-gradient(180deg, #b8c6d0, #8ba0ad);
}

/* Primary "start game" call-to-action — big, green, gently pulsing. */
.btn-start {
  font-size: clamp(20px, 5.2vw, 28px);
  padding: 15px 46px;
  box-shadow: 0 6px 0 rgba(0,0,0,.16), 0 12px 24px rgba(0,0,0,.24);
  animation: startPulse 1.8s ease-in-out infinite;
}
@keyframes startPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.btn-start:active { animation: none; }

/* ============================================================
   Level select (menu)
   ============================================================ */
.trophy-line { font-weight: 700; }
.level-grid { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 430px; }
.level-btn {
  cursor: pointer;
  width: 94px; padding: 10px 8px;
  border: var(--stroke); border-radius: 16px;
  background: linear-gradient(180deg, var(--grass), var(--grass-deep));
  color: #fff;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .08s ease, filter .15s ease;
}
.level-btn:hover { filter: brightness(1.08); }
.level-btn:active { transform: translateY(2px); }
.level-btn.locked { background: linear-gradient(180deg, #9fb0a4, #75857a); cursor: default; filter: none; }
.level-no { font-size: 24px; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.level-name { font-size: 13px; font-weight: 700; }
.level-stars { font-size: 15px; letter-spacing: 1px; color: #fff; }

/* ============================================================
   "Did you know?" fact (game over)
   ============================================================ */
.fact {
  font-size: clamp(13px, 3.6vw, 17px) !important;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.22);
  border-radius: 12px;
  padding: 9px 15px;
  max-width: 34ch;
  line-height: 1.4;
}

/* ============================================================
   Sorting guide (learn screen)
   ============================================================ */
.overlay.learn { justify-content: flex-start; overflow-y: auto; gap: 12px; }
.learn-title { margin-top: 4px; font-size: clamp(26px, 7vw, 46px); }
.learn-grid { display: flex; flex-direction: column; gap: 12px; width: min(560px, 92vw); }
.learn-card {
  background: rgba(255,255,255,.93);
  border: var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.learn-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(15px, 4vw, 20px);
  text-shadow: 0 2px 2px rgba(0,0,0,.35);
}
.learn-icon { font-size: 1.4em; }
.learn-items { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
.learn-item { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 72px; }
.learn-item img { width: 52px; height: 52px; object-fit: contain; }
.learn-item span { font-size: 11px; font-weight: 700; color: var(--ink); text-align: center; line-height: 1.15; }

/* ============================================================
   Floating virtual joystick (touch controls)
   ============================================================ */
.joystick {
  position: absolute;
  /* fixed, always visible — offset past a home indicator / rounded corner */
  left: calc(26px + env(safe-area-inset-left, 0px));
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.6);
  background: rgba(255,255,255,.14);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  pointer-events: none;
  z-index: 35;
  transition: background .12s ease, border-color .12s ease;
}
.joystick.active { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.9); }
.joy-thumb {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
  border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  transition: transform .04s linear;
}

/* ============================================================
   Pop quiz ("which doesn't belong?")
   ============================================================ */
.quiz {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: clamp(10px, 2.2vh, 16px);
  padding: clamp(14px, 3.5vh, 20px);
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(60,40,110,.6), rgba(30,50,30,.62));
  backdrop-filter: blur(3px);
  animation: popIn .3s ease;
}
.quiz > :first-child { margin-top: auto; }
.quiz > :last-child { margin-bottom: auto; }
.quiz-badge {
  background: linear-gradient(180deg, var(--purple), #7a5fc0);
  color: #fff;
  border: var(--stroke);
  border-radius: 999px;
  padding: 6px 18px;
  font-weight: 800;
  font-size: clamp(14px, 4vw, 18px);
  box-shadow: var(--shadow-sm);
}
.quiz h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(20px, 5.5vw, 30px);
  text-shadow: -2px -2px 0 #5a3e8c, 2px -2px 0 #5a3e8c, -2px 2px 0 #5a3e8c, 2px 2px 0 #5a3e8c, 0 6px 0 rgba(0,0,0,.18);
}
.quiz-opts { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.quiz-opt {
  width: clamp(92px, 22vw, 132px);
  background: #fff;
  border: var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 10px 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .08s ease, filter .15s ease;
}
.quiz-opt img { width: 100%; height: clamp(64px, 15vw, 92px); object-fit: contain; pointer-events: none; }
.quiz-opt-name { font-size: clamp(11px, 3vw, 14px); font-weight: 700; color: var(--ink); }
/* Text-question answer: big bin icon over the bin label. */
.quiz-qopt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: clamp(96px, 21vw, 124px);
}
.quiz-qicon { font-size: clamp(40px, 10vw, 58px); line-height: 1; pointer-events: none; }
/* Statement answers: a stack of full-width text buttons. */
.quiz-sopts { flex-direction: column; flex-wrap: nowrap; width: min(92vw, 480px); gap: 10px; }
.quiz-sopt {
  width: 100%;
  padding: 14px 18px;
  display: block;            /* plain block so long text wraps within the button */
  text-align: center;
}
.quiz-sopt-text { font-size: clamp(14px, 4vw, 18px); font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }

/* Quiz gate between levels: progress pips + back button. */
.gate-pips { display: flex; gap: 12px; }
.gate-pip {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.3); border: 2px solid #fff;
  transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.gate-pip.on { background: var(--sun); box-shadow: 0 0 10px var(--sun); transform: scale(1.15); }
.gate-back { padding: 10px 22px; font-size: clamp(14px, 3.6vw, 18px); }
.quiz-opt:hover { filter: brightness(1.05); transform: translateY(-3px); }
.quiz-opt:active { transform: translateY(1px); }
.quiz-opt.correct { box-shadow: 0 0 0 5px var(--grass-deep), var(--shadow); animation: qPop .4s ease; }
.quiz-opt.wrong   { box-shadow: 0 0 0 5px var(--red), var(--shadow); animation: qShake .4s ease; }
.quiz-opt.dim     { opacity: .4; }
@keyframes qPop   { 0%{ transform: scale(1);} 50%{ transform: scale(1.12);} 100%{ transform: scale(1);} }
@keyframes qShake { 0%,100%{ transform: translateX(0);} 25%{ transform: translateX(-6px);} 75%{ transform: translateX(6px);} }
.quiz-feedback {
  min-height: 26px;
  max-width: min(92vw, 540px);   /* keep long explanations to a readable width */
  margin: 0 auto;
  line-height: 1.35;
  font-weight: 800;
  font-size: clamp(15px, 4vw, 20px);
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
/* Explanation text stays white for readability; the answer buttons + the
   "Oikein!/Väärin." prefix already signal right vs. wrong. */
.quiz-feedback.good { color: #fff; }
.quiz-feedback.bad  { color: #fff; }

/* Tietovisa (QuizScene) result view */
.quiz-score {
  font-weight: 800; color: #fff;
  font-size: clamp(30px, 9vw, 48px);
  text-shadow: -2px -2px 0 #5a3e8c, 2px -2px 0 #5a3e8c, -2px 2px 0 #5a3e8c, 2px 2px 0 #5a3e8c, 0 6px 0 rgba(0,0,0,.18);
}
.quiz-note { margin: 0; color: #fff; font-weight: 700; font-size: clamp(15px, 4vw, 20px); text-shadow: 0 2px 4px rgba(0,0,0,.4); }
.quiz-scene .coin-earn { color: #ffe066; }
.quiz-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ============================================================
   In-game editor (toggle with "E")
   ============================================================ */
.ed-marker {
  position: absolute;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.5);
  cursor: grab;
  touch-action: none;
  z-index: 40;
}
.ed-marker:active { cursor: grabbing; }
.ed-marker .ed-lbl {
  position: absolute;
  left: 50%; top: -8px;
  transform: translate(-50%, -100%);
  background: rgba(0,0,0,.8);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
}

.ed-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: min(320px, 86vw);
  background: #243a2c;
  color: #e9f5ee;
  font-family: system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(0,0,0,.4);
  z-index: 1000;
}
.ed-head { display: flex; align-items: center; justify-content: space-between; }
.ed-head h2 { margin: 0; font-size: 18px; }
.ed-x {
  cursor: pointer; border: none; background: #3c5a45; color: #e9f5ee;
  width: 30px; height: 30px; border-radius: 8px; font-size: 15px;
}
.ed-x:hover { background: #4a6e55; }
.ed-hint { margin: 0; font-size: 12.5px; color: #a9c9b5; line-height: 1.45; }
.ed-list { display: flex; flex-direction: column; gap: 6px; }
.ed-row {
  display: flex; align-items: center; gap: 8px;
  background: #1b2a20; border: 1px solid #34503e; border-radius: 8px;
  padding: 7px 9px; font-size: 12.5px; cursor: pointer;
}
.ed-row.sel { border-color: #ffd43b; }
.ed-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; flex: 0 0 auto; }
.ed-name { flex: 1; font-weight: 600; }
.ed-coord { color: #9fc1ac; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ed-actions { display: flex; gap: 8px; }
.ed-btn {
  cursor: pointer; border: none; border-radius: 8px; padding: 9px 10px;
  font-size: 13px; font-weight: 700; background: #3c5a45; color: #e9f5ee; flex: 1;
}
.ed-btn:hover { background: #4a6e55; }
.ed-save { background: #2f9e54; }
.ed-save:hover { background: #37b863; }
.ed-reset { background: #8a3b3b; }
.ed-reset:hover { background: #a64545; }
.ed-msg { font-size: 13px; font-weight: 700; color: #8be0a6; min-height: 18px; text-align: center; }
.ed-add-ob { background: #8a3b3b; margin-top: 4px; }
.ed-add-ob:hover { background: #a64545; }

/* Collision zones drawn in the editor (visible only while editing). */
.ed-obstacle {
  position: absolute;
  background: rgba(255, 70, 70, .28);
  border: 2px dashed #ff5d6c;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3);
  cursor: grab;
  touch-action: none;
  z-index: 38;
}
.ed-obstacle:active { cursor: grabbing; }
.ed-ob-tag { position: absolute; left: 4px; top: 2px; font-size: 15px; pointer-events: none; }
.ed-ob-del {
  position: absolute; right: -10px; top: -10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #ff5d6c; color: #fff; border: 2px solid #fff;
  font-size: 13px; font-weight: 800; line-height: 18px; text-align: center;
  cursor: pointer; z-index: 39;
}
.ed-ob-resize {
  position: absolute; right: -8px; bottom: -8px;
  width: 18px; height: 18px; border-radius: 4px;
  background: #fff; border: 2px solid #ff5d6c;
  cursor: nwse-resize; touch-action: none;
}
.ed-ob-rotate {
  position: absolute; left: 50%; top: -30px;
  transform: translateX(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: #6bd0ff; color: #06344a; border: 2px solid #fff;
  font-size: 15px; font-weight: 800; line-height: 20px; text-align: center;
  cursor: grab; touch-action: none; z-index: 39;
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
}
/* Stalk connecting the rotate knob to the box. */
.ed-ob-rotate::before {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: 2px; height: 8px; background: #fff; transform: translateX(-50%);
}

/* ============================================================
   Splash / title screen (shown on launch)
   ============================================================ */
.splash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-deep) 48%, var(--grass) 100%);
  animation: popIn .35s ease;
  cursor: pointer;
}
.splash-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.28));
}
.splash-cta {
  position: absolute; bottom: 6%; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, var(--grass), var(--grass-deep));
  color: #fff; border: var(--stroke); border-radius: 999px;
  padding: 12px 32px; font-weight: 800;
  font-size: clamp(16px, 4.5vw, 24px);
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
  box-shadow: var(--shadow);
  animation: splashPulse 1.4s ease-in-out infinite;
  cursor: pointer;
}
@keyframes splashPulse {
  0%,100% { transform: translateX(-50%) scale(1); }
  50%     { transform: translateX(-50%) scale(1.06); }
}

/* ============================================================
   Boot / loading
   ============================================================ */
.loader {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  color: #fff; font-size: clamp(18px, 5vw, 26px); font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.loader .bar {
  width: min(64vw, 340px); height: 16px;
  border-radius: 999px; background: rgba(255,255,255,.5);
  border: var(--stroke); overflow: hidden;
}
.loader .bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--sun), var(--orange), var(--red));
  transition: width .2s ease;
}

/* ============================================================
   Meta loop: coins, daily challenge, daily reward, hat shop
   ============================================================ */

/* In-game hat worn over the cat (Player). */
.avatar-hat {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 16;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
  will-change: left, top;
}

/* Menu mascot + its hat. */
.mascot-wrap { position: relative; display: inline-block; }
.mascot-wrap .mascot-hat {
  position: absolute; left: 50%; top: 2%;
  transform: translate(-50%, -55%);
  font-size: clamp(30px, 8vw, 52px);
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}

/* Daily challenge button in the menu. */
.daily-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 26px;
  background: linear-gradient(180deg, var(--red), #e23a4c);
  line-height: 1.2;
}
.daily-btn.done { background: linear-gradient(180deg, var(--grass), var(--grass-deep)); }
.daily-title { font-size: clamp(15px, 4vw, 20px); }
.daily-desc { font-size: clamp(11px, 3vw, 14px); font-weight: 600; opacity: .92; }

.menu-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* Coins earned line on the result screen. */
.coin-earn { font-weight: 800; color: #b8860b; }
@media (prefers-color-scheme: dark) { .coin-earn { color: #ffd23f; } }

/* --- Win/lose score meter (GameOverScene): bar fills + number counts up --- */
.score-meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(320px, 78vw);
}
.score-meter-label {
  font-size: clamp(12px, 3.2vw, 15px);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.score-meter-track {
  position: relative;
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.35), 0 0 0 2px rgba(255,255,255,.25);
  overflow: hidden;
}
.score-meter-fill {
  position: relative;
  display: block;
  height: 100%;
  width: 0;                       /* driven by JS (_animateScore) */
  border-radius: 999px;
  background: linear-gradient(90deg, #86cf4e, #ffd23f);
  box-shadow: 0 0 10px rgba(255,210,63,.7);
}
.score-meter-fill::after {        /* travelling gloss so the fill feels alive */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  transform: translateX(-100%);
  animation: meterShine 1.2s ease-in-out infinite;
}
@keyframes meterShine { to { transform: translateX(100%); } }
.score-meter-num {
  font-size: clamp(30px, 8vw, 52px);
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow:
    -2px -2px 0 var(--grass-deep), 2px -2px 0 var(--grass-deep),
    -2px  2px 0 var(--grass-deep), 2px  2px 0 var(--grass-deep),
     0 5px 0 rgba(0,0,0,.2);
}
.score-meter-num.pop { animation: scorePop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes scorePop { 0% { transform: scale(1); } 45% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* --- Shared modal shell (daily reward + shop) --- */
.modal-backdrop {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(20, 30, 20, .5);
  backdrop-filter: blur(3px);
  animation: popIn .2s ease;
}
.modal {
  width: min(94vw, 460px);
  max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #ffffff, #f2f7ef);
  border: var(--stroke);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 26px);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--ink);
  animation: popIn .25s ease;
}
.modal h2 { margin: 0; font-size: clamp(20px, 5.5vw, 28px); color: var(--grass-deep); }
.dr-badge {
  font-weight: 800; color: #fff;
  background: linear-gradient(180deg, var(--orange), #ef6f2a);
  border: var(--stroke); border-radius: 999px;
  padding: 6px 16px; font-size: clamp(15px, 4vw, 19px);
}

/* --- Daily reward calendar --- */
.dr-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: 100%; }
.dr-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 12px;
  background: #e8eee2; border: 2px solid transparent;
  font-weight: 700;
}
.dr-day-n { font-size: 11px; color: #6a7a63; }
.dr-day-coin { font-size: clamp(12px, 3vw, 15px); }
.dr-day.done { background: #cfe8c2; opacity: .8; }
.dr-day.today {
  background: linear-gradient(180deg, var(--sun), var(--orange));
  border-color: #fff; color: #4a3400;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(255,150,40,.5);
}
.dr-note { margin: 0; font-size: clamp(12px, 3.4vw, 15px); color: #5a6a53; max-width: 30ch; }

/* --- Shop --- */
.shop-head { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; }
.shop-coins {
  font-weight: 800; font-size: clamp(16px, 4.4vw, 20px);
  background: #fff6d8; border: 2px solid var(--sun); border-radius: 999px; padding: 4px 12px;
}
.shop-coins.deny { animation: shopDeny .4s ease; }
@keyframes shopDeny { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shop-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%;
}
.shop-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border-radius: 14px;
  background: #eef3ea; border: 2px solid transparent;
}
.shop-item.on { border-color: var(--grass); background: #dff0d2; }
.shop-emoji { font-size: 34px; line-height: 1; }
.shop-name { font-size: 12px; font-weight: 700; color: #4a5a44; }
.shop-btn {
  cursor: pointer; border: none; border-radius: 999px;
  padding: 6px 12px; font-family: inherit; font-weight: 800; font-size: 13px; color: #fff;
  background: linear-gradient(180deg, var(--sun), var(--orange));
}
.shop-btn.equip { background: linear-gradient(180deg, var(--blue), #2b7fc7); }
.shop-btn.equipped { background: linear-gradient(180deg, var(--grass), var(--grass-deep)); cursor: default; }
.shop-btn:active { transform: translateY(2px); }

/* ============================================================
   Lajitteluralli — time-attack drag-to-bin mode
   ============================================================ */
/* Full-screen playfield. Non-interactive itself; only the falling items are,
   so taps on empty space fall through and pointerup can hit-test the bins. */
.rally-field {
  position: absolute;
  inset: 0;
  z-index: 6;                /* above the bin row, so trash falls in front of it */
  pointer-events: none;
  overflow: hidden;
}

/* Falling trash is draggable (overrides .trash's pointer-events: none). */
.rally-item { pointer-events: auto; cursor: grab; touch-action: none; }
.rally-item.dragging { cursor: grabbing; z-index: 40; filter: drop-shadow(0 8px 12px rgba(0,0,0,.5)); }

/* Bin targets pinned along the bottom; height is set from settings in JS. */
.rally-bins {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.18));
}
.rally-bin {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  border: var(--stroke);
  background: linear-gradient(180deg, var(--bin-color), rgba(0,0,0,.25));
  box-shadow: var(--shadow-sm);
  color: #fff;
  overflow: hidden;
}
.rally-bin-icon { font-size: clamp(20px, 5vw, 34px); line-height: 1; }
.rally-bin-label {
  font-size: clamp(9px, 2.4vw, 14px);
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rally-bin.hit  { animation: rallyHit .4s ease; }
.rally-bin.miss { animation: rallyMiss .4s ease; }
@keyframes rallyHit  { 0%,100% { transform: translateY(0); filter: brightness(1); } 40% { transform: translateY(-8px) scale(1.05); filter: brightness(1.4); } }
@keyframes rallyMiss { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

/* Timer chip: teal normally, pulsing red in the final seconds. */
.chip--time { background: linear-gradient(180deg, var(--teal), #1fa99c); }
.chip--time.danger {
  background: linear-gradient(180deg, var(--red), #e23a4c);
  animation: pilePulse .5s ease-in-out infinite;
}

/* Combo badge, centred near the top of the field. */
.rally-combo {
  position: absolute;
  left: 50%; top: 14%;
  transform: translateX(-50%) scale(.8);
  z-index: 30;
  padding: 8px 18px;
  border-radius: 999px;
  border: var(--stroke);
  background: linear-gradient(180deg, var(--orange), #ef6f2a);
  color: #fff;
  font-weight: 800;
  font-size: clamp(18px, 5vw, 26px);
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
}
.rally-combo.show { animation: rallyCombo .6s ease; }
@keyframes rallyCombo {
  0%   { opacity: 0; transform: translateX(-50%) scale(.6); }
  35%  { opacity: 1; transform: translateX(-50%) scale(1.15); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* End-of-round result chip (bigger than the HUD score chip). */
.rally-over .rally-final {
  font-size: clamp(28px, 8vw, 44px);
  padding: 12px 26px;
  border: var(--stroke);
  box-shadow: var(--shadow);
}

/* Menu launch button. */
.btn-rally { background: linear-gradient(180deg, var(--purple), #7d5fc4) !important; }
.btn-quiz  { background: linear-gradient(180deg, var(--purple), #7d5fc4) !important; }

/* ============================================================
   Final-win celebration (whole week cleared)
   ============================================================ */
.win-pro {
  font-size: clamp(20px, 5.5vw, 32px) !important;
  font-weight: 800;
  color: #fff;
  text-shadow:
    -2px -2px 0 var(--grass-deep), 2px -2px 0 var(--grass-deep),
    -2px  2px 0 var(--grass-deep), 2px  2px 0 var(--grass-deep),
     0 6px 0 rgba(0,0,0,.18);
  animation: winProPulse 1.1s ease-in-out infinite;
}
@keyframes winProPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* Full-screen layer of tumbling trash flying up and off the top. */
.win-storm {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}
.win-trash {
  position: absolute;
  top: 100%;                       /* start just below the bottom edge */
  width: var(--sz, 48px);
  height: var(--sz, 48px);
  will-change: transform, opacity;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.35));
  animation: winFly var(--dur, 3s) linear forwards;
}
.win-trash img { width: 100%; height: 100%; object-fit: contain; }
@keyframes winFly {
  0%   { transform: translate(0, 0) rotate(0); opacity: 0; }
  10%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translate(var(--drift, 0), var(--rise, -120vh)) rotate(var(--spin, 360deg)); opacity: 0; }
}
