:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #66707a;
  --paper: #fffdf3;
  --sun: #f8d84a;
  --sky: #54c7ec;
  --leaf: #40b36a;
  --berry: #f0627a;
  --violet: #7956d8;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  height: 100dvh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(32, 33, 36, 0.035) 1px, transparent 1px),
    #eef7f1;
  background-size: 1.5rem 1.5rem;
  color: var(--ink);
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 4px solid rgba(84, 199, 236, 0.5);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell,
.screen {
  min-height: 100dvh;
}

.app-shell {
  height: 100dvh;
  overflow: hidden;
}

.screen {
  width: min(70rem, 100%);
  margin: 0 auto;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    max(0.85rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-left));
}

/* アプリ起動ロゴ */
.launch-screen {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: none;
  overflow: hidden;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background: #fff;
}

.launch-logo-video {
  display: block;
  width: clamp(8rem, 42vw, 10.5rem);
  max-width: 100%;
  max-height: 42dvh;
  border: 0;
  background: #fff;
  object-fit: contain;
  opacity: 0;
  animation: launch-logo-fade-in 300ms ease-out forwards;
}

.launch-screen.is-fading-out .launch-logo-video {
  animation: launch-logo-fade-out 1400ms ease-in-out forwards;
}

@keyframes launch-logo-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes launch-logo-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* オープニング */
.opening-screen {
  position: relative;
  width: 100%;
  max-width: none;
  overflow: hidden;
  padding: 0;
  background:
    radial-gradient(circle at 50% 110%, rgba(22, 111, 137, 0.28), transparent 52%),
    #02060d;
  color: #e8ffff;
  image-rendering: pixelated;
}

.prologue-overlay {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  inset: 0;
  width: 100%;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
  border: 0;
  background: #000;
  color: #edf9f8;
  cursor: pointer;
}

.prologue-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: min(24rem, 82%);
  min-height: 12rem;
  font-family: "Courier New", "Hiragino Kaku Gothic ProN", monospace;
  font-size: clamp(1.05rem, 5.4vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.9;
  text-align: left;
  text-shadow: 2px 0 #233149;
  transition:
    opacity 1.1s steps(6, end),
    transform 1.1s steps(6, end);
}

.prologue-copy.is-leaving {
  opacity: 0;
  transform: translateY(-5px);
}

.prologue-line {
  display: block;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 1.15s steps(6, end),
    transform 1.15s steps(6, end);
}

.prologue-line.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.prologue-line.prologue-gap {
  min-height: 1.25rem;
}

.prologue-shock {
  display: inline-block;
}

.prologue-overlay.is-ready .prologue-shock {
  animation: prologueShake 0.22s 0.18s steps(2, end) 3;
  color: #fff4db;
  text-shadow:
    2px 0 #694141,
    -2px 0 #24304c;
}

.prologue-hint {
  position: absolute;
  right: 1.2rem;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  color: #8edbdc;
  opacity: 0;
  transition: opacity 0.2s;
}

.prologue-overlay.is-ready .prologue-hint {
  opacity: 1;
  animation: openingNext 0.8s steps(2, end) infinite;
}

.opening-skip-button {
  position: absolute;
  z-index: 30;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  min-height: 2.6rem;
  border: 3px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  background: rgba(7, 10, 30, 0.38);
  padding: 0.45rem 0.9rem;
  color: rgba(255, 255, 255, 0.76);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 1000;
  cursor: pointer;
  opacity: 0.72;
}

.opening-skip-button[hidden] {
  display: none;
}

.opening-skip-button:active {
  transform: translate(2px, 2px);
}

.opening-tank {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
}

.opening-tank::before {
  position: absolute;
  z-index: 3;
  inset: 0;
  background:
    linear-gradient(104deg, transparent 0 8%, rgba(154, 244, 247, 0.08) 10%, transparent 14% 83%, rgba(154, 244, 247, 0.06) 86%, transparent 91%),
    radial-gradient(ellipse at 50% 48%, transparent 38%, rgba(1, 8, 22, 0.16) 67%, rgba(1, 5, 15, 0.62) 100%);
  box-shadow:
    inset 28px 0 55px rgba(0, 10, 30, 0.35),
    inset -28px 0 55px rgba(0, 10, 30, 0.35);
  content: "";
  pointer-events: none;
}

.opening-lab {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 0 92%, #21165c 92% 100%) 0 0 / 4rem 4rem,
    linear-gradient(transparent 0 92%, #21165c 92% 100%) 0 0 / 4rem 4rem,
    #0d0936;
  opacity: 0;
}

.opening-screen.lab-scene .opening-tank,
.opening-screen.lab-scene .opening-eyelids {
  display: none;
}

.opening-screen.lab-scene .opening-lab {
  animation: labSceneReveal 0.9s steps(6, end) forwards;
}

.opening-lab::after {
  position: absolute;
  z-index: 8;
  inset: 0;
  background: transparent;
  box-shadow:
    inset 18px 0 #05031c,
    inset -18px 0 #05031c,
    inset 0 14px #05031c,
    inset 0 -14px #05031c;
  content: "";
  pointer-events: none;
}

.opening-lab.switch-pressed {
  animation: labSwitchFlash 0.55s steps(2, end);
}

.opening-lab.lab-shaking {
  opacity: 1;
}

.opening-screen.lab-scene .opening-lab.lab-shaking {
  animation: labPowerShake 0.12s steps(2, end) infinite;
}

.lab-scene-three-art,
.lab-scene-four-art {
  position: absolute;
  inset: 0;
}

.lab-scene-three-art {
  z-index: 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 58% 44%, rgba(74, 39, 133, 0.24), transparent 36%),
    #10083f;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 2s ease-in-out,
    visibility 0s;
}

.lab-scene-four-art {
  z-index: 2;
  display: block;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 2s ease-in-out,
    visibility 0s 2s;
}

.opening-lab.scene-four .lab-scene-three-art {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 2s ease-in-out,
    visibility 0s 2s;
}

.opening-lab.scene-four .lab-scene-four-art {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 2s ease-in-out,
    visibility 0s;
}

.lab-scene-four-art > :not(.scene4-frame) {
  display: none;
}

.scene4-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100vw, 100dvh);
  aspect-ratio: 1;
  overflow: hidden;
  background: #0d0836;
  transform: translate(-50%, -50%);
}

.scene4-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  transition: opacity 0.36s steps(3, end);
}

.scene4-background-pulled {
  opacity: 0;
}

.opening-lab.lever-pulled .scene4-background-idle {
  opacity: 0;
}

.opening-lab.lever-pulled .scene4-background-pulled {
  opacity: 1;
}

.scene4-doctor-sprite {
  position: absolute;
  z-index: 3;
  bottom: 0;
  left: 12%;
  width: 64%;
  aspect-ratio: 1;
  background: url("./assets/opening/scene4-doctor-sprites-v3.png") 0 0 / 200% 100% no-repeat;
  image-rendering: pixelated;
}

.opening-lab.lever-pulled .scene4-doctor-sprite {
  background-position: 100% 0;
  transform-origin: 62% 72%;
  animation: scene4DoctorPullNudge 0.5s steps(3, end);
}

.opening-lab.scene-four ~ .opening-ui .opening-dialogue.lab-dialogue {
  top: 42%;
  left: 73%;
  width: min(21rem, 52%);
}

.opening-screen.opening-final-line .opening-lab.scene-four ~ .opening-ui .opening-dialogue.lab-dialogue {
  top: 50%;
  left: 50%;
  width: min(34rem, 92%);
}

.scene4-tank {
  position: absolute;
  z-index: 2;
  top: 17.4%;
  left: 12%;
  width: 30.7%;
  height: 57.1%;
  overflow: hidden;
  background: #063257;
  box-shadow:
    inset 10px 0 rgba(56, 208, 230, 0.14),
    inset -8px 0 rgba(5, 16, 66, 0.35);
}

.scene4-tank::after {
  position: absolute;
  z-index: 4;
  inset: 0;
  background: rgba(218, 253, 255, 0.92);
  box-shadow:
    inset 0 0 18px #fff,
    0 0 12px rgba(93, 238, 255, 0.9);
  content: "";
  opacity: 0;
  pointer-events: none;
}

.opening-lab.capsule-preflash .scene4-tank::after {
  animation: scene4TankPreflash 1s linear forwards;
}

.scene4-liquid {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(58, 221, 235, 0.16), transparent 30%, transparent 72%, rgba(13, 10, 74, 0.2)),
    linear-gradient(180deg, rgba(31, 142, 184, 0.2), rgba(3, 43, 88, 0.65));
}

.scene4-liquid::before {
  position: absolute;
  top: 2%;
  right: 0;
  left: 0;
  height: 2.5%;
  background: rgba(80, 235, 242, 0.45);
  content: "";
  animation: scene4LiquidRipple 1.2s steps(3, end) infinite;
}

.scene4-electricity {
  position: absolute;
  z-index: 1;
  top: 0;
  left: -40%;
  width: 180%;
  height: 100%;
  opacity: 0;
  transform-origin: 50% 40%;
}

.opening-lab.capsule-powered .scene4-electricity {
  opacity: 1;
  animation:
    scene4ElectricOrbit 1.8s steps(8, end) infinite,
    scene4ElectricPulse 0.24s steps(2, end) infinite;
}

.scene4-bolt {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 66%;
  height: 8%;
  background: var(--bolt-color, #b746ff);
  filter: drop-shadow(0 0 3px var(--bolt-glow, #f3c4ff));
  transform-origin: 0 50%;
}

.scene4-bolt-one {
  --bolt-color: #b946ff;
  --bolt-glow: #edb6ff;
  width: 72%;
  height: 8%;
  clip-path: polygon(0 34%, 13% 34%, 19% 4%, 29% 67%, 40% 19%, 51% 78%, 63% 8%, 72% 62%, 85% 23%, 93% 58%, 100% 58%, 100% 84%, 92% 84%, 84% 52%, 72% 91%, 63% 39%, 51% 100%, 40% 48%, 29% 94%, 19% 42%, 13% 69%, 0 69%);
  transform: rotate(0deg);
}

.scene4-bolt-two {
  --bolt-color: #42e9ff;
  --bolt-glow: #bdf9ff;
  width: 51%;
  height: 9%;
  clip-path: polygon(0 42%, 9% 42%, 16% 18%, 25% 63%, 34% 5%, 46% 72%, 55% 30%, 67% 88%, 78% 12%, 87% 57%, 100% 36%, 100% 68%, 88% 87%, 78% 45%, 67% 100%, 55% 57%, 46% 96%, 34% 33%, 25% 91%, 16% 48%, 9% 73%, 0 73%);
  transform: rotate(45deg);
}

.scene4-bolt-three {
  --bolt-color: #ff4fbd;
  --bolt-glow: #ffc2eb;
  width: 64%;
  height: 7.5%;
  clip-path: polygon(0 29%, 11% 29%, 20% 57%, 31% 2%, 40% 71%, 53% 21%, 61% 87%, 73% 36%, 82% 5%, 91% 63%, 100% 48%, 100% 78%, 90% 92%, 82% 39%, 73% 69%, 61% 100%, 53% 51%, 40% 96%, 31% 34%, 20% 88%, 11% 59%, 0 59%);
  transform: rotate(90deg);
}

.scene4-bolt-four {
  --bolt-color: #5578ff;
  --bolt-glow: #bbc8ff;
  width: 46%;
  height: 9.5%;
  clip-path: polygon(0 39%, 15% 39%, 22% 10%, 35% 81%, 47% 27%, 58% 68%, 70% 3%, 80% 74%, 89% 31%, 100% 55%, 100% 83%, 89% 61%, 80% 100%, 70% 34%, 58% 94%, 47% 52%, 35% 100%, 22% 45%, 15% 70%, 0 70%);
  transform: rotate(135deg);
}

.scene4-bolt-five {
  --bolt-color: #ffe45b;
  --bolt-glow: #fff5b6;
  width: 68%;
  height: 8.5%;
  clip-path: polygon(0 45%, 10% 45%, 17% 9%, 28% 59%, 37% 16%, 45% 85%, 57% 34%, 66% 3%, 75% 73%, 87% 25%, 94% 62%, 100% 62%, 100% 88%, 93% 88%, 86% 55%, 75% 100%, 66% 39%, 57% 66%, 45% 100%, 37% 45%, 28% 91%, 17% 40%, 10% 75%, 0 75%);
  transform: rotate(180deg);
}

.scene4-bolt-six {
  --bolt-color: #42e9ff;
  --bolt-glow: #bdf9ff;
  width: 55%;
  height: 7%;
  clip-path: polygon(0 32%, 12% 32%, 21% 61%, 30% 6%, 42% 75%, 50% 23%, 62% 93%, 71% 42%, 81% 13%, 89% 70%, 100% 49%, 100% 81%, 89% 99%, 81% 48%, 71% 74%, 62% 100%, 50% 55%, 42% 98%, 30% 38%, 21% 92%, 12% 62%, 0 62%);
  transform: rotate(225deg);
}

.scene4-bolt-seven {
  --bolt-color: #ff4fbd;
  --bolt-glow: #ffc2eb;
  width: 76%;
  height: 9%;
  clip-path: polygon(0 41%, 8% 41%, 15% 21%, 24% 70%, 36% 1%, 45% 58%, 54% 27%, 64% 89%, 76% 17%, 85% 76%, 94% 38%, 100% 38%, 100% 69%, 93% 69%, 85% 100%, 76% 48%, 64% 100%, 54% 59%, 45% 90%, 36% 33%, 24% 98%, 15% 53%, 8% 72%, 0 72%);
  transform: rotate(270deg);
}

.scene4-bolt-eight {
  --bolt-color: #5578ff;
  --bolt-glow: #bbc8ff;
  width: 49%;
  height: 8%;
  clip-path: polygon(0 36%, 14% 36%, 23% 4%, 32% 77%, 44% 32%, 56% 91%, 65% 18%, 74% 61%, 83% 8%, 92% 68%, 100% 51%, 100% 82%, 91% 96%, 83% 43%, 74% 93%, 65% 49%, 56% 100%, 44% 62%, 32% 100%, 23% 39%, 14% 67%, 0 67%);
  transform: rotate(315deg);
}

.scene4-monster {
  position: absolute;
  z-index: 2;
  inset: 0;
  animation: scene4MonsterTwitch 3.8s steps(1, end) infinite;
}

.scene4-brain {
  position: absolute;
  top: 20%;
  left: 23%;
  width: 54%;
  aspect-ratio: 1.05;
  background: #f45291;
  clip-path: polygon(16% 10%, 38% 10%, 38% 2%, 58% 2%, 58% 10%, 80% 10%, 80% 21%, 92% 21%, 92% 38%, 100% 38%, 100% 66%, 91% 66%, 91% 82%, 77% 82%, 77% 93%, 24% 93%, 24% 85%, 10% 85%, 10% 71%, 2% 71%, 2% 39%, 9% 39%, 9% 22%, 16% 22%);
  filter: drop-shadow(0 0 5px rgba(255, 79, 162, 0.45));
}

.scene4-brain-groove {
  position: absolute;
  display: block;
  width: 25%;
  height: 8%;
  background: #bd2d75;
}

.scene4-brain-groove::after {
  position: absolute;
  width: 35%;
  height: 170%;
  background: inherit;
  content: "";
}

.scene4-brain-groove.groove-one {
  top: 24%;
  left: 13%;
}

.scene4-brain-groove.groove-one::after {
  top: 0;
  right: -35%;
}

.scene4-brain-groove.groove-two {
  top: 46%;
  right: 14%;
}

.scene4-brain-groove.groove-two::after {
  top: -70%;
  left: -35%;
}

.scene4-brain-groove.groove-three {
  bottom: 23%;
  left: 19%;
}

.scene4-brain-groove.groove-three::after {
  right: -35%;
  bottom: 0;
}

.scene4-brain-groove.groove-four {
  top: 16%;
  right: 18%;
  width: 8%;
  height: 24%;
}

.scene4-monster-body {
  position: absolute;
  top: 45%;
  left: 39%;
  width: 24%;
  height: 42%;
  background: #bd75e7;
  clip-path: polygon(0 0, 68% 0, 68% 12%, 100% 12%, 100% 30%, 61% 30%, 61% 47%, 92% 47%, 92% 64%, 54% 64%, 54% 82%, 80% 82%, 80% 100%, 18% 100%, 18% 88%, 0 88%, 0 70%, 35% 70%, 35% 51%, 8% 51%, 8% 34%, 43% 34%, 43% 17%, 0 17%);
  filter: drop-shadow(0 0 4px rgba(184, 98, 239, 0.5));
}

.scene4-bubble {
  position: absolute;
  z-index: 3;
  bottom: 3%;
  width: 10%;
  aspect-ratio: 1;
  border: 2px solid rgba(106, 239, 247, 0.92);
  background: rgba(103, 229, 244, 0.14);
  box-shadow: inset 2px 2px rgba(221, 255, 255, 0.35);
  opacity: 0;
  animation: scene4BubbleRise 2.6s steps(8, end) infinite;
}

.scene4-bubble.bubble-one {
  left: 13%;
}

.scene4-bubble.bubble-two {
  left: 30%;
  width: 7%;
  animation-delay: -1.2s;
}

.scene4-bubble.bubble-three {
  left: 62%;
  width: 11%;
  animation-delay: -2s;
}

.scene4-bubble.bubble-four {
  left: 78%;
  width: 6%;
  animation-delay: -0.55s;
}

.scene4-bubble.bubble-five {
  left: 48%;
  width: 8%;
  animation-delay: -1.7s;
}

.scene3-floor {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 14%;
  border-top: clamp(6px, 1vw, 12px) solid #4a2b82;
  background: #241253;
  box-shadow: inset 0 14px #1a0c48;
}

.scene3-capsule {
  position: absolute;
  z-index: 2;
  top: 6%;
  bottom: 10%;
  left: 3%;
  width: 45%;
  filter: drop-shadow(10px 12px 0 #070326);
}

.scene3-capsule-glass {
  position: absolute;
  top: 12%;
  right: 7%;
  bottom: 23%;
  left: 7%;
  overflow: hidden;
  border-right: clamp(7px, 1vw, 12px) solid #493873;
  border-left: clamp(7px, 1vw, 12px) solid #493873;
  background:
    linear-gradient(90deg, rgba(37, 130, 164, 0.36), transparent 16% 84%, rgba(7, 28, 73, 0.4)),
    #05446c;
  box-shadow:
    inset 12px 0 rgba(62, 182, 202, 0.18),
    inset -12px 0 rgba(0, 15, 54, 0.28);
}

.scene3-capsule-top {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 2%;
  left: 2%;
  height: 17%;
  background:
    linear-gradient(to bottom, #4b3180 0 28%, #5f4390 28% 55%, #7655a1 55%);
  box-shadow:
    0 8px #20104f,
    inset 0 -7px #3a216e;
  clip-path: polygon(17% 0, 83% 0, 83% 9%, 96% 9%, 96% 25%, 100% 25%, 100% 100%, 0 100%, 0 25%, 4% 25%, 4% 9%, 17% 9%);
}

.scene3-capsule-base {
  position: absolute;
  z-index: 4;
  right: 2%;
  bottom: 0;
  left: 2%;
  height: 27%;
  border-top: clamp(7px, 1vw, 12px) solid #7655a1;
  background:
    repeating-linear-gradient(90deg, #120a3f 0 8%, transparent 8% 13%) 8% 60% / 84% 42% no-repeat,
    #3f286f;
  box-shadow:
    inset 0 10px #593a87,
    0 9px #170a45;
}

.scene3-monster {
  position: absolute;
  z-index: 2;
  top: 22%;
  left: 50%;
  width: 46%;
  aspect-ratio: 0.72;
  transform: translateX(-50%);
  transform-origin: 50% 55%;
  animation: scene3MonsterTwitch 5.6s steps(1, end) infinite;
}

.scene3-monster-head {
  position: absolute;
  top: 0;
  left: 50%;
  width: 100%;
  aspect-ratio: 1.16;
  background:
    linear-gradient(90deg, #e6448d 0 12%, transparent 12% 88%, #e6448d 88%) 0 0 / 100% 18% no-repeat,
    #f34f95;
  box-shadow:
    -7px 7px #ab2a7f,
    7px 7px #ab2a7f;
  clip-path: polygon(18% 0, 42% 0, 42% 12%, 58% 12%, 58% 0, 82% 0, 82% 10%, 92% 10%, 92% 23%, 100% 23%, 100% 78%, 90% 78%, 90% 90%, 75% 90%, 75% 100%, 25% 100%, 25% 92%, 10% 92%, 10% 80%, 0 80%, 0 23%, 8% 23%, 8% 10%, 18% 10%);
  transform: translateX(-50%);
}

.scene3-monster-head::before,
.scene3-monster-head::after {
  position: absolute;
  background: #b72e7c;
  content: "";
}

.scene3-monster-head::before {
  top: 14%;
  left: 44%;
  width: 13%;
  height: 70%;
  clip-path: polygon(0 0, 100% 0, 100% 15%, 42% 15%, 42% 31%, 100% 31%, 100% 47%, 42% 47%, 42% 63%, 100% 63%, 100% 79%, 42% 79%, 42% 100%, 0 100%, 0 72%, 58% 72%, 58% 56%, 0 56%, 0 40%, 58% 40%, 58% 24%, 0 24%);
}

.scene3-monster-head::after {
  top: 34%;
  left: 17%;
  width: 22%;
  height: 9%;
  box-shadow:
    0 18px #b72e7c,
    clamp(2.6rem, 8vw, 5.2rem) -9px #b72e7c,
    clamp(2.6rem, 8vw, 5.2rem) 12px #b72e7c;
}

.scene3-monster-tail {
  position: absolute;
  z-index: -1;
  top: 52%;
  left: 50%;
  width: 46%;
  height: 72%;
  background: #bd81e4;
  clip-path: polygon(40% 0, 60% 0, 60% 20%, 80% 20%, 80% 60%, 45% 60%, 45% 70%, 65% 70%, 65% 100%, 50% 100%, 50% 85%, 30% 85%, 30% 45%, 65% 45%, 65% 35%, 40% 35%);
  transform: translateX(-50%);
}

.scene3-bubble {
  position: absolute;
  bottom: -8%;
  width: clamp(0.65rem, 3.8vw, 2.8rem);
  aspect-ratio: 1;
  background: #45c0d9;
  box-shadow:
    inset 5px 0 #79e5e6,
    5px 5px #07557c;
  opacity: 0;
  animation: scene3BubbleRise 5s steps(9, end) infinite;
}

.scene3-bubble-one {
  left: 12%;
  animation-delay: -0.8s;
}

.scene3-bubble-two {
  left: 76%;
  width: clamp(0.45rem, 2.8vw, 2rem);
  animation-delay: -2.3s;
}

.scene3-bubble-three {
  left: 28%;
  width: clamp(0.35rem, 2.1vw, 1.45rem);
  animation-delay: -4.1s;
}

.scene3-bubble-four {
  left: 63%;
  animation-delay: -3.2s;
  animation-duration: 6.2s;
}

.scene3-bubble-five {
  left: 46%;
  width: clamp(0.3rem, 1.8vw, 1.1rem);
  animation-delay: -1.7s;
  animation-duration: 4.3s;
}

.scene3-console {
  position: absolute;
  z-index: 4;
  bottom: 9%;
  left: 47%;
  width: 15%;
  height: 39%;
  border: clamp(6px, 0.8vw, 10px) solid #100735;
  background:
    linear-gradient(to bottom, #4d317d 0 52%, #68458f 52% 58%, #47296f 58%);
  box-shadow:
    inset 8px 0 #6f4b9b,
    inset -8px 0 #2c175c,
    8px 9px #080326;
  clip-path: polygon(10% 0, 90% 0, 100% 14%, 100% 100%, 0 100%, 0 14%);
}

.scene3-button {
  position: absolute;
  top: 7%;
  right: 18%;
  left: 18%;
  height: 21%;
  border: clamp(5px, 0.65vw, 8px) solid #24104f;
  background: linear-gradient(to bottom, #ffb60c 0 70%, #ff5b11 70%);
  box-shadow:
    inset 6px 0 #ffd44a,
    0 7px #2b155e;
  transform-origin: center bottom;
}

.opening-lab.switch-pressed .scene3-button {
  transform: translateY(7px) scaleY(0.78);
}

.scene3-doctor {
  position: absolute;
  z-index: 5;
  right: 1%;
  bottom: 8%;
  width: 41%;
  height: 72%;
  filter: drop-shadow(8px 10px 0 #080326);
}

.scene3-doctor-body {
  position: absolute;
  z-index: 2;
  top: 39%;
  right: 10%;
  bottom: 18%;
  left: 14%;
  background: #e5e4f2;
  box-shadow:
    inset 10px 0 #f9f8ff,
    inset -10px 0 #aaa5d0;
  clip-path: polygon(15% 0, 85% 0, 100% 18%, 92% 100%, 8% 100%, 0 18%);
}

.scene3-doctor-shirt {
  position: absolute;
  z-index: 3;
  top: 42%;
  bottom: 19%;
  left: 43%;
  width: 22%;
  background: #201052;
}

.scene3-doctor-head {
  position: absolute;
  z-index: 5;
  top: 3%;
  left: 31%;
  width: 48%;
  height: 38%;
  background: #d69a57;
  border-bottom: clamp(6px, 0.8vw, 10px) solid #8e5b37;
  box-shadow:
    inset 8px 0 #e9b36c,
    inset -8px 0 #af713e;
}

.scene3-doctor-head::before {
  position: absolute;
  z-index: 1;
  top: 45%;
  right: -12%;
  left: -12%;
  height: clamp(4px, 0.55vw, 7px);
  background: #282268;
  content: "";
}

.scene3-doctor-hair {
  position: absolute;
  z-index: 6;
  top: -1%;
  left: 22%;
  width: 66%;
  height: 22%;
}

.scene3-doctor-hair::before,
.scene3-doctor-hair::after {
  position: absolute;
  top: 8%;
  width: 34%;
  height: 92%;
  background: #f1f0fb;
  content: "";
}

.scene3-doctor-hair::before {
  left: 0;
  clip-path: polygon(24% 0, 100% 0, 100% 68%, 76% 68%, 76% 100%, 0 100%, 0 34%, 24% 34%);
}

.scene3-doctor-hair::after {
  right: 0;
  clip-path: polygon(0 0, 76% 0, 76% 34%, 100% 34%, 100% 100%, 24% 100%, 24% 68%, 0 68%);
}

.scene3-doctor-glasses {
  position: absolute;
  z-index: 7;
  top: 17%;
  left: 36%;
  width: 14%;
  height: 10%;
  border: clamp(4px, 0.55vw, 7px) solid #282268;
  background: #fff;
  box-shadow:
    clamp(1.7rem, 4vw, 3.3rem) 0 0 -4px #fff,
    clamp(1.7rem, 4vw, 3.3rem) 0 0 0 #282268;
}

.scene3-doctor-glasses::before,
.scene3-doctor-glasses::after {
  position: absolute;
  top: 35%;
  width: 20%;
  aspect-ratio: 1;
  background: #11102f;
  content: "";
}

.scene3-doctor-glasses::before {
  left: 34%;
}

.scene3-doctor-glasses::after {
  left: calc(clamp(1.7rem, 4vw, 3.3rem) + 38%);
}

.scene3-doctor-beard {
  position: absolute;
  z-index: 7;
  top: 30%;
  left: 31%;
  width: 50%;
  height: 14%;
  background: #f1f0fb;
  clip-path: polygon(0 0, 100% 0, 100% 65%, 78% 65%, 78% 100%, 61% 100%, 61% 72%, 39% 72%, 39% 100%, 22% 100%, 22% 65%, 0 65%);
}

.scene3-doctor-left-arm {
  position: absolute;
  z-index: 4;
  top: 45%;
  right: 68%;
  width: 49%;
  height: 11%;
  background: #e5e4f2;
  box-shadow:
    inset 0 -8px #aaa5d0,
    0 7px #0b0430;
  transform: rotate(-72deg);
  transform-origin: right center;
  transition: transform 0.45s steps(4, end);
}

.scene3-doctor-left-arm::before {
  position: absolute;
  top: 8%;
  left: -12%;
  width: 19%;
  height: 84%;
  background: #d69a57;
  box-shadow: inset 0 -5px #8e5b37;
  content: "";
}

.opening-lab.switch-pressed .scene3-doctor-left-arm {
  transform: rotate(0deg);
}

.scene3-doctor-right-arm {
  position: absolute;
  z-index: 4;
  top: 45%;
  right: 3%;
  width: 14%;
  height: 39%;
  background: #e5e4f2;
  box-shadow:
    inset -8px 0 #aaa5d0,
    7px 0 #0b0430;
}

.scene3-doctor-right-arm::after {
  position: absolute;
  right: 0;
  bottom: -8%;
  left: 0;
  height: 18%;
  background: #d69a57;
  content: "";
}

.scene3-doctor-legs {
  position: absolute;
  z-index: 1;
  bottom: 0;
  left: 32%;
  width: 16%;
  height: 25%;
  background: #1e0e51;
  box-shadow:
    clamp(3.4rem, 7vw, 6rem) 0 #1e0e51,
    0 10px #05031d,
    clamp(3.4rem, 7vw, 6rem) 10px #05031d;
}

@media (max-aspect-ratio: 4 / 5) {
  .lab-scene-three-art {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: 100vw;
    height: 100vw;
    transform: translate(-50%, -50%);
  }
}

.lab-floor {
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 32%;
  border-top: 10px solid #39236f;
  background:
    linear-gradient(135deg, #120a3d 25%, transparent 25%) 0 0 / 2.5rem 2.5rem,
    linear-gradient(225deg, #211052 25%, transparent 25%) 0 0 / 2.5rem 2.5rem,
    #170c45;
}

.lab-pipe {
  position: absolute;
  z-index: 0;
  top: 0;
  width: 1.35rem;
  height: 42%;
  border-right: 6px solid #0a062b;
  border-left: 6px solid #49317e;
  background: #241657;
  box-shadow: 0 0 0 5px #06031d;
}

.lab-pipe::after {
  position: absolute;
  right: -0.65rem;
  bottom: -0.7rem;
  left: -0.65rem;
  height: 1.4rem;
  border: 5px solid #06031d;
  background: #442b76;
  content: "";
}

.lab-pipe-left {
  left: 8%;
}

.lab-pipe-right {
  right: 14%;
  height: 28%;
}

.lab-capsule {
  position: absolute;
  z-index: 2;
  bottom: 8%;
  left: clamp(0.7rem, 7vw, 5rem);
  width: clamp(11rem, 38vw, 19rem);
  height: min(70dvh, 35rem);
  filter: drop-shadow(10px 12px 0 #05031e);
}

.lab-capsule-glass {
  position: absolute;
  top: 7%;
  right: 8%;
  bottom: 7%;
  left: 8%;
  overflow: hidden;
  border: 9px solid #493176;
  border-radius: 0;
  background:
    linear-gradient(90deg, #163c68 0 12%, transparent 12% 88%, #092751 88%),
    #07345b;
  box-shadow:
    inset 12px 0 #1b6d8e,
    inset -12px 0 #06173d;
}

.lab-capsule-cap {
  position: absolute;
  z-index: 4;
  right: 0;
  left: 0;
  height: 12%;
  border: 8px solid #080326;
  background:
    linear-gradient(to bottom, #6a4b9e 0 28%, #3a236f 28% 66%, #513487 66%);
  box-shadow: inset 0 -7px #21114f;
}

.lab-capsule-cap::before {
  position: absolute;
  top: 34%;
  right: 10%;
  left: 10%;
  height: 5px;
  background: repeating-linear-gradient(90deg, #896bb5 0 10%, #281658 10% 18%);
  content: "";
}

.lab-capsule-cap.cap-top {
  top: 0;
  clip-path: polygon(12% 0, 88% 0, 88% 18%, 100% 18%, 100% 100%, 0 100%, 0 18%, 12% 18%);
}

.lab-capsule-cap.cap-bottom {
  bottom: 0;
  transform: rotate(180deg);
  clip-path: polygon(12% 0, 88% 0, 88% 18%, 100% 18%, 100% 100%, 0 100%, 0 18%, 12% 18%);
}

.lab-liquid-line {
  position: absolute;
  z-index: 3;
  top: 17%;
  right: 0;
  left: 0;
  height: 8px;
  background: #35b7d1;
  box-shadow: 0 8px #071d49;
  opacity: 0.8;
}

.lab-electricity {
  position: absolute;
  z-index: 4;
  inset: 8% 4% 6%;
  opacity: 0;
}

.electric-bolt {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 58%;
  height: 8%;
  background: #a56cff;
  filter: drop-shadow(0 0 5px #55e8ff);
  clip-path: polygon(0 34%, 18% 34%, 29% 0, 40% 68%, 56% 18%, 66% 62%, 82% 28%, 90% 58%, 100% 58%, 100% 84%, 87% 84%, 80% 54%, 64% 88%, 55% 48%, 38% 100%, 27% 34%, 19% 64%, 0 64%);
  transform-origin: 0 50%;
}

.electric-bolt.bolt-one {
  transform: rotate(0deg);
}

.electric-bolt.bolt-two {
  background: #54dfff;
  transform: rotate(45deg);
}

.electric-bolt.bolt-three {
  transform: rotate(90deg);
}

.electric-bolt.bolt-four {
  background: #54dfff;
  transform: rotate(135deg);
}

.electric-bolt.bolt-five {
  transform: rotate(180deg);
}

.electric-bolt.bolt-six {
  background: #54dfff;
  transform: rotate(225deg);
}

.electric-bolt.bolt-seven {
  transform: rotate(270deg);
}

.electric-bolt.bolt-eight {
  background: #54dfff;
  transform: rotate(315deg);
}

.opening-lab.capsule-powered .lab-electricity {
  opacity: 1;
  animation: labElectricPulse 0.36s steps(2, end) infinite;
}

.opening-lab.capsule-powered .lab-capsule-glass {
  animation: labCapsuleFlash 0.32s steps(2, end) infinite;
}

.opening-lab.capsule-powered .lab-subject {
  animation: labSubjectShock 0.16s steps(2, end) infinite;
}

.lab-subject {
  position: absolute;
  z-index: 1;
  right: 18%;
  bottom: 9%;
  left: 18%;
  height: 54%;
  opacity: 0.92;
  transform-origin: 50% 64%;
  animation: labSubjectTwitch 5.4s steps(1, end) infinite;
}

.subject-head {
  position: absolute;
  top: 4%;
  left: 50%;
  width: 64%;
  aspect-ratio: 1;
  border-radius: 0;
  background: #ef4f91;
  clip-path: polygon(22% 0, 78% 0, 78% 12%, 92% 12%, 92% 28%, 100% 28%, 100% 72%, 90% 72%, 90% 88%, 72% 88%, 72% 100%, 28% 100%, 28% 92%, 12% 92%, 12% 78%, 0 78%, 0 28%, 10% 28%, 10% 12%, 22% 12%);
  box-shadow:
    -8px 8px 0 #8b2779,
    8px 8px 0 #8b2779;
  transform: translateX(-50%);
}

.subject-head::before,
.subject-head::after {
  position: absolute;
  top: 34%;
  width: 22%;
  aspect-ratio: 1;
  background: #fff8ff;
  box-shadow: inset 0 -5px #ddd2ff;
  content: "";
}

.subject-head::before {
  left: 20%;
}

.subject-head::after {
  right: 20%;
}

.subject-body {
  position: absolute;
  top: 25%;
  left: 55%;
  width: 12px;
  height: 12px;
  background: #c989ed;
  box-shadow:
    -12px 12px 0 #c989ed,
    -12px 24px 0 #c989ed,
    0 24px 0 #c989ed,
    0 36px 0 #c989ed,
    12px 36px 0 #c989ed,
    12px 48px 0 #c989ed,
    0 48px 0 #c989ed,
    0 60px 0 #c989ed,
    -12px 60px 0 #c989ed,
    -12px 72px 0 #c989ed,
    -24px 72px 0 #c989ed;
  transform: translateX(-50%);
}

.lab-small-bubble {
  position: absolute;
  z-index: 2;
  bottom: -1rem;
  width: 0.7rem;
  aspect-ratio: 1;
  border: 0;
  background: #42c1d5;
  box-shadow:
    -4px 0 #0a5f83,
    0 -4px #77e4e5;
  animation: labBubble 4s steps(8, end) infinite;
}

.lab-small-bubble.bubble-a {
  left: 18%;
}

.lab-small-bubble.bubble-b {
  left: 70%;
  animation-delay: -1.7s;
}

.lab-small-bubble.bubble-c {
  left: 50%;
  width: 0.35rem;
  animation-delay: -3s;
}

.lab-machine {
  position: absolute;
  z-index: 3;
  right: clamp(0.7rem, 7vw, 5rem);
  bottom: 15%;
  width: clamp(8.5rem, 27vw, 14rem);
  height: min(36dvh, 15rem);
  border: 8px solid #070322;
  background: #3a256b;
  box-shadow:
    inset 9px 0 #634391,
    inset -9px 0 #21114d,
    0 10px 0 #05031a;
  clip-path: polygon(0 16%, 86% 16%, 86% 0, 100% 0, 100% 100%, 0 100%);
}

.machine-screen {
  position: absolute;
  top: 20%;
  right: 13%;
  left: 16%;
  height: 26%;
  border: 6px solid #070322;
  background:
    linear-gradient(90deg, transparent 0 46%, #4ce2dd 46% 56%, transparent 56%),
    linear-gradient(#081943 0 44%, #4ce2dd 44% 56%, #081943 56%);
  box-shadow: inset 0 0 0 5px #12346b;
}

.machine-light,
.machine-key {
  position: absolute;
  display: block;
  border: 3px solid #070322;
}

.machine-light {
  top: 55%;
  width: 0.75rem;
  aspect-ratio: 1;
  background: #dfb642;
  animation: machineLight 1.2s steps(2, end) infinite;
}

.machine-light.light-one {
  left: 18%;
}

.machine-light.light-two {
  left: 34%;
  background: #4bcbb5;
  animation-delay: -0.4s;
}

.machine-light.light-three {
  left: 50%;
  background: #ba5754;
  animation-delay: -0.8s;
}

.machine-key {
  bottom: 15%;
  width: 1rem;
  height: 0.55rem;
  background: #8296a0;
}

.machine-key.key-one {
  left: 19%;
}

.machine-key.key-two {
  left: 42%;
}

.machine-key.key-three {
  left: 65%;
}

.machine-switch {
  position: absolute;
  right: 9%;
  bottom: 11%;
  width: 1.4rem;
  height: 1rem;
  border: 4px solid #070322;
  background: #ff8a18;
  box-shadow:
    inset 0 -5px #e44321,
    0 5px #12072f;
  transform-origin: center bottom;
}

.opening-lab.switch-pressed .machine-switch {
  transform: translateY(5px) scaleY(0.65);
}

.lab-lever {
  position: absolute;
  z-index: 6;
  right: clamp(0.7rem, 5vw, 4rem);
  bottom: 7%;
  width: clamp(5.2rem, 17vw, 8rem);
  height: min(42dvh, 18rem);
  opacity: 0;
  transform: translateY(calc(100% + 4rem));
}

.opening-lab.lever-ready .lab-lever {
  animation: labLeverRise 0.7s steps(6, end) forwards;
}

.lab-lever::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 32%;
  border: 7px solid #070322;
  background: #483174;
  box-shadow:
    inset 8px 0 #7454a0,
    inset -8px 0 #24134f,
    0 8px #05031a;
  clip-path: polygon(18% 0, 82% 0, 100% 25%, 100% 100%, 0 100%, 0 25%);
  content: "";
}

.lab-lever-slot {
  position: absolute;
  z-index: 2;
  right: 19%;
  bottom: 19%;
  left: 19%;
  height: 12%;
  border: 5px solid #090329;
  background: #160b40;
}

.lab-lever-stick {
  position: absolute;
  z-index: 3;
  bottom: 23%;
  left: 48%;
  width: 11%;
  height: 60%;
  background: #d21d32;
  box-shadow:
    inset 5px 0 #f05a4e,
    inset -5px 0 #7d0b29,
    5px 0 #090329;
  transform: rotate(24deg);
  transform-origin: 50% 93%;
}

.lab-lever-grip {
  position: absolute;
  z-index: 4;
  top: -12%;
  left: 50%;
  width: 320%;
  height: 20%;
  border: 5px solid #090329;
  background: #ed2737;
  box-shadow: inset 0 -7px #a30d2b;
  transform: translateX(-50%);
}

.opening-lab.lever-pulled .lab-lever-stick {
  animation: labLeverPull 0.58s steps(4, end) forwards;
}

.lab-doctor {
  position: absolute;
  z-index: 5;
  right: clamp(5.5rem, 19vw, 15rem);
  bottom: 7%;
  width: clamp(9rem, 29vw, 16rem);
  aspect-ratio: 1;
  filter:
    brightness(0.9)
    saturate(0.8)
    drop-shadow(8px 9px 0 #05031d);
  transform: rotate(2deg);
  transform-origin: bottom;
}

.lab-doctor-sprite {
  position: absolute;
  inset: 0;
  background: url("./assets/opening/opening-doctor-sprites.png") 0 0 / 300% 100% no-repeat;
  animation: labDoctorBlink 4.6s steps(1, end) infinite;
}

.lab-doctor-side {
  position: absolute;
  display: none;
  inset: 0;
}

.opening-lab.scene-four .lab-doctor-sprite {
  display: none;
}

.opening-lab.scene-four .lab-doctor-side {
  display: block;
}

.doctor-side-body {
  position: absolute;
  top: 45%;
  right: 18%;
  bottom: 8%;
  left: 20%;
  background: #d8d9e8;
  box-shadow:
    inset 10px 0 #f3f1ff,
    inset -10px 0 #9d9ac7,
    -10px 10px #d8d9e8;
  clip-path: polygon(16% 0, 82% 0, 100% 24%, 92% 100%, 0 100%, 0 24%);
}

.doctor-side-head {
  position: absolute;
  z-index: 2;
  top: 18%;
  right: 22%;
  width: 34%;
  height: 30%;
  background: #bd8955;
  border-bottom: 7px solid #865b3c;
  box-shadow:
    -12px -8px #e3e2f3,
    3px -13px #e3e2f3,
    -17px 4px #e3e2f3;
  clip-path: polygon(0 0, 76% 0, 76% 22%, 100% 22%, 100% 70%, 76% 70%, 76% 100%, 0 100%);
}

.doctor-side-glasses {
  position: absolute;
  z-index: 4;
  top: 27%;
  right: 11%;
  width: 29%;
  height: 14%;
  border: 6px solid #272568;
  background: #f8fbff;
  box-shadow: -9px 0 #272568;
}

.doctor-side-glasses::after {
  position: absolute;
  top: 28%;
  right: 22%;
  width: 28%;
  aspect-ratio: 1;
  background: #272568;
  content: "";
}

.doctor-side-beard {
  position: absolute;
  z-index: 3;
  top: 41%;
  right: 17%;
  width: 35%;
  height: 15%;
  background: #e3e2f3;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 72% 70%, 72% 100%, 28% 100%, 28% 70%, 0 70%);
}

.opening-lab.doctor-turning .lab-doctor {
  transform: none;
}

.opening-lab.doctor-turning .lab-doctor-sprite {
  background: none;
  animation: none;
}

.opening-lab.doctor-turning .lab-doctor-sprite::before {
  position: absolute;
  top: 43%;
  right: 24%;
  bottom: 8%;
  left: 24%;
  background: #d8d9e8;
  box-shadow:
    -12px 10px 0 #d8d9e8,
    12px 10px 0 #d8d9e8,
    inset 10px 0 #f3f1ff,
    inset -10px 0 #9d9ac7;
  content: "";
}

.opening-lab.doctor-turning .lab-doctor-sprite::after {
  position: absolute;
  top: 16%;
  left: 50%;
  width: 34%;
  height: 31%;
  background: #bd8955;
  border-bottom: 7px solid #865b3c;
  box-shadow:
    -13px -7px 0 #e3e2f3,
    13px -7px 0 #e3e2f3,
    -17px 5px 0 #e3e2f3,
    17px 5px 0 #e3e2f3,
    0 -12px 0 #e3e2f3;
  content: "";
  transform: translateX(-50%);
}

.opening-lab.doctor-turning .lab-doctor::before {
  position: absolute;
  z-index: 3;
  bottom: 0;
  left: 31%;
  width: 14%;
  height: 22%;
  background: #160a45;
  box-shadow: 39px 0 #160a45;
  content: "";
}

.opening-lab.doctor-turning .lab-doctor::after {
  position: absolute;
  z-index: 3;
  top: 48%;
  bottom: 12%;
  left: 50%;
  width: 7px;
  background: #aaa6d1;
  content: "";
  transform: translateX(-50%);
}

.lab-doctor-arm {
  position: absolute;
  z-index: 2;
  right: -14%;
  bottom: 49%;
  width: 42%;
  height: 14%;
  border: 0;
  background: #d8d9e8;
  box-shadow:
    inset 0 -6px #9d9ac7,
    0 6px #090329;
  opacity: 0;
  transform: rotate(-6deg) scaleX(0.42);
  transform-origin: left center;
}

.lab-doctor-arm::before {
  position: absolute;
  top: 16%;
  right: -16%;
  width: 22%;
  height: 68%;
  background: #bd8955;
  box-shadow: inset 0 -4px #865b3c;
  content: "";
}

.lab-doctor-arm::after {
  position: absolute;
  top: 18%;
  right: 7%;
  width: 18%;
  height: 64%;
  background: #aaa6d1;
  content: "";
}

.opening-lab.switch-pressed .lab-doctor-arm {
  opacity: 1;
  animation: labDoctorPress 0.65s steps(4, end) forwards;
}

.opening-lab.lever-ready .lab-doctor-arm {
  z-index: 6;
  opacity: 1;
  transform: rotate(-8deg) translateX(25%) scaleX(1.25);
}

.opening-lab.lever-pulled .lab-doctor-arm {
  animation: labDoctorLeverPull 0.58s steps(4, end) forwards;
}

.lab-virtual-world {
  position: absolute;
  z-index: 7;
  inset: -5% -4%;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.opening-lab.virtualizing .lab-virtual-world {
  opacity: 1;
}

.virtual-mosaic-grid {
  position: absolute;
  z-index: 0;
  inset: 0;
}

.virtual-mosaic-tile {
  position: absolute;
  top: calc(var(--mosaic-row) * 5%);
  left: calc(var(--mosaic-column) * 7.142857%);
  width: 7.25%;
  height: 5.15%;
  background: #fff;
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.82);
  opacity: 0;
  transform: scale(0.15);
}

.virtual-mosaic-tile.is-sky {
  --mosaic-reality: linear-gradient(135deg, #70e3ff, #42bfee);
}

.virtual-mosaic-tile.is-field {
  --mosaic-reality: linear-gradient(135deg, #75e84c, #48c936);
}

.virtual-mosaic-tile.is-deep-field {
  --mosaic-reality: linear-gradient(135deg, #49c936, #269b28);
}

.opening-lab.virtualizing .virtual-mosaic-tile {
  animation: labVirtualMosaicTile var(--mosaic-duration) steps(1, end) var(--mosaic-delay) forwards;
}

.virtual-plus,
.virtual-pixel {
  position: absolute;
  z-index: 2;
  color: #9df600;
  font-family: "Courier New", monospace;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
}

.opening-lab.virtualizing .virtual-plus,
.opening-lab.virtualizing .virtual-pixel {
  animation: labVirtualSymbolReveal 0.18s steps(2, end) forwards;
}

.virtual-plus {
  font-size: clamp(3rem, 13vw, 8rem);
}

.plus-one {
  top: 12%;
  right: 12%;
  animation-delay: 0.28s !important;
}

.plus-two {
  top: 48%;
  right: 38%;
  animation-delay: 0.83s !important;
}

.plus-three {
  right: 8%;
  bottom: 8%;
  animation-delay: 0.42s !important;
}

.virtual-pixel {
  width: clamp(0.8rem, 4vw, 2rem);
  aspect-ratio: 1;
  background: #fff;
}

.pixel-one {
  top: 22%;
  left: 18%;
  animation-delay: 1.38s !important;
}

.pixel-two {
  top: 61%;
  left: 8%;
  animation-delay: 1.62s !important;
}

.pixel-three {
  right: 22%;
  bottom: 18%;
  animation-delay: 0.65s !important;
}

.lab-whiteout {
  position: absolute;
  z-index: 8;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.opening-lab.whiteout .lab-whiteout {
  animation: labWhiteout 1.6s linear forwards;
}

.opening-screen.opening-final-line .opening-dialogue.lab-dialogue {
  color: #18122f;
  text-shadow: none;
}

.opening-menu-transition {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.opening-menu-transition[hidden] {
  display: none;
}

.opening-menu-black,
.opening-menu-mosaic-grid {
  position: absolute;
  inset: 0;
}

.opening-menu-black {
  z-index: 1;
  background: #000;
  opacity: 0;
}

.opening-menu-mosaic-grid {
  z-index: 2;
  opacity: 0;
}

.opening-menu-mosaic-tile {
  position: absolute;
  top: calc(var(--menu-mosaic-row) * 5%);
  left: calc(var(--menu-mosaic-column) * 7.142857%);
  width: 7.25%;
  height: 5.15%;
  background: #000;
  opacity: 1;
  transform: scale(1.04);
}

.opening-menu-transition.is-fading-in .opening-menu-black {
  animation: openingMenuBlackFade 1.5s ease-in forwards;
}

.opening-menu-transition.is-revealing .opening-menu-black {
  animation: none;
  opacity: 0;
}

.opening-menu-transition.is-revealing .opening-menu-mosaic-grid {
  opacity: 1;
}

.opening-menu-transition.is-revealing .opening-menu-mosaic-tile {
  animation: openingMenuMosaicReveal 0.62s steps(4, end) var(--menu-mosaic-delay) forwards;
}

.opening-doctor {
  position: absolute;
  z-index: 1;
  top: 48%;
  left: 50%;
  width: min(158vw, 46rem);
  opacity: 0;
  filter:
    saturate(0.74)
    hue-rotate(8deg)
    brightness(0.92)
    contrast(0.98)
    drop-shadow(0 10px 0 rgba(3, 12, 35, 0.42));
  -webkit-mask-image: linear-gradient(to bottom, #000 0 81%, transparent 99%);
  mask-image: linear-gradient(to bottom, #000 0 81%, transparent 99%);
  transform: translate(-50%, -68%) rotate(-9deg) scale(0.7);
  transform-origin: 50% 42%;
}

.opening-doctor.is-visible {
  animation: openingDoctorApproach 2.8s steps(12, end) forwards;
}

.opening-doctor-sprite {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
}

.opening-doctor-band {
  position: absolute;
  inset: 0;
  display: block;
  background: url("./assets/opening/opening-doctor-sprites.png") 0 0 / 300% 100% no-repeat;
  image-rendering: pixelated;
}

.opening-doctor-band.band-one {
  clip-path: inset(0 0 73% 0);
  animation: doctorWaterShiftLeft 2.2s steps(4, end) infinite;
}

.opening-doctor-band.band-two {
  clip-path: inset(27% 0 49% 0);
  animation: doctorWaterShiftRight 2.8s steps(5, end) infinite;
}

.opening-doctor-band.band-three {
  clip-path: inset(51% 0 24% 0);
  animation: doctorWaterShiftLeft 3.1s steps(5, end) infinite reverse;
}

.opening-doctor-band.band-four {
  clip-path: inset(76% 0 0 0);
  animation: doctorWaterShiftRight 2.5s steps(4, end) infinite reverse;
}

.opening-doctor-sprite.frame-blink .opening-doctor-band {
  background-position: 50% 0;
}

.opening-doctor-sprite.frame-hand .opening-doctor-band {
  background-position: 100% 0;
}

.opening-eyelids {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.opening-eyelids::after {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 14%;
  left: 14%;
  height: 5px;
  background: #143b50;
  box-shadow: 0 0 0 3px #06131f;
  content: "";
  opacity: 0;
  transform: scaleX(0);
}

.opening-eyelid {
  position: absolute;
  right: 0;
  left: 0;
  display: block;
  height: 56%;
  background: #000;
}

.opening-eyelid-top {
  top: 0;
  clip-path: polygon(0 0, 100% 0, 100% 86%, 75% 96%, 50% 100%, 25% 96%, 0 86%);
}

.opening-eyelid-bottom {
  bottom: 0;
  clip-path: polygon(0 14%, 25% 4%, 50% 0, 75% 4%, 100% 14%, 100% 100%, 0 100%);
}

.opening-screen.opening-awake .opening-tank {
  animation: openingLiquidFade 1.55s 3.4s steps(5, end) both;
}

.opening-screen.opening-awake .opening-eyelid-top {
  animation: openingEyeTop 1.55s 3.4s steps(5, end) forwards;
}

.opening-screen.opening-awake .opening-eyelid-bottom {
  animation: openingEyeBottom 1.55s 3.4s steps(5, end) forwards;
}

.opening-screen.opening-awake .opening-eyelids::after {
  animation: openingEyeSlit 0.8s 3s steps(6, end) forwards;
}

.opening-screen.opening-doctor-scene .opening-eyelids::after {
  animation: none;
  opacity: 0;
  transform: scaleX(0);
}

.opening-bubble {
  position: absolute;
  z-index: 2;
  bottom: -4rem;
  width: 1.1rem;
  aspect-ratio: 1;
  border: 5px solid #55eef1;
  background: transparent;
  box-shadow:
    5px 0 0 #126c8c,
    0 5px 0 #126c8c;
  animation: openingBubble 6s steps(12, end) infinite;
}

.bubble-one {
  left: 14%;
  animation-delay: -1s;
}

.bubble-two {
  left: 31%;
  width: 0.65rem;
  animation-delay: -4.4s;
  animation-duration: 5.2s;
}

.bubble-three {
  left: 53%;
  width: 1.4rem;
  animation-delay: -2.5s;
  animation-duration: 7.1s;
}

.bubble-four {
  left: 72%;
  width: 0.8rem;
  animation-delay: -5.5s;
  animation-duration: 5.8s;
}

.bubble-five {
  left: 86%;
  width: 1rem;
  animation-delay: -3.6s;
  animation-duration: 6.6s;
}

.opening-ui {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(0.8rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(0.8rem, env(safe-area-inset-left));
}

.opening-dialogue,
.name-entry-panel,
.name-confirm-panel {
  width: min(34rem, 100%);
  border: 5px solid #f2ffff;
  border-radius: 4px;
  background: #07142d;
  box-shadow:
    0 0 0 5px #27358b,
    8px 8px 0 rgba(0, 0, 0, 0.55);
}

.opening-dialogue {
  position: relative;
  appearance: none;
  min-height: 8rem;
  padding: 1.25rem 2.6rem;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #e8ffff;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.opening-dialogue:hover,
.opening-dialogue:active,
.opening-dialogue:focus {
  background: transparent;
  box-shadow: none;
}

.opening-dialogue.doctor-dialogue {
  position: absolute;
  top: max(6%, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-shadow:
    3px 3px 0 #07142d,
    -2px -2px 0 #07142d;
}

.opening-dialogue.lab-dialogue {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: min(34rem, 92%);
  min-height: 6.5rem;
  padding: 0.65rem 1rem;
  background: transparent;
  box-shadow: none;
  color: #fff;
  text-shadow:
    -2px -2px 0 #000,
    0 -2px 0 #000,
    2px -2px 0 #000,
    -2px 0 0 #000,
    2px 0 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    2px 2px 0 #000;
  transform: translate(-50%, -50%);
}

.opening-dialogue.lab-dialogue:focus-visible {
  outline: none;
}

.opening-dialogue.lab-dialogue #openingText {
  font-size: clamp(1.15rem, 5.2vw, 1.65rem);
  letter-spacing: 0.06em;
  line-height: 1.6;
  white-space: pre-line;
}

.opening-dialogue #openingText {
  font-family: "Courier New", "Hiragino Kaku Gothic ProN", monospace;
  font-size: clamp(1.45rem, 7vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.8;
}

.opening-next {
  display: inline-block;
  margin-left: 0.25em;
  color: #62f5ee;
  font-size: clamp(1rem, 5vw, 1.35rem);
  vertical-align: 0.08em;
  animation: openingNext 0.8s steps(2, end) infinite;
}

.name-entry-panel {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1rem;
  text-align: center;
}

.name-question,
.name-confirm-panel p {
  margin: 0 0 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.name-slots {
  display: grid;
  grid-template-columns: repeat(4, 2.7rem);
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.name-slots span {
  display: grid;
  place-items: center;
  min-height: 2.8rem;
  border-bottom: 4px solid #62f5ee;
  font-size: 1.45rem;
  font-weight: 900;
}

.hiragana-keyboard {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.28rem;
}

.hiragana-key {
  min-width: 0;
  min-height: 2.25rem;
  padding: 0;
  border: 2px solid #7184cb;
  border-radius: 2px;
  background: #172653;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
}

.hiragana-key:active,
.opening-command:active {
  transform: translate(2px, 2px);
}

.name-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.opening-command {
  min-width: 7rem;
  padding: 0.65rem 0.8rem;
  border: 3px solid #f2ffff;
  border-radius: 2px;
  background: #27345c;
  color: #fff;
  box-shadow: 3px 3px 0 #02060d;
  font-weight: 900;
}

.opening-command.primary {
  background: #6546c7;
}

.opening-command:disabled {
  opacity: 0.35;
}

.name-confirm-panel {
  align-self: center;
  padding: 1.4rem;
  text-align: center;
}

.name-confirm-panel strong {
  display: block;
  min-height: 2.4rem;
  color: #62f5ee;
  font-size: 1.7rem;
  letter-spacing: 0.25em;
}

@keyframes openingBubble {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(calc(-100dvh - 8rem));
  }
}

@keyframes prologueShake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-5px, 1px);
  }
  50% {
    transform: translate(5px, -1px);
  }
  75% {
    transform: translate(-3px, 0);
  }
}

@keyframes openingLiquidFade {
  from {
    opacity: 0.08;
  }
  to {
    opacity: 1;
  }
}

@keyframes labSceneReveal {
  from {
    opacity: 0;
    filter: brightness(0);
  }

  to {
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes scene3BubbleRise {
  0% {
    opacity: 0;
    transform: translateY(0);
  }

  18%,
  78% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translateY(-54dvh);
  }
}

@keyframes scene3MonsterTwitch {
  0%,
  71%,
  76%,
  100% {
    transform: translateX(-50%) translate(0, 0) rotate(0);
  }

  72% {
    transform: translateX(-50%) translate(-4px, 1px) rotate(-1deg);
  }

  73% {
    transform: translateX(-50%) translate(4px, -2px) rotate(1deg);
  }

  74% {
    transform: translateX(-50%) translate(-2px, 1px) rotate(-0.5deg);
  }

  75% {
    transform: translateX(-50%) translate(0, 0) rotate(0);
  }
}

@keyframes scene4ElectricPulse {
  50% {
    filter: brightness(1.8);
    opacity: 0.65;
  }
}

@keyframes scene4DoctorPullNudge {
  33% {
    transform: translate(-1.5%, 1%) rotate(1deg);
  }

  66% {
    transform: translate(1%, -0.5%) rotate(-0.5deg);
  }

  100% {
    transform: translate(0, 0) rotate(0);
  }
}

@keyframes scene4TankPreflash {
  0%,
  10%,
  34%,
  54%,
  79%,
  100% {
    opacity: 0;
  }

  15%,
  29% {
    opacity: 0.78;
  }

  59%,
  74% {
    opacity: 0.94;
  }
}

@keyframes scene4ElectricOrbit {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes scene4LiquidRipple {
  50% {
    transform: translateX(5%);
  }
}

@keyframes scene4MonsterTwitch {
  0%,
  88%,
  94%,
  100% {
    transform: translate(0, 0);
  }

  89% {
    transform: translate(-2%, 0);
  }

  91% {
    transform: translate(2%, -1%);
  }
}

@keyframes scene4BubbleRise {
  0% {
    bottom: 3%;
    opacity: 0;
    transform: translateX(0) scale(0.7);
  }

  12%,
  78% {
    opacity: 0.85;
  }

  42% {
    transform: translateX(65%) scale(1);
  }

  80% {
    bottom: 88%;
    opacity: 0;
    transform: translateX(-30%) scale(0.8);
  }

  100% {
    bottom: 88%;
    opacity: 0;
  }
}

@keyframes labBubble {
  from {
    opacity: 0;
    transform: translateY(0);
  }

  20%,
  80% {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(-28dvh);
  }
}

@keyframes labSubjectTwitch {
  0%,
  68%,
  72%,
  100% {
    transform: translate(0, 0) rotate(0);
  }

  69% {
    transform: translate(-2px, 1px) rotate(-0.5deg);
  }

  70% {
    transform: translate(2px, -1px) rotate(0.5deg);
  }

  71% {
    transform: translate(-1px, 0) rotate(0);
  }
}

@keyframes machineLight {
  50% {
    filter: brightness(1.8);
    box-shadow: 0 0 8px currentColor;
  }
}

@keyframes labDoctorBlink {
  0%,
  46%,
  51%,
  100% {
    background-position: 0 0;
  }

  47%,
  50% {
    background-position: 50% 0;
  }
}

@keyframes labDoctorPress {
  0% {
    transform: rotate(-6deg) scaleX(0.42);
  }

  60%,
  100% {
    transform: rotate(-12deg) translate(5px, -3px) scaleX(1.25);
  }
}

@keyframes labLeverPull {
  to {
    transform: rotate(-28deg);
  }
}

@keyframes labLeverRise {
  from {
    opacity: 0;
    transform: translateY(calc(100% + 4rem));
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes labDoctorLeverPull {
  to {
    transform: rotate(15deg) translate(-18%, 18%) scaleX(1.18);
  }
}

@keyframes labPowerShake {
  0%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }

  25% {
    opacity: 1;
    transform: translateY(-7px);
  }

  75% {
    opacity: 1;
    transform: translateY(7px);
  }
}

@keyframes labElectricPulse {
  50% {
    filter: brightness(1.9);
    transform: scale(1.04);
  }
}

@keyframes labCapsuleFlash {
  50% {
    filter: brightness(1.7) saturate(1.35);
  }
}

@keyframes labSubjectShock {
  0%,
  100% {
    transform: translate(-3px, 2px) rotate(-1deg);
  }

  50% {
    transform: translate(3px, -2px) rotate(1deg);
  }
}

@keyframes labVirtualMosaicTile {
  0% {
    background: #fff;
    box-shadow: 0 0 8px #fff;
    opacity: 0;
    transform: scale(0.15);
  }

  1% {
    background: #fff;
    box-shadow: 0 0 8px #fff;
    opacity: 1;
    transform: scale(0.25);
  }

  30% {
    background: #fff;
    box-shadow: 0 0 8px #fff;
    opacity: 1;
    transform: scale(0.45);
  }

  55% {
    background: #fff;
    box-shadow: 0 0 8px #fff;
    opacity: 1;
    transform: scale(0.68);
  }

  80%,
  99% {
    background: #fff;
    box-shadow: 0 0 8px #fff;
    opacity: 1;
    transform: scale(1);
  }

  100% {
    background: var(--mosaic-reality);
    box-shadow: none;
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes labVirtualSymbolReveal {
  to {
    opacity: 1;
  }
}

@keyframes labWhiteout {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes openingMenuBlackFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes openingMenuMosaicReveal {
  to {
    opacity: 0;
    transform: scale(0);
  }
}

@keyframes labSwitchFlash {
  0%,
  100% {
    background-color: #0d0936;
  }

  50% {
    background-color: #342180;
  }
}

@keyframes doctorWaterShiftLeft {
  0%,
  100% {
    transform: translateX(-2px);
  }
  50% {
    transform: translateX(3px);
  }
}

@keyframes doctorWaterShiftRight {
  0%,
  100% {
    transform: translateX(2px);
  }
  50% {
    transform: translateX(-3px);
  }
}

@keyframes openingDoctorApproach {
  0% {
    opacity: 0;
    transform: translate(-50%, -68%) rotate(-9deg) scale(0.7);
  }
  45% {
    opacity: 0.5;
  }
  100% {
    opacity: 0.96;
    transform: translate(-50%, -50%) rotate(-9deg) scale(1.03);
  }
}

@keyframes openingEyeTop {
  to {
    height: 0;
  }
}

@keyframes openingEyeBottom {
  to {
    height: 0;
  }
}

@keyframes openingEyeSlit {
  10% {
    opacity: 1;
    transform: scaleX(0.08);
  }
  85% {
    opacity: 1;
    transform: scaleX(1);
  }
  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@keyframes openingNext {
  50% {
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .opening-bubble,
  .opening-next {
    animation-duration: 12s;
  }
}

.menu-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 100dvh;
}

/* タイトル画面 */
.title-screen {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}

.title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: min(24rem, 100%);
  text-align: center;
}

.title-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title-plus {
  display: grid;
  place-items: center;
  width: 3.4rem;
  aspect-ratio: 1;
  margin-bottom: 0.4rem;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 2rem;
  font-weight: 900;
}

.title-logo h1 {
  font-size: clamp(1.5rem, 7vw, 2.3rem);
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.title-logo p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.title-avatar {
  width: min(52%, 11rem);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(6px 8px 0 rgba(32, 33, 36, 0.18));
  animation: menuIdle 2.2s steps(2, end) infinite;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(18rem, 100%);
  margin-top: 0.5rem;
}

.title-buttons .start-button,
.title-buttons .secondary-button {
  width: 100%;
}

.start-button.is-dim {
  opacity: 0.45;
}

.title-message {
  min-height: 1.1rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.menu-header,
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.8rem;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 1.8rem;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 4vw, 1.75rem);
  line-height: 1.1;
}

.brand p,
.menu-command > p,
.record-band span,
.level-badge span,
.game-metric span,
.xp-row span {
  color: var(--muted);
}

.brand p {
  margin-top: 0.15rem;
  font-size: 0.82rem;
}

.level-badge {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  border-bottom: 4px solid var(--violet);
  padding: 0.35rem 0.15rem;
}

.level-badge span,
.game-metric span {
  font-size: 0.7rem;
  font-weight: 800;
}

.level-badge strong {
  font-size: 2rem;
  line-height: 1;
}

.reset-button {
  display: grid;
  place-items: center;
  width: 2.7rem;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
}

.menu-hero {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 8px 8px 0 rgba(32, 33, 36, 0.16);
  padding: 0.7rem;
}

.char-actions {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0.6rem;
}

.char-actions .start-button {
  width: 100%;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3.3rem;
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  box-shadow: 5px 5px 0 var(--ink);
  background: white;
  font-size: 0.98rem;
  font-weight: 900;
  cursor: pointer;
}

.action-button.evolve {
  background: var(--violet);
  color: white;
}

.action-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.avatar-zone {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 16rem;
  border: 3px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--sky);
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tap-hint {
  position: absolute;
  z-index: 2;
  top: 0.7rem;
  right: 0.7rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 253, 243, 0.92);
  padding: 0.25rem 0.6rem;
  font-size: 0.66rem;
  font-weight: 800;
}

.char-info {
  position: absolute;
  z-index: 6;
  top: 4rem;
  left: 1rem;
  width: min(16rem, 70%);
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  background: var(--paper);
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.25);
  padding: 0.85rem 1rem;
  text-align: left;
}

.char-info h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.char-info dl {
  margin: 0;
  display: grid;
  gap: 0.3rem;
}

.char-info dl div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.char-info dt {
  color: var(--muted);
  font-weight: 800;
}

.char-info dd {
  margin: 0;
  font-weight: 800;
}

.char-info p {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.pixel-burst {
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  border: 1.2rem solid rgba(255, 255, 255, 0.35);
  outline: 1.2rem solid rgba(248, 216, 74, 0.5);
  transform: rotate(45deg);
}

.menu-avatar {
  position: relative;
  z-index: 1;
  width: min(62%, 18rem);
  max-height: 76%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(7px 9px 0 rgba(32, 33, 36, 0.2));
  animation: menuIdle 2.2s steps(2, end) infinite;
}

.avatar-name {
  position: absolute;
  z-index: 2;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border: 3px solid var(--ink);
  border-radius: 0.35rem;
  background: var(--paper);
  padding: 0.65rem 0.75rem;
}

.avatar-name strong {
  font-size: 1.2rem;
}

.avatar-name span {
  color: var(--violet);
  font-size: 0.78rem;
  font-weight: 800;
}

.menu-command {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: clamp(1.35rem, 4vw, 2.5rem);
  text-align: center;
}

.menu-command h2 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.15;
}

.menu-command > p:not(.menu-kicker) {
  margin: 0.7rem 0;
  min-height: 1.2rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.start-button,
.secondary-button {
  min-height: 3.3rem;
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  padding: 0.65rem 1.1rem;
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 900;
}

.start-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: var(--sun);
  font-size: 1.15rem;
}

.start-button.compact {
  width: 100%;
  font-size: 1rem;
}

.secondary-button {
  width: 100%;
  background: white;
}

.start-button:active,
.secondary-button:active,
.symbol-button:active,
.voice-button:active,
.reset-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.start-button:disabled,
.voice-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.xp-row {
  display: grid;
  grid-template-columns: auto minmax(6rem, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin-top: 1.35rem;
  font-size: 0.72rem;
}

.xp-track {
  overflow: hidden;
  height: 0.65rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.xp-track div {
  width: 0;
  height: 100%;
  background: var(--leaf);
  transition: width 0.25s ease;
}

.menu-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.nav-button {
  display: grid;
  justify-items: start;
  gap: 0.15rem;
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  background: white;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 0.7rem 0.9rem;
  text-align: left;
  cursor: pointer;
}

.nav-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.nav-button strong {
  font-size: 1rem;
}

.nav-button .nav-sub {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  background: var(--sky);
  font-size: 1rem;
  font-weight: 900;
}

.nav-icon.evolve-icon {
  background: var(--violet);
  color: white;
}

/* タップで開くモーダル */
.modal-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 33, 36, 0.58);
  padding: 0.9rem;
}

.modal-panel {
  width: min(30rem, 100%);
  max-height: min(92dvh, 46rem);
  overflow-y: auto;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 1rem 1.1rem 1.2rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.modal-header h2 {
  font-size: 1.35rem;
}

.close-button {
  display: grid;
  place-items: center;
  width: 2.4rem;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
}

.close-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* せいせき分析 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.summary-item {
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  background: white;
  padding: 0.55rem 0.7rem;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.summary-item strong {
  display: block;
  overflow: hidden;
  margin-top: 0.1rem;
  font-size: 1.15rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item.good {
  border-color: var(--leaf);
}

.summary-item.weak {
  border-color: var(--berry);
}

.heatmap-title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.heatmap-note {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.heatmap-wrap {
  overflow-x: auto;
}

.heatmap {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.heatmap th {
  padding: 0.1rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.heatmap tr.dan-learned td:last-child,
.stage-mini-heatmap tr.dan-learned td:last-child {
  position: relative;
}

.heatmap tr.dan-learned td:last-child::after,
.stage-mini-heatmap tr.dan-learned td:last-child::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.18rem);
  color: var(--ink);
  font-size: 0.55rem;
  line-height: 1;
  content: "●";
  transform: translateY(-50%);
}

.heatmap td {
  aspect-ratio: 1;
  min-width: 1.35rem;
  border: 1px solid rgba(32, 33, 36, 0.25);
  border-radius: 0.2rem;
  cursor: pointer;
}

.heatmap td.none {
  background: #e7e9ec;
}

.heatmap td.good {
  background: var(--leaf);
}

.heatmap td.mid {
  background: #a9dfb8;
}

.heatmap td.weak {
  background: var(--berry);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.legend-chip {
  display: inline-block;
  width: 0.85rem;
  aspect-ratio: 1;
  margin-left: 0.4rem;
  border: 1px solid rgba(32, 33, 36, 0.3);
  border-radius: 0.2rem;
}

.legend-chip:first-child {
  margin-left: 0;
}

.legend-chip.good { background: var(--leaf); }
.legend-chip.mid { background: var(--sun); }
.legend-chip.weak { background: var(--berry); }
.legend-chip.none { background: #e7e9ec; }

.cell-detail {
  min-height: 1.2rem;
  margin: 0.6rem 0 0;
  border: 2px dashed rgba(32, 33, 36, 0.25);
  border-radius: 0.4rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
}

/* ステータス(子ども向けレーダー) */
.status-panel {
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.16);
  padding: 0.9rem;
  text-align: center;
}

.status-head strong {
  font-size: 1.2rem;
}

.status-head span {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.radar-wrap {
  position: relative;
  width: min(18rem, 82vw);
  margin: 0.6rem auto 0.4rem;
  aspect-ratio: 1;
}

.radar-wrap canvas {
  width: 100%;
  height: 100%;
}

/* 段の数字は素の数字で表示(丸囲みにしない) */
.radar-buttons button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2rem;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.radar-buttons button.good { color: var(--leaf); }
.radar-buttons button.mid { color: #c9a516; }
.radar-buttons button.weak { color: var(--berry); }
.radar-buttons button.none { color: #b3b9c0; }

.radar-buttons button.selected {
  transform: translate(-50%, -50%) scale(1.35);
  text-decoration: underline 3px;
  text-underline-offset: 0.2em;
}

.kids-analysis {
  min-height: 2.4rem;
  display: grid;
  place-items: center;
  margin: 0.4rem 0 0;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: #fffbe8;
  padding: 0.6rem 0.8rem;
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.4;
}

.kids-analysis.good { background: #e7f7ec; }
.kids-analysis.mid { background: #fff6dd; }
.kids-analysis.weak { background: #fde7ec; }

/* 大人向け分析 */
.adult-analysis {
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: white;
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.12);
  padding: 0.9rem;
}

.adult-head {
  margin-bottom: 0.7rem;
}

.adult-head span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.adult-head strong {
  font-size: 1.05rem;
}

.carry-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.carry-item {
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
}

.carry-item span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.mini-track {
  overflow: hidden;
  height: 0.55rem;
  margin: 0.35rem 0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.mini-track div {
  width: 0;
  height: 100%;
  background: var(--sky);
  transition: width 0.25s ease;
}

.carry-item strong {
  font-size: 1.05rem;
}

.carry-insight {
  margin: 0 0 0.9rem;
  border-left: 4px solid var(--violet);
  padding: 0.4rem 0.6rem;
  background: rgba(121, 86, 216, 0.06);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.5;
}

.insight-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.insight-item {
  border: 2px solid rgba(32, 33, 36, 0.2);
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
}

.insight-item span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.insight-item strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 1rem;
}

.menu-status {
  min-height: 1rem;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

/* 設定 */
.modal-panel.narrow {
  width: min(24rem, 100%);
}

.settings-list {
  display: grid;
  gap: 0.75rem;
}

.setting-row,
.setting-block {
  border: 2px solid var(--ink);
  border-radius: 0.45rem;
  background: white;
  padding: 0.75rem 0.9rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.setting-label strong {
  display: block;
  font-size: 1rem;
}

.setting-label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.toggle {
  position: relative;
  flex-shrink: 0;
  width: 3.6rem;
  height: 2rem;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #d7dbe0;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle.on {
  background: var(--leaf);
}

.toggle-knob {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

.toggle.on .toggle-knob {
  transform: translateX(1.55rem);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.segmented button {
  min-height: 2.6rem;
  border: 3px solid var(--ink);
  border-radius: 0.4rem;
  background: white;
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
}

.segmented button.active {
  background: var(--sun);
  box-shadow: inset 3px 3px 0 rgba(32, 33, 36, 0.15);
}

/* しんかラボ */
.evolve-stage {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 0.45rem;
  background: var(--sky);
  padding: 0.7rem 0.9rem;
}

.evolve-stage canvas {
  width: 6.5rem;
  height: auto;
  image-rendering: pixelated;
}

.evolve-stage-info strong {
  display: block;
  font-size: 1.25rem;
}

.evolve-stage-info span {
  color: rgba(32, 33, 36, 0.7);
  font-size: 0.75rem;
  font-weight: 800;
}

.evolve-stage-info p {
  min-height: 1.1rem;
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  font-weight: 800;
}

.evolve-xp {
  margin-top: 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 0.45rem;
  background: white;
  padding: 0.75rem 0.9rem;
}

.evolve-xp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.evolve-xp-head span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.evolve-xp-head strong {
  font-size: 1.35rem;
}

.xp-track.big {
  height: 0.95rem;
}

.xp-track.big div {
  background: var(--violet);
}

.evolve-xp p {
  margin: 0.4rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.allocate-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.allocate-button {
  min-height: 2.6rem;
  border: 3px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
}

.allocate-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.allocate-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.brain-panel {
  margin-top: 0.9rem;
  border: 2px solid #f77fb0;
  border-radius: 0.45rem;
  background: #fff0f7;
  padding: 0.75rem 0.9rem;
}

.brain-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.brain-head strong {
  font-size: 0.95rem;
}

.brain-head em {
  font-style: normal;
  color: #d6559a;
}

.xp-track.brain-track div {
  background: #f77fb0;
}

.brain-panel p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

@keyframes evolveFlash {
  0% { filter: brightness(3) saturate(0); transform: scale(0.85); }
  60% { filter: brightness(1.6); transform: scale(1.08); }
  100% { filter: none; transform: scale(1); }
}

.evolve-flash {
  animation: evolveFlash 0.7s steps(5, end);
}

.game-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-screen .stage {
  flex: 1;
  min-height: 0;
}

.game-hud {
  justify-content: flex-start;
}

.symbol-button {
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  background: white;
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 900;
}

.symbol-button {
  width: 3rem;
  aspect-ratio: 1;
  border-radius: 0.4rem;
}

.game-metric {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 5rem;
  border-bottom: 3px solid var(--ink);
  padding: 0.35rem 0.55rem;
}

.game-metric strong {
  font-size: 1.45rem;
  line-height: 1;
}

.game-metric:nth-of-type(1) {
  border-color: var(--sky);
}

.game-metric:nth-of-type(2) {
  border-color: var(--leaf);
}

.game-metric:nth-of-type(3) {
  border-color: var(--berry);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 22rem;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(32, 33, 36, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 2.4rem 2.4rem;
  box-shadow: 8px 8px 0 rgba(32, 33, 36, 0.16);
}

.flight-path {
  position: absolute;
  inset: 1rem;
  border: 2px dashed rgba(32, 33, 36, 0.16);
  border-radius: 999px;
}

/* 計算カード:散歩枠と問題エリアを跨いで最前面に出す。
   位置と動き(頭から飛び出す放物線+遠近)はJSで制御する。 */
.problem {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  width: min(72vw, 25rem);
  aspect-ratio: 1.38;
  border: 4px solid var(--ink);
  border-radius: 0.55rem;
  background: #ffffff;
  box-shadow: 8px 8px 0 var(--ink);
  font-size: clamp(4rem, 20vw, 9rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  transform-origin: center center;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity, filter;
}

.game-screen.type-mode .problem {
  aspect-ratio: 1.12;
}

.feedback {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: min(72vw, 20rem);
  aspect-ratio: 1;
  font-size: min(34vw, 10rem);
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: scale(0.72);
  pointer-events: none;
  text-shadow: 0 0.06em 0 rgba(32, 33, 36, 0.18);
}

.feedback.show {
  opacity: 1;
  animation: feedbackFade 0.86s ease-in-out forwards;
}

.feedback.correct {
  color: var(--leaf);
}

.feedback.wrong {
  color: var(--berry);
}

@keyframes feedbackFade {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }
  28% {
    opacity: 1;
    transform: scale(1.08);
  }
  58% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

.companion {
  position: absolute;
  z-index: 3;
  bottom: 0.55rem;
  left: 0.55rem;
  width: clamp(4.5rem, 12vw, 7rem);
  aspect-ratio: 1;
  pointer-events: none;
}

.companion canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
  animation: companionIdle 1.4s steps(2, end) infinite;
}

.companion.cheer canvas {
  animation: cheer 0.65s steps(4, end);
}

.companion.ouch canvas {
  animation: ouch 0.55s steps(4, end);
  filter: grayscale(0.45);
}

@keyframes menuIdle {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-0.45rem) rotate(1deg);
  }
}

@keyframes companionIdle {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg) scaleY(1);
  }
  50% {
    transform: translateY(-0.25rem) rotate(2deg) scaleY(0.96);
  }
}

@keyframes cheer {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  35% {
    transform: translateY(-1.3rem) rotate(-7deg);
  }
  65% {
    transform: translateY(-0.35rem) rotate(6deg);
  }
}

@keyframes ouch {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-0.65rem) rotate(-6deg);
  }
  50% {
    transform: translateX(0.65rem) rotate(6deg);
  }
  75% {
    transform: translateX(-0.35rem);
  }
}

.speech-bubble {
  position: fixed;
  z-index: 8;
  right: -0.65rem;
  bottom: calc(max(0.8rem, env(safe-area-inset-bottom)) + 4.2rem);
  width: min(17rem, calc(100vw - 3.4rem));
  border: 3px solid var(--ink);
  border-radius: 0.45rem 0 0 0.45rem;
  background: white;
  box-shadow: 5px 5px 0 rgba(32, 33, 36, 0.2);
  padding: 0.55rem 1.15rem 0.55rem 0.75rem;
  pointer-events: none;
}

.speech-bubble::after {
  position: absolute;
  right: 1.1rem;
  bottom: -0.8rem;
  width: 1rem;
  height: 1rem;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: white;
  content: "";
  transform: skewY(35deg);
}

.speech-bubble span,
.speech-bubble strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speech-bubble span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.speech-bubble strong {
  margin-top: 0.1rem;
  font-size: 1rem;
}

.game-controls {
  position: fixed;
  z-index: 9;
  right: max(0.7rem, env(safe-area-inset-right));
  bottom: max(0.7rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.6rem;
}

.game-controls .symbol-button {
  background: var(--sky);
}

.game-controls .voice-button {
  background: var(--sun);
  font-size: 0.95rem;
}

.pause-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 33, 36, 0.58);
  padding: 1rem;
}

.pause-panel {
  width: min(22rem, 100%);
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 1.4rem;
  text-align: center;
}

.pause-icon {
  display: grid;
  place-items: center;
  width: 4rem;
  aspect-ratio: 1;
  margin: 0 auto 0.75rem;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  font-size: 1.5rem;
  font-weight: 900;
}

.pause-panel h2 {
  font-size: 1.8rem;
}

.pause-panel p {
  margin: 0.35rem 0 1.15rem;
  color: var(--muted);
}

.pause-panel .secondary-button {
  margin-top: 0.65rem;
}

.pause-panel.stage-select-panel {
  width: min(18rem, 88vw);
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  perspective: 900px;
}

.stage-select-panel h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage-select-list {
  --stage-page-turn: 0;
  position: relative;
  width: 100%;
  height: 18.5rem;
  margin: 0;
  perspective: 900px;
  transform-style: preserve-3d;
}

.stage-select-sheet {
  position: absolute;
  inset: 0;
  transform: rotateY(calc(var(--stage-page-turn) * -180deg));
  transform-origin: center center;
  transform-style: preserve-3d;
  transition: transform 560ms cubic-bezier(0.22, 0.76, 0.28, 1);
}

.stage-select-list.dragging .stage-select-sheet,
.stage-select-list.without-page-animation .stage-select-sheet {
  transition: none;
}

.stage-select-page {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  border: 3px solid var(--ink);
  border-radius: 0.35rem 0.72rem 0.72rem 0.35rem;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 1.15rem 1.1rem 1.2rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.1), transparent 0.9rem),
    #fffdf3;
}

.stage-select-page h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.stage-select-page.review-page {
  transform: rotateY(180deg);
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.1), transparent 0.9rem),
    #eee9ff;
}

.stage-select-page-buttons {
  display: grid;
  align-content: center;
  gap: 0.8rem;
}

.stage-select-choice {
  width: 100%;
  min-height: 3.1rem;
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  background: #fff;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 0.55rem;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
}

.stage-select-choice.medium {
  background: #fff2bd;
}

.stage-select-choice.hard {
  background: #f7d9e5;
}

.review-page .stage-select-choice {
  background: #fff;
  border-color: #5f4b96;
  box-shadow: 4px 4px 0 #5f4b96;
  color: #4e3c82;
}

.review-page .stage-select-choice.medium {
  background: #fff5cb;
}

.review-page .stage-select-choice.hard {
  background: #f8dce7;
}

.stage-select-choice:disabled {
  box-shadow: 1px 1px 0 rgba(32, 33, 36, 0.45);
  cursor: default;
  filter: grayscale(0.75);
  opacity: 0.48;
}

.stage-select-choice:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(3px, 3px);
}

.stage-select-choice:disabled:active {
  transform: none;
}

.stage-page-arrow {
  position: absolute;
  z-index: 5;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 3.6rem;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
  font: inherit;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-50%);
  cursor: grab;
  touch-action: none;
  text-shadow:
    0 1px 0 #fff,
    1px 0 0 #fff,
    0 -1px 0 #fff,
    -1px 0 0 #fff;
}

.stage-page-arrow.previous {
  left: -2.35rem;
}

.stage-page-arrow.next {
  right: -2.35rem;
}

.stage-page-arrow:disabled {
  opacity: 0.45;
  cursor: default;
}

.stage-select-list.dragging .stage-page-arrow:not(:disabled) {
  cursor: grabbing;
}

.reset-icon {
  background: var(--sky);
}

.danger-button {
  color: #9b2440;
}

@media (max-width: 700px) {
  .screen {
    padding-inline: 0.55rem;
  }

  .menu-header {
    align-items: flex-start;
  }

  .brand p {
    display: none;
  }

  .menu-hero {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(14rem, 1.1fr) auto;
    min-height: 0;
  }

  .avatar-zone {
    min-height: 0;
    border-right: 0;
    border-bottom: 3px solid var(--ink);
  }

  .menu-avatar {
    width: min(56%, 13rem);
    max-height: 82%;
  }

  .avatar-name {
    padding-block: 0.45rem;
  }

  .menu-command {
    padding: 1rem;
  }

  .menu-command h2 {
    font-size: clamp(1.8rem, 9vw, 2.65rem);
  }

  .menu-command > p:not(.menu-kicker) {
    margin-block: 0.45rem 0.75rem;
  }

  .start-button {
    min-height: 3rem;
  }

  .xp-row {
    margin-top: 0.85rem;
  }

  .menu-nav {
    gap: 0.5rem;
  }

  .nav-button {
    padding: 0.55rem 0.7rem;
  }

  .heatmap td {
    min-width: 1.6rem;
  }

  .game-screen {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.45rem;
  }

  .game-hud {
    gap: 0.35rem;
  }

  .symbol-button {
    width: 2.65rem;
  }

  .game-metric {
    flex: 1;
    grid-template-columns: 1fr;
    gap: 0;
    min-width: 0;
    padding: 0.25rem;
    text-align: center;
  }

  .game-metric strong {
    font-size: 1.2rem;
  }

  .stage {
    min-height: 0;
  }

  .problem {
    width: min(74vw, 20rem);
    font-size: clamp(3.3rem, 18vw, 7rem);
  }

}

@media (max-height: 700px) and (max-width: 700px) {
  .menu-header {
    display: none;
  }

  .menu-avatar {
    width: min(45%, 10rem);
  }

  .menu-command h2 {
    font-size: 1.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .companion.cheer canvas,
  .companion.ouch canvas,
  .companion canvas,
  .menu-avatar {
    animation-duration: 1ms;
  }
}

/* ========== うろうろステージ(メニュー) ========== */

.menu-stage {
  position: relative;
  overflow: hidden;
  min-height: clamp(15rem, 42vh, 22rem);
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, #bfe8f5 0%, #dff4ec 78%, #dff4ec 100%);
  box-shadow: 8px 8px 0 rgba(32, 33, 36, 0.16);
  padding: 0;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.menu-stage .ground {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1.6rem;
  border-top: 3px solid var(--ink);
  background: repeating-linear-gradient(
    90deg,
    #6fcf8e 0 1.2rem,
    #57bd7a 1.2rem 2.4rem
  );
}

.roamer {
  position: absolute;
  bottom: 1.35rem;
  left: 0;
  width: clamp(5rem, 22vw, 7rem);
  will-change: transform;
}

.roamer canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(4px 5px 0 rgba(32, 33, 36, 0.16));
  transform-origin: 50% 88%;
}

.mode-segment {
  margin-top: 0;
}

.mode-segment button {
  font-size: 0.74rem;
  min-height: 3.3rem;
  padding: 0;
  white-space: nowrap;
}

/* ========== ステータス画面 ========== */

.status-rank {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  background: var(--paper);
  padding: 0.6rem 0.8rem;
}

.status-rank strong {
  font-size: 1.2rem;
}

.status-rank span {
  color: var(--violet);
  font-size: 0.78rem;
  font-weight: 800;
}

.care-grid {
  display: grid;
  grid-template-columns: minmax(8.5rem, 0.9fr) 1.2fr;
  gap: 0.7rem;
  align-items: stretch;
}

.face-box {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--sky);
  box-shadow: 5px 5px 0 rgba(32, 33, 36, 0.18);
  padding: 0.5rem 0.5rem 1.6rem;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.face-box canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.face-hint {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  border-top: 3px solid var(--ink);
  background: var(--paper);
  padding: 0.25rem;
  font-size: 0.7rem;
  font-weight: 900;
}

.care-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: white;
  box-shadow: 5px 5px 0 rgba(32, 33, 36, 0.12);
  padding: 0.75rem 0.85rem;
}

.care-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.care-label {
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.care-label strong {
  font-size: 1.1rem;
}

.care-panel .allocate-button {
  min-height: 2.3rem;
  padding-inline: 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.allocate-button.inject {
  background: #f9c8dd;
}

.care-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.care-message {
  min-height: 1.1rem;
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 900;
  color: #b03d68;
}

.status-list-panel {
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: white;
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.12);
  padding: 0.9rem;
}

.stat-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.stat-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 2px dashed rgba(32, 33, 36, 0.16);
  padding: 0.45rem 0.1rem;
}

.stat-list li:last-child {
  border-bottom: 0;
}

.stat-list span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stat-list strong {
  font-size: 1.05rem;
}

.status-screen,
.analysis-screen {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.adult-radar-wrap {
  display: grid;
  place-items: center;
  margin-bottom: 0.6rem;
}

.adult-radar-wrap canvas {
  width: min(19rem, 90%);
  height: auto;
}

/* ========== ゲーム画面:横スクロール演出 ========== */

.stage.scrolling {
  background:
    linear-gradient(90deg, rgba(32, 33, 36, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(32, 33, 36, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf3 0%, #fffdf3 82%, #e2f4e8 82%, #e2f4e8 100%);
  background-size: 2.4rem 2.4rem, 2.4rem 2.4rem, 100% 100%;
  animation: stageScroll 6s linear infinite;
}

@keyframes stageScroll {
  from {
    background-position: 0 0, 0 0, 0 0;
  }
  to {
    background-position: -2.4rem 0, 0 0, 0 0;
  }
}

.companion.runner {
  animation: runnerDrift 5.5s ease-in-out infinite;
}

@keyframes runnerDrift {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(1.4rem);
  }
  70% {
    transform: translateX(-0.6rem);
  }
}

.exit-button {
  margin-left: auto;
  background: var(--berry);
  color: white;
  font-size: 1.2rem;
}

.exit-rewards {
  min-height: 1.1rem;
  margin: -0.5rem 0 1rem;
  color: #b03d68;
}

.exit-rewards .exit-reward-note,
.exit-rewards .exit-reward-item {
  display: block;
}

.exit-rewards .exit-reward-note {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.45;
}

.exit-rewards .exit-reward-note.bonus {
  margin-top: 0.65rem;
}

.exit-rewards .exit-reward-item {
  color: #b03d68;
  font-size: 1.2rem;
  font-weight: 1000;
  line-height: 1.5;
}

.exit-rewards .exit-reward-item.essence {
  font-size: 1.05rem;
}

/* 唇(音声モードのキャンセルボタン) */
.lips-button {
  position: absolute;
  z-index: 5;
  bottom: clamp(4.6rem, 13vw, 7.2rem);
  left: 0.8rem;
  display: grid;
  place-items: center;
  width: 3.6rem;
  aspect-ratio: 3 / 2;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0.2rem;
  cursor: pointer;
}

.lips-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.lips-button canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

/* ========== 打込みモード(テンキー) ========== */

.numpad {
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.16);
  padding: 0.6rem;
}

.typed-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  background: white;
  padding: 0.35rem 0.7rem;
}

.typed-row span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.typed-row strong {
  min-height: 1.6rem;
  font-size: 1.6rem;
  line-height: 1;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.numpad-grid button {
  min-height: clamp(2.6rem, 7.5vh, 3.4rem);
  border: 3px solid var(--ink);
  border-radius: 0.45rem;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.numpad-grid button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.numpad-grid .key-del {
  background: #ffe3e9;
}

.numpad-grid .key-ok {
  background: var(--sun);
}

@media (max-width: 700px) {
  .care-grid {
    grid-template-columns: 1fr 1.15fr;
    gap: 0.5rem;
  }

  .care-panel {
    padding: 0.6rem;
  }

  .roamer {
    width: clamp(4.2rem, 24vw, 6rem);
  }
}

/* ================= v13:メニューのシーン ================= */

button,
.side-key,
.numpad-grid button,
.radar-buttons button,
.menu-stage {
  touch-action: manipulation; /* ダブルタップ拡大を防ぐ */
}

.menu-stage {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: clamp(24rem, 66vh, 38rem);
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: linear-gradient(180deg, #a9e2f5 0%, #cdeef7 55%, #e5f6ee 82%, #e5f6ee 100%);
  box-shadow: 8px 8px 0 rgba(32, 33, 36, 0.16);
  padding: 0;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.stage-menu-button {
  position: absolute;
  z-index: 12;
  top: 0.7rem;
  right: 0.7rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 253, 243, 0.94);
  box-shadow: 3px 3px 0 rgba(32, 33, 36, 0.22);
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.stage-menu-list {
  position: absolute;
  z-index: 13;
  top: 3.25rem;
  right: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.stage-menu-list button {
  border: 0;
  background: transparent;
  min-height: 2.7rem;
  padding: 0.35rem 0.5rem;
  color: var(--ink);
  font-size: clamp(1.2rem, 5.2vw, 1.55rem);
  font-weight: 900;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    1px 0 0 rgba(255, 255, 255, 0.95),
    0 -1px 0 rgba(255, 255, 255, 0.95),
    -1px 0 0 rgba(255, 255, 255, 0.95);
  cursor: pointer;
}

.stage-menu-list button.active {
  color: var(--violet);
}

.stage-info-overlay {
  position: absolute;
  z-index: 8;
  top: 0.8rem;
  right: 1rem;
  left: 1rem;
  max-height: 53%;
  overflow: auto;
  pointer-events: none;
}

.stage-info-overlay.records-open {
  bottom: 0.8rem;
  max-height: calc(100% - 1.6rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(32, 33, 36, 0.26) transparent;
}

.stage-info-overlay.status-open {
  bottom: 0.8rem;
  max-height: calc(100% - 1.6rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

.stage-info-overlay.records-open::-webkit-scrollbar {
  width: 4px;
}

.stage-info-overlay.records-open::-webkit-scrollbar-track {
  background: transparent;
}

.stage-info-overlay.records-open::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(32, 33, 36, 0.22);
}

.stage-info-content {
  width: min(29rem, 100%);
  color: var(--ink);
  font-size: clamp(0.72rem, 3vw, 0.9rem);
  font-weight: 800;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.96),
    1px 0 0 rgba(255, 255, 255, 0.96),
    0 -1px 0 rgba(255, 255, 255, 0.96),
    -1px 0 0 rgba(255, 255, 255, 0.96);
  pointer-events: auto;
}

.stage-info-content.records-view {
  width: min(42rem, 100%);
}

.stage-info-content h2,
.stage-info-content p {
  margin: 0 0 0.35rem;
}

.stage-character-name {
  margin-top: 0.8rem !important;
  margin-bottom: 0.1rem !important;
  color: #1c7d48;
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  font-weight: 900;
}

.stage-rank-text {
  color: var(--violet);
}

.stage-level-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.stage-level-line span {
  font-size: 0.78rem;
}

.stage-level-line strong {
  color: #f0b429;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  line-height: 1;
  letter-spacing: 0.1rem;
}

.stage-xp-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: min(9.5rem, 65%);
  margin-top: 0.55rem;
}

.stage-xp-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0.3rem;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.stage-xp-line em {
  color: var(--ink);
  font-style: normal;
}

.stage-xp-track {
  overflow: hidden;
  flex: 1;
  min-width: 5rem;
  height: 0.65rem;
  border: 2px solid rgba(32, 33, 36, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.stage-xp-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sky), var(--violet));
}

.stage-brain-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0.65rem;
  width: min(15rem, 72%);
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.stage-brain-line em {
  color: #d6559a;
  font-size: 0.78rem;
  font-weight: 900;
  font-style: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.stage-stat-list {
  display: grid;
  gap: 0.15rem;
  width: min(15rem, 72%);
  margin-top: 2rem;
}

.stage-stat-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  align-items: center;
  gap: 0.55rem;
}

.stage-stat-row span {
  font-size: 0.78rem;
}

.stage-stat-row i {
  overflow: hidden;
  height: 0.82rem;
  border: 2px solid rgba(32, 33, 36, 0.68);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

.stage-stat-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f8d84a, #f28e49);
}

.stage-learned-moves {
  width: min(15rem, 72%);
  margin-top: 0.7rem;
  text-align: left;
}

.stage-learned-moves h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.stage-learned-move-list {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.stage-learned-move {
  min-height: 1rem;
  color: var(--violet);
  font-size: 0.82rem;
  font-weight: 900;
}

.stage-learned-move.is-unavailable {
  opacity: 0.42;
}

.stage-inventory {
  width: min(24rem, 100%);
  margin-top: 0.8rem;
}

.stage-inventory dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  margin: 0;
}

.stage-inventory dl div {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  border-left: 0.3rem solid var(--leaf);
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.42);
  padding: 0.3rem 0.45rem;
}

.stage-inventory dt,
.stage-inventory dd {
  margin: 0;
}

.stage-inventory dd {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 900;
}

.stage-inventory button {
  min-width: 5.6rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  padding: 0.22rem 0.55rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  white-space: nowrap;
  cursor: pointer;
}

.stage-inventory button:disabled {
  opacity: 0.42;
  cursor: default;
}

.stage-info-title {
  font-size: clamp(1.25rem, 6vw, 2rem);
  line-height: 1.05;
}

.stage-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.8rem;
  width: min(23rem, 100%);
  margin: 0;
}

.stage-info-grid div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.stage-info-grid dt,
.stage-info-grid dd {
  margin: 0;
}

.stage-info-grid dd {
  font-weight: 900;
}

.stage-record-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.05rem;
  width: min(18rem, 100%);
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
}

.stage-record-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(32, 33, 36, 0.24);
  padding: 0.12rem 0.2rem;
}

.stage-analysis-bars {
  display: grid;
  gap: 0.35rem;
  width: min(25rem, 100%);
  margin: 0.65rem 0;
}

.stage-analysis-bars > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr 2.8rem;
  align-items: center;
  gap: 0.4rem;
}

.stage-analysis-bars i {
  overflow: hidden;
  height: 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.stage-analysis-bars b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sun), var(--berry));
}

.stage-graph {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}

.stage-record-dashboard {
  display: grid;
  grid-template-columns: 14rem 7rem;
  align-items: center;
  gap: 5rem;
  width: min(26rem, 100%);
  margin-top: 0.1rem;
}

.stage-record-dashboard.number-radar-dashboard {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 0.35rem;
  width: min(26rem, 100%);
}

.formula-achievement {
  width: 90vw;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin-top: 0.55rem;
}

.formula-achievement canvas {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(32, 33, 36, 0.45);
  background: #fff;
  image-rendering: pixelated;
}

.stage-radar-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.number-radar-wrap {
  justify-self: center;
  width: min(23rem, 100%);
}

.number-radar-wrap .stage-graph {
  position: relative;
  z-index: 1;
}

.radar-warp-effect {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.radar-warp-effect.active {
  opacity: var(--warp-opacity, 0);
}

.radar-warp-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  box-sizing: border-box;
  border: 1px solid rgba(21, 24, 34, 0.72);
  border-radius: 44% 56% 48% 52%;
  filter: blur(0.25px);
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.radar-warp-ring.ring-one {
  width: var(--warp-ring-one, 0);
  height: var(--warp-ring-one, 0);
  border-color: rgba(121, 86, 216, 0.85);
  animation: radarWarpPulse 2.2s ease-in-out infinite;
}

.radar-warp-ring.ring-two {
  width: var(--warp-ring-two, 0);
  height: var(--warp-ring-two, 0);
  border-style: dashed;
  border-color: rgba(35, 48, 70, 0.58);
  animation: radarWarpPulse 2.8s ease-in-out -0.9s infinite;
}

.radar-warp-ring.ring-three {
  width: var(--warp-ring-three, 0);
  height: var(--warp-ring-three, 0);
  border-color: rgba(240, 98, 122, 0.38);
  animation: radarWarpPulse 3.4s ease-in-out -1.7s infinite;
}

.radar-warp-effect i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 1.5px;
  border-radius: 999px;
  background: hsl(var(--warp-hue) 78% 48%);
  box-shadow: 0 0 3px hsl(var(--warp-hue) 82% 62%);
  transform-origin: 0 50%;
  animation: radarWarpSuction var(--warp-duration) linear infinite;
  animation-delay: var(--warp-delay);
}

.radar-warp-effect i[hidden] {
  display: none;
}

@keyframes radarWarpPulse {
  0%, 100% {
    opacity: 0.38;
    transform: translate(-50%, -50%) scale(1.04);
  }
  50% {
    opacity: 0.86;
    transform: translate(-50%, -50%) scale(0.97);
  }
}

@keyframes radarWarpSuction {
  0% {
    opacity: 0;
    transform: rotate(var(--warp-angle)) translateX(var(--warp-reach)) scaleX(1.7);
  }
  18% { opacity: 0.9; }
  72% { opacity: 0.72; }
  100% {
    opacity: 0;
    transform: rotate(var(--warp-angle)) translateX(var(--warp-core-radius)) scaleX(0.15);
  }
}

.number-radar-orbit {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.number-radar-orbit span {
  position: absolute;
  font-size: 0.36rem;
  font-weight: 800;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.98),
    1px 0 0 rgba(255, 255, 255, 0.98),
    0 -1px 0 rgba(255, 255, 255, 0.98),
    -1px 0 0 rgba(255, 255, 255, 0.98);
  transform: translate(-50%, -50%);
}

.stage-radar-switches {
  display: grid;
  gap: 0.28rem;
  justify-self: end;
  justify-items: end;
  width: max-content;
  max-width: 100%;
  margin-right: clamp(0.4rem, 5vw, 2.4rem);
}

.stage-radar-switches .stage-view-toggle {
  justify-self: end;
  width: max-content;
  padding-right: 0.08rem;
  padding-left: 0.08rem;
  text-align: right;
}

.stage-data-mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 6.2rem;
  margin: 0.05rem 0 0.45rem;
  padding: 0.18rem;
  border: 2px solid rgba(32, 33, 36, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 2px 0 rgba(32, 33, 36, 0.14);
  isolation: isolate;
}

.stage-data-mode-switch::before {
  position: absolute;
  z-index: 0;
  top: 0.18rem;
  bottom: 0.18rem;
  left: 0.18rem;
  width: calc(50% - 0.18rem);
  border-radius: inherit;
  background: #176b42;
  content: "";
  transition: transform 220ms ease-out;
}

.stage-data-mode-switch.is-old::before {
  transform: translateX(100%);
}

.stage-data-mode-switch button {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 0.2rem 0.55rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: none;
  cursor: pointer;
}

.stage-data-mode-switch button.active {
  color: #fff;
}

.stage-radar-buttons {
  position: absolute;
  inset: 0;
}

.stage-radar-buttons button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: default;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    1px 0 0 rgba(255, 255, 255, 0.95),
    0 -1px 0 rgba(255, 255, 255, 0.95),
    -1px 0 0 rgba(255, 255, 255, 0.95);
  transform: translate(-50%, -50%);
}

.stage-radar-buttons button.good {
  color: #188449;
}

.stage-radar-buttons button.mid {
  color: #a86d00;
}

.stage-radar-buttons button.weak {
  color: #d22f52;
}

.stage-radar-buttons button.none {
  color: var(--muted);
}

.stage-radar-buttons button.selected {
  font-size: 0.95rem;
  text-decoration: underline;
  text-decoration-color: var(--violet);
  text-decoration-thickness: 0.16rem;
  text-underline-offset: 0.14rem;
}

.stage-dan-detail {
  display: grid;
  gap: 0.4rem;
  justify-self: end;
  width: 100%;
}

.stage-dan-detail h3 {
  margin: 0;
  color: var(--violet);
  font-size: 1rem;
}

.stage-dan-detail > div {
  display: grid;
  gap: 0.12rem;
  border-left: 0.3rem solid;
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.45);
  padding: 0.28rem 0.4rem;
}

.stage-dan-detail > div.strong {
  border-color: var(--leaf);
}

.stage-dan-detail > div.weak {
  border-color: var(--berry);
}

.stage-dan-detail strong {
  font-size: 0.58rem;
  white-space: nowrap;
}

.stage-dan-detail span {
  font-size: 0.78rem;
}

.stage-view-toggle {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--violet);
  background: transparent;
  padding: 0.2rem 0;
  color: var(--violet);
  font-size: 0.7rem;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.stage-deep-analysis {
  display: grid;
  grid-template-columns: 11rem 15rem;
  gap: 0.45rem;
  width: min(26.5rem, 100%);
  margin-top: -0.15rem;
}

.stage-mini-heatmap h3,
.stage-parent-analysis h3 {
  margin: 0 0 0.3rem;
  font-size: 0.76rem;
}

.stage-mini-heatmap {
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stage-mini-heatmap table {
  width: 7.92rem;
  border-collapse: collapse;
  table-layout: fixed;
}

.stage-mini-heatmap th {
  padding: 0;
  color: var(--muted);
  font-size: 0.5rem;
  line-height: 1;
}

.stage-mini-heatmap td {
  height: 0.95rem;
  border: 1px solid rgba(32, 33, 36, 0.28);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.stage-mini-heatmap td.none {
  background: rgba(231, 233, 236, 0.82);
}

.stage-mini-heatmap td.good {
  background: var(--leaf);
}

.stage-mini-heatmap td.mid {
  background: #a9dfb8;
}

.stage-mini-heatmap td.weak {
  background: var(--berry);
}

.stage-parent-analysis dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.12rem;
  margin: 0;
}

.stage-parent-analysis dl div {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: start;
  gap: 0.35rem;
  border-bottom: 0;
}

.stage-parent-analysis dt,
.stage-parent-analysis dd {
  margin: 0;
  font-size: 0.64rem;
}

.stage-parent-analysis dd {
  font-weight: 900;
}

.stage-overall-commentary {
  grid-column: 1 / -1;
  width: min(26.5rem, 100%);
}

.stage-overall-commentary h3 {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
}

.stage-overall-commentary p {
  margin: 0 0 0.16rem;
  font-size: 0.58rem;
  line-height: 1.4;
}

.stage-cell-popup {
  position: absolute;
  z-index: 20;
  display: grid;
  min-width: 7.5rem;
  border: 2px solid var(--ink);
  border-radius: 0.35rem;
  background: rgba(255, 253, 243, 0.98);
  box-shadow: 3px 3px 0 rgba(32, 33, 36, 0.2);
  padding: 0.28rem 0.4rem;
  font-size: 0.62rem;
  line-height: 1.3;
  pointer-events: none;
  transform: none;
}

.stage-cell-popup strong {
  color: var(--violet);
  font-size: 0.75rem;
}

.stage-cell-popup[hidden] {
  display: none;
}

.stage-analysis-number,
.stage-parent-analysis dd {
  color: #c8203f;
}

.stage-info-content.deep-open .stage-record-list,
.stage-info-content.deep-open .formula-achievement {
  display: none;
}

@media (max-width: 430px) {
  .formula-achievement {
    position: relative;
    left: 50%;
    width: 90vw;
    max-width: none;
    aspect-ratio: 1 / 1;
    transform: translateX(-50%);
  }

  .stage-record-dashboard {
    grid-template-columns: minmax(10rem, 1fr) 5.5rem;
    gap: 0.35rem;
    width: 100%;
  }

  .stage-record-dashboard.number-radar-dashboard {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .number-radar-wrap {
    width: min(21rem, 91vw);
  }

  .stage-radar-switches {
    width: max-content;
    margin-right: 0.55rem;
  }

  .stage-radar-buttons button {
    width: 1.2rem;
    height: 1.2rem;
  }

  .stage-deep-analysis {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    row-gap: 0.65rem;
    width: 100%;
    margin-top: -0.08rem;
  }

  .stage-parent-analysis {
    width: 100%;
  }

  .stage-mini-heatmap {
    width: min(20rem, 92%);
  }

  .stage-mini-heatmap table {
    width: 100%;
  }

  .stage-mini-heatmap td {
    height: clamp(1rem, 4.8vw, 1.2rem);
  }

  .stage-mini-heatmap h3,
  .stage-parent-analysis h3 {
    margin-bottom: 0.24rem;
    font-size: 0.72rem;
  }

  .stage-mini-heatmap th {
    font-size: 0.48rem;
  }

  .stage-parent-analysis dl {
    gap: 0.08rem;
  }

  .stage-parent-analysis dl div {
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 0.12rem;
    border-bottom: 1px solid rgba(32, 33, 36, 0.2);
    padding: 0.13rem 0.05rem;
    line-height: 1.2;
  }

  .stage-parent-analysis dt,
  .stage-parent-analysis dd {
    font-size: clamp(0.56rem, 2.45vw, 0.66rem);
  }

  .stage-overall-commentary {
    grid-column: 1;
    width: 100%;
  }

  .stage-overall-commentary p {
    margin-bottom: 0.42rem;
    font-size: clamp(0.66rem, 2.9vw, 0.76rem);
    line-height: 1.5;
  }

  .stage-info-content.deep-open .stage-view-toggle {
    font-size: 0.62rem;
  }

  .stage-info-content.deep-open .stage-cell-popup {
    min-width: 6.7rem;
    font-size: 0.58rem;
  }
}

@media (max-width: 350px) {
  .stage-record-dashboard {
    grid-template-columns: 9.5rem 5.25rem;
    gap: 0.25rem;
  }

  .stage-record-dashboard.number-radar-dashboard {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-mini-heatmap table {
    width: 100%;
  }

  .stage-mini-heatmap td {
    height: 0.95rem;
  }

  .stage-deep-analysis {
    gap: 0.32rem;
  }

  .stage-parent-analysis dl {
    gap: 0.04rem;
  }

  .stage-parent-analysis dt,
  .stage-parent-analysis dd {
    font-size: 0.54rem;
  }

  .stage-overall-commentary p {
    margin-bottom: 0.12rem;
    font-size: 0.56rem;
    line-height: 1.3;
  }
}

.menu-screen .char-actions {
  grid-template-columns: minmax(7rem, 1.08fr) minmax(0, 1.92fr);
  gap: 0.45rem;
}

.menu-screen .char-actions .start-button {
  font-size: clamp(0.78rem, 3.5vw, 1rem);
  white-space: nowrap;
}

.menu-screen .mode-segment {
  grid-template-columns: auto repeat(2, minmax(3.5rem, 3.9rem));
  align-items: center;
  justify-content: end;
  gap: 0.3rem;
}

.mode-label {
  justify-self: end;
  color: var(--muted);
  font-size: clamp(0.58rem, 2.6vw, 0.72rem);
  font-weight: 900;
  white-space: nowrap;
}

.menu-screen .mode-segment button {
  min-height: 3.3rem;
  padding: 0.25rem;
  font-size: 0.8rem;
}

/* ---------- はじめての遊び方 ---------- */

.menu-tutorial {
  position: fixed;
  z-index: 800;
  inset: 0;
  overflow: hidden;
  background: rgba(7, 10, 30, 0.56);
  isolation: isolate;
}

.menu-tutorial[hidden] {
  display: none;
}

.tutorial-focus[hidden],
.tutorial-arrow[hidden] {
  display: none;
}

.tutorial-focus {
  position: fixed;
  z-index: 1;
  left: var(--tutorial-focus-left);
  top: var(--tutorial-focus-top);
  width: var(--tutorial-focus-width);
  height: var(--tutorial-focus-height);
  border: 5px solid #fff36b;
  border-radius: 1rem;
  box-shadow:
    0 0 0 999vmax rgba(7, 10, 30, 0.22),
    0 0 22px rgba(255, 243, 107, 0.9);
  animation: tutorialFocusPulse 0.9s steps(2, end) infinite;
  pointer-events: none;
}

.tutorial-arrow {
  position: fixed;
  z-index: 3;
  left: var(--tutorial-arrow-left);
  top: var(--tutorial-arrow-top);
  width: 66px;
  height: 84px;
  color: #ff4b55;
  font-family: "Arial Black", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 78px;
  font-weight: 1000;
  line-height: 0.9;
  text-align: center;
  -webkit-text-stroke: 4px #ff4b55;
  image-rendering: pixelated;
  animation: tutorialArrowPoint 0.72s steps(3, end) infinite alternate;
  pointer-events: none;
}

.tutorial-arrow::before {
  content: "↓";
}

.tutorial-arrow.points-up {
  animation-name: tutorialArrowPointUp;
}

.tutorial-arrow.points-up::before {
  content: "↑";
}

.tutorial-doctor {
  position: fixed;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(88vw, 34rem);
  text-align: center;
  transform: translate(-50%, -54%);
  pointer-events: none;
}

.tutorial-doctor-fragment {
  position: absolute;
  z-index: 2;
  inset: 0;
  opacity: 0;
  background: url("./assets/opening/opening-doctor-sprites.png") 0 0 / 300% 100% no-repeat;
  filter:
    grayscale(0.2)
    hue-rotate(145deg)
    saturate(2)
    brightness(1.35)
    drop-shadow(10px 0 0 rgba(255, 75, 85, 0.32))
    drop-shadow(-10px 0 0 rgba(92, 225, 230, 0.42));
  image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(to bottom, #000 0 74%, transparent 98%);
  mask-image: linear-gradient(to bottom, #000 0 74%, transparent 98%);
}

.tutorial-doctor-fragment.fragment-left {
  clip-path: inset(0 50% 0 0);
}

.tutorial-doctor-fragment.fragment-right {
  clip-path: inset(0 0 0 50%);
}

.tutorial-doctor-signal {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  opacity: 0.34;
  filter:
    grayscale(0.35)
    sepia(0.2)
    hue-rotate(145deg)
    saturate(1.8)
    brightness(1.25)
    drop-shadow(4px 5px 0 rgba(92, 225, 230, 0.35));
}

.tutorial-doctor-sprite {
  position: absolute;
  inset: 0;
  background: url("./assets/opening/opening-doctor-sprites.png") 0 0 / 300% 100% no-repeat;
  image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(to bottom, #000 0 74%, transparent 98%);
  mask-image: linear-gradient(to bottom, #000 0 74%, transparent 98%);
  animation: tutorialDoctorBlink 5.2s steps(1, end) infinite;
}

.tutorial-doctor-noise {
  position: absolute;
  z-index: 2;
  inset: 0;
  opacity: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 5px,
      rgba(255, 255, 255, 0.92) 5px 8px,
      rgba(92, 225, 230, 0.75) 8px 11px
    ),
    url("./assets/opening/opening-doctor-sprites.png") 0 0 / 300% 100% no-repeat;
  mix-blend-mode: screen;
  animation: tutorialNoiseBurst 4.8s steps(1, end) infinite;
  image-rendering: pixelated;
}

.menu-tutorial.is-preparing .tutorial-doctor-signal,
.menu-tutorial.is-connecting .tutorial-doctor-signal {
  opacity: 0;
}

.menu-tutorial.is-connecting .tutorial-doctor {
  animation: tutorialDoctorAttachBounce 1s steps(10, end) both;
}

.menu-tutorial.is-connecting .fragment-left {
  animation: tutorialDoctorLeftIn 1s steps(10, end) both;
}

.menu-tutorial.is-connecting .fragment-right {
  animation: tutorialDoctorRightIn 1s steps(10, end) both;
}

.menu-tutorial.is-preparing .tutorial-message,
.menu-tutorial.is-preparing .tutorial-skip,
.menu-tutorial.is-preparing .tutorial-arrow,
.menu-tutorial.is-preparing .tutorial-focus,
.menu-tutorial.is-connecting .tutorial-message,
.menu-tutorial.is-connecting .tutorial-skip,
.menu-tutorial.is-connecting .tutorial-arrow,
.menu-tutorial.is-connecting .tutorial-focus {
  opacity: 0;
  pointer-events: none;
}

.menu-tutorial.is-waiting .tutorial-message,
.menu-tutorial.is-waiting .tutorial-skip,
.menu-tutorial.is-waiting .tutorial-arrow,
.menu-tutorial.is-waiting .tutorial-focus {
  opacity: 0;
  pointer-events: none;
}

.menu-tutorial.is-disconnecting .tutorial-doctor-signal {
  animation: tutorialDoctorSignalVanish 0.18s steps(2, end) forwards;
}

.menu-tutorial.is-disconnecting .fragment-left {
  animation: tutorialDoctorLeftOut 1.1s steps(8, end) both;
}

.menu-tutorial.is-disconnecting .fragment-right {
  animation: tutorialDoctorRightOut 1.1s steps(8, end) both;
}

.menu-tutorial.is-disconnecting .tutorial-message {
  animation: tutorialDialogueVanish 1.1s steps(6, end) forwards;
}

.menu-tutorial.is-disconnecting .tutorial-skip,
.menu-tutorial.is-disconnecting .tutorial-arrow,
.menu-tutorial.is-disconnecting .tutorial-focus {
  opacity: 0;
  pointer-events: none;
}

.tutorial-message {
  position: fixed;
  z-index: 4;
  top: 60%;
  left: 50%;
  width: min(92vw, 34rem);
  min-height: 0;
  padding: 0.75rem 1rem;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  outline: none;
  transform: translate(-50%, -50%);
}

.tutorial-message:focus,
.tutorial-message:focus-visible {
  outline: none;
}

.tutorial-message #tutorialText {
  display: block;
  white-space: pre-line;
  font-size: clamp(1.08rem, 5vw, 1.55rem);
  font-weight: 1000;
  line-height: 1.6;
  text-shadow:
    3px 3px 0 #0b0d22,
    -2px -2px 0 #0b0d22,
    2px -2px 0 #0b0d22,
    -2px 2px 0 #0b0d22;
}

.tutorial-next-marker {
  display: inline-block;
  margin-top: 0.3rem;
  color: #fff36b;
  font-size: 1rem;
  text-shadow: 2px 2px 0 #0b0d22;
  animation: tutorialNextMarker 0.8s steps(2, end) infinite;
}

.tutorial-next-marker[hidden] {
  display: none;
}

.tutorial-skip {
  position: fixed;
  z-index: 5;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  min-height: 2.6rem;
  padding: 0.45rem 0.9rem;
  border: 3px solid #fff;
  border-radius: 999px;
  background: rgba(7, 10, 30, 0.68);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 1000;
}

.tutorial-skip:active {
  transform: translate(2px, 2px);
}

@keyframes tutorialArrowPoint {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(13px);
  }
}

@keyframes tutorialArrowPointUp {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-13px);
  }
}

@keyframes tutorialFocusPulse {
  50% {
    border-color: #5ce1e6;
  }
}

@keyframes tutorialDoctorLeftIn {
  0% {
    opacity: 0;
    transform: translateX(-100vw);
  }
  32% {
    opacity: 0.28;
    transform: translateX(-22vw);
  }
  54% {
    opacity: 0.55;
    transform: translateX(92px);
  }
  68% {
    opacity: 0.25;
    transform: translateX(-34px);
  }
  79% {
    opacity: 0.48;
    transform: translateX(19px);
  }
  89% {
    opacity: 0.3;
    transform: translateX(-8px);
  }
  100% {
    opacity: 0.34;
    transform: translateX(0);
  }
}

@keyframes tutorialDoctorRightIn {
  0% {
    opacity: 0;
    transform: translateX(100vw);
  }
  32% {
    opacity: 0.28;
    transform: translateX(22vw);
  }
  54% {
    opacity: 0.55;
    transform: translateX(-92px);
  }
  68% {
    opacity: 0.25;
    transform: translateX(34px);
  }
  79% {
    opacity: 0.48;
    transform: translateX(-19px);
  }
  89% {
    opacity: 0.3;
    transform: translateX(8px);
  }
  100% {
    opacity: 0.34;
    transform: translateX(0);
  }
}

@keyframes tutorialDoctorAttachBounce {
  0%,
  52% {
    transform: translate(-50%, -54%) scale(1);
  }
  66% {
    transform: translate(-50%, -54%) scaleX(0.92) scaleY(1.05);
  }
  78% {
    transform: translate(-50%, -54%) scaleX(1.1) scaleY(0.94);
  }
  89% {
    transform: translate(-50%, -54%) scaleX(0.97) scaleY(1.02);
  }
  100% {
    transform: translate(-50%, -54%) scale(1);
  }
}

@keyframes tutorialDoctorSignalVanish {
  to {
    opacity: 0;
  }
}

@keyframes tutorialDoctorLeftOut {
  0% {
    opacity: 0.34;
    transform: translateX(0);
  }
  25% {
    opacity: 0.58;
    transform: translateX(13px);
  }
  45% {
    opacity: 0.2;
    transform: translateX(-8px);
  }
  100% {
    opacity: 0;
    transform: translateX(-100vw);
  }
}

@keyframes tutorialDoctorRightOut {
  0% {
    opacity: 0.34;
    transform: translateX(0);
  }
  25% {
    opacity: 0.58;
    transform: translateX(-13px);
  }
  45% {
    opacity: 0.2;
    transform: translateX(8px);
  }
  100% {
    opacity: 0;
    transform: translateX(100vw);
  }
}

@keyframes tutorialDialogueVanish {
  0%,
  40% {
    opacity: 1;
  }
  55% {
    opacity: 0.38;
    transform: translate(-48%, -50%);
  }
  68% {
    opacity: 0.8;
    transform: translate(-52%, -50%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%);
  }
}

@keyframes tutorialDoctorBlink {
  0%,
  88%,
  94%,
  100% {
    background-position: 0 0;
  }
  89%,
  92% {
    background-position: 50% 0;
  }
}

@keyframes tutorialNoiseBurst {
  0%,
  79%,
  86%,
  100% {
    opacity: 0;
    transform: translateX(0);
    clip-path: inset(42% 0 42%);
  }
  80% {
    opacity: 0.9;
    transform: translateX(15px);
    clip-path: inset(18% 0 64%);
  }
  82% {
    opacity: 0.72;
    transform: translateX(-18px);
    clip-path: inset(48% 0 32%);
  }
  84% {
    opacity: 0.84;
    transform: translateX(10px);
    clip-path: inset(70% 0 12%);
  }
}

@keyframes tutorialNextMarker {
  50% {
    transform: translateY(4px);
  }
}

@media (max-height: 650px) {
  .tutorial-doctor {
    width: min(72vw, 27rem);
  }

  .tutorial-message {
    top: 55%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-arrow,
  .tutorial-focus,
  .tutorial-doctor-sprite,
  .tutorial-doctor-noise,
  .tutorial-next-marker {
    animation: none;
  }
}

.menu-stage .tap-hint {
  z-index: 4;
  pointer-events: none;
}

.sky-layer,
.food-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.food-layer {
  z-index: 3;
}

.sky-layer {
  z-index: 1;
}

.cloud {
  position: absolute;
  left: 0;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
  will-change: transform;
}

.sky-critter {
  position: absolute;
  left: 0;
  border: 0;
  background: transparent;
  padding: 0.3rem;
  font-size: 1.6rem;
  cursor: pointer;
  pointer-events: auto;
  transform-origin: top left;
  will-change: transform;
  animation: critterBob 0.8s ease-in-out infinite;
}

@keyframes critterBob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -0.3rem; }
}

.food-drop {
  position: absolute;
  transform: translateX(-50%);
  font-size: 1.7rem;
  filter: drop-shadow(2px 3px 0 rgba(32, 33, 36, 0.2));
}

.roamer {
  position: absolute;
  bottom: 1.5rem;
  left: 0;
  z-index: 2;
  width: clamp(11rem, 52vw, 15rem);
  will-change: transform;
}

.roamer canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(5px 7px 0 rgba(32, 33, 36, 0.18));
  transform-origin: 50% 88%;
}

.menu-stage .ground {
  height: 32%;
  z-index: 1;
  border-top: 2px solid rgba(32, 33, 36, 0.3);
  background:
    radial-gradient(ellipse at 12% 26%, rgba(57, 139, 78, 0.42) 0 5%, transparent 6%),
    radial-gradient(ellipse at 38% 62%, rgba(38, 120, 66, 0.3) 0 4%, transparent 5%),
    radial-gradient(ellipse at 72% 34%, rgba(88, 167, 96, 0.45) 0 5%, transparent 6%),
    radial-gradient(ellipse at 91% 78%, rgba(39, 126, 70, 0.34) 0 4%, transparent 5%),
    linear-gradient(180deg, #9fd39d 0%, #73bd7e 58%, #55a86a 100%);
  background-size: 7rem 4rem, 8rem 5rem, 9rem 4.5rem, 7rem 5rem, 100% 100%;
}

.menu-stage .ground::before {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: clamp(3.5rem, 10vh, 5.5rem);
  background:
    linear-gradient(180deg, transparent 0 72%, rgba(92, 151, 112, 0.22) 72% 100%),
    url("./assets/far-scenery.svg") repeat-x left bottom;
  background-size: 100% 100%, 19rem 82%;
  content: "";
  opacity: 0.72;
  pointer-events: none;
}

.tongue {
  position: absolute;
  left: 50%;
  top: 52%;
  z-index: 3;
  width: 0.7rem;
  height: 34%;
  border-radius: 0 0 0.4rem 0.4rem;
  background: #f0627a;
  border: 2px solid var(--ink);
  transform: translateX(-50%) scaleY(0);
  transform-origin: top center;
}

.xp-popup-layer {
  position: absolute;
  top: -1.2rem;
  left: 50%;
  z-index: 5;
  transform: translateX(-50%);
  pointer-events: none;
}

.xp-popup {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  padding: 0.1rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 900;
}

/* 進化シネマ */
.evolve-cinema {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(90, 67, 151, 0.74), transparent 42%),
    #100c25;
  color: #fff;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.evolve-cinema:focus,
.evolve-cinema:focus-visible {
  outline: none;
}

.evolve-cinema.is-entering {
  cursor: default;
  animation: evolveCinemaFadeIn 0.5s ease-out both;
}

.evolve-cinema.is-exiting {
  cursor: default;
  animation: evolveCinemaFadeOut 0.52s ease-in both;
  pointer-events: none;
}

@keyframes evolveCinemaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes evolveCinemaFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.evolve-cinema.is-evolving {
  cursor: default;
  animation: cinemaPulse 0.7s steps(5, end) infinite alternate;
}

@keyframes cinemaPulse {
  from { background-color: #2c185a; }
  to { background-color: #8a254e; }
}

.evolve-rays {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.02);
}

.evolve-rays::before {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  flex: 0 0 auto;
  width: 190vmax;
  aspect-ratio: 1;
  margin-top: -95vmax;
  margin-left: -95vmax;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    #ff4f70 0deg 10deg,
    #ffca3a 10deg 21deg,
    #54d681 21deg 31deg,
    #3fc7ee 31deg 42deg,
    #7456e8 42deg 53deg,
    #ff76cf 53deg 64deg
  );
  content: "";
}

.evolve-cinema.is-complete .evolve-rays {
  opacity: 1;
  transform: scale(1);
}

.evolve-cinema.is-complete .evolve-rays::before {
  animation: evolveRaysSpin 8s linear infinite;
}

@keyframes evolveRaysSpin {
  to { transform: rotate(1turn); }
}

.evolve-cinema canvas {
  position: relative;
  z-index: 2;
  width: min(60%, 15rem);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.9));
  transform: translateY(-8vh);
  transition: opacity 0.25s steps(2, end);
}

.evolve-cinema.is-entering canvas,
.evolve-cinema.is-awaiting canvas {
  opacity: 0.28;
  filter:
    grayscale(0.75)
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.4));
}

.evolve-cinema.is-evolving canvas {
  animation: evolveBlinkShake 0.18s steps(2, end) infinite;
}

.evolve-cinema.is-complete canvas {
  animation: evolveCharacterReveal 0.9s steps(9, end) both;
  filter:
    drop-shadow(0 0 10px #fff)
    drop-shadow(0 0 24px rgba(255, 235, 96, 0.95));
}

@keyframes evolveBlinkShake {
  0%, 100% { transform: translate(0, -8vh) scale(1); }
  50% { transform: translate(3px, calc(-8vh - 2px)) scale(1.03); }
}

@keyframes evolveCharacterReveal {
  from { opacity: 0; transform: translateY(-8vh) scale(0.35) rotate(-5deg); }
  70% { opacity: 1; transform: translateY(-8vh) scale(1.16) rotate(2deg); }
  to { opacity: 1; transform: translateY(-8vh) scale(1) rotate(0); }
}

.cinema-text {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(92vw, 34rem);
  min-height: 1.4rem;
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0.5rem 1rem;
  color: #fff;
  font-size: clamp(1.25rem, 6vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.55;
  opacity: 0;
  text-align: center;
  text-shadow:
    -3px -3px 0 #100c25,
    3px -3px 0 #100c25,
    -3px 3px 0 #100c25,
    3px 3px 0 #100c25,
    0 0 14px rgba(255, 255, 255, 0.7);
  transform: translate(-50%, -50%) scale(0.6);
  white-space: pre-line;
}

.evolve-cinema.is-complete .cinema-text {
  top: min(78%, calc(100% - 7rem));
}

.evolve-cinema.is-awaiting .cinema-text {
  top: min(72%, calc(100% - 6rem));
}

.evolve-cinema.is-awaiting .cinema-text::after,
.evolve-cinema.is-complete .cinema-text::after {
  display: block;
  margin-top: 0.4rem;
  color: #fff5a8;
  font-size: 0.7em;
  content: "▼";
  animation: evolveTapMarker 0.8s steps(2, end) infinite;
}

.cinema-text.show {
  animation: cinemaText 0.5s steps(5, end) forwards;
}

@keyframes cinemaText {
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes evolveTapMarker {
  0%, 49% { transform: translateY(0); }
  50%, 100% { transform: translateY(0.3rem); }
}

/* のうみそメニュー */
.brain-menu {
  position: fixed;
  z-index: 1800;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(18, 23, 34, 0.68);
  cursor: default;
}

.brain-menu[hidden] {
  display: none;
}

.brain-menu-panel {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(92%, 25rem);
  max-height: calc(100% - 1rem);
  overflow: auto;
  padding: 1.2rem 1.2rem 1.35rem;
  border: 5px solid #202124;
  border-radius: 0.6rem;
  background: #fff8dd;
  box-shadow: 8px 10px 0 rgba(32, 33, 36, 0.25);
}

.brain-menu-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.brain-menu-close {
  position: absolute;
  z-index: 30;
  top: 0.55rem;
  right: 0.6rem;
  display: grid;
  width: 2.5rem;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid #202124;
  border-radius: 50%;
  background: #fff;
  color: #202124;
  font-size: 1.5rem;
  font-weight: 1000;
  line-height: 1;
  cursor: pointer;
}

.brain-menu-face {
  position: relative;
  width: min(94%, 20rem);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #202124;
  background: linear-gradient(#b9ebff, #efffdc);
}

.brain-menu-face canvas {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(85%, 17rem);
  height: min(85%, 17rem);
  object-fit: contain;
  image-rendering: pixelated;
  transform: translateX(-50%);
}

.brain-menu-label-row {
  display: grid;
  width: 100%;
  grid-template-columns: 8.3rem 2.5rem minmax(7rem, 1fr);
  align-items: center;
  column-gap: 0.45rem;
  margin: 0.75rem 0;
  padding: 0.2rem 0;
  color: #202124;
  font-size: clamp(0.92rem, 3.7vw, 1.15rem);
  font-weight: 900;
}

.brain-menu-label {
  grid-column: 3;
  justify-self: center;
  max-width: 100%;
  margin: 0;
  color: #d6559a;
  font-size: clamp(1.05rem, 4.4vw, 1.45rem);
  font-weight: 1000;
  overflow-wrap: anywhere;
  line-height: 1.08;
  text-align: center;
}

.brain-menu-essence {
  display: grid;
  width: 100%;
  grid-template-columns: 8.3rem 2.5rem minmax(7rem, 1fr);
  align-items: center;
  column-gap: 0.45rem;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  font-weight: 900;
}

.brain-menu-essence strong {
  justify-self: start;
}

.brain-menu-essence button {
  justify-self: center;
  flex: 0 0 auto;
  min-width: 4.6rem;
  min-height: 2.55rem;
  padding: 0.35rem 0.75rem;
  border: 3px solid #202124;
  border-radius: 0.35rem;
  background: #f8d84a;
  color: #202124;
  font: inherit;
  font-weight: 1000;
  cursor: pointer;
}

.brain-menu-essence button:disabled {
  cursor: default;
  filter: grayscale(0.85);
  opacity: 0.45;
}

.brain-syringe {
  --syringe-fill: 0%;
  --syringe-used: 0%;
  --syringe-push: 0rem;
  --syringe-top: 32%;
  --syringe-right: 4%;
  --syringe-x: 0.75rem;
  --syringe-y: -1.2rem;
  position: absolute;
  z-index: 4;
  top: var(--syringe-top);
  right: var(--syringe-right);
  width: 7.8rem;
  height: 3.6rem;
  border: 0;
  background: transparent;
  color: #202124;
  cursor: grab;
  outline: none;
  touch-action: none;
  transform: translate(var(--syringe-x), var(--syringe-y)) rotate(-45deg);
  transform-origin: 58% 50%;
  transition: transform 0.22s ease-out, opacity 0.2s linear;
  -webkit-tap-highlight-color: transparent;
}

.brain-syringe[hidden] {
  display: none;
}

.brain-syringe.is-entering {
  animation: brainSyringeEnter 0.28s linear both;
}

.brain-syringe.is-pierced {
  cursor: grab;
}

.brain-syringe.is-dragging {
  cursor: grabbing;
  transition: none;
}

.brain-syringe.is-returning {
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.brain-syringe.is-trauma-frozen {
  cursor: default;
  pointer-events: none;
  transition: none;
}

.brain-syringe.is-trauma-frozen .syringe-push-arrow {
  opacity: 0;
}

.brain-syringe.is-empty {
  opacity: 0.62;
}

.brain-syringe:focus-visible .syringe-barrel {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.syringe-barrel {
  position: absolute;
  top: 0.7rem;
  left: 1.55rem;
  width: 4.35rem;
  height: 2.1rem;
  overflow: hidden;
  border: 2px solid #202124;
  border-radius: 0.2rem;
  background: rgba(245, 252, 255, 0.92);
  box-shadow: inset 0 0 0 2px rgba(127, 212, 207, 0.28);
}

.syringe-barrel::after {
  position: absolute;
  z-index: 1;
  inset: 0 0 0 auto;
  width: var(--syringe-used);
  border-left: 1px solid rgba(32, 33, 36, 0.24);
  background: rgba(215, 224, 228, 0.3);
  content: "";
  pointer-events: none;
}

.syringe-liquid {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--syringe-fill);
  background:
    repeating-linear-gradient(
      135deg,
      #ff77b3 0 0.45rem,
      #ee5a9d 0.45rem 0.9rem
    );
  transition: width 0.13s steps(2, end);
}

.syringe-ticks {
  position: absolute;
  z-index: 2;
  top: 0.18rem;
  right: 0;
  left: 0;
  height: 0.42rem;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  pointer-events: none;
}

.syringe-ticks i {
  height: 0.36rem;
  border-right: 0.5px solid rgba(32, 33, 36, 0.55);
}

.syringe-ticks i:nth-child(5n) {
  height: 0.48rem;
  border-right-width: 0.8px;
}

.syringe-needle {
  position: absolute;
  top: 1.64rem;
  left: 0.05rem;
  width: 1.65rem;
  height: 0.18rem;
  background: #202124;
  clip-path: polygon(0 50%, 14% 0, 100% 0, 100% 100%, 14% 100%);
}

.syringe-needle::after {
  position: absolute;
  top: 50%;
  left: 0.05rem;
  width: 0.28rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d84252;
  content: "";
  transform: translate(-40%, -50%);
}

.syringe-tip-anchor {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.syringe-piston {
  position: absolute;
  z-index: 3;
  top: 0.68rem;
  right: 1.82rem;
  width: 0.25rem;
  height: 2.14rem;
  border: 1px solid #202124;
  background: rgba(215, 224, 228, 0.42);
  transform: translateX(var(--syringe-push));
}

.syringe-plunger {
  position: absolute;
  z-index: 6;
  top: 0.55rem;
  right: -0.05rem;
  width: 2rem;
  height: 2.4rem;
  background: transparent;
  cursor: grab;
  transform: translateX(var(--syringe-push));
}

.syringe-plunger::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1.75rem;
  height: 0.34rem;
  border: 1px solid #202124;
  background: rgba(215, 224, 228, 0.48);
  content: "";
  transform: translateY(-50%);
}

.syringe-plunger::after {
  position: absolute;
  top: 50%;
  right: 0;
  width: 0.28rem;
  height: 2.08rem;
  border: 1px solid #202124;
  background: #fff;
  content: "";
  transform: translateY(-50%);
}

.syringe-push-arrow {
  position: absolute;
  z-index: 5;
  top: 1rem;
  right: -1.85rem;
  color: #e42d3f;
  font-size: 1.55rem;
  font-weight: 1000;
  line-height: 1;
  text-shadow:
    1px 0 0 #fff,
    -1px 0 0 #fff,
    0 1px 0 #fff,
    0 -1px 0 #fff;
  opacity: 0;
  pointer-events: none;
  translate: var(--syringe-push) 0;
  animation: syringePushArrow 0.8s ease-in-out infinite;
}

.brain-syringe.is-loaded .syringe-push-arrow {
  opacity: 1;
}

.brain-pain-text {
  position: absolute;
  z-index: 7;
  top: calc(var(--brain-blood-top, 42%) - 1.85rem);
  left: calc(var(--brain-blood-left, 66%) - 3.3rem);
  color: #6b1021;
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  text-shadow:
    1px 0 #fff,
    -1px 0 #fff,
    0 1px #fff,
    0 -1px #fff;
  transform: translateY(0.3rem) scale(0.86);
}

.brain-pain-text.show {
  animation: brainPainLine 1.05s ease-in-out both;
}

.brain-puncture-mark {
  position: absolute;
  z-index: 3;
  top: var(--brain-blood-top, 42%);
  left: var(--brain-blood-left, 66%);
  width: 0.2rem;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: #b41632;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.brain-puncture-mark.show {
  opacity: 1;
}

.brain-blood-effect {
  position: absolute;
  z-index: 6;
  top: var(--brain-blood-top, 42%);
  left: var(--brain-blood-left, 66%);
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.brain-blood-stream {
  position: absolute;
  top: 0;
  left: -1.5rem;
  width: 3rem;
  height: 8.8rem;
  overflow: visible;
}

.brain-blood-stream path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.brain-blood-stream .blood-stream-main {
  stroke: #b41632;
  stroke-width: 7;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
}

.brain-blood-stream .blood-stream-branch {
  stroke: #b41632;
  stroke-width: 5;
  stroke-dasharray: 130;
  stroke-dashoffset: 130;
}

.brain-blood-stream .blood-falling-drop {
  fill: #b41632;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.brain-blood-spurt {
  position: absolute;
  top: -0.12rem;
  left: -0.12rem;
  width: 0.38rem;
  aspect-ratio: 1;
  border-radius: 60% 40% 55% 45%;
  background: #b41632;
  box-shadow:
    0.55rem 0.45rem 0 -0.05rem #b41632,
    -0.42rem 0.68rem 0 -0.06rem #b41632,
    0.12rem 1rem 0 -0.1rem #b41632;
  opacity: 0;
}

.brain-blood-spurt.spurt-two {
  left: -0.08rem;
  width: 0.32rem;
  box-shadow:
    -0.58rem 0.42rem 0 -0.04rem #b41632,
    0.46rem 0.65rem 0 -0.05rem #b41632,
    -0.08rem 0.95rem 0 -0.08rem #b41632;
}

.brain-menu.is-brain-bleeding .brain-blood-effect {
  opacity: 1;
}

.brain-menu.is-brain-bleeding .blood-stream-main {
  animation:
    brainBloodTrailMain 8.6s cubic-bezier(0.32, 0.06, 0.76, 0.42) forwards,
    brainBloodPulseMain 0.9s ease-in-out 1s infinite alternate;
}

.brain-menu.is-brain-bleeding .blood-stream-branch {
  animation:
    brainBloodTrailBranch 6.8s cubic-bezier(0.3, 0.08, 0.74, 0.42) 0.75s forwards,
    brainBloodPulseBranch 1.05s ease-in-out 1.6s infinite alternate;
}

.brain-menu.is-brain-bleeding .blood-falling-drop.drop-main {
  animation: brainBloodDrop 0.82s ease-in 1.2s infinite;
}

.brain-menu.is-brain-bleeding .blood-falling-drop.drop-branch {
  animation: brainBloodDrop 0.92s ease-in 1.65s infinite;
}

.brain-menu.is-brain-bleeding .brain-blood-spurt.spurt-one {
  animation: brainBloodSpurtLeft 0.62s ease-out 0.08s infinite;
}

.brain-menu.is-brain-bleeding .brain-blood-spurt.spurt-two {
  animation: brainBloodSpurtRight 0.62s ease-out 0.36s infinite;
}

.brain-trauma-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: rgba(2, 1, 4, 0);
  opacity: 1;
  pointer-events: all;
  transition: none;
}

.brain-trauma-overlay[hidden] {
  display: none;
}

.brain-trauma-overlay.dark-stage-1 {
  background-color: rgba(2, 1, 4, 0.3);
}

.brain-trauma-overlay.dark-stage-2 {
  background-color: rgba(2, 1, 4, 0.68);
}

.brain-trauma-overlay.dark-stage-3 {
  background-color: #020104;
}

.brain-trauma-overlay.is-recovering {
  animation: none;
  background: #020104;
  opacity: 0;
  transition: opacity 1.4s ease;
}

.brain-trauma-overlay p {
  margin: 0;
  padding: 1.2rem;
  color: #d5cfcc;
  font-size: clamp(1.15rem, 5vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0;
  text-align: center;
  white-space: nowrap;
}

.brain-trauma-overlay.show-message p {
  animation: brainTraumaText 1.8s ease forwards;
}

@keyframes brainSyringeEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes syringePushArrow {
  50% {
    transform: translateX(-0.32rem);
  }
}

@keyframes brainPainLine {
  0%, 100% { opacity: 0; transform: translateY(0.3rem) scale(0.86); }
  22%, 68% { opacity: 0.86; transform: translateY(0) scale(1); }
}

@keyframes brainBloodTrailMain {
  to { stroke-dashoffset: 0; }
}

@keyframes brainBloodTrailBranch {
  to { stroke-dashoffset: 0; }
}

@keyframes brainBloodPulseMain {
  from { stroke-width: 6; }
  to { stroke-width: 8; }
}

@keyframes brainBloodPulseBranch {
  from { stroke-width: 4; }
  to { stroke-width: 6; }
}

@keyframes brainBloodDrop {
  0% { opacity: 0; transform: translateY(0) scale(0.65); }
  18% { opacity: 1; transform: translateY(0.25rem) scale(1); }
  100% { opacity: 0; transform: translateY(2.1rem) scale(0.72); }
}

@keyframes brainBloodSpurtLeft {
  0% { opacity: 0; transform: translate(0, 0) scale(0.45); }
  14% { opacity: 1; transform: translate(-0.22rem, -1rem) scale(1.15); }
  100% { opacity: 0; transform: translate(-1.8rem, -6.4rem) scale(0.52); }
}

@keyframes brainBloodSpurtRight {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  14% { opacity: 1; transform: translate(0.25rem, -0.95rem) scale(1.1); }
  100% { opacity: 0; transform: translate(1.65rem, -5.9rem) scale(0.48); }
}

@keyframes brainTraumaText {
  0% { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

.brain-menu-message {
  display: grid;
  width: 100%;
  height: 2.8em;
  place-items: start center;
  margin: 0.7rem 0 0;
  font-weight: 900;
  line-height: 1.35;
  overflow: hidden;
  text-align: center;
}

@media (max-width: 420px) {
  .brain-menu {
    padding: 0.45rem;
  }

  .brain-menu-panel {
    width: min(calc(100vw - 0.9rem), 24rem);
    max-height: calc(100dvh - 0.9rem);
    padding: 0.8rem 0.75rem 0.65rem;
  }

  .brain-menu-panel h2 {
    margin-bottom: 0.2rem;
  }

  .brain-menu-face {
    width: min(84vw, 20rem);
  }

  .brain-menu-label-row {
    margin: 0.45rem 0;
  }

  .brain-menu-label-row .brain-menu-label {
    margin: 0;
  }

  .brain-menu-essence {
    gap: 0.45rem;
    padding: 0.45rem 0;
    font-size: 0.9rem;
  }

  .brain-menu-essence button {
    min-width: 4.1rem;
    min-height: 2.4rem;
    padding-inline: 0.55rem;
  }

  .brain-menu-message {
    margin-top: 0.45rem;
    font-size: 0.9rem;
  }
}

/* 開発確認用:のうみそ7段階 */
.brain-stages-preview {
  position: fixed;
  z-index: 2100;
  inset: 0;
  overflow: auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: #fff8dd;
  color: #202124;
}

.brain-stages-preview h2 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.4rem);
  font-weight: 1000;
  text-align: center;
}

.brain-stages-preview > p {
  margin: 0.35rem auto 1rem;
  font-weight: 900;
  text-align: center;
}

.brain-stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 42vw), 1fr));
  gap: 0.9rem;
  width: min(72rem, 100%);
  margin: 0 auto;
}

.brain-stages-grid article {
  display: grid;
  justify-items: center;
  overflow: hidden;
  border: 4px solid #202124;
  border-radius: 0.45rem;
  background: linear-gradient(#b9ebff, #efffdc);
  box-shadow: 4px 5px 0 rgba(32, 33, 36, 0.18);
}

.brain-stages-grid canvas {
  display: block;
  width: min(100%, 13rem);
  height: auto;
  image-rendering: pixelated;
}

.brain-stages-grid strong {
  align-self: stretch;
  width: 100%;
  padding: 0.55rem 0.35rem;
  border-top: 3px solid #202124;
  background: #fff;
  color: #d6559a;
  font-size: clamp(0.72rem, 3.2vw, 1rem);
  font-weight: 1000;
  overflow-wrap: anywhere;
  text-align: center;
}

/* はじめから:削除ボタンを目立たせる */
.danger-fill {
  background: var(--berry);
  color: white;
}

/* はじめから:最終確認 */
.new-game-final-overlay {
  position: fixed;
  z-index: 2000;
  inset: 0;
  overflow: hidden;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.new-game-final-overlay[hidden] {
  display: none;
}

.new-game-final-overlay.is-visible {
  pointer-events: auto;
  animation: newGameFinalFadeIn 2.75s steps(1, end) forwards;
}

.new-game-final-overlay.is-returning,
.new-game-final-overlay.is-deleting {
  pointer-events: none;
  animation: newGameFinalFadeOut 2.75s steps(1, end) forwards;
}

.new-game-final-panel {
  position: absolute;
  inset: 0;
  color: #fff;
}

.new-game-warning-wall {
  position: absolute;
  z-index: 1;
  inset: -0.4rem;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(0.82rem, 2.25vw, 1.45rem);
  font-weight: 1000;
  line-height: 1.38;
  letter-spacing: 0.025em;
  text-align: justify;
  text-shadow:
    2px 0 0 rgba(255, 50, 80, 0.22),
    -2px 0 0 rgba(90, 220, 255, 0.18);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.new-game-final-foreground {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.new-game-final-overlay.is-visible .new-game-final-foreground {
  animation: newGameFinalContentIn 0.1s steps(1, end) 2.65s forwards;
  pointer-events: auto;
}

.new-game-final-warning {
  margin: 0;
  color: #ff6376;
  font-size: clamp(1.55rem, 6vw, 3.2rem);
  font-weight: 1000;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-shadow:
    4px 4px 0 #000,
    0 0 16px rgba(255, 99, 118, 0.75);
}

.new-game-final-actions {
  display: flex;
  justify-content: center;
  gap: clamp(0.8rem, 4vw, 1.5rem);
  margin-top: clamp(1.5rem, 6vh, 3rem);
}

.new-game-final-button {
  min-width: min(9rem, 38vw);
  min-height: 3.4rem;
  border: 3px solid #fff;
  border-radius: 0.45rem;
  padding: 0.65rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 1000;
  cursor: pointer;
}

.new-game-final-button.erase {
  background: #b51f3c;
  color: #fff;
}

.new-game-final-button.return {
  background: #fff;
  color: #15151d;
}

.new-game-final-button:active {
  transform: translate(2px, 2px);
}

@keyframes newGameFinalFadeIn {
  0% { opacity: 0; }
  20% { opacity: 0.2; }
  40% { opacity: 0.4; }
  60% { opacity: 0.6; }
  80% { opacity: 0.8; }
  100% { opacity: 1; }
}

@keyframes newGameFinalFadeOut {
  0% { opacity: 1; }
  20% { opacity: 0.8; }
  40% { opacity: 0.6; }
  60% { opacity: 0.4; }
  80% { opacity: 0.2; }
  100% { opacity: 0; }
}

@keyframes newGameFinalContentIn {
  to { opacity: 1; }
}

/* つづきから:渦巻き遷移 */
.continue-transition {
  position: fixed;
  z-index: 2100;
  inset: 0;
  overflow: hidden;
  background: transparent;
  pointer-events: auto;
}

.continue-transition[hidden] {
  display: none;
}

.continue-swirl,
.continue-swirl-core {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
}

.continue-swirl {
  width: 180vmax;
  aspect-ratio: 1;
  background:
    radial-gradient(circle, transparent 0 8%, #05020d 8.5% 13%, transparent 13.5% 19%, #05020d 19.5% 25%, transparent 25.5%),
    repeating-conic-gradient(
      from 0deg,
      #05020d 0deg 12deg,
      #452071 12deg 18deg,
      #12133c 18deg 27deg,
      #05020d 27deg 39deg
    );
  box-shadow: 0 0 0 100vmax #05020d;
}

.continue-swirl-core {
  z-index: 1;
  width: 15vmax;
  aspect-ratio: 1;
  background: #020107;
  box-shadow:
    0 0 0 1.1vmax #7d3e9f,
    0 0 0 2.2vmax #080415;
}

.continue-transition.is-closing .continue-swirl {
  animation: continueSwirlClose 1.05s steps(14, end) forwards;
}

.continue-transition.is-closing .continue-swirl-core {
  animation: continueSwirlCoreClose 0.72s 0.33s steps(8, end) forwards;
}

.continue-transition.is-revealing .continue-swirl {
  animation: continueSwirlReveal 1s steps(14, end) forwards;
}

.continue-transition.is-revealing .continue-swirl-core {
  animation: continueSwirlCoreReveal 0.65s steps(8, end) forwards;
}

@keyframes continueSwirlClose {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(0.012); }
  100% { transform: translate(-50%, -50%) rotate(400deg) scale(1); }
}

@keyframes continueSwirlCoreClose {
  0% { transform: translate(-50%, -50%) scale(0); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes continueSwirlReveal {
  0% { transform: translate(-50%, -50%) rotate(400deg) scale(1); }
  100% { transform: translate(-50%, -50%) rotate(800deg) scale(0); }
}

@keyframes continueSwirlCoreReveal {
  0% { transform: translate(-50%, -50%) scale(1); }
  100% { transform: translate(-50%, -50%) scale(0); }
}

/* メニュー入場:現在時刻 */
.menu-time-overlay {
  position: fixed;
  z-index: 2050;
  inset: 0;
  display: grid;
  width: 100%;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: transparent;
  color: #baffed;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-time-overlay[hidden] {
  display: none;
}

.menu-time-overlay:focus,
.menu-time-overlay:focus-visible {
  outline: none;
}

.menu-time-text {
  --time-digit-width: clamp(1.5rem, 4.7vw, 3.7rem);
  --time-digit-height: clamp(2.7rem, 8.4vw, 6.6rem);
  --time-segment-size: clamp(0.32rem, 0.82vw, 0.68rem);
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.65rem, 2.2vw, 1.35rem);
  min-width: min(96vw, 48rem);
  min-height: clamp(7rem, 20vw, 15rem);
  filter:
    drop-shadow(3px 0 0 rgba(40, 129, 255, 0.3))
    drop-shadow(-3px 0 0 rgba(255, 55, 113, 0.24))
    drop-shadow(0 0 5px rgba(2, 5, 13, 0.72));
}

.menu-time-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.18rem, 0.72vw, 0.55rem);
  min-height: var(--time-digit-height);
}

.menu-time-glyph {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: var(--time-digit-width);
  height: var(--time-digit-height);
}

.time-segment {
  position: absolute;
  display: block;
  background: rgba(34, 77, 71, 0.15);
  opacity: 0.35;
}

.time-segment.is-lit,
.time-slash i,
.time-colon i {
  background: #dffff2;
  box-shadow:
    inset 2px 2px 0 rgba(52, 119, 139, 0.55),
    0 0 5px rgba(105, 255, 222, 0.82);
  opacity: 1;
}

.segment-a,
.segment-d,
.segment-g {
  left: 14%;
  width: 72%;
  height: var(--time-segment-size);
  clip-path: polygon(10% 0, 90% 0, 100% 50%, 90% 100%, 10% 100%, 0 50%);
}

.segment-a {
  top: 0;
}

.segment-g {
  top: 50%;
  transform: translateY(-50%);
}

.segment-d {
  bottom: 0;
}

.segment-b,
.segment-c,
.segment-e,
.segment-f {
  width: var(--time-segment-size);
  height: 43%;
  clip-path: polygon(50% 0, 100% 10%, 100% 90%, 50% 100%, 0 90%, 0 10%);
}

.segment-b,
.segment-c {
  right: 0;
}

.segment-e,
.segment-f {
  left: 0;
}

.segment-b,
.segment-f {
  top: 5%;
}

.segment-c,
.segment-e {
  bottom: 5%;
}

.time-slash {
  width: clamp(0.9rem, 2.9vw, 2.3rem);
}

.time-slash i {
  position: absolute;
  top: 1%;
  left: 50%;
  width: var(--time-segment-size);
  height: 98%;
  clip-path: polygon(50% 0, 100% 5%, 100% 95%, 50% 100%, 0 95%, 0 5%);
  transform: translateX(-50%) rotate(24deg);
}

.time-colon {
  width: clamp(0.58rem, 1.8vw, 1.4rem);
}

.time-colon i {
  position: absolute;
  left: 50%;
  width: var(--time-segment-size);
  aspect-ratio: 1;
  transform: translateX(-50%);
}

.time-colon i:first-child {
  top: 28%;
}

.time-colon i:last-child {
  bottom: 28%;
}

.menu-time-hint {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 0;
  font-family: "Courier New", monospace;
  font-size: clamp(0.65rem, 2.5vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.24em;
  opacity: 0;
  text-align: center;
}

.menu-time-overlay.is-ready .menu-time-hint {
  opacity: 0.72;
  animation: menuTimeHintBlink 1.15s steps(2, end) infinite;
}

.menu-time-overlay.is-dissolving {
  pointer-events: none;
}

.menu-time-overlay.is-dissolving .menu-time-hint {
  opacity: 0;
}

.menu-time-overlay.is-dissolving .menu-time-glyph {
  animation: menuTimeGlyphMosaicOut 0.54s steps(5, end) forwards;
}

.menu-time-overlay.is-dissolving .menu-time-glyph:nth-child(2n) {
  animation-delay: 0.08s;
}

.menu-time-overlay.is-dissolving .menu-time-glyph:nth-child(3n) {
  animation-delay: 0.16s;
}

.menu-time-overlay.is-dissolving .menu-time-glyph:nth-child(5n) {
  animation-delay: 0.04s;
}

.menu-time-overlay.is-dissolving .menu-time-glyph:nth-child(7n) {
  animation-delay: 0.12s;
}

@keyframes menuTimeHintBlink {
  0%, 49% { opacity: 0.72; }
  50%, 100% { opacity: 0.22; }
}

@keyframes menuTimeGlyphMosaicOut {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  20% { opacity: 0.2; transform: translate(3px, -2px) scale(1); }
  40% { opacity: 1; transform: translate(-2px, 2px) scale(0.88); }
  60% { opacity: 0.12; transform: translate(4px, 1px) scale(0.7); }
  80% { opacity: 0.65; transform: translate(-3px, -3px) scale(0.42); }
  100% { opacity: 0; transform: translate(5px, -4px) scale(0.12); }
}

/* ================= v13:ゲーム画面 ================= */

.walk-lane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  height: clamp(5rem, 17vh, 7.5rem);
  overflow: hidden;
  border-bottom: 3px dashed rgba(32, 33, 36, 0.2);
  background: linear-gradient(180deg, transparent 0%, transparent 62%, #d7f0dd 62%, #c7e9d0 100%);
}

.walk-lane .companion {
  position: absolute;
  left: 0;
  bottom: 0.2rem;
  z-index: 1;
  width: clamp(3.4rem, 12vw, 5rem);
  aspect-ratio: auto;
  will-change: transform;
}

.walk-lane .companion canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  animation: none;
  filter: drop-shadow(3px 4px 0 rgba(32, 33, 36, 0.15));
}

/* 口(唇):大きく・枠なし */
.lips-button {
  position: absolute;
  z-index: 5;
  bottom: 0.7rem;
  left: 0.7rem;
  width: clamp(4.6rem, 17vw, 6.4rem);
  aspect-ratio: 3 / 2;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
}

.lips-button:active {
  transform: scale(0.92);
  box-shadow: none;
}

.lips-button canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(32, 33, 36, 0.22));
}

/* 吹き出し:コンパクト・唇の上から出る */
.speech-bubble {
  position: absolute;
  z-index: 6;
  left: 0.6rem;
  bottom: clamp(4rem, 13vw, 5.6rem);
  right: auto;
  width: max-content;
  max-width: min(15rem, 70vw);
  border: 3px solid var(--ink);
  border-radius: 0.5rem 0.5rem 0.5rem 0;
  background: white;
  box-shadow: 3px 3px 0 rgba(32, 33, 36, 0.2);
  padding: 0.35rem 0.6rem;
  pointer-events: none;
}

.speech-bubble::after {
  position: absolute;
  left: 1rem;
  bottom: -0.62rem;
  width: 0.85rem;
  height: 0.85rem;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: white;
  content: "";
  transform: skewX(-18deg);
}

.speech-bubble strong {
  display: block;
  overflow: hidden;
  font-size: 0.95rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 脱出ボタン(音声モード:右下) */
/* 右下に縦に積む丸ボタン(下=やめる、その上=ならび) */
.corner-actions {
  position: fixed;
  z-index: 9;
  right: max(0.8rem, env(safe-area-inset-right));
  bottom: max(0.9rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.input-zone {
  position: relative;
}

.game-screen.type-mode .input-zone {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 6px 6px 0 rgba(32, 33, 36, 0.16);
  padding: 0.6rem;
}

.game-screen.type-mode .numpad {
  display: contents;
}

.game-screen.type-mode .numpad-grid {
  grid-column: 1 / 4;
}

.game-screen.type-mode .corner-actions {
  position: static;
  grid-column: 4;
  align-items: stretch;
  width: auto;
  height: 100%;
}

.game-screen.type-mode .round-actions {
  margin-top: auto;
}

.fab {
  display: grid;
  place-items: center;
  width: 3.4rem;
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.fab:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.fab.exit {
  background: var(--berry);
  color: white;
}

.side-delete {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: clamp(3rem, 9vh, 4.8rem);
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: #ffe3e9;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.round-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.side-delete:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* 入力した数字(ゆびモード):問題エリア中央・問題カードより前に表示 */
.typed-display {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: clamp(4.5rem, 23vw, 9rem);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #17c65a;
  text-shadow:
    -3px -3px 0 rgba(255, 255, 255, 0.95),
    3px -3px 0 rgba(255, 255, 255, 0.95),
    -3px 3px 0 rgba(255, 255, 255, 0.95),
    3px 3px 0 rgba(255, 255, 255, 0.95),
    0 6px 0 rgba(9, 110, 48, 0.28);
  pointer-events: none;
}

.game-screen.type-mode .typed-display {
  z-index: 50;
}

/* テンキー:こたえ枠を廃止。右下の丸ボタン列ぶんだけ右に余白を空け、
   その分キーを縦長(背高)にする */
.numpad {
  display: block;
  padding-right: 0;
}

.numpad .numpad-grid {
  gap: 0.5rem;
}

.numpad .numpad-grid button {
  min-height: clamp(3rem, 9vh, 4.8rem);
  font-size: 1.55rem;
}

/* ================= v13.1:調整 ================= */

/* メニューのキャラを2/3くらいに */
.roamer {
  width: clamp(7.5rem, 34vw, 10rem);
  bottom: 1.5rem;
  transform-origin: 50% 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.roamer:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.95);
  outline-offset: 4px;
}

/* 雲(絵文字をやめてCSSで) */
.cloud {
  position: absolute;
  left: 0;
  width: calc(4rem * var(--cloud-scale, 1));
  height: calc(2.4rem * var(--cloud-scale, 1));
  background:
    radial-gradient(circle at 30% 66%, #fff 0 40%, transparent 42%),
    radial-gradient(circle at 54% 46%, #fff 0 42%, transparent 44%),
    radial-gradient(circle at 73% 68%, #fff 0 36%, transparent 38%),
    radial-gradient(circle at 50% 86%, #fff 0 50%, transparent 52%);
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.5));
}

/* 鳥・虫(ドット絵canvas) */
.sky-critter {
  font-size: 0;
  padding: 0.35rem;
}

.sky-critter canvas {
  display: block;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(32, 33, 36, 0.18));
}

.sky-critter.caught {
  animation: none;
}

.food-drop {
  line-height: 0;
}

.food-drop canvas {
  display: block;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(32, 33, 36, 0.2));
}

.food-drop.food-bundle canvas {
  filter:
    drop-shadow(0 0 0.35rem rgba(248, 216, 74, 0.72))
    drop-shadow(3px 5px 0 rgba(32, 33, 36, 0.24));
}

/* エサ残数の表示 */
.tap-hint.shake {
  animation: hintShake 0.34s ease;
}

@keyframes hintShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ベロ(高さはJSで設定、向きはrotateで上下) */
.tongue {
  height: 34%;
}

/* ================= v13.1:ゲーム画面 上部散歩ゾーン ================= */

.game-screen {
  gap: 0.4rem;
}

.field-top {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.walk-lane {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  height: clamp(5rem, 13vh, 6.8rem);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 0.5rem;
  background: linear-gradient(180deg, #a9e2f5 0%, #cdeef7 56%, #bfe6c8 56%, #a9dbb3 100%);
}

/* 遠景の雲(いちばんゆっくり流れる) */
.walk-clouds {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 60%;
  background-image:
    radial-gradient(closest-side at 12% 62%, #ffffff 0 72%, transparent 78%),
    radial-gradient(closest-side at 20% 74%, #ffffff 0 60%, transparent 66%),
    radial-gradient(closest-side at 28% 64%, #ffffff 0 66%, transparent 72%),
    radial-gradient(closest-side at 60% 52%, #ffffff 0 62%, transparent 68%),
    radial-gradient(closest-side at 70% 66%, #ffffff 0 66%, transparent 72%),
    radial-gradient(closest-side at 80% 56%, #ffffff 0 60%, transparent 66%);
  background-repeat: repeat-x;
  background-size: 24rem 3rem;
  background-position: 0 0.3rem;
  opacity: 0.92;
  animation: laneClouds 34s linear infinite;
}

@keyframes laneClouds {
  from { background-position: 0 0.3rem; }
  to { background-position: -24rem 0.3rem; }
}

/* 遠景の山・木・森・街のシルエット(中くらいの速さ) */
.walk-far {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40%;
  height: 34%;
  background: url("./assets/far-scenery.svg") repeat-x left bottom;
  background-size: 19rem 100%;
  opacity: 0.95;
  animation: laneFar 17s linear infinite;
}

@keyframes laneFar {
  from { background-position: 0 bottom; }
  to { background-position: -19rem bottom; }
}

/* 手前の草(いちばん速く流れる。色の濃淡で草を点在) */
.walk-scenery {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46%;
  background-color: #5cbb7c;
  background-image:
    radial-gradient(circle at 8% 92%, #7fd39a 0 0.5rem, transparent 0.55rem),
    radial-gradient(circle at 20% 100%, #45a869 0 0.7rem, transparent 0.75rem),
    radial-gradient(circle at 34% 96%, #7fd39a 0 0.42rem, transparent 0.47rem),
    radial-gradient(circle at 48% 100%, #45a869 0 0.66rem, transparent 0.7rem),
    radial-gradient(circle at 62% 94%, #7fd39a 0 0.5rem, transparent 0.55rem),
    radial-gradient(circle at 76% 100%, #45a869 0 0.72rem, transparent 0.78rem),
    radial-gradient(circle at 90% 96%, #7fd39a 0 0.46rem, transparent 0.5rem);
  background-repeat: repeat-x;
  background-size: 14rem 100%;
  animation: laneGrass 2.8s linear infinite;
}

@keyframes laneGrass {
  from { background-position: 0 0; }
  to { background-position: -14rem 0; }
}

.walk-lane .companion {
  position: absolute;
  left: 50%;
  bottom: 0.35rem;
  z-index: 1;
  width: clamp(3.6rem, 13vw, 5.2rem);
  transform: translateX(-50%);
  animation: strollBob 0.44s steps(2, end) infinite;
}

/* 出題の瞬間:キャラも景色も一瞬止まる */
.walk-lane.frozen .walk-clouds,
.walk-lane.frozen .walk-far,
.walk-lane.frozen .walk-scenery {
  animation-play-state: paused;
}

.walk-lane .companion.present {
  animation-play-state: paused;
}

.walk-lane .companion canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  animation: none;
  filter: drop-shadow(3px 4px 0 rgba(32, 33, 36, 0.15));
}

@keyframes strollBob {
  0%, 100% { margin-bottom: 0; }
  50% { margin-bottom: 0.18rem; }
}

/* ライフ(ハートのドット絵) */
.hearts-row {
  display: block;
  width: auto;
  max-width: 100%;
  height: 1.3rem;
  margin: 0 auto;
  image-rendering: pixelated;
}

/* 一時停止・退出時に問題カードを隠す(端がのぞくのを防ぐ) */
.problem.card-hidden {
  opacity: 0;
  visibility: hidden;
}

/* 口(唇):縦幅アップ・枠なし */
.lips-button {
  aspect-ratio: auto;
  height: auto;
  width: clamp(4.4rem, 16vw, 6rem);
  bottom: 0.7rem;
  left: 0.7rem;
}

.lips-button canvas {
  width: 100%;
  height: auto;
}

/* 吹き出し:大きめ・高い位置・とんがり */
.speech-bubble {
  left: 0.9rem;
  bottom: clamp(6rem, 21vw, 7.6rem);
  min-height: 1.8rem;
  min-width: 3.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.6rem;
  padding: 0.5rem 0.85rem;
  text-align: center;
}

.speech-bubble strong {
  font-size: 1.15rem;
  white-space: nowrap;
}

.speech-bubble::after {
  position: absolute;
  left: 1.1rem;
  bottom: -0.7rem;
  width: 0;
  height: 0;
  border-left: 0.55rem solid transparent;
  border-right: 0.55rem solid transparent;
  border-top: 0.75rem solid var(--ink);
  background: none;
  transform: none;
  content: "";
}

.speech-bubble::before {
  position: absolute;
  left: 1.2rem;
  bottom: -0.42rem;
  z-index: 1;
  width: 0;
  height: 0;
  border-left: 0.4rem solid transparent;
  border-right: 0.4rem solid transparent;
  border-top: 0.55rem solid white;
  content: "";
}
