:root {
  --cream: #fff8df;
  --paper: #fffdf2;
  --ink: #3f4932;
  --green: #4f8d55;
  --green-dark: #377443;
  --green-light: #a8cf74;
  --orange: #f28737;
  --orange-dark: #ce5b29;
  --yellow: #f7c84b;
  --coral: #f47f69;
  --blue: #73b9cf;
  --shadow: rgba(79, 90, 50, 0.22);
  --rough-border: 3px solid rgba(72, 88, 55, 0.64);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: #eaf0c8;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "Comic Sans MS", cursive;
  background:
    linear-gradient(rgba(255, 249, 217, 0.76), rgba(239, 246, 202, 0.82)),
    url("assets/meadow-storybook.png") center / cover fixed;
}

button {
  color: inherit;
  font: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible {
  outline: 4px dashed #e47a3e;
  outline-offset: 4px;
}

.paper-grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(80, 73, 45, 0.22) 0 0.7px, transparent 0.9px),
    radial-gradient(circle at 80% 60%, rgba(255, 255, 255, 0.9) 0 0.8px, transparent 1px);
  background-size: 5px 5px, 7px 7px;
  mix-blend-mode: multiply;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 34px));
  margin: 0 auto;
  padding-bottom: 50px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 14px 8px;
}

.brand-button,
.round-action,
.sticker-book-button,
.back-button,
.text-button {
  border: 0;
  background: transparent;
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
  text-align: left;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 57px;
  height: 50px;
  place-items: center;
  border: 3px solid #496543;
  border-radius: 50% 47% 45% 52%;
  background: #fffaf1;
  box-shadow: 3px 4px 0 rgba(59, 98, 55, 0.2);
}

.mini-ear {
  position: absolute;
  top: -17px;
  width: 15px;
  height: 30px;
  border: 3px solid #496543;
  border-bottom: 0;
  border-radius: 60% 60% 20% 20%;
  background: #fffaf1;
  transform-origin: bottom;
}

.mini-ear-left {
  left: 9px;
  transform: rotate(-13deg);
}

.mini-ear-right {
  right: 9px;
  transform: rotate(12deg);
}

.mini-face {
  position: relative;
  top: 1px;
  font-size: 18px;
  letter-spacing: 2px;
}

.brand-button strong {
  display: block;
  font-size: 23px;
  letter-spacing: 2px;
}

.brand-button small {
  display: block;
  margin-top: 2px;
  color: #6c7c54;
  font-size: 13px;
  letter-spacing: 3px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-action {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px dashed rgba(68, 92, 57, 0.42);
  border-radius: 22px 18px 20px 16px;
  background: rgba(255, 253, 236, 0.78);
  font-weight: 700;
}

.round-action.is-muted #soundIcon::after {
  content: "╱";
  margin-left: -7px;
  color: var(--coral);
}

#soundIcon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
}

.sticker-book-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid #c36a38;
  border-radius: 13px 18px 14px 20px;
  background: #f8a95a;
  box-shadow: 3px 4px 0 #b85d32;
  color: #64351f;
  font-weight: 800;
  transform: rotate(0.5deg);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.sticker-book-button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 4px 6px 0 #b85d32;
}

.book-icon {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 2px solid #7a4b26;
  border-radius: 4px 9px 9px 4px;
  background: #fff2a8;
  color: #e67f35;
}

.sticker-book-button b {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 248, 213, 0.72);
  font-size: 13px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: page-in 450ms cubic-bezier(0.18, 0.8, 0.22, 1) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: 1.03fr 0.97fr;
  min-height: 460px;
  overflow: hidden;
  border: var(--rough-border);
  border-radius: 48px 28px 54px 30px;
  background: rgba(255, 252, 229, 0.88);
  box-shadow: 9px 12px 0 rgba(93, 119, 65, 0.17), 0 28px 70px rgba(71, 90, 45, 0.16);
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  border: 2px dashed rgba(99, 119, 63, 0.25);
  border-radius: 39px 22px 46px 25px;
}

.hero-copy {
  position: relative;
  z-index: 2;
  align-self: center;
  padding: 64px 36px 54px 8.5vw;
}

.eyebrow,
.tiny-label,
.mission-label,
.reward-kicker {
  color: #dd6c32;
  font-weight: 800;
  letter-spacing: 4px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
}

.eyebrow i {
  width: 22px;
  height: 3px;
  border-radius: 50%;
  background: #e6a641;
  transform: rotate(-5deg);
}

.hero-copy h1 {
  margin: 17px 0 18px;
  font-size: clamp(44px, 5.25vw, 76px);
  line-height: 1.04;
  letter-spacing: 4px;
  text-shadow: 2px 3px 0 #fff5c6;
}

.hero-copy h1 em {
  color: var(--orange);
  font-style: normal;
  -webkit-text-stroke: 1px #bd572d;
}

.hero-copy p {
  max-width: 600px;
  margin: 0 0 27px;
  color: #62714c;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.75;
}

.primary-button,
.secondary-button {
  border: 0;
  font-weight: 900;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  min-width: 190px;
  padding: 15px 20px 14px 25px;
  border: 3px solid #a84927;
  border-radius: 18px 24px 17px 22px;
  background: var(--orange);
  box-shadow: 5px 6px 0 #a84927;
  color: #fffdf0;
  font-size: 20px;
  letter-spacing: 2px;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 7px 9px 0 #a84927;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 2px 3px 0 #a84927;
}

.primary-button i {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #fff3bd;
  color: #b74d28;
  font-style: normal;
}

.primary-button.small {
  min-width: 150px;
  padding: 11px 16px;
  font-size: 17px;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 25px;
  color: #6c7659;
  font-size: 14px;
  font-weight: 700;
}

.keyboard-hint .keycap:last-of-type {
  margin-right: 6px;
}

.keycap,
.mission-keys kbd {
  display: grid;
  place-items: center;
  border: 2px solid #77925d;
  background: #fffdf1;
  box-shadow: 0 3px 0 #91a976;
  font-weight: 900;
}

.keycap {
  width: 27px;
  height: 27px;
  border-radius: 8px 6px 7px 5px;
}

.hero-art {
  position: relative;
  min-height: 460px;
  overflow: hidden;
  background:
    linear-gradient(to top, #a9d077 0 24%, transparent 24%),
    linear-gradient(150deg, #a5dbe5, #e4f2c2 68%);
  clip-path: polygon(11% 0, 100% 0, 100% 100%, 0 100%, 5% 70%, 0 45%);
}

.hero-art::before,
.hero-art::after {
  content: "";
  position: absolute;
  bottom: 49px;
  width: 360px;
  height: 115px;
  border-radius: 50% 50% 0 0;
  background: #74b863;
  opacity: 0.7;
}

.hero-art::before { left: -120px; transform: rotate(6deg); }
.hero-art::after { right: -120px; transform: rotate(-4deg); }

.sun-doodle {
  position: absolute;
  top: 46px;
  right: 62px;
  width: 78px;
  height: 78px;
  border: 4px dashed #e6a72e;
  border-radius: 50%;
  animation: slow-spin 18s linear infinite;
}

.sun-doodle span {
  position: absolute;
  inset: 10px;
  border-radius: 50% 45% 52% 48%;
  background: var(--yellow);
}

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

.cloud {
  position: absolute;
  width: 100px;
  height: 29px;
  border: 3px solid #7eaeb2;
  border-radius: 50%;
  background: #fffdf1;
  opacity: 0.82;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 7px;
  border: 3px solid #7eaeb2;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  background: #fffdf1;
}

.cloud::before { left: 18px; width: 34px; height: 28px; }
.cloud::after { right: 14px; width: 40px; height: 39px; }
.cloud-one { top: 102px; left: 64px; transform: rotate(-3deg) scale(0.75); }
.cloud-two { top: 158px; right: 30px; transform: rotate(4deg) scale(0.58); }

.bunny-illustration {
  position: absolute;
  z-index: 3;
  left: 45%;
  bottom: 48px;
  width: 235px;
  height: 310px;
  transform: translateX(-50%) rotate(-2deg);
  animation: hero-bob 3s ease-in-out infinite;
}

@keyframes hero-bob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  50% { transform: translateX(-50%) translateY(-8px) rotate(1deg); }
}

.hero-ear {
  position: absolute;
  z-index: 1;
  top: 0;
  width: 67px;
  height: 155px;
  border: 4px solid #56684d;
  border-radius: 70% 70% 42% 42%;
  background: #fffaf0;
}

.hero-ear i {
  position: absolute;
  inset: 18px 17px 22px;
  border-radius: 60%;
  background: #f5aea2;
}

.hero-ear-left { left: 34px; transform: rotate(-13deg); }
.hero-ear-right { right: 34px; transform: rotate(14deg); }

.hero-bunny-head {
  position: absolute;
  z-index: 3;
  top: 91px;
  left: 15px;
  width: 205px;
  height: 175px;
  border: 5px solid #56684d;
  border-radius: 52% 48% 47% 55%;
  background: #fffaf0;
  box-shadow: inset -12px -9px 0 rgba(224, 207, 178, 0.35);
}

.hero-eye {
  position: absolute;
  top: 70px;
  width: 13px;
  height: 18px;
  border-radius: 50%;
  background: #42503b;
  box-shadow: inset 3px 2px 0 #fff;
}

.eye-left { left: 53px; }
.eye-right { right: 53px; }

.hero-cheek {
  position: absolute;
  top: 100px;
  width: 34px;
  height: 17px;
  border-radius: 50%;
  background: rgba(244, 138, 128, 0.55);
}

.cheek-left { left: 29px; transform: rotate(5deg); }
.cheek-right { right: 29px; transform: rotate(-5deg); }

.hero-nose {
  position: absolute;
  top: 96px;
  left: 50%;
  width: 17px;
  height: 13px;
  border-radius: 55% 55% 65% 65%;
  background: #e47d72;
  transform: translateX(-50%);
}

.hero-mouth {
  position: absolute;
  top: 108px;
  left: 50%;
  font-family: serif;
  font-size: 30px;
  transform: translateX(-50%);
}

.hero-body {
  position: absolute;
  z-index: 2;
  bottom: 0;
  left: 45px;
  width: 150px;
  height: 105px;
  border: 5px solid #56684d;
  border-radius: 50% 50% 32% 35%;
  background: #fffaf0;
}

.hero-paw {
  position: absolute;
  right: -24px;
  top: 15px;
  width: 58px;
  height: 37px;
  border: 4px solid #56684d;
  border-radius: 50%;
  background: #fffaf0;
  transform: rotate(-18deg);
}

.carrot-shape {
  position: relative;
  width: 40px;
  height: 60px;
  border: 3px solid #a84e2a;
  border-radius: 48% 45% 58% 56%;
  background: repeating-linear-gradient(170deg, var(--orange) 0 9px, #e97730 10px 12px);
  clip-path: polygon(7% 0, 95% 0, 54% 100%);
}

.carrot-shape::before,
.carrot-shape::after,
.carrot-shape span {
  content: "";
  position: absolute;
  z-index: -1;
  top: -29px;
  left: 15px;
  width: 14px;
  height: 36px;
  border: 3px solid #397b48;
  border-radius: 70% 20% 70% 20%;
  background: #6eae55;
  transform-origin: bottom;
}

.carrot-shape::before { transform: rotate(-32deg); }
.carrot-shape::after { transform: rotate(35deg); }
.carrot-shape span { transform: translateY(-3px) rotate(3deg); }

.hero-carrot {
  position: absolute;
  z-index: 4;
  right: 73px;
  bottom: 62px;
  width: 74px;
  height: 110px;
  transform: rotate(14deg);
}

.hero-carrot::before,
.hero-carrot::after,
.hero-carrot span {
  top: -46px;
  left: 27px;
  width: 21px;
  height: 59px;
}

.doodle-star {
  position: absolute;
  z-index: 4;
  color: #f8bf3f;
  font-size: 28px;
  animation: twinkle 1.8s ease-in-out infinite alternate;
}

.star-one { left: 13%; bottom: 120px; }
.star-two { right: 17%; top: 170px; animation-delay: 0.6s; }
.star-three { right: 7%; bottom: 175px; animation-delay: 1.1s; }

@keyframes twinkle { to { transform: rotate(15deg) scale(1.35); opacity: 0.6; } }

.level-section {
  margin-top: 44px;
  padding: 0 4px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 19px;
  padding: 0 8px;
}

.tiny-label {
  font-size: 13px;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 36px;
  letter-spacing: 4px;
}

.progress-note {
  padding: 8px 14px;
  border: 2px dashed #809b62;
  border-radius: 14px 19px 14px 18px;
  background: rgba(255, 252, 226, 0.76);
  color: #63754f;
  font-weight: 800;
}

.progress-note span {
  color: var(--orange-dark);
  font-size: 22px;
}

.difficulty-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 7px 18px;
  color: #657450;
  font-weight: 800;
}

.difficulty-guide > span,
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid rgba(82, 103, 65, 0.45);
  border-radius: 999px 880px 999px 850px;
  background: rgba(255, 253, 232, 0.82);
}

.difficulty-guide > span {
  padding: 5px 10px;
  font-size: 13px;
}

.difficulty-guide i {
  width: 10px;
  height: 10px;
  border-radius: 50% 43% 55% 46%;
  background: var(--difficulty-color);
}

.difficulty-guide .beginner { --difficulty-color: #79b765; }
.difficulty-guide .medium { --difficulty-color: #eda849; }
.difficulty-guide .advanced { --difficulty-color: #dc756c; }

.difficulty-guide small {
  margin-left: auto;
  color: #7b8768;
  font-size: 12px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.level-card {
  position: relative;
  min-height: 170px;
  padding: 20px 17px 16px;
  overflow: hidden;
  border: 3px solid rgba(75, 96, 57, 0.56);
  border-radius: 22px 15px 26px 18px;
  background: rgba(255, 253, 237, 0.9);
  box-shadow: 4px 6px 0 rgba(90, 113, 65, 0.22);
  text-align: left;
  transform: rotate(var(--tilt));
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.level-card:not(:disabled):hover {
  transform: translateY(-6px) rotate(calc(var(--tilt) * -1));
  box-shadow: 7px 11px 0 rgba(90, 113, 65, 0.22);
}

.level-card.is-locked {
  opacity: 0.68;
  filter: saturate(0.65);
}

.level-card.is-done {
  border-color: #d46d38;
  background: #fff6c8;
}

.level-number {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 3px solid #507048;
  border-radius: 50% 45% 53% 47%;
  background: var(--card-color, #b9d985);
  font-size: 23px;
  font-weight: 900;
}

.level-card strong {
  display: block;
  margin-top: 14px;
  font-size: 18px;
}

.difficulty-badge {
  position: absolute;
  top: 61px;
  right: 12px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
}

.difficulty-初级 { border-color: #70a65d; background: #e4f2c5; color: #4c7c45; }
.difficulty-中级 { border-color: #d99443; background: #fff0bd; color: #a45c2c; }
.difficulty-高级 { border-color: #cb6b63; background: #ffe0d2; color: #9e4c48; }

.level-card small {
  display: block;
  margin-top: 4px;
  color: #73805f;
  font-size: 13px;
}

.level-status {
  position: absolute;
  top: 15px;
  right: 13px;
  color: #d76732;
  font-size: 22px;
  transform: rotate(7deg);
}

.level-card.is-locked .level-status {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  background: #d9d8b9;
  color: #71745f;
  font-size: 15px;
}

.coming-ribbon {
  position: absolute;
  right: -28px;
  bottom: 16px;
  width: 120px;
  padding: 4px;
  background: #aeb69b;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  transform: rotate(-35deg);
}

/* Game */
.game-screen {
  padding-top: 5px;
}

.game-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 14px;
}

.back-button {
  justify-self: start;
  padding: 9px 13px;
  border: 2px dashed #71845b;
  border-radius: 14px;
  background: rgba(255, 253, 238, 0.72);
  font-weight: 800;
}

.back-button span {
  margin-right: 5px;
  font-size: 21px;
}

.level-title {
  text-align: center;
}

.level-title small {
  display: block;
  color: var(--orange-dark);
  font-weight: 900;
  letter-spacing: 4px;
}

.level-title strong {
  display: block;
  margin-top: 2px;
  font-size: 27px;
  letter-spacing: 4px;
}

.carrot-counter {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 9px;
  min-width: 100px;
  padding: 8px 13px;
  border: 3px solid #ca6b32;
  border-radius: 18px 13px 20px 15px;
  background: #fff4b8;
  color: #9d4d29;
}

.tiny-carrot {
  position: relative;
  width: 15px;
  height: 26px;
  border-radius: 50% 45% 60% 60%;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: rotate(10deg);
}

.tiny-carrot::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 12px 0;
  background: var(--green);
  transform: translate(3px, -8px) rotate(30deg);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(155px, 0.72fr) minmax(520px, 3.05fr) minmax(155px, 0.72fr);
  align-items: center;
  gap: 22px;
}

.mission-card,
.treasure-card {
  position: relative;
  padding: 35px 22px 25px;
  border: 3px solid rgba(77, 91, 58, 0.58);
  background: rgba(255, 251, 223, 0.91);
  box-shadow: 5px 7px 0 rgba(83, 104, 64, 0.2);
  text-align: center;
}

.mission-card {
  border-radius: 26px 18px 31px 15px;
  transform: rotate(-1.2deg);
}

.treasure-card {
  border-radius: 17px 29px 15px 32px;
  transform: rotate(1.2deg);
}

.tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 81px;
  height: 27px;
  background: rgba(245, 189, 85, 0.62);
  transform: translateX(-50%) rotate(-3deg);
}

.tape-right { transform: translateX(-50%) rotate(4deg); }

.mission-label {
  font-size: 12px;
}

.mission-card h3,
.treasure-card h3 {
  margin: 8px 0 9px;
  font-size: 21px;
  line-height: 1.35;
}

.mission-card p,
.treasure-card p {
  color: #697654;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.mission-keys {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  justify-content: center;
  gap: 4px;
  margin: 17px auto 10px;
}

.mission-keys kbd {
  width: 34px;
  height: 32px;
  border-radius: 8px;
}

.mission-card > small {
  color: #768263;
  font-weight: 800;
}

.mascot-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 10px 8px;
  border: 2px dashed #d37e43;
  border-radius: 18px;
  background: #fff4c7;
  color: #a0522d;
  font-size: 13px;
}

.tip-face {
  display: grid;
  flex: 0 0 auto;
  width: 37px;
  height: 33px;
  place-items: center;
  border: 2px solid #788166;
  border-radius: 50%;
  background: white;
  font-size: 10px;
}

.maze-frame {
  position: relative;
  padding: 21px 24px 25px;
  border: 4px solid #697e4f;
  border-radius: 28px 19px 33px 23px;
  background: #fff8d8;
  box-shadow: 8px 10px 0 rgba(67, 94, 52, 0.27), inset 0 0 0 3px rgba(255, 255, 255, 0.7);
  transform: rotate(-0.2deg);
}

.maze-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 2px dashed rgba(83, 105, 62, 0.25);
  border-radius: 20px 14px 25px 17px;
}

.maze-pin {
  position: absolute;
  z-index: 5;
  top: 8px;
  width: 15px;
  height: 15px;
  border: 2px solid #8f4e32;
  border-radius: 50%;
  background: #e8794d;
  box-shadow: 1px 2px 0 #8f4e32;
}

.pin-one { left: 12px; }
.pin-two { right: 12px; }

.maze-caption {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #657650;
  font-size: 14px;
  font-weight: 800;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-goal {
  position: relative;
  width: 17px;
  height: 22px;
  flex: 0 0 auto;
}

.legend-goal::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 0;
  width: 11px;
  height: 17px;
  background: var(--orange);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.legend-goal::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: 1px;
  width: 15px;
  height: 9px;
  background: var(--yellow);
  clip-path: polygon(0 18%, 24% 57%, 50% 0, 76% 57%, 100% 18%, 88% 100%, 12% 100%);
  filter: drop-shadow(0 1px 0 #a96129);
}

.maze {
  --cols: 11;
  --rows: 9;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  width: 100%;
  overflow: hidden;
  outline: none;
  border: 3px solid #4c7549;
  border-radius: 20px 14px 23px 17px;
  background:
    linear-gradient(rgba(255, 249, 210, 0.35), rgba(255, 249, 210, 0.35)),
    url("assets/meadow-storybook.png") center / cover;
  box-shadow: inset 0 0 20px rgba(63, 95, 54, 0.18);
}

.maze-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
}

.maze-cell.path::after {
  content: "";
  position: absolute;
  inset: 37%;
  border-radius: 50%;
  background: rgba(126, 118, 72, 0.2);
}

.maze-cell.wall {
  z-index: 1;
  margin: -1px;
  border: 1px dashed rgba(44, 94, 48, 0.28);
  border-radius: 32% 42% 28% 45%;
  background:
    radial-gradient(circle at 28% 25%, rgba(220, 239, 142, 0.86) 0 12%, transparent 13%),
    radial-gradient(circle at 68% 67%, rgba(53, 124, 67, 0.52) 0 16%, transparent 17%),
    linear-gradient(135deg, var(--wall-a, #84bd68), var(--wall-b, #4c975d));
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.34), inset -3px -4px 0 rgba(46, 105, 54, 0.24);
}

.maze-cell.wall[data-decoration]::after {
  content: attr(data-decoration);
  position: absolute;
  z-index: 3;
  right: -11%;
  bottom: -14%;
  font-size: clamp(10px, 1.25vw, 19px);
  filter: drop-shadow(1px 2px 0 rgba(50, 73, 44, 0.2));
  transform: rotate(8deg);
}

.maze-cell.wall:nth-child(3n) { border-radius: 45% 27% 42% 31%; filter: hue-rotate(7deg); }
.maze-cell.wall:nth-child(5n) { border-radius: 26% 47% 33% 43%; filter: brightness(1.04); }

.maze-cell.carrot-cell,
.maze-cell.goal-cell {
  z-index: 2;
  display: grid;
  place-items: center;
}

.game-carrot {
  position: relative;
  z-index: 2;
  width: 32%;
  height: 55%;
  border: 2px solid #a34f29;
  border-radius: 50%;
  background: linear-gradient(100deg, #f59c42, #e8792f);
  clip-path: polygon(3% 0, 98% 0, 52% 100%);
  filter: drop-shadow(2px 3px 0 rgba(114, 72, 35, 0.22));
  animation: carrot-wiggle 1.7s ease-in-out infinite;
}

.game-carrot::before,
.game-carrot::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -45%;
  left: 38%;
  width: 42%;
  height: 60%;
  border-radius: 70% 10% 70% 10%;
  background: #4f984e;
}

.game-carrot::before { transform: rotate(-37deg); }
.game-carrot::after { transform: rotate(35deg); }

.goal-treasure {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  isolation: isolate;
}

.goal-treasure::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 8%;
  border: 2px dashed rgba(244, 184, 49, 0.78);
  border-radius: 50% 46% 52% 47%;
  background: radial-gradient(circle, rgba(255, 244, 147, 0.58), transparent 68%);
  animation: treasure-halo 1.5s ease-in-out infinite alternate;
}

.goal-crown {
  position: absolute;
  z-index: 5;
  top: -2%;
  left: 50%;
  width: 68%;
  overflow: visible;
  fill: #ffd653;
  stroke: #9f5a2b;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(1px 2px 0 rgba(113, 70, 29, 0.28));
  animation: crown-bob 1.35s ease-in-out infinite alternate;
}

.goal-crown circle {
  fill: #fff1a6;
}

.goal-sparkle {
  position: absolute;
  z-index: 6;
  top: 22%;
  color: #f6c33f;
  font-size: 28%;
  font-style: normal;
  text-shadow: 0 1px 0 #a96129;
  animation: goal-sparkle 1.1s ease-in-out infinite alternate;
}

.sparkle-left { left: 3%; }
.sparkle-right { right: 3%; animation-delay: 0.45s; }

.goal-carrot {
  width: 48%;
  height: 72%;
  animation: goal-glow 1.25s ease-in-out infinite alternate;
}

@keyframes carrot-wiggle {
  0%, 100% { transform: rotate(-7deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-5%); }
}

@keyframes goal-glow {
  from { transform: scale(0.96) rotate(-4deg); filter: drop-shadow(0 0 3px #fff5a3); }
  to { transform: scale(1.1) rotate(5deg); filter: drop-shadow(0 0 11px #ffe66c); }
}

@keyframes crown-bob {
  from { transform: translate(-50%, 0) rotate(-5deg); }
  to { transform: translate(-50%, -8%) rotate(5deg); }
}

@keyframes treasure-halo {
  from { opacity: 0.58; transform: scale(0.92) rotate(-3deg); }
  to { opacity: 1; transform: scale(1.05) rotate(3deg); }
}

@keyframes goal-sparkle {
  from { opacity: 0.35; transform: scale(0.7) rotate(-8deg); }
  to { opacity: 1; transform: scale(1.25) rotate(8deg); }
}

.maze-player {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  padding: 7px;
  pointer-events: none;
  transition: transform 145ms cubic-bezier(0.2, 0.88, 0.34, 1.25);
}

.maze-player.is-bumping .player-bunny {
  animation: player-bump 260ms ease;
}

.maze-player.is-celebrating .player-bunny {
  animation: player-celebrate 650ms ease-in-out infinite;
}

.player-bunny {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(1px 3px 0 rgba(86, 87, 45, 0.25));
}

.player-head {
  position: absolute;
  inset: 22% 12% 5%;
  border: 2.5px solid #56604e;
  border-radius: 52% 46% 49% 53%;
  background: #fffaf0;
}

.player-head::before,
.player-head::after {
  content: "";
  position: absolute;
  top: 42%;
  width: 9%;
  height: 14%;
  border-radius: 50%;
  background: #3c463a;
}

.player-head::before { left: 27%; }
.player-head::after { right: 27%; }

.player-ear {
  position: absolute;
  z-index: -1;
  top: -28%;
  width: 31%;
  height: 59%;
  border: 2.5px solid #56604e;
  border-radius: 60% 60% 35% 35%;
  background: linear-gradient(90deg, #fffaf0 25%, #f5afa0 27% 64%, #fffaf0 66%);
}

.player-ear.left { left: 9%; transform: rotate(-13deg); }
.player-ear.right { right: 9%; transform: rotate(13deg); }

.player-nose {
  position: absolute;
  left: 50%;
  top: 59%;
  width: 13%;
  height: 10%;
  border-radius: 50%;
  background: #ec8d83;
  transform: translateX(-50%);
}

@keyframes player-bump {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-12%) rotate(-7deg); }
  65% { transform: translateX(10%) rotate(6deg); }
}

@keyframes player-celebrate {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-20%) rotate(8deg) scale(1.08); }
}

.maze-message {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: 34px;
  max-width: 82%;
  padding: 11px 18px;
  border: 3px solid #c46737;
  border-radius: 17px 21px 15px 23px;
  background: #fff7b8;
  box-shadow: 4px 5px 0 rgba(137, 76, 39, 0.25);
  color: #9f4e29;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px) scale(0.85) rotate(-2deg);
  transition: opacity 180ms ease, transform 250ms cubic-bezier(0.2, 0.85, 0.25, 1.25);
}

.maze-message.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1) rotate(-1deg);
}

.maze-message.is-big {
  bottom: 45%;
  padding: 17px 27px;
  font-size: clamp(21px, 3vw, 35px);
}

.treasure-stamp {
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid #d97543;
  border-radius: 50%;
  color: #c45d31;
  font-size: 12px;
  font-weight: 900;
  transform: rotate(-5deg);
}

.sticker-preview {
  display: grid;
  width: 122px;
  height: 122px;
  margin: 18px auto 8px;
  place-items: center;
  border: 3px dashed #9eb06e;
  border-radius: 50% 45% 52% 48%;
  background: #eff4c8;
}

.sticker-preview .sticker-art {
  transform: scale(0.85) rotate(-6deg);
}

.mini-progress {
  height: 14px;
  margin-top: 18px;
  padding: 3px;
  overflow: hidden;
  border: 2px solid #78905d;
  border-radius: 999px;
  background: #fffef1;
}

.mini-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: repeating-linear-gradient(45deg, #ef8a43 0 8px, #f7c34d 8px 16px);
  transition: width 350ms ease;
}

.mobile-controls {
  display: none;
}

/* Sticker art */
.sticker-art {
  position: relative;
  width: 92px;
  height: 92px;
  filter: drop-shadow(3px 5px 0 rgba(71, 76, 47, 0.18));
}

.sticker-art::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 7px solid #fffef4;
  border-radius: 48% 44% 51% 45%;
  background: var(--sticker-bg, #f6d55c);
  box-shadow: 0 0 0 2px rgba(84, 91, 54, 0.35);
}

.sticker-bunny .sticker-face {
  position: absolute;
  z-index: 2;
  inset: 28px 20px 15px;
  border: 2px solid #596250;
  border-radius: 50%;
  background: #fffaf0;
}

.sticker-bunny .sticker-face::before,
.sticker-bunny .sticker-face::after {
  content: "";
  position: absolute;
  top: -28px;
  width: 18px;
  height: 38px;
  border: 2px solid #596250;
  border-radius: 50%;
  background: linear-gradient(90deg, #fffaf0 30%, #f5afa4 31% 65%, #fffaf0 66%);
}

.sticker-bunny .sticker-face::before { left: 4px; transform: rotate(-9deg); }
.sticker-bunny .sticker-face::after { right: 4px; transform: rotate(9deg); }

.sticker-expression {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 48px;
  font-size: 14px;
  letter-spacing: 2px;
  transform: translateX(-50%);
}

.sticker-crown {
  position: absolute;
  z-index: 4;
  top: 4px;
  left: 50%;
  width: 43px;
  height: 28px;
  border: 2px solid #9b612b;
  background: #ffd954;
  clip-path: polygon(0 20%, 25% 55%, 50% 0, 75% 55%, 100% 20%, 88% 100%, 12% 100%);
  transform: translateX(-50%) rotate(-4deg);
}

.sticker-carrot .big-sticker-carrot {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 27px;
  width: 36px;
  height: 52px;
  border: 2px solid #a84e2a;
  border-radius: 50%;
  background: #f48737;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%) rotate(8deg);
}

.sticker-carrot .big-sticker-carrot::before,
.sticker-carrot .big-sticker-carrot::after {
  content: "";
  position: absolute;
  top: -20px;
  left: 10px;
  width: 16px;
  height: 27px;
  border-radius: 60% 15%;
  background: #4d9955;
}

.sticker-carrot .big-sticker-carrot::before { transform: rotate(-35deg); }
.sticker-carrot .big-sticker-carrot::after { transform: rotate(31deg); }

.sticker-vector svg {
  position: absolute;
  z-index: 3;
  inset: 10px;
  width: 72px;
  height: 72px;
  overflow: visible;
  fill: none;
  stroke: #4f5c48;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sticker-king .sticker-crown {
  top: 0;
  width: 51px;
  height: 32px;
}

.sticker-king .big-sticker-carrot {
  top: 31px;
  transform: translateX(-50%) rotate(-8deg) scale(1.08);
}

/* Dialogs */
.paper-dialog {
  position: fixed;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 30px);
  overflow: auto;
  border: 4px solid #576a49;
  border-radius: 29px 19px 35px 23px;
  background: #fff9dd;
  box-shadow: 10px 13px 0 rgba(49, 69, 40, 0.32);
  color: var(--ink);
}

.paper-dialog::backdrop {
  background: rgba(51, 72, 45, 0.62);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 15px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid #59694d;
  border-radius: 50%;
  background: #fffef1;
  color: #526045;
  font-size: 27px;
}

.sticker-dialog {
  width: min(820px, calc(100vw - 28px));
  padding: 37px 40px 28px;
}

.dialog-heading {
  text-align: center;
}

.dialog-heading span {
  color: var(--orange-dark);
  font-weight: 900;
  letter-spacing: 4px;
}

.dialog-heading h2 {
  margin: 6px 0;
  font-size: 38px;
  letter-spacing: 4px;
}

.dialog-heading p {
  margin: 0;
  color: #71805e;
  font-weight: 700;
}

.sticker-collection {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 13px;
  margin: 28px 0;
}

.collection-slot {
  display: grid;
  min-height: 155px;
  padding: 11px 7px;
  place-items: center;
  border: 2px dashed #93a278;
  border-radius: 22px 15px 25px 18px;
  background: rgba(237, 242, 199, 0.62);
  text-align: center;
}

.collection-slot:nth-child(even) { transform: rotate(1deg); }
.collection-slot:nth-child(odd) { transform: rotate(-1deg); }

.collection-slot.is-locked .sticker-art {
  filter: grayscale(1);
  opacity: 0.2;
}

.collection-slot strong {
  font-size: 14px;
}

.collection-slot small {
  display: block;
  margin-top: 3px;
  color: #839071;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 15px;
  border-top: 2px dashed #a5ad83;
  color: #697653;
  font-weight: 800;
}

.text-button {
  padding: 8px;
  color: #b95a35;
  font-weight: 900;
  text-decoration: underline wavy rgba(185, 90, 53, 0.45);
  text-underline-offset: 5px;
}

.reward-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 41px 35px 33px;
  overflow: hidden;
  text-align: center;
}

.reward-dialog > *:not(.reward-rays) {
  position: relative;
  z-index: 2;
}

.reward-rays {
  position: absolute;
  top: 135px;
  left: 50%;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(247, 196, 62, 0.34) 0 9deg, transparent 9deg 18deg);
  transform: translate(-50%, -50%);
  animation: slow-spin 18s linear infinite;
}

.reward-kicker {
  font-size: 14px;
}

.reward-dialog h2 {
  margin: 7px 0 6px;
  color: var(--orange-dark);
  font-size: 39px;
}

.reward-dialog > p {
  margin: 0;
  color: #697651;
  font-size: 17px;
  font-weight: 800;
}

.reward-sticker {
  display: grid;
  width: 145px;
  height: 145px;
  margin: 24px auto 14px;
  place-items: center;
  border: 4px dashed #f1ac3f;
  border-radius: 50% 46% 52% 47%;
  background: #fff5b9;
  animation: sticker-arrive 700ms cubic-bezier(0.16, 0.9, 0.25, 1.4) both;
}

.reward-sticker .sticker-art { transform: scale(1.25) rotate(-6deg); }

@keyframes sticker-arrive {
  from { opacity: 0; transform: scale(0.2) rotate(-35deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.reward-label small {
  display: block;
  color: #87916e;
  font-weight: 800;
}

.reward-label strong {
  color: #b85830;
  font-size: 23px;
}

.reward-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-top: 24px;
}

.secondary-button {
  padding: 12px 18px;
  border: 2px solid #75885e;
  border-radius: 15px 20px 14px 19px;
  background: #f1f3cb;
  box-shadow: 3px 4px 0 #a4ae7d;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -30px;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall var(--fall-time) cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
}

@keyframes confetti-fall {
  0% { transform: translate(0, -10vh) rotate(0); opacity: 1; }
  100% { transform: translate(var(--drift), 110vh) rotate(var(--spin)); opacity: 0.75; }
}

@media (max-width: 1120px) {
  .hero-copy { padding-left: 6vw; }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
  .game-layout { grid-template-columns: minmax(140px, 0.65fr) minmax(500px, 2.7fr); }
  .treasure-card { display: none; }
}

@media (max-width: 840px) {
  .app-shell { width: min(100% - 20px, 720px); }
  .topbar { min-height: 76px; }
  .brand-button small, .action-label { display: none; }
  .brand-button strong { font-size: 19px; }
  .brand-mark { transform: scale(0.86); }
  .hero-card { grid-template-columns: 1fr; }
  .hero-copy { padding: 42px 30px 36px; text-align: center; }
  .eyebrow { justify-content: center; }
  .hero-copy p { margin-inline: auto; }
  .keyboard-hint { justify-content: center; }
  .hero-art { min-height: 360px; clip-path: polygon(0 7%, 28% 0, 55% 7%, 76% 2%, 100% 8%, 100% 100%, 0 100%); }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .difficulty-guide { flex-wrap: wrap; justify-content: center; }
  .difficulty-guide small { width: 100%; margin-left: 0; text-align: center; }
  .game-toolbar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .back-button { font-size: 0; }
  .back-button span { font-size: 23px; }
  .level-title strong { font-size: 20px; }
  .game-layout { display: block; }
  .mission-card { display: none; }
  .maze-frame { padding: 19px 13px 15px; }
  .maze-player { padding: 4px; }
  .mobile-controls { display: block; margin-top: 18px; text-align: center; }
  .mobile-controls p { margin: 0 0 8px; color: #64734f; font-weight: 800; }
  .dpad { display: grid; grid-template-columns: repeat(3, 55px); justify-content: center; gap: 6px; }
  .dpad button { width: 55px; height: 49px; border: 3px solid #5f794f; border-radius: 15px 11px 17px 12px; background: #fff8cf; box-shadow: 0 4px 0 #8ea172; font-size: 25px; font-weight: 900; }
  .dpad button:active { transform: translateY(3px); box-shadow: 0 1px 0 #8ea172; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 14px, 520px); }
  .topbar { padding-inline: 0; }
  .brand-button strong { display: none; }
  .sticker-book-button { padding: 8px; }
  .sticker-book-button > span:nth-child(2) { display: none; }
  .hero-card { min-height: 0; border-radius: 30px 20px; }
  .hero-copy { padding: 36px 20px 27px; }
  .hero-copy h1 { font-size: 41px; }
  .hero-copy p { font-size: 16px; }
  .keyboard-hint span:last-child { display: none; }
  .hero-art { min-height: 310px; }
  .bunny-illustration { transform: translateX(-50%) scale(0.82); transform-origin: bottom; }
  @keyframes hero-bob { 0%, 100% { transform: translateX(-50%) scale(0.82) translateY(0) rotate(-2deg); } 50% { transform: translateX(-50%) scale(0.82) translateY(-8px) rotate(1deg); } }
  .hero-carrot { right: 36px; transform: rotate(14deg) scale(0.75); }
  .level-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .level-card { min-height: 145px; padding: 15px 13px; }
  .difficulty-guide { gap: 6px; }
  .difficulty-guide > span { padding: 4px 7px; font-size: 11px; }
  .difficulty-badge { top: 55px; right: 9px; }
  .section-heading h2 { font-size: 29px; }
  .progress-note { font-size: 12px; }
  .maze-caption .legend { display: none; }
  .maze-frame { border-width: 3px; }
  .maze-message { font-size: 15px; }
  .sticker-dialog { padding: 34px 15px 20px; }
  .dialog-heading h2 { font-size: 29px; }
  .sticker-collection { grid-template-columns: repeat(2, 1fr); }
  .dialog-footer { align-items: flex-start; flex-direction: column; gap: 5px; }
  .reward-dialog { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
