:root {
  color-scheme: light;
  --ink: #16324a;
  --ink-soft: #3d5a73;
  --paper: #fffef8;
  --line: #d5e4ee;
  --green: #0a6b40;
  --green-deep: #064e2e;
  --clean: #1f9d6a;
  --clean-soft: #e5f8ee;
  --coral: #e25b45;
  --coral-deep: #9d2b1a;
  --coral-soft: #fff1ee;
  --gold: #8a5a00;
  --gold-soft: #fff4d6;
  --heart: #e23b4a;
  --font: "PingFang HK", "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  background: #8ecff2;
}

button {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  line-height: 1.25;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  line-height: 1.3;
}

h3 {
  font-size: 1.15rem;
  line-height: 1.35;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  flex: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.7rem calc(1rem + env(safe-area-inset-left));
  background: rgba(255, 254, 248, 0.94);
  border-bottom: 3px solid rgba(22, 50, 74, 0.08);
}

.topbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat {
  min-width: 7.5rem;
  padding: 0.3rem 0.75rem 0.35rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
}

.stat-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.stat-value-row,
.hearts {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-height: 1.9rem;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.heart {
  color: var(--heart);
  font-size: 1.35rem;
  line-height: 1;
}

.heart.is-empty {
  opacity: 0.28;
}

.stat-hearts.is-hurt {
  animation: hurt 0.45s ease;
}

.stat.is-urgent {
  background: var(--coral-soft);
  border-color: #f3b2a6;
}

.stat.is-urgent .stat-value {
  color: var(--coral-deep);
}

.pause-flag {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
}

.timebar {
  height: 10px;
  overflow: hidden;
  background: #e4eef5;
  border-radius: 999px;
}

.timebar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #0a6b40, #7ed0a4);
  transform: scaleX(1);
  transform-origin: left center;
}

.timebar.is-urgent .timebar-fill {
  background: linear-gradient(90deg, #e25b45, #ffb199);
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen:not([hidden]) {
  flex: 1;
  min-height: 0;
}

[hidden] {
  display: none !important;
}

.screen-start:not([hidden]) {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 1rem 1rem 1.4rem;
}

.panel,
.end-wrap {
  width: min(42rem, 100%);
}

.panel {
  margin: auto;
  padding: 1.2rem 1.15rem 1.3rem;
  background: rgba(255, 254, 248, 0.96);
  border-radius: 24px;
  box-shadow: 0 10px 24px rgba(22, 50, 74, 0.12);
}

.hero,
.modal-emoji,
.review-emoji,
.emoji,
.fig {
  font-family: var(--emoji);
}

.hero {
  font-size: 3rem;
  line-height: 1.2;
}

.lede,
.review-intro,
.result-learn,
.result-hearts {
  margin-top: 0.4rem;
  color: var(--ink-soft);
}

.rules,
.pairs {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
}

.rules li,
.pairs li {
  margin: 0.35rem 0;
}

.pair-heading {
  margin-top: 0.9rem;
}

.pairs {
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 11rem;
  min-height: 3.4rem;
  padding: 0.75rem 1.6rem;
  border: 0;
  border-radius: 999px;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 0 var(--green-deep);
}

.btn-primary:active,
.btn-modal:active {
  transform: translateY(2px);
}

.btn-modal {
  width: 100%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 0 #0c2233;
}

.screen-play:not([hidden]) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.play-hint {
  flex: none;
  margin: 0.5rem 0.7rem 0.4rem;
  padding: 0.4rem 0.7rem;
  text-align: center;
  font-weight: 700;
  background: rgba(255, 254, 248, 0.88);
  border-radius: 14px;
}

.scene {
  position: relative;
  isolation: isolate;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 260px;
  margin: 0 0.55rem 0.5rem;
  overflow: hidden;
  border-radius: 22px;
  background: #8ecff2;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.scene.is-hurt {
  box-shadow: inset 0 0 0 5px var(--heart);
}

.scene-sky,
.skyline,
.park,
.bike-lane,
.road,
.scene-title {
  pointer-events: none;
}

.scene-sky {
  position: absolute;
  inset: 0;
}

.sun {
  position: absolute;
  top: 18px;
  left: 46%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffe08a;
  box-shadow: 0 0 0 12px rgba(255, 224, 138, 0.35);
}

.cloud {
  position: absolute;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  animation: cloud-drift 16s ease-in-out infinite alternate;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before {
  width: 26px;
  height: 26px;
  left: 10px;
  top: -14px;
}

.cloud::after {
  width: 18px;
  height: 18px;
  right: 8px;
  top: -8px;
}

.cloud-a {
  width: 92px;
  top: 28px;
  left: 18%;
}

.cloud-b {
  width: 70px;
  top: 58px;
  right: 18%;
  animation-duration: 20s;
}

.skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 34%;
  height: 42%;
}

.factory {
  position: absolute;
  left: 4%;
  bottom: 0;
  width: min(28vw, 150px);
}

.factory-body {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: flex-end;
  height: 74px;
  padding-bottom: 8px;
  background: #9aa7b4;
  border: 3px solid #5e6d7a;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.factory-body span {
  width: 16px;
  height: 24px;
  background: #e7f7ff;
  border: 2px solid #5e6d7a;
}

.chimney {
  position: absolute;
  left: 16px;
  bottom: 74px;
  width: 22px;
  height: 40px;
  background: #6d584e;
  border-radius: 3px 3px 0 0;
}

.bg-puff {
  position: absolute;
  left: 4px;
  bottom: 36px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(70, 70, 70, 0.4);
  animation: rise 2.6s linear infinite;
}

.bg-puff-b {
  left: 12px;
  animation-delay: 1.2s;
}

.school {
  position: absolute;
  right: 5%;
  bottom: 0;
  width: min(26vw, 130px);
}

.roof {
  height: 0;
  border-left: 65px solid transparent;
  border-right: 65px solid transparent;
  border-bottom: 36px solid #e25b45;
}

.school-body {
  position: relative;
  height: 58px;
  background: #f4e2c4;
  border: 3px solid #8a5a3b;
  border-top: 0;
}

.door {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 22px;
  height: 32px;
  transform: translateX(-50%);
  background: #8a5a3b;
  border-radius: 8px 8px 0 0;
}

.place-label {
  margin-top: 2px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink);
}

.park {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  height: 28%;
  background: linear-gradient(#8fd16a, #67b84d);
}

.bg-tree {
  position: absolute;
  bottom: 8px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #1f8a45;
  box-shadow: inset -8px -6px 0 rgba(0, 0, 0, 0.08);
}

.bg-tree::after {
  content: "";
  position: absolute;
  left: 23px;
  bottom: -16px;
  width: 8px;
  height: 20px;
  background: #8a5a2b;
}

.t1 { left: 28%; }
.t2 { left: 46%; width: 64px; height: 64px; }
.t3 { right: 22%; }

.bike-lane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14%;
  height: 8%;
  background: #d5e38a;
}

.road {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16%;
  background: #5d6b76;
}

.dashes {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  height: 4px;
  background: repeating-linear-gradient(90deg, #fff 0 28px, transparent 28px 52px);
  animation: drive 1.1s linear infinite;
}

.scene-title {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 4;
  margin: 0;
  padding: 0.15rem 0.55rem;
  background: rgba(255, 254, 248, 0.9);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}

.actors {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.actor {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  max-width: 11rem;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

.actor:focus {
  outline: none;
}

.actor:focus-visible .sprite {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.sprite-wrap {
  display: block;
}

.sprite {
  position: relative;
  display: block;
  margin: 0 auto;
}

.face-left .sprite {
  transform: scaleX(-1);
}

.actor-name {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1.15rem);
  display: block;
  width: max-content;
  max-width: 8.8rem;
  margin: 0;
  overflow: visible;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 0 #fff, 0 0 6px #fff;
  white-space: normal;
  transform: translateX(-50%);
}

.review-name {
  display: block;
  overflow: visible;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  white-space: normal;
}

.mini-meter {
  position: absolute;
  left: 50%;
  bottom: 100%;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  width: 4.8rem;
  transform: translateX(-50%);
}

.mini-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(22, 50, 74, 0.18);
}

.mini-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--coral);
  transform: scaleX(0);
  transform-origin: left center;
}

.actor.is-purify .mini-fill {
  background: var(--clean);
}

.meter-num {
  flex: none;
  color: var(--coral-deep);
  font-size: 0.68rem;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff;
  white-space: nowrap;
}

.actor.is-purify .meter-num {
  color: var(--green);
}

.badge.is-pollution {
  background: #fde2dc;
  color: var(--coral-deep);
}

.badge.is-purify {
  background: var(--clean-soft);
  color: var(--green);
}

.puffs {
  position: absolute;
  z-index: 2;
  width: 48px;
  height: 36px;
}

.puffs i {
  position: absolute;
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(78, 78, 78, 0.55);
  animation: exhaust-puff 1.15s ease-out infinite;
}

.puffs i:nth-child(2) { animation-delay: 0.28s; }
.puffs i:nth-child(3) { left: 10px; animation-delay: 0.55s; }
.puffs i:nth-child(4) { left: 6px; animation-delay: 0.82s; }

.puffs-exhaust { left: 0; top: 18px; }
.puffs-stack { left: 18px; top: 0; }
.puffs-stack i { animation-name: stack-puff; background: rgba(90, 90, 90, 0.5); }
.puffs-smoke { left: 28px; top: 0; }
.puffs-smoke i { animation-name: stack-puff; }
.puffs-mist { right: 0; top: 28px; width: 54px; }
.puffs-mist i { background: rgba(186, 214, 120, 0.72); animation-name: mist-puff; }

.wheel {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #24303a;
  box-shadow: inset 0 0 0 4px #e8eef2, inset 0 0 0 7px #24303a;
  animation: wheel-spin 0.45s linear infinite;
}

.wheel::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 9px;
  height: 3px;
  background: #e8eef2;
}

.sprite-car { width: 138px; height: 72px; }
.car { position: absolute; left: 34px; right: 0; bottom: 0; height: 58px; }
.car-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  height: 32px;
  background: #e23b4a;
  border-radius: 8px 16px 10px 8px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}
.car-top {
  position: absolute;
  left: 28px;
  top: -18px;
  width: 48px;
  height: 20px;
  background: #9fd7f2;
  border: 3px solid #b32636;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}
.car-light {
  position: absolute;
  right: 4px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffe08a;
}
.sprite-car .wheel-a { left: 12px; bottom: 0; }
.sprite-car .wheel-b { right: 10px; bottom: 0; }

.sprite-bus { width: 168px; height: 78px; }
.bus { position: absolute; inset: 0; }
.bus-body {
  position: absolute;
  left: 8px;
  right: 4px;
  bottom: 16px;
  height: 46px;
  background: #f4b942;
  border: 3px solid #8a5a00;
  border-radius: 10px 14px 8px 8px;
}
.bus-win {
  display: inline-block;
  width: 22px;
  height: 16px;
  margin: 8px 0 0 8px;
  background: #dff4ff;
  border: 2px solid #8a5a00;
  border-radius: 3px;
}
.bus-door {
  position: absolute;
  right: 8px;
  bottom: 0;
  width: 16px;
  height: 28px;
  background: #fff6df;
  border: 2px solid #8a5a00;
  border-bottom: 0;
}
.sprite-bus .wheel { width: 20px; height: 20px; }
.sprite-bus .wheel-a { left: 28px; bottom: 0; }
.sprite-bus .wheel-b { right: 26px; bottom: 0; }

.sprite-bike { width: 124px; height: 86px; }
.bike { position: absolute; inset: 0; }
.rider { position: absolute; left: 48px; top: 0; }
.rider .head,
.person .head,
.planter .head {
  display: block;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  background: #f3c7a5;
  border: 2px solid #8a5a3b;
  border-radius: 50%;
}
.rider-body {
  display: block;
  width: 8px;
  height: 24px;
  margin-left: 11px;
  background: #1f9d6a;
  border-radius: 6px;
}
.bike-frame {
  position: absolute;
  left: 28px;
  right: 24px;
  bottom: 16px;
  height: 8px;
  background: #16324a;
  border-radius: 4px;
  transform: rotate(-8deg);
}
.sprite-bike .wheel-a { left: 8px; bottom: 0; }
.sprite-bike .wheel-b { right: 8px; bottom: 0; }

.sprite-factory { width: 118px; height: 108px; }
.stack-chimney {
  position: absolute;
  left: 22px;
  top: 28px;
  width: 18px;
  height: 36px;
  background: #6d584e;
  border-radius: 3px 3px 0 0;
}
.mill {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
  height: 52px;
  padding-bottom: 6px;
  background: #9aa7b4;
  border: 3px solid #5e6d7a;
  border-radius: 6px 6px 0 0;
}
.mill span {
  width: 14px;
  height: 22px;
  background: #e7f7ff;
  border: 2px solid #5e6d7a;
}

.sprite-fire { width: 108px; height: 96px; }
.flames { position: absolute; left: 24px; bottom: 18px; width: 64px; height: 48px; }
.flame {
  position: absolute;
  bottom: 0;
  width: 18px;
  height: 32px;
  background: #ff8a1e;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flicker 0.35s ease-in-out infinite alternate;
}
.flame-a { left: 8px; background: #ffd15c; height: 26px; }
.flame-b { left: 22px; height: 40px; animation-delay: 0.12s; }
.flame-c { left: 36px; background: #e23b4a; height: 28px; animation-delay: 0.2s; }
.pile {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 22px;
  background: #8a5a2b;
  border-radius: 40%;
}

.sprite-spray { width: 132px; height: 112px; }
.person { position: absolute; left: 18px; bottom: 0; width: 40px; height: 92px; }
.person .torso,
.planter .torso {
  display: block;
  width: 22px;
  height: 28px;
  margin-left: 6px;
  background: #3d7ea6;
  border-radius: 8px;
}
.leg {
  position: absolute;
  bottom: 0;
  width: 7px;
  height: 28px;
  background: #24303a;
  border-radius: 4px;
  transform-origin: top center;
}
.leg-a { left: 10px; animation: step 0.45s ease-in-out infinite; }
.leg-b { left: 20px; animation: step 0.45s ease-in-out infinite reverse; }
.sprayer {
  position: absolute;
  left: 46px;
  bottom: 36px;
  width: 36px;
  height: 10px;
  background: #5e6d7a;
  border-radius: 6px;
}
.sprayer::before {
  content: "";
  position: absolute;
  left: -8px;
  top: -16px;
  width: 16px;
  height: 22px;
  background: #7d8b86;
  border-radius: 4px;
}

.sprite-tree { width: 132px; height: 118px; }
.planter { position: absolute; left: 8px; bottom: 8px; width: 48px; height: 86px; }
.planter .torso { background: #0a6b40; }
.arm {
  position: absolute;
  left: 20px;
  top: 28px;
  width: 28px;
  height: 7px;
  background: #8a5a3b;
  border-radius: 4px;
  transform-origin: left center;
  animation: dig 1.1s ease-in-out infinite;
}
.sapling {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 48px;
  transform-origin: center bottom;
  animation: sprout 2.4s ease-in-out infinite;
}
.leaves {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  background: #1f8a45;
  border-radius: 50%;
}
.trunk {
  display: block;
  width: 8px;
  height: 18px;
  margin: -4px auto 0;
  background: #8a5a2b;
}
.soil {
  position: absolute;
  left: 18px;
  right: 10px;
  bottom: 0;
  height: 14px;
  background: #6b4423;
  border-radius: 40%;
}

.actor.is-burst .sprite,
.actor.is-leave .sprite {
  animation: pop-out 0.4s ease forwards;
}

.toast {
  position: absolute;
  top: 46px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 0.45rem 0.8rem;
  background: #fff;
  color: var(--coral-deep);
  border: 3px solid var(--heart);
  border-radius: 999px;
  font-weight: 800;
  text-align: center;
}

body.is-paused .actors {
  visibility: hidden;
  pointer-events: none;
}

body.is-paused .scene *,
body.is-paused .actor {
  animation-play-state: paused !important;
}

.screen-end:not([hidden]) {
  display: block;
  overflow: auto;
  padding: 1rem 1rem calc(1.4rem + env(safe-area-inset-bottom));
}

.end-wrap {
  width: min(54rem, 100%);
  margin: 0 auto;
}

.result-score {
  display: inline-block;
  margin-top: 0.7rem;
  padding: 0.3rem 0.85rem;
  background: var(--gold-soft);
  color: var(--gold);
  border-radius: 999px;
  font-size: 1.35rem;
  font-weight: 800;
}

.end-wrap h3 {
  margin-top: 1.1rem;
}

.review-intro {
  margin-bottom: 0.7rem;
}

.review-table {
  width: 100%;
  border: 1px solid var(--line);
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border-radius: 16px;
}

.review-table th,
.review-table td {
  padding: 0.75rem 0.85rem;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.review-table th {
  background: var(--ink);
  color: #fff;
}

.review-table th:first-child { width: 36%; border-top-left-radius: 16px; }
.review-table th:last-child { border-top-right-radius: 16px; }
.review-table tr:last-child td { border-bottom: 0; }
.review-table tr:last-child td:first-child { border-bottom-left-radius: 16px; }
.review-table tr:last-child td:last-child { border-bottom-right-radius: 16px; }

.review-emoji {
  display: block;
  margin: 0.2rem 0;
  font-size: 1.7rem;
  line-height: 1.3;
}

.review-pair,
.review-tip {
  margin-top: 0.3rem;
  color: var(--ink-soft);
}

.review-label {
  display: block;
  margin-bottom: 0.1rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

#btn-replay { margin-top: 1rem; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(1rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: rgba(16, 42, 62, 0.58);
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: min(36rem, 100%);
  max-height: min(90dvh, 42rem);
  padding: 1.05rem 1.05rem 0.95rem;
  overflow: hidden;
  background: var(--paper);
  border-radius: 24px;
}

.modal-card.is-pollution { border-top: 8px solid var(--coral); }
.modal-card.is-purify { border-top: 8px solid var(--clean); }

.badge,
#modal-title,
.score-note,
.btn-modal,
.modal-emoji {
  flex-shrink: 0;
}

.modal-emoji {
  margin: 0.2rem 0;
  font-size: 3rem;
  line-height: 1.2;
}

.score-pill {
  display: inline-block;
  align-self: flex-start;
  margin-top: 0.45rem;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-weight: 800;
}

.score-pill.is-plus { background: var(--gold-soft); color: var(--gold); }
.score-pill.is-zero { background: #eef3f7; color: var(--ink); }
.score-note { margin-top: 0.35rem; font-weight: 700; }

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0.65rem 0 0.8rem;
  overflow: auto;
}

.pair-line {
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.kicker {
  margin-top: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.science {
  margin-top: 0.15rem;
  padding: 0.6rem 0.7rem;
  background: #f4f9fc;
  border-radius: 12px;
}

.pause-note {
  margin-top: 0.65rem;
  color: var(--gold);
  font-size: 0.92rem;
  font-weight: 700;
}

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

.noscript {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 60;
  padding: 0.8rem 1rem;
  background: #fff;
  border-radius: 12px;
}

@keyframes cloud-drift {
  from { translate: 0 0; }
  to { translate: 16px 4px; }
}

@keyframes rise {
  0% { transform: translateY(8px) scale(0.6); opacity: 0.15; }
  100% { transform: translateY(-28px) scale(1.4); opacity: 0; }
}

@keyframes puff {
  0% { transform: translate(0, 6px) scale(0.5); opacity: 0.15; }
  100% { transform: translate(-18px, -16px) scale(1.25); opacity: 0; }
}

@keyframes mist {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0.1; }
  100% { transform: translate(16px, -10px) scale(1.3); opacity: 0; }
}

@keyframes flicker {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-4px) scale(1.08); }
}

@keyframes grow {
  0%, 100% { transform: scale(0.9); }
  50% { transform: scale(1.08); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes drive {
  from { background-position: 0 0; }
  to { background-position: -52px 0; }
}

@keyframes pop-out {
  to { transform: scale(1.12); opacity: 0; }
}

@keyframes exhaust-puff {
  0% { transform: translate(10px, 6px) scale(0.35); opacity: 0.15; }
  100% { transform: translate(-26px, -16px) scale(1.35); opacity: 0; }
}

@keyframes stack-puff {
  0% { transform: translate(0, 10px) scale(0.4); opacity: 0.2; }
  100% { transform: translate(6px, -28px) scale(1.45); opacity: 0; }
}

@keyframes mist-puff {
  0% { transform: translate(0, 0) scale(0.4); opacity: 0.15; }
  100% { transform: translate(22px, -8px) scale(1.4); opacity: 0; }
}

@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}

@keyframes step {
  0%, 100% { transform: rotate(22deg); }
  50% { transform: rotate(-22deg); }
}

@keyframes dig {
  0%, 100% { transform: rotate(10deg); }
  50% { transform: rotate(62deg); }
}

@keyframes sprout {
  0%, 100% { transform: scale(0.55); }
  55% { transform: scale(1); }
}

@keyframes hurt {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.time-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.time-caption {
  flex: none;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.time-row .timebar {
  position: relative;
  flex: 1;
  height: 28px;
  overflow: hidden;
  background: #d7e6f2;
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px rgba(22, 50, 74, 0.08);
}

.time-row .timebar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #0a6b40, #7ed0a4);
  transform: scaleX(1);
  transform-origin: left center;
}

.timebar-readout {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff, 0 0 4px #fff;
  pointer-events: none;
}

.time-row .timebar.is-urgent .timebar-fill {
  background: linear-gradient(90deg, #e25b45, #ffb199);
}

.backdrop,
.backdrop * {
  pointer-events: none;
}

.backdrop {
  position: absolute;
  inset: 0;
}

.sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(#8ecff2, #d7f1ff 58%, transparent 59%);
}

.scene.is-factory .sky {
  background: linear-gradient(#b9c9d6, #e4edf3 55%, transparent 56%);
}

.scene.is-park .sky {
  background: linear-gradient(#8ecff2, #e7f8ff 46%, transparent 47%);
}

.far { display: none; position: absolute; left: 0; right: 0; }
.scene.is-road .far-road,
.scene.is-factory .far-factory,
.scene.is-park .far-park { display: block; }

.grass { display: none; }

.scene.is-combined .far-road,
.scene.is-combined .far-park,
.scene.is-combined .grass,
.scene.is-combined .lane { display: block; }

.scene.is-combined .far-factory { display: none; }
.scene.is-combined .far-road { bottom: 46%; }
.scene.is-combined .far-park { bottom: 40%; }

.scene.is-combined .grass {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16%;
  height: 30%;
  background: linear-gradient(#9adf74, #67b84d);
}

.scene.is-combined .ground {
  height: 18%;
  background: #5d6b76;
}

.scene.is-combined .lane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16%;
  height: 8%;
  background: #d5e38a;
  border-top: 3px dashed rgba(255, 255, 255, 0.75);
}

.far-road {
  bottom: 28%;
  height: 28%;
}

.far-road span {
  position: absolute;
  bottom: 0;
  width: 70px;
  height: 78px;
  background: #f4e7d4;
  border: 3px solid #243044;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.far-road span:nth-child(1) { left: 8%; height: 64px; }
.far-road span:nth-child(2) { left: 42%; height: 92px; background: #f7d7c4; }
.far-road span:nth-child(3) { right: 10%; width: 84px; }

.far-factory {
  left: 8%;
  right: 8%;
  bottom: 22%;
  height: 18%;
}

.tank {
  position: absolute;
  right: 6%;
  bottom: 0;
  width: 54px;
  height: 54px;
  background: #9aa7b4;
  border: 3px solid #243044;
  border-radius: 50%;
}

.fence {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  background: repeating-linear-gradient(90deg, #d7c39a 0 10px, transparent 10px 18px);
  border-top: 3px solid #8a5a3b;
}

.far-park {
  bottom: 38%;
  height: 22%;
}

.hill {
  position: absolute;
  left: -5%;
  right: 20%;
  bottom: 0;
  height: 70px;
  background: #b7e39a;
  border-radius: 80px 80px 0 0;
}

.far-park i {
  position: absolute;
  bottom: 8px;
  width: 14px;
  height: 14px;
  background: #f28ab0;
  border: 2px solid #243044;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.far-park i:nth-child(2) { left: 18%; background: #ffe08a; }
.far-park i:nth-child(3) { left: 62%; }
.far-park i:nth-child(4) { right: 12%; background: #9fd7f5; }

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

.lane { display: none; }

.scene.is-road .ground {
  height: 20%;
  background: #5d6b76;
}

.scene.is-road .lane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  height: 10%;
  background: #d5e38a;
  border-top: 3px dashed rgba(255, 255, 255, 0.7);
}

.scene.is-factory .ground {
  height: 46%;
  background: #c5cdd4;
}

.scene.is-factory .lane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8%;
  height: 8px;
  background: #e7e1c8;
}

.scene.is-park .ground {
  height: 48%;
  background: linear-gradient(#8fd16a, #67b84d);
}

.scene.is-park .lane { display: none; }

.sticker {
  display: block;
  width: 168px;
  height: 112px;
}

.sticker-factory { width: 78px; height: 148px; }
.sticker-bus { width: 196px; height: 112px; }
.sticker-fire,
.sticker-spray,
.sticker-tree { width: 156px; height: 132px; }

.sticker .art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.face-left .sticker .art {
  transform: scaleX(-1);
}

.sticker .wheel {
  transform-box: fill-box;
  transform-origin: center;
  animation: wheel-spin 0.55s linear infinite;
}

.sticker .puff {
  transform-box: fill-box;
  transform-origin: center;
  animation: sticker-puff 1.3s ease-out infinite;
}

.sticker .puff:nth-child(2) { animation-delay: 0.35s; }
.sticker .puff:nth-child(3) { animation-delay: 0.7s; }

.sticker .flame {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: flicker 0.35s ease-in-out infinite alternate;
}

.sticker .sapling {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: sprout 2.4s ease-in-out infinite;
}

.sticker .arm {
  transform-box: fill-box;
  transform-origin: left center;
  animation: dig 1.1s ease-in-out infinite;
}

.sticker .leg {
  transform-box: fill-box;
  transform-origin: top center;
  animation: step 0.5s ease-in-out infinite;
}

.sticker .leg-b { animation-direction: reverse; }

.actor.is-burst .sticker,
.actor.is-leave .sticker {
  animation: pop-out 0.4s ease forwards;
}

@keyframes sticker-puff {
  0% { opacity: 0.2; transform: translate(0, 6px) scale(0.6); }
  100% { opacity: 0; transform: translate(-4px, -16px) scale(1.35); }
}

@media (max-width: 720px) {
  .review-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .review-table,
  .review-table tbody,
  .review-table tr,
  .review-table td {
    display: block;
    width: auto;
  }

  .review-table { border: 0; background: transparent; }

  .review-table tr {
    margin-bottom: 0.7rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .review-table td { border-bottom: 0; }
  .review-table td + td { padding-top: 0; }

  .review-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: var(--ink-soft);
    font-size: 0.78rem;
    font-weight: 800;
  }

  .roof {
    border-left-width: 46px;
    border-right-width: 46px;
    border-bottom-width: 26px;
  }

  .sticker { width: 132px; height: 92px; }
  .sticker-factory { width: 64px; height: 124px; }
  .sticker-bus { width: 156px; height: 92px; }
  .actor-name { font-size: 0.68rem; }
}

@media (max-height: 520px) {
  .modal-emoji { font-size: 2.2rem; }
  .modal-card { padding: 0.7rem 0.75rem; }
  .play-hint { margin-top: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud,
  .bg-puff,
  .exhaust i,
  .stack i,
  .sticker .puff,
  .sticker .wheel,
  .sticker .flame,
  .sticker .leg,
  .sticker .arm,
  .sticker .sapling,
  .dashes {
    animation: none;
  }
}
