:root {
  --ink: #2b2b3a;
  --accent: #ff8a3d;
  --good: #3bb54a;
  --bad: #e5484d;
  --shadow: rgba(0, 0, 0, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.15rem;
  color: var(--ink);
  background: linear-gradient(#bfe9ff, #e6f7ff 40%, #fff3d6) fixed;
  min-height: 100vh;
}
main { max-width: 1000px; margin: 0 auto; padding: 16px; }
h2, h3 { margin: 0 0 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(6px);
  box-shadow: 0 2px 0 var(--shadow);
}
.topbar nav { display: flex; gap: 8px; }
.logo { font-weight: 800; font-size: 1.6rem; color: var(--ink); text-decoration: none; display: inline-block; }
.logo:hover { animation: wiggle .5s; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 16px;
  background: #fff; box-shadow: 0 4px 0 var(--shadow); cursor: pointer;
  transition: transform .1s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.btn.big { font-size: 1.3rem; padding: 12px 22px; background: var(--accent); color: #fff; }
.btn.big.on { background: var(--good); animation: pulse 1s infinite; }
:focus-visible { outline: 4px solid #2a7fff; outline-offset: 3px; }

/* ---------- home grid ---------- */
.subtitle { text-align: center; font-size: 1.4rem; font-weight: 700; margin: 4px 0 16px; animation: pop-in .6s; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: #fff; border-radius: 24px; padding: 12px; color: inherit; text-decoration: none;
  border-bottom: 8px solid var(--c);
  box-shadow: 0 6px 16px var(--shadow);
  animation: pop-in .5s backwards; animation-delay: calc(var(--i) * 70ms);
  transition: transform .2s;
}
.card:hover, .card:focus-visible { transform: translateY(-6px) rotate(-1.5deg); }
.card .dino { width: 100%; height: auto; }
.card-name { font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.card-meaning { font-size: .95rem; opacity: .7; }

/* ---------- dino part animations ---------- */
.dino { overflow: visible; display: block; }
.dino .tail { animation: sway 2.4s ease-in-out infinite; }
.dino .head { animation: bob 3s ease-in-out infinite; }
.walking .leg-a, .card:hover .leg-a { animation: step .8s ease-in-out infinite; }
.walking .leg-b, .card:hover .leg-b { animation: step .8s ease-in-out -.4s infinite; }
.dino.walking, .card:hover .dino { animation: bounce .4s ease-in-out infinite; }
.dino.pterosaur { animation: glide 1.4s ease-in-out infinite; }
.pterosaur .wing-l { animation: flap-l .7s ease-in-out infinite; }
.pterosaur .wing-r { animation: flap-r .7s ease-in-out infinite; }
.dino.mosasaur { animation: swim 2s ease-in-out infinite; }
.mosasaur .tail { animation: sway .8s ease-in-out infinite; }
.mosasaur .bubble { animation: bubble 2s ease-in infinite; }
.mosasaur .bubble.b2 { animation-delay: -1s; }
.dino.roaring { animation: shake .25s 4; }
.roaring .jaw { animation: jaw 1.1s ease-out; }
.roaring .head { animation: roar-head 1.1s ease-out; }

@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
@keyframes bob { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
@keyframes step { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
@keyframes bounce { 50% { transform: translateY(-3px); } }
@keyframes glide { 50% { transform: translateY(-8px); } }
@keyframes flap-l { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(24deg); } }
@keyframes flap-r { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-24deg); } }
@keyframes swim { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-4px); } }
@keyframes bubble { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }
@keyframes jaw { 15%, 70% { transform: rotate(24deg); } }
@keyframes roar-head { 15%, 70% { transform: rotate(-10deg) translate(2px, -3px); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- detail stage ---------- */
.stage {
  position: relative; overflow: hidden;
  height: clamp(240px, 45vw, 380px); margin: 12px 0;
  border-radius: 28px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .1);
  background: linear-gradient(#8fd3ff, #d8f3ff);
}
.scene-sky { background: linear-gradient(#ffb36b, #ffe2b8 70%); }
.scene-sea { background: linear-gradient(#4cb6ea, #0d4f8b); }
.sun {
  position: absolute; top: 18px; right: 24px; width: 60px; height: 60px; border-radius: 50%;
  background: #ffd84a; box-shadow: 0 0 0 12px rgba(255, 216, 74, .35);
  animation: pulse 4s ease-in-out infinite;
}
.cloud {
  position: absolute; top: 34px; left: -140px; width: 110px; height: 34px; border-radius: 40px;
  background: #fff; opacity: .9; animation: drift 32s linear infinite;
}
.cloud::before { content: ''; position: absolute; top: -24px; left: 22px; width: 50px; height: 50px; border-radius: 50%; background: #fff; }
.cloud.c2 { top: 90px; animation-duration: 48s; animation-delay: -24s; }
.volcano {
  position: absolute; bottom: 20%; left: 6%; width: 0; height: 0;
  border: 0 solid transparent; border-width: 0 70px 110px; border-bottom-color: #8b5a3c;
}
.smoke {
  position: absolute; top: -18px; left: -16px; width: 32px; height: 32px; border-radius: 50%;
  background: #9a9a9a; opacity: 0; animation: smoke 3s ease-out infinite;
}
.smoke.s2 { animation-delay: -1.5s; }
.ground { position: absolute; inset: auto 0 0; height: 22%; background: #7cc46a; border-top: 6px solid #5fa35a; }
.scene-sky .ground { background: #2f8fc4; border-top-color: #bfe0ff; }
.scene-sea .ground { background: #e9d39a; border-top-color: #d1b874; height: 14%; }
.plant { position: absolute; bottom: 16%; font-size: 3rem; transform-origin: bottom center; animation: sway 3s ease-in-out infinite; }
.plant.p1 { right: 5%; }
.plant.p2 { left: 42%; font-size: 2.2rem; animation-delay: -1s; }
.scene-sea .plant { bottom: 8%; }
.walker {
  position: absolute; bottom: 6%; left: 0; width: min(46%, 320px);
  padding: 0; border: 0; background: none; cursor: pointer;
  animation: patrol 18s linear infinite;
}
.walker .flip { display: block; animation: flip 18s linear infinite; }
.walker.paused, .walker.paused .flip { animation-play-state: paused; }
.scene-sky .walker { bottom: 30%; animation: patrol 14s linear infinite, soar 5s ease-in-out infinite; }
.scene-sky .walker .flip { animation-duration: 14s; }
.scene-sky .walker.paused { animation-play-state: paused; }
.walking.pterosaur { animation: bank 2.5s ease-in-out infinite; }
.walking.pterosaur .wing-l, .walking.pterosaur .wing-r { animation-duration: .45s; }
.scene-sea .walker { bottom: 22%; }
.tap-hint {
  position: absolute; top: 12px; left: 12px; padding: 4px 12px; border-radius: 999px;
  background: #fff; font-weight: 800; animation: bounce 1s ease-in-out infinite; pointer-events: none;
}
@keyframes drift { to { left: 110%; } }
@keyframes smoke { 0% { opacity: .8; transform: translateY(0) scale(.6); } 100% { opacity: 0; transform: translateY(-70px) scale(2); } }
@keyframes patrol { 50% { left: calc(100% - min(46%, 320px)); } }
@keyframes soar { 0%, 100% { bottom: 22%; } 35% { bottom: 52%; } 60% { bottom: 40%; } }
@keyframes bank { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-10px); } }
@keyframes flip { 0%, 49.9% { transform: scaleX(1); } 50%, 99.9% { transform: scaleX(-1); } }

/* ---------- detail info ---------- */
.dino-name { font-size: clamp(2rem, 7vw, 3rem); line-height: 1.1; animation: pop-in .5s; }
.badge { display: inline-block; margin: 6px 0; padding: 4px 14px; border-radius: 999px; background: #ffe066; font-weight: 800; animation: wiggle 1.5s ease-in-out infinite; }
.meaning { font-size: 1.3rem; margin: 4px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.chip {
  background: #fff; border-radius: 18px; padding: 10px 14px; box-shadow: 0 4px 0 var(--shadow);
  animation: pop-in .4s backwards; animation-delay: calc(var(--i) * 80ms);
}
.chip small { display: block; font-size: .85rem; opacity: .6; }
.panel { background: #fff; border-radius: 24px; padding: 16px 20px; margin: 16px 0; box-shadow: 0 6px 0 var(--shadow); }
.desc { font-size: 1.25rem; line-height: 1.6; margin: 0; }
.size-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; margin: 10px 0; }
.size-row .who { font-size: 2.6rem; text-align: center; }
.size-row .dino { width: 64px; }
.bar { height: 26px; width: var(--w); min-width: 26px; border-radius: 999px; background: var(--c); animation: grow 1.4s ease-out backwards; }
.bar-label { grid-column: 2; font-size: .95rem; margin-top: -8px; opacity: .75; }
.facts { padding: 0; margin: 0; }
.facts li {
  list-style: none; margin: 8px 0; padding: 10px 14px; border-radius: 16px; background: #fff7d6;
  animation: slide-in .5s backwards; animation-delay: calc(var(--i) * 150ms + .3s);
}
.facts li::before { content: '🦴 '; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin: 24px 0; }
@keyframes grow { from { width: 0; min-width: 0; } }

/* ---------- quiz ---------- */
.quiz { text-align: center; }
.dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.dots span { width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #0002; }
.dots .done { background: var(--accent); }
.question { font-size: 1.8rem; margin: 8px 0; animation: pop-in .4s; }
.q-art { max-width: 340px; margin: 0 auto; }
.q-art .dino { transition: filter .8s; }
.silhouette .dino { filter: brightness(0) opacity(.75); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.opt {
  font: inherit; font-size: 1.2rem; font-weight: 800; color: var(--ink);
  padding: 14px; border-radius: 20px; border: 4px solid transparent; background: #fff;
  box-shadow: 0 5px 0 var(--shadow); cursor: pointer;
  animation: pop-in .4s backwards; animation-delay: calc(var(--i) * 90ms);
}
.opt:disabled { cursor: default; }
.opt .dino { width: 100%; }
.opt.right { border-color: var(--good); background: #e5ffe8; animation: tada .6s; }
.opt.wrong { border-color: var(--bad); background: #ffe8e8; animation: shake .2s 2; }
.feedback { font-size: 1.4rem; font-weight: 800; min-height: 2.2em; }
.stars { font-size: 3rem; animation: pop-in .6s; }
.confetti { position: fixed; top: -16px; z-index: 20; width: 10px; height: 14px; pointer-events: none; animation: fall 2.2s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
@keyframes tada { 30% { transform: scale(1.1) rotate(-3deg); } 60% { transform: scale(1.1) rotate(3deg); } }

/* ---------- shared ---------- */
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-24px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes pulse { 50% { transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
