:root {
  --red: #e60012;
  --red-dark: #b5000e;
  --cream: #fffaf4;
  --ink: #1d1d1d;
  --gold: #ffc72c;
  --grass: #8fd16a;
  --ground-h: 17vh;
  --display: "Baloo 2", "ZCOOL KuaiLe", system-ui, sans-serif;
  --cn: "ZCOOL KuaiLe", "Baloo 2", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--display); color: var(--ink); background: var(--cream); }

/* ---------- scene ---------- */
.scene { overflow: hidden; position: relative; min-height: 100vh; }

.sky {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(1200px 500px at 15% 110%, #ffe3ea 0%, transparent 60%),
    linear-gradient(180deg, #9fdcff 0%, #cdeeff 45%, #fff1f4 100%);
}
.sun {
  position: absolute; top: 9vh; left: 8vw; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff6c9, var(--gold));
  box-shadow: 0 0 0 14px #ffe58a55, 0 0 0 30px #ffe58a2a;
  animation: pulse 4s ease-in-out infinite;
}
.cloud {
  position: absolute; background: #fff; border-radius: 999px; height: 46px;
  box-shadow: 0 6px 0 #e9f6ff; animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 60px; height: 60px; top: -30px; left: 22px; }
.cloud::after  { width: 44px; height: 44px; top: -20px; left: 70px; }
.c1 { width: 150px; top: 16vh; animation-duration: 60s; animation-delay: -10s; }
.c2 { width: 120px; top: 30vh; animation-duration: 80s; animation-delay: -45s; }
.c3 { width: 170px; top: 8vh;  animation-duration: 70s; animation-delay: -30s; }

.flakes span {
  position: absolute; top: -5vh; left: var(--x); color: #fff;
  font-size: calc(var(--s) * 22px); text-shadow: 0 0 6px #9fdcff;
  animation: fall var(--d) linear infinite; animation-delay: var(--delay);
}

.title { position: relative; z-index: 6; text-align: center; padding-top: 5vh; animation: drop-in .9s cubic-bezier(.2, 1.6, .4, 1) both; }
.title h1 { margin: 0; line-height: .9; }
.title .cn {
  display: block; font-family: var(--cn); font-weight: 400; color: var(--red);
  font-size: clamp(3rem, 9vw, 7rem); letter-spacing: .08em;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 6px 6px 0 #fff, 9px 9px 0 var(--ink);
}
.title .en {
  display: inline-block; margin-top: .6rem; padding: .1rem 1.2rem .25rem;
  background: var(--ink); color: #fff; border-radius: 999px; transform: rotate(-2deg);
  font-size: clamp(1rem, 2.4vw, 1.6rem); font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.tagline { font-weight: 700; color: var(--red-dark); margin: .8rem 0 0; font-size: 1.05rem; }

.hills { position: absolute; left: 0; right: 0; bottom: calc(var(--ground-h) - 4vh); height: 30vh; z-index: 1; }
.hill { position: absolute; bottom: 0; border-radius: 50% 50% 0 0; border: 4px solid var(--ink); border-bottom: 0; }
.h1 { left: -8vw; width: 55vw; height: 22vh; background: #f4fbff; }
.h2 { left: 30vw; width: 50vw; height: 16vh; background: #ffffff; }
.h3 { right: -12vw; width: 50vw; height: 26vh; background: #eef8ff; }

.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--ground-h); z-index: 2;
  background:
    repeating-linear-gradient(90deg, transparent 0 60px, #ffffff55 60px 64px),
    linear-gradient(180deg, var(--grass) 0 14%, #f6e3c8 14% 100%);
  border-top: 4px solid var(--ink);
}

/* ---------- store ---------- */
.store {
  position: absolute; z-index: 3; right: 5vw; bottom: calc(var(--ground-h) - 14px);
  width: min(38vw, 470px); padding: 0; border: 0; background: none; cursor: pointer;
  transform-origin: bottom center; transition: transform .25s cubic-bezier(.2, 1.8, .4, 1);
}
.store:hover, .store:focus-visible { transform: scale(1.04) rotate(-1deg); outline: none; }
.store-svg {
  width: 100%; display: block; overflow: visible; transform-origin: bottom center;
  filter: drop-shadow(8px 8px 0 #1d1d1d33);
  animation: pop-in .9s .3s cubic-bezier(.2, 1.6, .4, 1) both;
}
.store-cn { font-family: var(--cn); font-size: 64px; fill: #fff; letter-spacing: 6px; }
.slogan { font-family: var(--cn); font-size: 21px; fill: #fff; letter-spacing: 2px; }
.rec-text { font-family: var(--cn); font-size: 19px; fill: #fff; }
.lights text { font-family: var(--display); font-size: 15px; fill: #fff; }
.open-sign { transform-origin: 222px 174px; animation: swing 2.4s ease-in-out infinite; }
.open-text { font-weight: 800; font-size: 13px; fill: var(--red); animation: blink 1.2s steps(2) infinite; }
.psst {
  position: absolute; left: -2.5rem; top: -2.4rem; z-index: 2; white-space: nowrap;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px 18px 18px 4px;
  padding: .2rem .8rem; font: 800 1rem var(--display); color: var(--red);
  animation: nudge 1.4s ease-in-out infinite;
}
.psst b { display: inline-block; animation: bounce-y .7s ease-in-out infinite alternate; }

/* ---------- parade ---------- */
.parade {
  position: absolute; z-index: 4; left: 0; bottom: 3vh;
  display: flex; align-items: flex-end; gap: 26px;
  animation: parade 18s linear infinite; pointer-events: none;
}
.runner { position: relative; transform-origin: bottom center; animation: waddle .46s ease-in-out infinite alternate; }
.r-cap    { animation-delay: -.15s; }
.r-phones { animation-delay: -.3s; }
.r-king   { animation-duration: .52s; }
.char { display: block; }
.buddy { width: 92px; overflow: visible; }
.king { width: 128px; filter: drop-shadow(0 6px 0 #1d1d1d22); }
.arm { transform-box: fill-box; transform-origin: center; animation: flap .3s ease-in-out infinite alternate; }
.arm-r { animation-direction: alternate-reverse; }
.bubble {
  position: absolute; top: -34px; left: 70px; white-space: nowrap;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px 16px 16px 4px;
  padding: 0 .7rem; font-weight: 800; color: var(--red);
  animation: chat 6s ease-in-out infinite;
}

.ticker {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; overflow: hidden;
  background: var(--red); color: #fff; border-top: 3px solid var(--ink);
  font-weight: 800; letter-spacing: .06em; font-size: .95rem;
}
.ticker-track { display: flex; width: max-content; animation: marquee 30s linear infinite; padding: .25rem 0; }
.ticker-track span { padding-right: 2rem; white-space: nowrap; }

/* ---------- counter dialog ---------- */
.counter {
  width: min(960px, 94vw); max-height: 90vh; padding: 0; border: 4px solid var(--ink);
  border-radius: 28px; background: var(--cream); color: var(--ink);
  box-shadow: 12px 12px 0 var(--ink); overflow: hidden;
}
.counter[open] { animation: pop-in .45s cubic-bezier(.2, 1.6, .4, 1) both; display: flex; flex-direction: column; }
.counter::backdrop { background: #e6001255; backdrop-filter: blur(3px); }
.counter-head {
  display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem;
  background: repeating-linear-gradient(90deg, var(--red) 0 40px, #fff 40px 80px);
  border-bottom: 4px solid var(--ink);
}
.counter-head > div { background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: .2rem 1rem; }
.counter-head h2 { margin: 0; font-size: 1.6rem; color: var(--red); line-height: 1.2; }
.counter-head p { margin: 0; font-weight: 700; font-size: .9rem; }
.close {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--gold);
  font-size: 1.2rem; font-weight: 800; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}
.close:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.tabs { display: flex; gap: .5rem; padding: 1rem 1.5rem 0; }
.tab {
  font: 800 1rem var(--display); padding: .35rem 1.1rem; cursor: pointer;
  border: 3px solid var(--ink); border-bottom: 0; border-radius: 14px 14px 0 0; background: #fff; color: var(--ink);
}
.tab.active { background: var(--red); color: #fff; }
.panel { display: none; padding: 1.2rem 1.5rem 1.5rem; border-top: 3px solid var(--ink); overflow-y: auto; }
.panel.active { display: block; }
.panel-note { margin: 0 0 1rem; font-weight: 700; color: var(--red-dark); }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; align-items: start; }
.treat {
  position: relative; text-align: left; font-family: var(--display); color: var(--ink); cursor: pointer;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: .9rem 1rem 1rem;
  box-shadow: 5px 5px 0 var(--ink); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: .15rem;
}
.treat:hover { transform: translate(-2px, -2px) rotate(-1deg); box-shadow: 7px 7px 0 var(--red); }
.treat.wide { grid-column: 1 / -1; }
.treat .emoji { font-size: 2rem; line-height: 1; }
.treat b { font-size: 1.1rem; }
.treat i { font-style: normal; font-weight: 800; color: var(--red); }
.treat em {
  font-style: normal; font-size: .92rem; font-weight: 600; line-height: 1.35;
  max-height: 0; overflow: hidden; opacity: 0; transition: max-height .35s, opacity .35s, margin .35s;
}
.treat.open { background: #fff5d6; }
.treat.open em { max-height: 200px; opacity: 1; margin-top: .4rem; }
.treat code { background: var(--ink); color: var(--gold); padding: 0 .3rem; border-radius: 4px; }

.player {
  display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; border-radius: 18px; padding: .7rem 1rem; margin-bottom: 1rem;
}
.now { display: flex; align-items: center; gap: .6rem; font-weight: 800; }
.disc { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
.player.playing .disc { animation: spin 1.6s linear infinite; }
.player audio { height: 36px; flex: 1 1 260px; }

.shelf-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  font: 800 .85rem var(--display); padding: .15rem .8rem; border-radius: 999px; cursor: pointer;
  border: 2.5px solid var(--ink); background: #fff; color: var(--ink);
}
.chip.active { background: var(--ink); color: var(--gold); }
.shuffle-note { font-weight: 700; font-size: .85rem; color: var(--red-dark); }

.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 1.1rem 0;
  padding: 1rem; border: 3px solid var(--ink); border-radius: 18px; background: #fff; min-height: 160px;
}
.loading { grid-column: 1 / -1; text-align: center; font-weight: 800; color: var(--red); }
.item {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .1rem;
  padding: 0 .3rem .4rem; border-bottom: 7px solid #c9b8a6; box-shadow: 0 3px 0 var(--ink);
  animation: stock .4s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(var(--i) * 25ms);
}
.item[hidden] { display: none; }
.item .play { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; align-items: center; }
.item svg { width: 52px; height: 66px; transition: transform .15s; }
.item .play:hover svg { transform: translateY(-5px) rotate(-6deg); }
.item.playing svg { animation: wiggle .4s ease-in-out infinite alternate; }
.item .name { font-weight: 800; font-size: .8rem; line-height: 1.1; margin-top: .2rem; }
.item .cn { font-family: var(--cn); font-size: .75rem; color: #6b5b55; }
.item .price { font-weight: 800; font-size: .8rem; color: var(--red); margin-top: auto; }
.item .dl {
  margin-top: .15rem; font-size: .7rem; font-weight: 800; color: #fff; background: var(--red);
  border-radius: 999px; padding: 0 .55rem; text-decoration: none; border: 2px solid var(--ink);
}
.item .dl:hover { background: var(--ink); color: var(--gold); }
.bundle {
  display: inline-block; margin-top: 1rem; padding: .45rem 1.1rem; border-radius: 999px; text-decoration: none;
  background: var(--gold); color: var(--ink); font-weight: 800; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}

.card {
  max-width: 420px; margin: .5rem auto; padding: 1.3rem 1.5rem; border-radius: 22px; color: #fff;
  background: radial-gradient(circle at 85% 15%, #ff5a68, var(--red) 45%, var(--red-dark));
  border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); transform: rotate(-2deg);
}
.card-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; letter-spacing: .12em; }
.card-chip { width: 48px; height: 56px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; border: 2px solid var(--ink); }
.card-name { font-size: 2rem; font-weight: 800; margin: 1rem 0 0; }
.card-tier { font-weight: 700; letter-spacing: .1em; }
.card-tier b { color: var(--gold); text-transform: uppercase; }
.tiers { margin: 1rem 0 0; padding: .6rem 1rem .6rem 2rem; background: #ffffff22; border-radius: 12px; font-weight: 700; }
.tiers li.current { color: var(--gold); }
.tiers li.current::after { content: "  ← you"; }

/* ---------- vault & denied ---------- */
.vault-page, .denied-page {
  min-height: 100vh; display: grid; place-items: center; padding: 4rem 1rem;
  background:
    radial-gradient(circle at 50% 0%, #ff3b4c 0%, transparent 55%),
    repeating-linear-gradient(45deg, #b5000e 0 22px, #a3000c 22px 44px);
}
.denied-page main { text-align: center; }
.guard { width: 190px; margin: 0 auto -8px; display: block; animation: waddle .6s ease-in-out infinite alternate; transform-origin: bottom center; }
.denied-box, .scroll {
  position: relative; background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 12px 12px 0 var(--ink); text-align: center;
}
.denied-box { padding: 1.5rem 2rem; max-width: 520px; }
.denied-box h1 { margin: 0; color: var(--red); font-size: 2.4rem; }
.denied-box .tier { display: inline-block; padding: .1rem .8rem; border-radius: 999px; background: var(--ink); color: var(--gold); font-weight: 800; }
.back { display: inline-block; margin-top: 1rem; font-weight: 800; color: var(--red); }

.scroll { max-width: 860px; width: 100%; padding: 2rem 2.4rem 2.2rem; background: linear-gradient(180deg, #fff6df, #fbe7bd); }
.scroll::before, .scroll::after {
  content: ""; position: absolute; left: -18px; right: -18px; height: 28px; border-radius: 14px;
  background: linear-gradient(180deg, #d79b4a, #a8692a); border: 4px solid var(--ink);
}
.scroll::before { top: -18px; }
.scroll::after { bottom: -18px; }
.scroll-king { width: 96px; display: block; margin: 0 auto; }
.scroll h1 { margin: .2rem 0 0; font-family: var(--cn); font-weight: 400; color: var(--red); font-size: 2.6rem; }
.scroll .seal-note { margin: .2rem 0 1.2rem; font-weight: 700; color: var(--red-dark); }
.scroll pre {
  text-align: left; white-space: pre-wrap; word-break: break-word; margin: 0;
  font: 600 1rem/1.6 "Courier Prime", "Courier New", monospace; color: #3a2414;
  background: #ffffff66; border: 2px dashed #a8692a; border-radius: 12px; padding: 1.2rem 1.4rem;
}

/* ---------- keyframes ---------- */
@keyframes parade { from { transform: translateX(-110%); } to { transform: translateX(105vw); } }
@keyframes waddle {
  from { transform: translateY(0) rotate(-7deg) scale(1.03, .97); }
  to   { transform: translateY(-16px) rotate(7deg) scale(.98, 1.02); }
}
@keyframes flap { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes chat { 0%, 55%, 100% { opacity: 0; transform: scale(.6); } 62%, 92% { opacity: 1; transform: scale(1); } }
@keyframes drift { from { left: -220px; } to { left: 105vw; } }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(110vh) rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes swing { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes nudge { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes bounce-y { to { transform: translateY(4px); } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wiggle { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes stock { from { opacity: 0; transform: translateY(14px) scale(.8); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-60px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } }

@media (max-width: 760px) {
  :root { --ground-h: 14vh; }
  .store { width: min(80vw, 340px); right: 50%; transform: translateX(50%); }
  .store:hover, .store:focus-visible { transform: translateX(50%) scale(1.04); }
  .psst { left: 0; }
  .king { width: 92px; } .buddy { width: 64px; }
  .h2 { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
  .parade { transform: translateX(8vw); }
}
