:root {
  color-scheme: light;
  --ink: #1d322b;
  --muted: #5c7067;
  --line: #dfe8df;
  --paper: #f5f8f4;
  --green: #205f49;
  --green-dark: #194c3b;
  --green-soft: #e9f2eb;
  --white: #fff;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .62; cursor: wait; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid #2a795e;
  outline-offset: 4px;
}
button[hidden], [hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.wrap { width: min(100% - 96px, 1280px); margin-inline: auto; }
.topbar { background: #fcfdfb; border-bottom: 1px solid #e3eae3; }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: #23473a; font-weight: 700; letter-spacing: .05em; font-size: 1.125rem; }
.brand-mark {
  display: inline-flex; justify-content: center; align-items: center; gap: 1px;
  width: 36px; height: 36px; border-radius: 10px; background: #236048; color: #f5f9ed;
}
.pine { width: 14px; height: 21px; background: currentColor; clip-path: polygon(50% 0, 85% 37%, 69% 37%, 100% 72%, 59% 72%, 59% 100%, 41% 100%, 41% 72%, 0 72%, 31% 37%, 15% 37%); }
.pine.small { width: 9px; height: 15px; margin-top: 6px; opacity: .74; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid transparent; border-radius: 11px; padding: 0 15px;
  min-height: 42px; font-size: .9375rem; font-weight: 650; line-height: 1.3;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.button-outline { background: #fff; border-color: #dbe5dc; color: #2f5545; }
.button-outline:hover { background: #ecf3ed; border-color: #bdcfc2; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { background: #edf3ee; color: #285841; }
.button-secondary:hover { background: #e1eee4; }
.icon-button { flex: 0 0 39px; height: 39px; padding: 0; border-radius: 10px; background: #f6f9f6; border: 1px solid #e6eee7; color: #365f4d; display: grid; place-items: center; }
.icon-button:hover { background: #e9f1ea; }

.icon { display: inline-block; position: relative; width: 16px; height: 16px; flex: 0 0 16px; color: inherit; }
.icon::before, .icon::after { content: ""; display: block; position: absolute; }
.icon-expand {
  background: linear-gradient(currentColor 0 0) top left / 6px 1.5px, linear-gradient(currentColor 0 0) top left / 1.5px 6px,
    linear-gradient(currentColor 0 0) top right / 6px 1.5px, linear-gradient(currentColor 0 0) top right / 1.5px 6px,
    linear-gradient(currentColor 0 0) bottom left / 6px 1.5px, linear-gradient(currentColor 0 0) bottom left / 1.5px 6px,
    linear-gradient(currentColor 0 0) bottom right / 6px 1.5px, linear-gradient(currentColor 0 0) bottom right / 1.5px 6px;
  background-repeat: no-repeat;
}
.icon-leaf::before { width: 13px; height: 11px; top: 2px; left: 2px; border: 1.5px solid currentColor; border-radius: 10px 1px 10px 1px; transform: rotate(-12deg); }
.icon-leaf::after { width: 11px; height: 1.5px; top: 9px; left: 1px; background: currentColor; transform: rotate(-42deg); }
.icon-sound { border-radius: 2px; background: linear-gradient(currentColor 0 0) 1px center/2px 7px, linear-gradient(currentColor 0 0) 5px center/2px 12px, linear-gradient(currentColor 0 0) 9px center/2px 16px, linear-gradient(currentColor 0 0) 13px center/2px 8px; background-repeat: no-repeat; }
.icon-adjust { background: repeating-linear-gradient(to bottom, currentColor 0 1.5px, transparent 1.5px 6px) center 2px / 15px 13.5px no-repeat; }
.icon-adjust::before { width: 4px; height: 4px; top: 1px; left: 4px; border-radius: 1px; background: currentColor; box-shadow: 6px 6px currentColor, -1px 12px currentColor; }
.icon-mic { background: linear-gradient(currentColor 0 0) bottom center / 6px 1.5px no-repeat, linear-gradient(currentColor 0 0) center bottom / 1.5px 4px no-repeat; }
.icon-mic::before { width: 6px; height: 10px; top: 0; left: 5px; border: 1.5px solid currentColor; border-radius: 5px; }
.icon-mic::after { width: 12px; height: 8px; top: 5px; left: 2px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px; }
.icon-stop::before { width: 10px; height: 10px; top: 3px; left: 3px; background: currentColor; border-radius: 2px; }
.icon-play::before { top: 2px; left: 4px; border-left: 10px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.icon-lock::before { width: 11px; height: 8px; left: 2.5px; top: 7px; border: 1.5px solid currentColor; border-radius: 2px; }
.icon-lock::after { width: 7px; height: 7px; left: 4.5px; top: 1px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }

.main { padding-block: 28px 46px; }
.intro { margin-bottom: 22px; }
.intro h1 { color: #203e33; font-size: clamp(2rem, 3.45vw, 2.875rem); font-weight: 750; line-height: 1.23; letter-spacing: .035em; }
.intro p { margin-top: 8px; color: var(--muted); font-size: 1.02rem; line-height: 1.5; }
.scene-picker { border: 0; padding: 0; margin: 0 0 17px; min-width: 0; }
.scene-picker legend { padding: 0; margin-bottom: 8px; color: #375749; font-size: .875rem; font-weight: 700; }
.scene-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 816px; }
.scene-options label { min-width: 0; cursor: pointer; }
.scene-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scene-options span { display: flex; align-items: center; gap: 8px; min-height: 44px; border: 1px solid #dfe8df; border-radius: 10px; padding: 5px 8px; background: #fff; color: #435b50; font-size: .875rem; font-weight: 600; }
.scene-options i { flex: 0 0 36px; height: 29px; border-radius: 5px; background: var(--scene-color) var(--scene-image) center / cover; }
.scene-options label:hover span { border-color: #a8c4b1; }
.scene-options input:checked + span { border-color: #6b9c82; box-shadow: inset 0 0 0 1px #6b9c82; background: #e8f3eb; color: #244f3d; }
.scene-options input:focus-visible + span { outline: 2px solid #2a795e; outline-offset: 2px; }

[data-scene="forest"] { --scene-image: url("assets/forest.jpg"); --scene-color: #789263; }
[data-scene="reef"] { --scene-image: url("assets/reef.jpg"); --scene-color: #589d9e; --scene-shade: 15 50 59; --atlas: url("assets/reef-arctic-animals.png"); }
[data-scene="arctic"] { --scene-image: url("assets/arctic.jpg"); --scene-color: #97b0c6; --scene-shade: 34 49 71; --atlas: url("assets/reef-arctic-animals.png"); }
[data-scene="savanna"] { --scene-image: url("assets/savanna.jpg"); --scene-color: #b1a063; --scene-shade: 55 45 25; --sprite-scale: 400% 300%; }
[data-scene="desert"] { --scene-image: url("assets/desert.jpg"); --scene-color: #c69465; --scene-shade: 68 42 29; --sprite-scale: 400% 300%; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 20px; }

.stage { position: relative; display: flex; flex-direction: column; justify-content: space-between; isolation: isolate; overflow: hidden; border-radius: 20px; min-height: 438px; background: #597856; color: white; }
.scene-art, .scene-weather, .scene-mist, .scene-shade, .inhabitants { position: absolute; inset: 0; pointer-events: none; }
.scene-art { z-index: -4; background: var(--scene-color) var(--scene-image) center 57% / cover no-repeat; transition: filter 1.3s; }
.scene-weather { z-index: -3; overflow: hidden; }
.scene-weather::before { content: ""; position: absolute; inset: 0; pointer-events: none; }
.scene-weather i {
  position: absolute; left: var(--particle-x, 38%); top: var(--particle-y, 10%); width: var(--particle-size, 10px);
  height: var(--particle-size, 10px); opacity: 0; animation-delay: var(--particle-delay, -1s);
}
.scene-weather i:nth-child(1) { --particle-x: 13%; --particle-y: 14%; --bubble-y: 27%; --particle-delay: -4s; }
.scene-weather i:nth-child(2) { --particle-x: 24%; --particle-y: 4%; --bubble-y: 14%; --particle-size: 8px; --particle-delay: -8s; }
.scene-weather i:nth-child(3) { --particle-x: 36%; --particle-y: 20%; --bubble-y: 19%; --particle-size: 7px; --particle-delay: -2.5s; }
.scene-weather i:nth-child(4) { --particle-x: 50%; --particle-y: 8%; --bubble-y: 42%; --particle-size: 5px; --particle-delay: -10.5s; }
.scene-weather i:nth-child(5) { --particle-x: 59%; --particle-y: 23%; --bubble-y: 31%; --particle-delay: -6s; }
.scene-weather i:nth-child(6) { --particle-x: 73%; --particle-y: 15%; --bubble-y: 12%; --particle-size: 12px; --particle-delay: -1.7s; }
.scene-weather i:nth-child(7) { --particle-x: 82%; --particle-y: 6%; --bubble-y: 35%; --particle-size: 8px; --particle-delay: -7s; }
.scene-weather i:nth-child(8) { --particle-x: 90%; --particle-y: 18%; --bubble-y: 23%; --particle-size: 6px; --particle-delay: -3.5s; }
.stage[data-scene="forest"] .scene-weather i:nth-child(even) { display: none; }
.stage[data-scene="forest"] .scene-weather i {
  height: calc(var(--particle-size, 10px) * .61);
  border-radius: 90% 12% 90% 12%;
  background: linear-gradient(24deg, #698c48 43%, #e2d59b 51%, #abc174 60%);
  animation-name: leaf-drift; animation-duration: 17s; animation-iteration-count: infinite;
}
.stage[data-scene="reef"] .scene-weather::before {
  inset: -8%;
  background: linear-gradient(111deg, transparent 34%, #f4ffcf32 40%, transparent 47%, #e0fff020 56%, transparent 64%);
  mask-image: linear-gradient(#000c, transparent 78%);
  animation: water-light 8s ease-in-out infinite alternate;
}
.stage[data-scene="reef"] .scene-weather i {
  top: auto; bottom: var(--bubble-y); border-radius: 50%; border: 1px solid #e1fff3c9;
  background: radial-gradient(circle at 30% 30%, #f4fff0c0, #c3fff221 36%, transparent 69%);
  box-shadow: 0 0 4px #e3fff462; animation-name: bubble-rise; animation-duration: 8s;
  animation-timing-function: linear; animation-iteration-count: infinite;
}
.stage[data-scene="arctic"] .scene-weather i {
  width: calc(var(--particle-size, 10px) * .55);
  height: calc(var(--particle-size, 10px) * .55);
  border-radius: 50%; background: #fff; box-shadow: 0 0 7px #ffffffc4;
  animation-name: snowfall; animation-duration: 12s; animation-timing-function: linear; animation-iteration-count: infinite;
}
.stage:is([data-scene="savanna"], [data-scene="desert"]) .scene-weather i:nth-child(even) { display: none; }
.stage[data-scene="savanna"] .scene-weather i {
  border-radius: 90% 12% 90% 12%; width: 7px; height: 3px; top: 47%; background: #e9d595;
  animation: dry-drift 14s var(--particle-delay, -1s) linear infinite;
}
.stage[data-scene="desert"] .scene-weather i {
  top: auto; bottom: var(--bubble-y); width: 4px; height: 3px; border-radius: 50%;
  background: #fee2b3; box-shadow: 0 0 4px #eed2a29c;
  animation: dry-drift 17s var(--particle-delay, -1s) linear infinite;
}
@keyframes leaf-drift {
  0%, 100% { opacity: 0; transform: translate(0, -8px) rotate(12deg); }
  14% { opacity: .56; }
  48% { transform: translate(22px, 37px) rotate(38deg) scaleX(.87); }
  66% { opacity: .48; }
  90%, 99% { opacity: 0; transform: translate(55px, 78px) rotate(71deg) scaleX(.75); }
}
@keyframes water-light {
  from { opacity: .4; transform: translateX(-2%) skewX(-3deg); }
  to { opacity: .88; transform: translateX(2%) skewX(4deg); }
}
@keyframes bubble-rise {
  0%, 100% { opacity: 0; transform: translate(0, 16px) scale(.72); }
  16% { opacity: .82; }
  48% { transform: translate(-12px, -82px) scale(.94); }
  78% { opacity: .56; }
  95%, 99% { opacity: 0; transform: translate(15px, -190px) scale(1.16); }
}
@keyframes snowfall {
  0%, 100% { opacity: 0; transform: translate(-25px, -38px); }
  15%, 69% { opacity: .83; }
  95%, 99% { opacity: 0; transform: translate(112px, 190px); }
}
@keyframes dry-drift {
  0%, 100% { opacity: 0; transform: translate(-22px, 4px) rotate(8deg); }
  18%, 66% { opacity: .56; }
  87%, 99% { opacity: 0; transform: translate(90px, -22px) rotate(47deg); }
}
.scene-mist { z-index: -2; opacity: 0; background: linear-gradient(135deg, #829a9880, #d5e0dce8 68%, #9caeab90); transition: opacity 1.3s ease; }
.stage[data-scene="reef"] .scene-mist { background: linear-gradient(135deg, #63798194, #a9beafd9 68%, #527384a0); }
.stage[data-scene="arctic"] .scene-mist { background: linear-gradient(155deg, #d2e7f5a0, #f2f9fff2 65%, #acbac5a0); }
.stage[data-scene="savanna"] .scene-mist { background: linear-gradient(145deg, #92866280, #dfcca2c9 65%, #a78e61a0); }
.stage[data-scene="desert"] .scene-mist { background: linear-gradient(145deg, #b5876088, #f7d3aac9 65%, #b7967ca0); }
.scene-shade { z-index: -1; background: linear-gradient(0deg, rgb(var(--scene-shade, 20 46 34) / .96), rgb(var(--scene-shade, 20 46 34) / .42) 24%, transparent 54%), linear-gradient(#15281f40, transparent 25%); }
.inhabitants { z-index: -3; }
.stage[data-state="loud"] .scene-mist { opacity: .7; }
.stage[data-state="loud"] .scene-art { filter: saturate(.64); }
.scene-top { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 9px; padding: 19px 21px; }
.scene-label, .scene-status, .scene-exit { min-height: 35px; border-radius: 999px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; font-weight: 650; }
.scene-label { color: #f7fbf4; background: #1d352bc2; border: 1px solid #f5f8ed46; }
.stage:not([data-scene="forest"]) .scene-label { background: rgb(var(--scene-shade) / .86); }
.stage:not([data-scene="forest"]) .scene-label .icon { display: none; }
.scene-status { margin-left: auto; color: #314939; background: #f6fbf0ee; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #809783; }
.stage[data-state="quiet"] .status-dot { background: #367c55; }
.stage[data-state="loud"] .scene-status { background: #fcf1d8; color: #604427; }
.stage[data-state="loud"] .status-dot, .stage[data-state="near"] .status-dot { background: #ad7539; }
.scene-exit { display: none; color: white; background: #1d352bc2; border: 1px solid #f5f8ed46; }
.scene-exit:hover { background: #1b342a; }
.scene-bottom { padding: 40px 25px 23px; display: flex; align-items: flex-end; gap: 20px; justify-content: space-between; }
.scene-message h2 { font-size: clamp(1.65rem, 2.7vw, 2.3rem); letter-spacing: .035em; line-height: 1.22; }
.scene-message p { margin-top: 8px; color: #f2f7ecd9; font-size: .9375rem; line-height: 1.55; }
.scene-progress { width: min(33%, 230px); min-width: 140px; margin-bottom: 3px; }
.progress-label { display: flex; gap: 10px; justify-content: space-between; color: #f6fae9; font-size: .875rem; letter-spacing: .01em; }
#progress-time { font-variant-numeric: tabular-nums; }
progress { appearance: none; width: 100%; height: 6px; margin-top: 9px; border: 0; background: #fff4; color: #c8e69d; border-radius: 99px; display: block; overflow: hidden; }
progress::-webkit-progress-bar { background: #fff4; border-radius: 99px; }
progress::-webkit-progress-value { background: #c8e69d; border-radius: 99px; }
progress::-moz-progress-bar { background: #c8e69d; border-radius: 99px; }

.controls { border: 1px solid var(--line); border-radius: 20px; padding: 20px; background: white; display: flex; flex-direction: column; box-shadow: 0 8px 28px #183d2610; }
.control-head, .control-title, .volume-heading { display: flex; align-items: center; }
.control-head, .volume-heading { justify-content: space-between; gap: 10px; }
.control-title { gap: 9px; }
.control-title h2 { font-size: 1.145rem; letter-spacing: .02em; }
.control-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #e9f3eb; color: #2f694e; }
.volume { margin-top: 19px; padding: 14px; background: #f5f8f4; border: 1px solid #edf1eb; border-radius: 12px; }
.volume-heading h3 { font-size: .9rem; font-weight: 650; }
.volume-heading span { font-size: .85rem; color: var(--muted); }
.meter { --limit: 42%; position: relative; height: 10px; background: #dce9dd; border-radius: 9px; margin: 13px 0 6px; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; max-width: 100%; border-radius: 9px; background: linear-gradient(90deg, #79b78d, #4f996d); transition: width .18s linear; }
.meter[data-overshoot="true"] .meter-fill { background: linear-gradient(90deg, #679f78, #cd9a54); }
.meter-limit { position: absolute; top: -3px; bottom: -3px; left: var(--limit); width: 2px; border-radius: 2px; background: #526b5d; }
.meter-caption { display: flex; justify-content: space-between; font-size: .8125rem; color: #526960; }
.activity { border: 0; padding: 0; margin: 19px 0 14px; min-width: 0; }
.activity legend { font-size: .9rem; font-weight: 650; padding: 0; margin-bottom: 9px; }
.activities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.activities label { cursor: pointer; }
.activities input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.activities span { display: flex; min-height: 37px; border-radius: 9px; align-items: center; justify-content: center; border: 1px solid #e0e8df; color: #4e6158; background: #fff; font-size: .875rem; }
.activities label:hover span { background: #f3f8f4; }
.activities input:checked + span { background: #e8f3eb; border-color: #b2d0bc; color: #20533e; font-weight: 700; }
.activities input:focus-visible + span { outline: 2px solid #2a795e; outline-offset: 2px; }
.mode-helper { margin-top: 8px; font-size: .8125rem; color: var(--muted); line-height: 1.45; }
.actions { display: grid; gap: 8px; margin-top: auto; }
.actions .button { width: 100%; }
.actions .button-primary { min-height: 46px; }
.error { margin-top: 10px; padding: 9px 11px; border-radius: 8px; background: #fff3e4; color: #684b30; font-size: .875rem; line-height: 1.45; }
.local-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; color: #5a7164; font-size: .8125rem; }

.collection { margin-top: 30px; }
.collection-head { display: flex; align-items: flex-end; gap: 12px; justify-content: space-between; margin-bottom: 14px; }
.collection-head h2 { font-size: 1.45rem; letter-spacing: .03em; }
.collection-head p { margin-top: 4px; color: var(--muted); line-height: 1.5; font-size: .9375rem; }
.collection-count { white-space: nowrap; border-radius: 20px; background: #e9f1e9; color: #35604c; padding: 7px 13px; font-size: .875rem; font-weight: 650; }
.animal-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 1200px) {
  .collection:is([data-scene="reef"], [data-scene="arctic"]) .animal-cards { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}
.animal-card { border: 1px solid #dfe8df; border-radius: 13px; overflow: hidden; background: white; color: var(--ink); padding: 7px; text-align: left; transition: border-color .18s, box-shadow .18s; }
.animal-card:hover { border-color: #9ab9a7; box-shadow: 0 5px 14px #13362612; }
.animal-thumb, .animal-detail-art { display: grid; place-items: center; border-radius: 9px; background: var(--animal-bg, #edf2e5); }
.animal-thumb { position: relative; height: clamp(72px, 8vw, 112px); }
.animal-name { display: block; padding: 9px 4px 5px; font-size: .875rem; font-weight: 650; }
.card-lock { position: absolute; right: 7px; top: 7px; display: grid; place-items: center; border-radius: 50%; width: 26px; height: 26px; color: #546f60; background: #ffffffa3; }
.animal-card[data-found="true"] .card-lock { display: none; }
.sprite { display: block; width: auto; aspect-ratio: 1; max-width: 90%; height: 94%; }
.animal-card[data-found="false"] .sprite, .animal-detail-art[data-found="false"] .sprite { filter: grayscale(1); opacity: .58; }
.scene-animal { position: absolute; width: var(--width); aspect-ratio: 1; left: var(--x); bottom: var(--bottom); transform: translateX(-50%); animation: arrive 1s ease-out both; }
.scene-animal[data-animal="owl"] { left: var(--forest-rock-x, var(--x)); bottom: var(--forest-rock-bottom, var(--bottom)); }
.animal-motion, .animal-gesture, .animal-art { position: absolute; inset: 0; }
.animal-motion {
  filter: drop-shadow(0 6px 3px #20361765);
  transform-origin: 50% 82%;
  animation: var(--motion-loop, animal-stroll) var(--motion-duration, 9s) var(--motion-delay, 0s) ease-in-out infinite;
}
.stage[data-scene="reef"] .animal-motion { filter: drop-shadow(0 4px 4px #1b62714d); }
.scene-animal[data-grounded] { --greet-lift: 0%; --contact-opacity: .3; --contact-color: #193126; }
.stage[data-scene="arctic"] .scene-animal[data-grounded] { --contact-opacity: .22; --contact-color: #36516c; }
.stage[data-scene="reef"] .scene-animal[data-grounded] { --contact-opacity: .2; --contact-color: #164b52; }
.stage:is([data-scene="savanna"], [data-scene="desert"]) .scene-animal[data-grounded] { --contact-color: #493c29; }
.scene-animal[data-grounded] .animal-motion { filter: none; }
.scene-animal[data-grounded] .animal-motion::before {
  content: ""; position: absolute; inset: auto 19% -3%; height: 7%; border-radius: 50%;
  background: var(--contact-color); opacity: var(--contact-opacity); filter: blur(3px);
}
.scene-animal[data-grounded] .animal-gesture { transform-origin: center bottom; }
.scene-animal[data-grounded] .animal-art { top: var(--foot-offset); bottom: auto; height: 100%; }
.scene-animal[data-animal="owl"] .animal-motion { transform-origin: center bottom; }
.scene-animal[data-motion="hop"] { --motion-loop: animal-hop; --motion-duration: 6s; }
.scene-animal[data-motion="trot"] { --motion-loop: animal-trot; --motion-duration: 7s; }
.scene-animal[data-motion="swim"] { --motion-loop: animal-swim; --motion-duration: 9s; }
.scene-animal[data-motion="float"] { --motion-loop: animal-float; --motion-duration: 6.6s; }
.scene-animal[data-motion="crawl"] { --motion-loop: animal-crawl; --motion-duration: 11s; }
.scene-animal[data-motion="slide"] { --motion-loop: animal-crawl; --motion-duration: 8.2s; }
.scene-animal[data-motion="perch"] { --motion-loop: animal-perch; --motion-duration: 6.2s; }
.scene-animal[data-motion="glide"] { --motion-loop: animal-glide; --motion-duration: 10s; }
.scene-animal[data-motion="flutter"] { --motion-loop: animal-flutter; --motion-duration: 6.5s; }
.scene-animal[data-motion="peck"] { --motion-loop: animal-peck; --motion-duration: 5.5s; }
.scene-animal:is([data-gait="waiting"], [data-stroke="waiting"]) .animal-motion { animation: none; }
.scene-animal[data-gait="ready"] .animal-motion {
  animation: gait-travel var(--gait-travel, 7.2s) var(--motion-delay) linear infinite,
    gait-turn var(--gait-travel, 7.2s) var(--motion-delay) steps(1, end) infinite;
}
.scene-animal[data-gait="ready"] .animal-art {
  background-image: var(--gait-atlas);
  background-size: 400% 300%;
  background-position: 0% var(--gait-row);
  clip-path: none;
  animation: gait-poses var(--gait-cycle, .9s) var(--motion-delay) steps(1, end) infinite;
}
.stage[data-scene="arctic"] .scene-animal[data-gait="ready"] .animal-art {
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
    linear-gradient(to bottom, transparent, #000 5%, #000 93%, transparent);
  mask-composite: intersect;
}
.scene-animal[data-gait][data-motion="trot"] { --gait-cycle: .68s; --gait-travel: 5.44s; }
.scene-animal[data-gait][data-motion="hop"] { --gait-cycle: .92s; --gait-travel: 5.52s; }
.scene-animal[data-gait][data-motion="crawl"] { --gait-cycle: 1.08s; --gait-travel: 8.64s; }
.scene-animal[data-gait][data-motion="slide"] { --gait-cycle: 1.23s; --gait-travel: 9.84s; }
.scene-animal[data-gait="ready"][data-motion="hop"] .animal-motion::before {
  animation: contact-shadow var(--gait-cycle) var(--motion-delay) ease-out infinite;
}
.scene-animal[data-animal="seahorse"] { --swim-turn: none; }
.scene-animal[data-stroke="ready"] .animal-motion {
  animation: swim-travel var(--swim-seconds) var(--motion-delay) ease-in-out infinite,
    var(--swim-turn, swim-turn) var(--swim-seconds) var(--motion-delay) ease-in-out infinite;
}
.scene-animal[data-stroke="ready"] .animal-art {
  background-image: var(--stroke-atlas);
  background-size: var(--stroke-size);
  background-position: 0% var(--stroke-row);
  animation: var(--stroke-cycle, gait-poses) var(--stroke-seconds) var(--motion-delay) steps(1, end) infinite;
}
.scene-animal[data-greeting]:not([data-stroke="ready"]) .animal-art { transform: scaleX(var(--greet-facing)); }
.scene-animal[data-greeting]:not([data-stroke="ready"]) .animal-motion,
.scene-animal[data-greeting]:not([data-stroke="ready"]) .animal-art,
.scene-animal[data-gait][data-greeting] .animal-motion::before { animation-play-state: paused; }
.scene-animal[data-greeting]:not([data-stroke="ready"]) .animal-gesture { animation: animal-greet 2.85s ease-in-out; }
.scene-animal[data-leaving] {
  animation: animal-exit 1.65s var(--exit-delay, 0ms) cubic-bezier(.45, .08, .7, .88) both;
}
.scene-animal[data-leaving] .animal-art { transform: scaleX(var(--exit-facing)); }
.scene-animal[data-leaving] .animal-motion { animation: none; }
.scene-animal[data-leaving][data-gait="ready"] .animal-art,
.scene-animal[data-leaving][data-gait="ready"][data-motion="hop"] .animal-motion::before { animation-duration: .42s; }
.scene-animal[data-leaving][data-stroke="ready"] .animal-art { animation-duration: calc(var(--stroke-seconds) * .65); }
.scene-animal[data-leaving="swimming"]:not([data-stroke="ready"]) .animal-gesture { animation: swim-away .52s ease-in-out infinite alternate; }
.scene-animal[data-leaving="flying"] .animal-gesture { animation: fly-away .38s ease-in-out infinite alternate; }
.scene-animal[data-leaving="flying"] .animal-motion::before { opacity: 0; }
.animal-signal { display: none; }
.scene-animal[data-greeting] .animal-signal {
  display: block; position: absolute; z-index: 1; left: calc(42% + 24% * var(--greet-direction)); top: 0;
  min-width: 25px; width: 28%; height: clamp(14px, 2.2vw, 22px);
  border: 1px solid #ffffffd9; border-radius: 999px; background: #f8fae8ec;
  box-shadow: 0 2px 7px #263d4244; color: #52745d; animation: animal-signal 2.85s ease-in-out both;
}
.animal-signal::after {
  content: ""; position: absolute; top: calc(50% - 1.5px); left: calc(50% - 1.5px); width: 3px; height: 3px;
  border-radius: 50%; background: currentColor; box-shadow: -5px 0 currentColor, 5px 0 currentColor;
}
.stage[data-scene="reef"] .animal-signal {
  min-width: 0; width: 9px; height: 9px; border-color: #e5fff4; background: #b9f4ee63;
  box-shadow: -6px -7px 0 -1px #dcfff4a8, 5px -15px 0 -2px #ddfff3b0;
}
.stage[data-scene="reef"] .animal-signal::after { display: none; }
@keyframes arrive { from { opacity: 0; transform: translate(-50%, 10px) scale(.92); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes animal-exit {
  0% { opacity: 1; transform: translateX(calc(-50% + var(--exit-start-x, 0px))); }
  38% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--exit-distance)), var(--exit-lift)); }
}
@keyframes swim-away { from { transform: rotate(-4deg); } to { transform: rotate(5deg) translateY(-3%); } }
@keyframes fly-away { from { transform: rotate(-8deg); } to { transform: rotate(4deg) scaleY(.87); } }
@keyframes animal-stroll {
  0%, 100% { transform: translateX(-13%); }
  18%, 68% { transform: translate(0, -4%) rotate(-3deg); }
  31%, 54% { transform: translate(9%, 0) scale(1.025, .985); }
  42% { transform: translate(17%, -3%) rotate(2deg); }
  82% { transform: translate(-8%, 0); }
}
@keyframes animal-hop {
  0%, 98%, 100% { transform: translateX(-15%); }
  12% { transform: translate(-5%, -24%) rotate(-6deg) scale(.97, 1.06); }
  25% { transform: translate(8%, 0) scale(1.08, .92); }
  40% { transform: translate(18%, -16%) rotate(6deg); }
  54%, 70% { transform: translate(22%, 0) scale(1.04, .96); }
  83% { transform: translate(4%, -17%) rotate(-4deg); }
}
@keyframes animal-trot {
  0%, 100% { transform: translateX(-22%); }
  14%, 82% { transform: translate(-8%, -8%) rotate(-5deg); }
  27%, 67% { transform: translate(6%, 0) scale(1.05, .96); }
  38%, 56% { transform: translate(18%, -8%) rotate(4deg); }
  47% { transform: translate(25%, 0); }
}
@keyframes animal-swim {
  0%, 100% { transform: translate(-18%, 3%) rotate(-7deg); }
  25% { transform: translate(-4%, -11%) rotate(2deg); }
  54% { transform: translate(20%, -3%) rotate(7deg) scale(.975, 1.025); }
  78% { transform: translate(4%, 10%) rotate(-2deg); }
}
@keyframes animal-float {
  0%, 100% { transform: translate(-8%, 3%) rotate(-5deg); }
  50% { transform: translate(8%, -15%) rotate(7deg) scale(.94, 1.06); }
}
@keyframes animal-crawl {
  0%, 100% { transform: translateX(-13%) rotate(-3deg); }
  27%, 72% { transform: translate(0, -4%) rotate(2deg) scale(1.055, .955); }
  53% { transform: translate(16%, 0); }
}
@keyframes animal-perch {
  0%, 100% { transform: rotate(-3deg) scale(1.02, .99); }
  52% { transform: rotate(3deg) scale(.98, 1.02); }
}
@keyframes animal-glide {
  0%, 100% { transform: translate(-26%, 9%) rotate(-9deg); }
  32% { transform: translate(-2%, -14%) rotate(4deg) scaleY(.91); }
  61% { transform: translate(24%, -5%) rotate(8deg); }
  83% { transform: translate(4%, 12%) rotate(-2deg) scaleY(.92); }
}
@keyframes animal-flutter {
  0%, 100% { transform: translate(-25%, 6%) rotate(-12deg); }
  14% { transform: translate(-15%, -13%) rotate(-7deg) scaleX(.65); }
  27% { transform: translate(2%, -5%) rotate(6deg); }
  40% { transform: translate(20%, -21%) rotate(12deg) scaleX(.62); }
  55% { transform: translate(36%, -8%) rotate(5deg); }
  70% { transform: translate(16%, 13%) rotate(-10deg) scaleX(.67); }
  85% { transform: translate(-5%, -4%) rotate(-5deg); }
}
@keyframes animal-peck {
  0%, 45%, 83%, 100% { transform: translateY(-2%) rotate(4deg); }
  11%, 25%, 38% { transform: translate(-9%, -4%) rotate(-7deg); }
  17%, 31% { transform: translate(2%, -2%) rotate(6deg); }
  64% { transform: translate(1%, -10%) rotate(4deg); }
}
@keyframes gait-travel {
  0%, 100% { translate: -19% 0; }
  50% { translate: 19% 0; }
}
@keyframes gait-turn {
  0%, 100% { scale: 1 1; }
  50% { scale: -1 1; }
}
@keyframes gait-poses {
  0% { background-position-x: 0%; }
  25% { background-position-x: 33.333%; }
  50% { background-position-x: 66.667%; }
  75%, 100% { background-position-x: 100%; }
}
@keyframes swim-travel {
  0%, 2%, 96%, 100% { translate: calc(-1 * var(--swim-range)) 0; }
  46%, 50% { translate: var(--swim-range) 0; }
}
@keyframes swim-turn {
  0%, 46%, 100% { scale: 1 1; }
  50%, 96% { scale: -1 1; }
}
@keyframes turtle-stroke {
  0% { background-position: 0% 0%; }
  16.667% { background-position: 50% 0%; }
  33.333% { background-position: 100% 0%; }
  50% { background-position: 0% 100%; }
  66.667% { background-position: 50% 100%; }
  83.333%, 100% { background-position: 100% 100%; }
}
@keyframes contact-shadow {
  0%, 35%, 81%, 100% { opacity: var(--contact-opacity); scale: 1 1; }
  52%, 69% { opacity: calc(var(--contact-opacity) * .55); scale: .75 1; }
}
@keyframes animal-greet {
  0%, 100% { transform: none; }
  30%, 58% { transform: translate(calc(var(--greet-nudge) * 10%), var(--greet-lift, -5%)) rotate(calc(var(--greet-nudge) * -6deg)); }
  42%, 71% { transform: translate(calc(var(--greet-nudge) * 12%), 0) rotate(calc(var(--greet-nudge) * 5deg)); }
}
@keyframes animal-signal {
  0%, 100% { opacity: 0; transform: translateY(3px) scale(.8); }
  28%, 65% { opacity: 1; transform: translateY(-5px) scale(1); }
  86% { opacity: .6; transform: translateY(-9px) scale(.95); }
}

dialog { width: min(460px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow: auto; border: 1px solid #d8e5d9; border-radius: 17px; background: white; color: var(--ink); padding: 23px; box-shadow: 0 16px 64px #112b2147; }
dialog::backdrop { background: #192c247d; backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.dialog-head h2 { font-size: 1.35rem; }
.dialog-head .icon-button { font-size: 1.55rem; line-height: 1; }
.settings-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.settings-label output { color: var(--green); font-variant-numeric: tabular-nums; font-weight: 700; }
#limit { width: 100%; accent-color: var(--green); margin: 12px 0 7px; }
.small-text { font-size: .875rem; line-height: 1.55; color: var(--muted); }
.pace-label { margin-top: 21px; }
#pace { appearance: none; width: 100%; margin: 9px 0; min-height: 42px; color: var(--ink); padding: 0 34px 0 11px; border: 1px solid #d4e2d7; border-radius: 9px;
  background: linear-gradient(45deg, transparent 50%, #4a6758 50%) right 17px center/5px 5px no-repeat,
    linear-gradient(135deg, #4a6758 50%, transparent 50%) right 12px center/5px 5px no-repeat, #f4f8f4; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.animal-detail-art { height: 170px; margin-bottom: 14px; }
#animal-fact { line-height: 1.6; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }

.stage:fullscreen, .stage.project-fallback { border-radius: 0; width: 100%; height: 100%; min-height: 0; }
.stage.project-fallback { position: fixed; inset: 0; z-index: 10; }
body.projection-active { overflow: hidden; }
.stage:fullscreen .scene-exit, .stage.project-fallback .scene-exit { display: inline-flex; }
.stage:fullscreen .scene-top, .stage.project-fallback .scene-top { padding: clamp(16px, 4vw, 45px); }
.stage:fullscreen .scene-bottom, .stage.project-fallback .scene-bottom { padding: clamp(20px, 5vw, 65px); }
.stage:fullscreen .scene-message h2, .stage.project-fallback .scene-message h2 { font-size: clamp(2rem, 5vw, 5rem); }
.stage:fullscreen .scene-message p, .stage.project-fallback .scene-message p { font-size: clamp(1rem, 2vw, 1.8rem); }
.stage:fullscreen .scene-progress, .stage.project-fallback .scene-progress { width: min(30%, 420px); }

@media (max-width: 980px) {
  .wrap { width: min(100% - 50px, 1280px); }
  .dashboard { grid-template-columns: minmax(0, 1fr) 284px; gap: 14px; }
  .controls { padding: 16px; }
  .scene-bottom { flex-wrap: wrap; gap: 13px; }
}
@media (max-width: 750px) {
  .wrap { width: calc(100% - 32px); }
  .topbar-inner { min-height: 59px; }
  .main { padding-top: 21px; }
  .intro { margin-bottom: 15px; }
  .dashboard { grid-template-columns: 1fr; }
  .scene-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage { min-height: clamp(288px, 65vw, 435px); }
  .scene-top { padding: 13px; }
  .scene-bottom { padding: 25px 15px 15px; }
  .controls { padding: 16px; }
  .animal-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .animal-thumb { height: clamp(66px, 18vw, 104px); }
}
@media (max-width: 390px) {
  .collection-count { padding: 6px 8px; font-size: .8125rem; }
  .projection-button { padding-inline: 10px; }
  .scene-options { gap: 5px; }
  .scene-options span { justify-content: center; padding-inline: 4px; gap: 4px; }
  .scene-options i { flex-basis: 22px; height: 23px; }
}
@media (max-width: 345px) {
  .scene-options i { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .scene-weather, .animal-signal { display: none !important; }
  .animal-motion, .animal-gesture, .animal-art, .animal-motion::before { animation: none !important; }
}

/* The illustrated atlas is arranged in three columns and two rows. */
.sprite, .animal-art {
  background-image: var(--atlas, url("assets/animals.png"));
  background-repeat: no-repeat;
  background-size: var(--sprite-scale, 300% 200%);
  background-position: var(--sprite-pos);
  clip-path: var(--sprite-crop, none);
}
[data-animal="walrus"] { --sprite-scale: 273% 200%; }
[data-animal="arctic-hare"] { --sprite-scale: 320% 200%; }
[data-animal="arctic-fox"] { --sprite-crop: polygon(0 0, 100% 0, 100% 65%, 94% 65%, 94% 100%, 0 100%); }
[data-animal="beluga"] { --sprite-crop: polygon(0 0, 100% 0, 100% 48%, 90% 48%, 90% 100%, 0 100%); }
[data-animal="narwhal"] {
  --sprite-scale: 270% 200%;
  --sprite-crop: polygon(13% 0, 100% 0, 100% 100%, 0 100%, 0 48%, 13% 48%);
}
