:root {
  --ink: #2b2118;
  --accent: #ff8c42;
  --accent-ink: #ffffff;
  --card: #ffffff;
  --focus: #1d4ed8;
  --sky: #bfe6ff;
  --ground: #9bd770;
  --radius: 24px;
  --tap: 64px;
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-size: 20px;
  background: linear-gradient(var(--sky) 0 58%, var(--ground) 58% 100%) fixed;
  transition: background 0.3s;
}

/* Illustrated scenery behind every screen; layers are pinned to different edges. */
#scenery { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#scenery svg { position: absolute; display: block; }
#scenery .sc-sky { inset: 0; width: 100%; height: 100%; }
#scenery .sc-top { top: 0; left: 0; width: 100%; height: 32%; }
#scenery .sc-ground { bottom: 0; left: 0; width: 100%; height: 45%; }
#scenery .sc-left { bottom: 0; left: 0; width: 42%; height: 58%; }
#scenery .sc-right { bottom: 0; right: 0; width: 42%; height: 58%; }
#scenery .sc-floor { bottom: 0; left: 0; width: 100%; height: 12%; }

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.screen { display: flex; flex-direction: column; gap: 16px; }

h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(28px, 6vw, 48px);
  text-shadow: 0 2px 0 #fff;
}
h1:focus { outline: none; }
h2 { margin: 8px 0 0; font-size: 26px; }

/* Titles sit on a soft card so they stay readable over every scene. */
.screen > h1,
.screen > h2 {
  align-self: center;
  padding: 4px 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

button {
  font: inherit;
  color: inherit;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 8px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
button:disabled { opacity: 0.35; cursor: default; transform: none; }
/* Locked buttons stay solid so they read clearly over the scenery. */
button[aria-disabled="true"] { background: #f1ebe4; color: #6b5f54; box-shadow: none; cursor: default; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 28px;
  font-weight: 800;
  padding: 12px 40px;
}
.btn-danger { background: #d62828; color: #fff; }

.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 800; }

/* Bruno */
.bruno { display: flex; align-items: flex-end; gap: 12px; }
.bruno-face {
  flex: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.bruno-face svg { display: block; width: 72px; height: 97px; overflow: visible; animation: bruno-float 3s ease-in-out infinite; }
.bruno-wave { transform-origin: 98px 74px; animation: bruno-wave 1.6s ease-in-out infinite; }
.bruno-eyes { transform-box: fill-box; transform-origin: center; animation: bruno-blink 4s infinite; }
.bubble.pop { animation: bubble-pop 0.35s ease-out; }
@keyframes bruno-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}
@keyframes bruno-wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-25deg); }
}
@keyframes bruno-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
@keyframes bubble-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Welcome screen: the zoo entrance. Overlay positions match the gate's 420x340 viewBox. */
.entrance { align-items: center; }
.entrance-layout { display: grid; gap: 12px; width: 100%; justify-items: center; }
.entrance-layout .bruno { width: 100%; max-width: 560px; }
.gate {
  position: relative;
  width: min(100%, calc((100vh - 260px) * 420 / 340), 640px);
  min-width: min(100%, 300px);
  aspect-ratio: 420 / 340;
  container-type: inline-size;
}
.gate > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gate-sign {
  position: absolute;
  left: 22.9%;
  width: 54.3%;
  top: 2.9%;
  height: 15.9%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 4.4cqw;
  line-height: 1.1;
  text-shadow: 0 2px 0 #5d3a1a;
}
.gate-topper { position: absolute; bottom: 71.8%; width: 13cqw; height: 13cqw; font-size: 9cqw; line-height: 1; transform: translateX(-50%); }
.gate-topper-left { left: 17.9%; }
.gate-topper-right { left: 82.1%; }
.gate-enter {
  position: absolute;
  left: 50%;
  bottom: 20%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: max(22px, 5cqw);
}
.gate-enter:active { transform: translateX(-50%) translateY(2px); }
.gate-door { transition: transform 0.8s ease-in-out; transform-box: fill-box; }
.gate-door-left { transform-origin: left center; }
.gate-door-right { transform-origin: right center; }
.opening .gate-door { transform: scaleX(0.1); }
.opening .gate-enter { opacity: 0; transition: opacity 0.3s; }

@media (orientation: landscape) and (min-width: 700px) {
  .entrance-layout { grid-template-columns: minmax(200px, 300px) minmax(300px, 640px); align-items: end; justify-content: center; }
  .entrance-layout .bruno { flex-direction: column; align-items: flex-start; }
  .entrance-layout .bruno .bubble::before { left: 36px; top: -12px; bottom: auto; border: 12px solid transparent; border-bottom-color: #fff; border-top: 0; }
  .entrance-layout .bruno-face svg { width: 96px; height: 130px; }
  .gate { width: min(100%, calc((100vh - 160px) * 420 / 340), 640px); }
}
.bubble {
  position: relative;
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  background: #fff;
  border-radius: var(--radius);
  font-size: 22px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}
.bruno .bubble::before {
  content: "";
  position: absolute;
  left: -12px;
  bottom: 18px;
  border: 12px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}

/* Grids and tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }

.zone-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 170px;
  font-size: 22px;
  font-weight: 800;
  background: var(--zone-color, #fff);
}
.zone-tile .art, .zone-tile .icon-lock { width: 72px; height: 72px; }
.zone-tile .sub { font-size: 18px; font-weight: 600; }
.zone-tile.locked { filter: grayscale(1); opacity: 0.75; }

.animal-btn { position: relative; min-height: 150px; font-size: 96px; line-height: 1; }
.animal-btn .art { width: 108px; height: 108px; }
.animal-btn .check {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 26px;
  background: #2a9d4b;
  color: #fff;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}

/* Bundled artwork and icons */
.art { display: block; object-fit: contain; user-select: none; }
.art-fallback { display: inline-grid; place-items: center; line-height: 1; }
.icon { width: 1.25em; height: 1.25em; flex: none; }
button > .icon { width: 1.6em; height: 1.6em; }
.title-art { display: inline-block; width: 1.3em; height: 1.3em; vertical-align: -0.28em; margin-right: 0.3em; }
.flag { width: 30px; height: 20px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); flex: none; }
.stars-row { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars-row .icon { width: 1em; height: 1em; }
.icon-star { color: #f4b400; }
.icon-starEmpty { color: #b9a68a; }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.zone-tile .sub { display: inline-flex; align-items: center; gap: 4px; }
.animal-btn .check .icon { width: 22px; height: 22px; }

/* Explore card */
.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}
.card {
  width: 100%;
  max-width: 540px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  background: #fff;
  border-radius: 32px;
  text-align: center;
}
.card .art-big { width: 150px; height: 150px; font-size: 128px; }
.card .name { margin: 0; font-size: 48px; font-weight: 800; }
.card .bubble { background: #fff6e0; }
.card .bruno .bubble::before { border-right-color: #fff6e0; }

/* Quiz */
.question-visual { display: flex; justify-content: center; font-size: 110px; }
.question-visual .art { width: 140px; height: 140px; }
.replay { min-height: 110px; min-width: 140px; }
.replay .icon { width: 56px; height: 56px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 150px;
  font-size: 22px;
  font-weight: 800;
}
.choice .art { width: 92px; height: 92px; font-size: 80px; }
.choice .icon { width: 64px; height: 64px; }
.choice .icon-thumbsUp { color: #2a9d4b; }
.choice .icon-thumbsDown { color: #c0392b; }
.choice.correct { background: #b7f5c4; }
.progress-text { font-weight: 800; }

/* Results */
.stars { display: flex; justify-content: center; font-size: 56px; }
.unlocked { text-align: center; font-weight: 800; background: #fff3b0; }

/* Stickers */
.sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 8px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  text-align: center;
  font-weight: 700;
}
.sticker .art { width: 72px; height: 72px; font-size: 56px; }
.sticker.unknown .art { filter: brightness(0); opacity: 0.2; }
.sticker.unknown .label { opacity: 0.6; }

/* Settings */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #fff;
  border-radius: 20px;
}
.credits { padding: 16px; background: #fff; border-radius: 20px; font-size: 16px; }
.credits ul { padding-left: 20px; margin: 8px 0 0; }
.credits li { margin-bottom: 6px; }
.credits a { color: var(--focus); }

.credit-art { display: inline-block; width: 1.5em; height: 1.5em; vertical-align: -0.4em; margin-right: 0.3em; }
.unlocked { display: flex; align-items: center; justify-content: center; gap: 8px; }
.icon-celebrate { color: #ff8c42; }
h1 > .icon { width: 1em; height: 1em; margin-right: 0.3em; vertical-align: -0.12em; }

@media (max-width: 480px) {
  body { font-size: 18px; }
  #app { padding: 12px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .animal-btn { min-height: 120px; font-size: 76px; }
  .animal-btn .art { width: 84px; height: 84px; }
  .bruno-face svg { width: 56px; height: 76px; }
  .bubble { font-size: 19px; }
  .choices { grid-template-columns: 1fr; }
  .choice { flex-direction: row; gap: 12px; min-height: 96px; }
  .choice .art { width: 64px; height: 64px; font-size: 56px; }
  .choice .icon { width: 48px; height: 48px; }
  .card .art-big { width: 112px; height: 112px; font-size: 96px; }
  .card .name { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  button:active { transform: none; }
  .bruno-face svg, .bruno-wave, .bruno-eyes, .bubble.pop { animation: none; }
}
