:root {
  --ink: #4b3428;
  --ink-soft: #765747;
  --cream: #fff8e8;
  --paper: #fffdf6;
  --sun: #ffd45c;
  --sun-deep: #f0b52c;
  --coral: #f47c67;
  --coral-deep: #d9544f;
  --teal: #54bfb3;
  --teal-deep: #318f8a;
  --sky: #70bce8;
  --green: #78c98f;
  --pink: #ea7dad;
  --danger: #d94b4b;
  --shadow: 0 9px 0 #c9854f, 0 18px 34px rgba(91, 56, 38, 0.19);
  --soft-shadow: 0 18px 46px rgba(91, 56, 38, 0.22);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.76) 0 7%, transparent 7.2%),
    radial-gradient(circle at 88% 8%, rgba(255, 244, 202, 0.7) 0 10%, transparent 10.2%),
    repeating-linear-gradient(118deg, rgba(122, 70, 38, 0.045) 0 2px, transparent 2px 18px),
    linear-gradient(145deg, #f9dd91 0%, #eebf66 48%, #d99754 100%);
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
.stage:focus-visible {
  outline: 4px solid #1c79b9;
  outline-offset: 3px;
}

.page-shell {
  width: min(1540px, calc(100vw - 28px));
  margin: 14px auto 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 10px 16px 10px 12px;
  border: 4px solid var(--ink);
  border-radius: 24px 24px 16px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 240, 199, 0.94)),
    var(--paper);
  box-shadow: var(--shadow);
}

.brand-lockup,
.top-actions,
.mission-strip,
.mission-copy,
.mission-progress,
.progress-label,
.stage-hud,
.hearts-card,
.helper-badge,
.action-ribbon,
.action-tip,
.keyboard-guide,
.key-group,
.panel-heading,
.rules-card {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 300px;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 50px;
  border: 3px solid var(--ink);
  border-radius: 48% 48% 44% 44%;
  background: linear-gradient(145deg, #ffb27d, var(--coral) 58%, #d9544f);
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.32), 0 5px 0 rgba(75, 52, 40, 0.16);
  transform: rotate(-4deg);
}

.brand-ear {
  position: absolute;
  top: -12px;
  width: 21px;
  height: 23px;
  border: 3px solid var(--ink);
  background: var(--coral);
  transform: rotate(45deg);
  z-index: -1;
}

.brand-ear-left {
  left: 4px;
}

.brand-ear-right {
  right: 4px;
}

.brand-face {
  font-size: 25px;
  font-weight: 900;
  transform: rotate(90deg);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--coral-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", "PingFang SC", cursive;
  font-weight: 900;
}

.topbar h1 {
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1;
}

.top-actions {
  justify-content: flex-end;
  gap: 10px;
}

.chapter-badge,
.icon-button {
  min-height: 46px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(75, 52, 40, 0.12);
}

.chapter-badge {
  display: grid;
  place-items: center;
  padding: 7px 15px;
  background: #dff4e8;
  font-size: 14px;
  font-weight: 900;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.icon-button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 6px 0 rgba(75, 52, 40, 0.15);
  background: #fff6cf;
}

.icon-button.is-off {
  color: #7c6b62;
  background: #eee7dc;
}

.button-icon {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  font-size: 16px;
  line-height: 1;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: 14px;
  margin-top: 14px;
}

.game-panel,
.level-panel {
  border: 4px solid var(--ink);
  background: linear-gradient(155deg, #fffef8, #ffeec7);
  box-shadow: var(--shadow);
}

.game-panel {
  min-width: 0;
  padding: 10px;
  border-radius: 18px 26px 22px 18px;
}

.mission-strip {
  position: relative;
  z-index: 3;
  gap: 14px;
  min-height: 82px;
  margin-bottom: 10px;
  padding: 9px 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.88), transparent 42%),
    linear-gradient(180deg, #fff7d4, #f4d98b);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.72), 0 5px 0 rgba(99, 59, 35, 0.13);
}

.mission-index {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 66px;
  height: 58px;
  border: 3px solid var(--ink);
  border-radius: 17px 13px 16px 12px;
  background: linear-gradient(145deg, #ffad80, var(--coral) 60%, #d9544f);
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.25), 0 5px 0 rgba(116, 48, 40, 0.22);
  color: #fff;
  transform: rotate(-2deg);
  text-shadow: 0 2px 0 rgba(80, 32, 24, 0.25);
}

.mission-kicker {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.mission-index strong {
  font-size: 28px;
  line-height: 1;
}

.mission-copy {
  flex: 1 1 auto;
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
  min-width: 210px;
}

.mission-copy h2 {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", "PingFang SC", cursive;
  font-size: clamp(21px, 2vw, 29px);
  line-height: 1.1;
}

.mission-copy p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.mission-progress {
  flex: 0 0 210px;
  align-items: stretch;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding-left: 14px;
  border-left: 2px dashed rgba(75, 52, 40, 0.32);
}

.progress-label {
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 900;
}

.progress-label strong {
  font-size: 16px;
}

.progress-track {
  height: 15px;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #fffdf6;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-right: 2px solid var(--ink);
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.35) 0 5px, transparent 5px 10px),
    var(--teal);
  transition: width 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 520px;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 20px 14px 24px 16px;
  background: #f6c983;
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.25),
    inset 0 -22px 34px rgba(91, 44, 24, 0.16),
    0 8px 0 rgba(75, 52, 40, 0.17);
  isolation: isolate;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  border: 0 solid rgba(217, 75, 75, 0);
  box-shadow: inset 0 0 55px transparent;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(255, 255, 225, 0.38), transparent 52%),
    linear-gradient(90deg, rgba(112, 60, 33, 0.08), transparent 13% 87%, rgba(112, 60, 33, 0.1));
  box-shadow: inset 0 0 48px rgba(75, 52, 40, 0.12);
}

.stage.danger::before {
  border-width: 8px;
  border-color: rgba(217, 75, 75, 0.5);
  box-shadow: inset 0 0 70px rgba(179, 30, 30, 0.23);
  animation: dangerPulse 760ms ease-in-out infinite alternate;
}

.room-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-hud {
  position: absolute;
  top: 13px;
  left: 14px;
  right: 14px;
  z-index: 40;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hearts-card {
  gap: 10px;
  min-height: 45px;
  padding: 5px 12px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 241, 201, 0.94));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.8), 0 6px 0 rgba(75, 52, 40, 0.15);
}

.hud-label {
  font-size: 12px;
  font-weight: 900;
}

.hearts {
  display: flex;
  gap: 5px;
}

.heart {
  position: relative;
  width: 23px;
  height: 20px;
  transform: rotate(-45deg);
  border: 2px solid var(--ink);
  border-radius: 4px 0 5px 0;
  background: var(--coral);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: inherit;
}

.heart::before {
  top: -8px;
  left: -2px;
  border-bottom-color: transparent;
  border-right-color: transparent;
}

.heart::after {
  top: 3px;
  right: -8px;
  border-bottom-color: transparent;
  border-left-color: transparent;
}

.heart.is-empty {
  background: #ded7ce;
  opacity: 0.65;
}

.helper-badge {
  gap: 7px;
  padding: 7px 12px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #dff4e8;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.helper-badge.show {
  opacity: 1;
  transform: translateY(0);
}

.helper-star {
  color: #dc8d18;
  font-size: 18px;
}

.safe-zone {
  position: absolute;
  left: 2.3%;
  bottom: 3.1%;
  z-index: 8;
  width: 15.6%;
  height: 20%;
  pointer-events: none;
  filter: drop-shadow(0 7px 4px rgba(77, 48, 30, 0.16));
}

.safe-roof {
  position: absolute;
  left: 7%;
  top: 0;
  width: 86%;
  height: 46%;
  border: 4px solid var(--ink);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--coral);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.safe-house {
  position: absolute;
  inset: 36% 9% 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 4px solid var(--ink);
  border-radius: 8px 8px 18px 18px;
  background: linear-gradient(160deg, #fff9de, #eecb75);
  box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.48);
  font-size: 12px;
  font-weight: 900;
}

.safe-paw {
  display: grid;
  place-items: center;
  width: 24px;
  height: 18px;
  border-radius: 50%;
  color: var(--coral);
  font-size: 18px;
}

.safe-zone.active {
  animation: safeGlow 760ms ease-in-out infinite alternate;
}

.safe-zone.active .safe-house {
  background: #fff29f;
}

.sprite {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sprite svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.object {
  z-index: 7;
  filter: drop-shadow(0 7px 1px rgba(76, 43, 26, 0.18)) drop-shadow(0 12px 8px rgba(76, 43, 26, 0.12));
  transition: opacity 220ms ease, filter 220ms ease;
}

.object.dim {
  opacity: 0.57;
  filter: saturate(0.75) drop-shadow(0 4px 2px rgba(76, 43, 26, 0.08));
}

.object.focus {
  opacity: 1;
  filter: saturate(1.16) drop-shadow(0 8px 1px rgba(76, 43, 26, 0.2)) drop-shadow(0 14px 10px rgba(76, 43, 26, 0.14));
}

.actor {
  z-index: 24;
  transition: filter 120ms ease;
  filter: drop-shadow(0 8px 1px rgba(67, 40, 24, 0.2)) drop-shadow(0 13px 8px rgba(67, 40, 24, 0.13));
}

.actor.moving svg {
  animation: characterBob 240ms ease-in-out infinite alternate;
}

.cat.dashing {
  filter: drop-shadow(-15px 3px 0 rgba(255, 255, 255, 0.62)) drop-shadow(-29px 4px 0 rgba(244, 124, 103, 0.32));
}

.cat.hit {
  animation: catHit 130ms linear 5;
}

.target-ring {
  position: absolute;
  z-index: 5;
  width: 104px;
  height: 70px;
  border: 6px solid rgba(255, 205, 53, 0.88);
  border-radius: 50%;
  background: rgba(255, 225, 94, 0.15);
  box-shadow: 0 0 0 8px rgba(255, 230, 122, 0.22);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: ringPulse 720ms ease-in-out infinite alternate;
}

.target-ring.hidden,
.guide-arrow.hidden {
  display: none;
}

.guide-arrow {
  position: absolute;
  z-index: 31;
  display: grid;
  justify-items: center;
  transform: translate(-50%, -100%);
  pointer-events: none;
  animation: guideBounce 650ms ease-in-out infinite alternate;
}

.guide-arrow span {
  padding: 5px 10px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  box-shadow: 0 4px 0 rgba(75, 52, 40, 0.16);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.guide-arrow i {
  position: relative;
  width: 0;
  height: 0;
  margin-top: -2px;
  border-top: 15px solid var(--ink);
  border-right: 11px solid transparent;
  border-left: 11px solid transparent;
}

.guide-arrow i::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 10px solid var(--sun);
  border-right: 7px solid transparent;
  border-left: 7px solid transparent;
  transform: translateX(-50%);
}

.drop-layer,
.particle-layer,
.yarn-trail {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.drop-layer {
  z-index: 10;
}

.particle-layer {
  z-index: 33;
  overflow: hidden;
}

.yarn-trail {
  z-index: 6;
  width: 100%;
  height: 100%;
}

.drop-item {
  position: absolute;
  transform: translate(-50%, -50%);
  animation: dropPop 320ms cubic-bezier(0.22, 1.4, 0.48, 1);
}

.particle {
  position: absolute;
  z-index: 33;
  width: 11px;
  height: 11px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--sun);
  animation: particleFly 680ms ease-out forwards;
}

.comic-burst {
  position: absolute;
  z-index: 43;
  left: 50%;
  top: 26%;
  min-width: 110px;
  padding: 13px 18px;
  border: 4px solid var(--ink);
  background: #fffdf6;
  color: var(--coral-deep);
  clip-path: polygon(9% 15%, 31% 18%, 40% 0, 54% 18%, 76% 5%, 82% 27%, 100% 39%, 83% 55%, 95% 80%, 69% 80%, 57% 100%, 40% 82%, 14% 94%, 17% 68%, 0 53%, 17% 40%);
  font-family: "Kaiti SC", "STKaiti", cursive;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
  pointer-events: none;
}

.comic-burst.show {
  animation: comicPop 820ms cubic-bezier(0.2, 1.3, 0.3, 1) forwards;
}

.floating-msg {
  position: absolute;
  z-index: 44;
  left: 50%;
  top: 78px;
  max-width: 70%;
  padding: 8px 15px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.95);
  box-shadow: 0 5px 0 rgba(75, 52, 40, 0.13);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.floating-msg.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.reaction-bubble {
  position: absolute;
  z-index: 46;
  top: 124px;
  right: 22px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  width: min(320px, 42%);
  padding: 11px 13px;
  border: 4px solid var(--ink);
  border-radius: 18px 18px 7px 18px;
  background: linear-gradient(155deg, #fffef9, #ffecc2);
  box-shadow: 0 8px 0 rgba(75, 52, 40, 0.18), 0 16px 28px rgba(75, 52, 40, 0.16);
  opacity: 0;
  transform: translateX(35px) rotate(2deg);
  pointer-events: none;
  transition: opacity 190ms ease, transform 240ms cubic-bezier(0.22, 1.2, 0.36, 1);
}

.reaction-bubble::after {
  content: "";
  position: absolute;
  right: 25px;
  bottom: -18px;
  width: 22px;
  height: 22px;
  border-right: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  background: #ffecc2;
  transform: rotate(45deg);
}

.reaction-bubble.show {
  opacity: 1;
  transform: translateX(0) rotate(-1deg);
}

.reaction-speaker,
.dialogue-speaker,
.result-speaker {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  min-height: 28px;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(75, 52, 40, 0.14);
}

.speaker-cat {
  background: #e98238;
}

.speaker-granny {
  background: #4b91c7;
}

.speaker-kid {
  background: #4aa66d;
}

.speaker-robot {
  background: #5baec5;
}

.reaction-bubble p {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.55;
}

.action-ribbon {
  position: absolute;
  z-index: 41;
  left: 50%;
  bottom: 11px;
  justify-content: center;
  gap: 8px;
  width: min(66%, 600px);
  transform: translateX(-50%);
  pointer-events: none;
}

.action-tip,
.danger-tip {
  min-height: 43px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(75, 52, 40, 0.13);
  font-size: 13px;
  font-weight: 900;
}

.action-tip {
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  padding: 7px 14px;
  background: rgba(255, 253, 246, 0.94);
}

.action-tip.ready {
  background: var(--sun);
  animation: readyPulse 520ms ease-in-out infinite alternate;
}

.action-dot {
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--teal);
}

.action-tip.ready .action-dot {
  background: var(--coral);
}

.danger-tip {
  display: none;
  place-items: center;
  padding: 7px 14px;
  background: var(--coral);
  color: #fff;
  text-shadow: 0 2px 0 rgba(86, 27, 24, 0.3);
}

.stage.danger .danger-tip {
  display: grid;
}

.story-modal,
.result-modal {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(70, 44, 31, 0.42);
  backdrop-filter: blur(3px);
}

.story-modal.show,
.result-modal.show {
  display: grid;
  animation: modalFade 220ms ease-out;
}

.story-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  width: min(760px, 94%);
  overflow: hidden;
  border: 5px solid var(--ink);
  border-radius: 24px 16px 26px 18px;
  background: linear-gradient(150deg, #fffef8, #fff0c9);
  box-shadow: 0 14px 0 rgba(75, 52, 40, 0.22), 0 28px 60px rgba(50, 28, 18, 0.24);
  transform: rotate(-0.5deg);
}

.story-portrait {
  display: grid;
  place-items: center;
  min-height: 285px;
  padding: 20px;
  border-right: 4px solid var(--ink);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 4px, transparent 5px) 0 0 / 24px 24px,
    #ffd568;
}

.story-portrait svg {
  width: 125px;
  height: 145px;
  filter: drop-shadow(0 8px 2px rgba(75, 52, 40, 0.16));
}

.story-content {
  padding: 24px 26px 22px;
}

.story-chapter {
  margin: 0 0 5px;
  color: var(--coral-deep);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.story-content h3 {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", cursive;
  font-size: 34px;
  line-height: 1.15;
}

.story-dialogues {
  display: grid;
  gap: 9px;
  min-height: 92px;
  margin: 11px 0 14px;
}

.dialogue-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 8px 10px;
  border: 2px solid rgba(75, 52, 40, 0.22);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.7);
}

.dialogue-row:nth-child(2) {
  transform: translateX(10px);
}

.dialogue-row p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.65;
}

.story-tip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 15px;
  padding: 8px 11px;
  border: 2px dashed rgba(75, 52, 40, 0.55);
  border-radius: 12px;
  background: #fff8dc;
  font-size: 13px;
  font-weight: 800;
}

.story-tip-key {
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(75, 52, 40, 0.18);
}

.primary-button {
  min-height: 48px;
  padding: 9px 22px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: var(--coral);
  color: #fff;
  box-shadow: 0 5px 0 #a9433f;
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(86, 27, 24, 0.28);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #a9433f;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #a9433f;
}

.result-card {
  width: min(480px, 92%);
  padding: 30px 25px 24px;
  border: 5px solid var(--ink);
  border-radius: 26px 18px 24px 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 208, 91, 0.3) 0 5px, transparent 6px) 0 0 / 28px 28px,
    var(--paper);
  box-shadow: 0 14px 0 rgba(75, 52, 40, 0.22), 0 30px 60px rgba(50, 28, 18, 0.22);
  text-align: center;
}

.result-stamp {
  display: grid;
  place-items: center;
  width: 94px;
  height: 94px;
  margin: -68px auto 14px;
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  color: var(--coral-deep);
  font-family: "Kaiti SC", "STKaiti", cursive;
  font-size: 29px;
  font-weight: 900;
  transform: rotate(-7deg);
}

.result-card h3 {
  margin: 0;
  font-family: "Kaiti SC", "STKaiti", cursive;
  font-size: 32px;
}

.result-card p {
  margin: 8px 0 18px;
  color: var(--ink-soft);
  font-weight: 700;
  line-height: 1.6;
}

.result-story {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 2px 0 20px;
  padding: 10px 12px;
  border: 2px dashed rgba(75, 52, 40, 0.55);
  border-radius: 14px;
  background: #fff7d9;
  text-align: left;
}

.result-story p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.touch-controls {
  position: absolute;
  inset: auto 14px 60px;
  z-index: 52;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 48px);
  gap: 3px;
}

.touch-actions {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.touch-button {
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  background: rgba(255, 253, 246, 0.88);
  box-shadow: 0 5px 0 rgba(75, 52, 40, 0.25);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.touch-button.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(75, 52, 40, 0.25);
}

.dpad .touch-button {
  border-radius: 13px;
  font-size: 18px;
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
}

.dpad-center {
  grid-column: 2;
  grid-row: 2;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(84, 191, 179, 0.76);
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
}

.dash-button,
.action-button {
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
}

.dash-button {
  width: 70px;
  height: 70px;
  background: var(--sky);
}

.action-button {
  width: 88px;
  height: 88px;
  background: var(--coral);
}

.action-button.ready {
  animation: touchReady 520ms ease-in-out infinite alternate;
}

.touch-button span {
  font-size: 15px;
  line-height: 1;
}

.touch-button small {
  font-size: 9px;
}

.keyboard-guide {
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  min-height: 58px;
  padding: 9px 8px 0;
}

.key-group {
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}

.keycap {
  padding: 4px 7px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #fff8df;
  box-shadow: 0 3px 0 rgba(75, 52, 40, 0.16);
}

.keycap-warm {
  background: #ffd0c7;
}

.keycap-blue {
  background: #ccecff;
}

.guide-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.level-panel {
  align-self: start;
  padding: 15px 13px;
  border-radius: 24px 16px 20px 14px;
}

.panel-heading {
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px 12px;
  border-bottom: 3px dashed rgba(75, 52, 40, 0.3);
}

.panel-heading h2 {
  font-size: 24px;
}

.overall-progress {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 68px;
  padding: 7px 10px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: var(--sun);
}

.overall-progress strong {
  font-size: 25px;
}

.overall-progress span {
  font-size: 12px;
  font-weight: 900;
}

.chapter-list {
  display: grid;
  gap: 12px;
  margin-top: 13px;
}

.chapter-block {
  padding: 10px;
  border: 3px solid var(--ink);
  border-radius: 15px 12px 17px 11px;
  background: #fff9e8;
}

.chapter-block:nth-child(2) {
  background: #eaf7ef;
}

.chapter-block:nth-child(3) {
  background: #e8f5fc;
}

.chapter-block:nth-child(4) {
  background: #fff0ed;
}

.chapter-block:nth-child(5) {
  background: #fff2c9;
}

.chapter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 900;
}

.chapter-title span {
  color: var(--ink-soft);
  font-size: 10px;
}

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

.level-button {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 12px 9px 13px 8px;
  background: var(--paper);
  box-shadow: 0 3px 0 rgba(75, 52, 40, 0.15);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  transition: transform 140ms ease, background 140ms ease;
}

.level-button:hover:not(:disabled) {
  transform: translateY(-2px) rotate(-2deg);
  background: #fff0b6;
}

.level-button.current {
  background: var(--sun);
  transform: rotate(-3deg);
}

.level-button.done {
  background: #bfe8d0;
}

.level-button.done::after {
  content: "✓";
  position: absolute;
  top: -7px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
}

.level-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  filter: grayscale(1);
}

.rules-card {
  align-items: flex-start;
  gap: 10px;
  margin-top: 13px;
  padding: 11px;
  border: 3px solid var(--ink);
  border-radius: 17px 11px 15px 12px;
  background: #fff0c4;
  transform: rotate(0.4deg);
}

.rules-cat {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 72px;
  height: 54px;
  border: 2px dashed var(--ink);
  border-radius: 50%;
  background: #fff;
  color: var(--coral-deep);
  font-family: monospace;
  font-size: 12px;
  font-weight: 900;
}

.rules-card h3 {
  margin: 0 0 3px;
  font-size: 14px;
}

.rules-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

@keyframes dangerPulse {
  to {
    border-color: rgba(217, 75, 75, 0.82);
    box-shadow: inset 0 0 85px rgba(179, 30, 30, 0.33);
  }
}

@keyframes safeGlow {
  to {
    filter: drop-shadow(0 0 15px rgba(255, 218, 66, 0.95));
    transform: scale(1.04);
  }
}

@keyframes characterBob {
  to {
    transform: translateY(-3px) rotate(1deg);
  }
}

@keyframes catHit {
  50% {
    opacity: 0.35;
    filter: saturate(0) brightness(2);
  }
}

@keyframes ringPulse {
  from {
    opacity: 0.55;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@keyframes guideBounce {
  to {
    transform: translate(-50%, calc(-100% - 9px));
  }
}

@keyframes dropPop {
  from {
    opacity: 0;
    transform: translate(-50%, -90%) scale(0.45) rotate(-18deg);
  }
}

@keyframes particleFly {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--spin)) scale(0.3);
  }
}

@keyframes comicPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(-10deg);
  }
  24%,
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-4deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1.12) rotate(2deg);
  }
}

@keyframes readyPulse {
  to {
    transform: scale(1.025);
    box-shadow: 0 7px 0 rgba(75, 52, 40, 0.16);
  }
}

@keyframes touchReady {
  to {
    box-shadow: 0 7px 0 rgba(75, 52, 40, 0.26), 0 0 0 7px rgba(255, 211, 82, 0.45);
    transform: scale(1.04);
  }
}

@keyframes modalFade {
  from {
    opacity: 0;
  }
}

@media (pointer: coarse), (max-width: 860px) {
  .touch-controls {
    display: flex;
  }

  .action-ribbon {
    bottom: 12px;
  }
}

@media (max-width: 1240px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .level-panel {
    width: 100%;
  }

  .chapter-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rules-card {
    display: none;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: calc(100vw - 14px);
    margin-top: 7px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .chapter-badge {
    flex: 0 0 100%;
    width: auto;
  }

  .mission-strip {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .mission-progress {
    flex: 1 1 100%;
    padding: 8px 0 0;
    border-top: 2px dashed rgba(75, 52, 40, 0.32);
    border-left: 0;
  }

  .stage {
    min-height: 0;
  }

  .keyboard-guide {
    display: none;
  }
}

@media (max-width: 680px) {
  .brand-lockup {
    min-width: 0;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .chapter-badge {
    width: 100%;
  }

  .icon-button {
    flex: 1 1 0;
  }

  .mission-index {
    width: 55px;
  }

  .mission-copy {
    min-width: 0;
  }

  .mission-copy p {
    font-size: 12px;
  }

  .stage {
    min-height: 430px;
    aspect-ratio: auto;
  }

  .story-card {
    grid-template-columns: 1fr;
  }

  .story-portrait {
    display: none;
  }

  .story-content {
    padding: 20px;
  }

  .dialogue-row:nth-child(2) {
    transform: none;
  }

  .reaction-bubble {
    top: 118px;
    right: 10px;
    width: min(300px, calc(100% - 20px));
  }

  .chapter-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .touch-controls {
    right: 8px;
    left: 8px;
  }

  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 43px);
  }

  .dash-button {
    width: 62px;
    height: 62px;
  }

  .action-button {
    width: 76px;
    height: 76px;
  }

  .action-ribbon {
    width: calc(100% - 24px);
  }

  .danger-tip {
    display: none !important;
  }
}

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