:root {
  --ink: #3c3340;
  --muted: #7b6f7c;
  --paper: #fffaf1;
  --panel: rgba(255, 255, 255, 0.84);
  --cream: #fff0c9;
  --pink: #ffb8cc;
  --rose: #ff759d;
  --blue: #b9e7ff;
  --mint: #c9f4df;
  --gold: #ffd36a;
  --shadow: 0 18px 42px rgba(86, 62, 78, 0.16);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  scrollbar-gutter: stable;
  overscroll-behavior: none;
}

body {
  position: relative;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 184, 204, 0.55), transparent 25%),
    radial-gradient(circle at 82% 8%, rgba(185, 231, 255, 0.58), transparent 25%),
    linear-gradient(135deg, #fff7df 0%, #ffe8ef 45%, #e9f8ff 100%);
  transition: background 500ms ease;
}

body[data-stage="sky"] {
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.7), transparent 18%),
    linear-gradient(180deg, #9bdcff 0%, #eaf8ff 64%, #d6f0c7 100%);
}

body[data-stage="stratosphere"] {
  background:
    radial-gradient(circle at 50% 95%, rgba(255, 255, 255, 0.68), transparent 34%),
    linear-gradient(180deg, #334e98 0%, #6cb7ff 46%, #f7fbff 100%);
}

body[data-stage="space"] {
  background:
    radial-gradient(circle at 74% 18%, rgba(178, 145, 255, 0.34), transparent 18%),
    radial-gradient(circle at 24% 70%, rgba(73, 189, 255, 0.22), transparent 20%),
    linear-gradient(180deg, #110f2f 0%, #1d2761 54%, #3b3170 100%);
}

body[data-stage="heaven"] {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.86), transparent 20%),
    radial-gradient(circle at 20% 80%, rgba(255, 228, 147, 0.42), transparent 24%),
    linear-gradient(180deg, #fff4b8 0%, #ffd9f0 48%, #def7ff 100%);
}

body[data-stage="dream"],
body[data-stage="aurora"],
body[data-stage="starlightPalace"],
body[data-stage="timeGarden"] {
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.72), transparent 18%),
    radial-gradient(circle at 76% 12%, rgba(116, 255, 227, 0.28), transparent 22%),
    linear-gradient(160deg, #fff6c7 0%, #ffb8ee 38%, #a8f2ff 100%);
}

body[data-stage="galaxy"],
body[data-stage="nebula"],
body[data-stage="cometSea"],
body[data-stage="nyanVerse"],
body[data-stage="infinityGate"],
body[data-stage="beyond"] {
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 103, 226, 0.32), transparent 16%),
    radial-gradient(circle at 22% 66%, rgba(80, 230, 255, 0.24), transparent 22%),
    radial-gradient(circle at 50% 42%, rgba(255, 234, 128, 0.16), transparent 28%),
    linear-gradient(180deg, #08051f 0%, #221049 48%, #111f4d 100%);
}

button {
  font: inherit;
}

#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  width: min(1280px, calc(100% - 16px));
  margin: 0 auto;
  padding: 8px 0;
  overflow: hidden;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--rose);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2.05rem);
  line-height: 1;
}

.title-row {
  display: flex;
  align-items: end;
  gap: 8px;
}

.version-badge {
  margin-bottom: 1px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 117, 157, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.save-chip {
  min-width: 86px;
  padding: 6px 9px;
  border: 2px solid rgba(255, 117, 157, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.share-menu {
  position: relative;
}

.share-button {
  min-height: 30px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(17, 17, 17, 0.16);
}

.share-button:hover,
.share-button:focus-visible {
  background: #2b2b2b;
}

.share-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 210;
  width: 172px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.share-popover-title {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.share-action-button {
  display: block;
  width: 100%;
  min-height: 31px;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 900;
  cursor: pointer;
}

.share-action-button + .share-action-button {
  border: 1px solid rgba(17, 17, 17, 0.16);
  background: #fff4bf;
  color: #111;
}

.settings-menu {
  position: relative;
  margin: 0;
}

.settings-menu summary {
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 1000;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  box-shadow: 0 8px 18px rgba(61, 45, 54, 0.12);
}

.settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-menu[open] summary {
  background: #fff4bf;
  color: #8a3350;
}

.settings-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 200;
  width: 168px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.settings-popover .save-chip {
  display: block;
  width: 100%;
  margin-bottom: 7px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  height: 100%;
  min-height: 0;
}

.play-panel,
.panel-block {
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.play-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}

.stage-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background-image: url("assets/stage-ground.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  pointer-events: none;
  transition: background-position 650ms ease, filter 650ms ease;
}

.stage-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 52%, transparent 0 34%, rgba(255, 255, 255, 0.18) 60%, rgba(255, 255, 255, 0.36) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.16));
}

.stage-sun,
.stage-cloud,
.stage-stars,
.stage-gate {
  position: absolute;
  display: none;
  opacity: 0;
  transition: opacity 500ms ease, transform 500ms ease;
}

.stage-sun {
  right: 12%;
  top: 12%;
  width: 96px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, #fff8bf 0%, #ffd86f 50%, transparent 72%);
}

.stage-cloud {
  width: 170px;
  height: 56px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(0.5px);
}

.stage-cloud::before,
.stage-cloud::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: inherit;
}

.stage-cloud::before {
  left: 28px;
  bottom: 20px;
  width: 72px;
  height: 72px;
}

.stage-cloud::after {
  right: 26px;
  bottom: 14px;
  width: 58px;
  height: 58px;
}

.cloud-a {
  left: 11%;
  top: 26%;
}

.cloud-b {
  right: 12%;
  bottom: 18%;
  transform: scale(0.72);
}

.stage-stars {
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(255, 225, 128, 0.86) 0 1px, transparent 1.7px);
  background-position: 0 0, 32px 48px;
  background-size: 92px 86px, 126px 118px;
}

.stage-gate {
  left: 50%;
  top: 12%;
  width: 190px;
  height: 92px;
  border: 8px solid rgba(255, 239, 161, 0.72);
  border-bottom: 0;
  border-radius: 110px 110px 0 0;
  transform: translateX(-50%);
  box-shadow: 0 0 34px rgba(255, 239, 161, 0.56);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  position: relative;
  z-index: 80;
  width: min(100%, 700px);
  margin-inline: auto;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 211, 106, 0.62);
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.72);
}

.stat-score {
  grid-column: 1 / -1;
  min-height: 36px;
  padding: 5px 9px;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-bottom: 0;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 210, 105, 0.28);
  color: #8a5b00;
  font-size: 0.62rem;
  letter-spacing: 0;
}

.stat strong {
  min-width: 0;
  flex: 1 1 auto;
  display: block;
  font-size: 1rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.stat-score strong {
  font-size: 1.18rem;
}

#game-area {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  overflow: visible;
  isolation: isolate;
  touch-action: manipulation;
}

.nyaan-canvas {
  position: absolute;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cat-aura {
  position: absolute;
  z-index: 10;
  width: min(42vmin, 360px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.96), rgba(255, 184, 204, 0.3) 58%, transparent 72%);
  opacity: 0.82;
  transform: scale(var(--aura-scale, 0.78)) rotate(var(--aura-rotate, 0deg));
  transition: transform 300ms ease, opacity 300ms ease;
}

#cat-button {
  position: relative;
  z-index: 60;
  width: min(35vmin, 286px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 48%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 22px 20px rgba(61, 45, 54, 0.22));
  -webkit-tap-highlight-color: transparent;
}

.stage-badge {
  position: absolute;
  left: 50%;
  top: 15%;
  z-index: 12;
  transform: translateX(-50%);
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  pointer-events: none;
}

.stage-gauge {
  position: absolute;
  right: 14px;
  top: 92px;
  bottom: 84px;
  z-index: 85;
  width: 136px;
  pointer-events: none;
}

.stage-gauge-track {
  position: absolute;
  right: 66px;
  top: 8px;
  bottom: 8px;
  width: 14px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.45)),
    linear-gradient(180deg, #ffffff 0%, #ff68d8 12%, #58f0ff 24%, #6d81ff 38%, #25245d 54%, #5d2ca0 68%, #f7f06a 84%, #fff1ad 100%);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.2),
    0 0 22px rgba(255, 216, 111, 0.48),
    0 12px 24px rgba(61, 45, 54, 0.18);
}

.stage-gauge-track::before,
.stage-gauge-track::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: radial-gradient(circle, #fff 0 26%, #ffd86f 28% 52%, transparent 56%);
  transform: translateX(-50%);
}

.stage-gauge-track::before {
  top: -18px;
}

.stage-gauge-track::after {
  bottom: -18px;
}

.stage-gauge-marker {
  position: absolute;
  right: -3px;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translateY(50%);
  color: var(--muted);
  font-size: 0.54rem;
  font-weight: 900;
  white-space: nowrap;
}

.stage-gauge-dot {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: radial-gradient(circle, #fff 0 32%, #ffd86f 35% 58%, #ff8fb0 62%);
  box-shadow:
    0 0 12px rgba(255, 216, 111, 0.72),
    0 4px 10px rgba(61, 45, 54, 0.14);
}

.stage-gauge-label {
  min-width: 3.6em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(45, 30, 51, 0.38);
  background: rgba(255, 246, 172, 0.98);
  color: #1f1724;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.92) inset,
    0 4px 12px rgba(25, 16, 30, 0.16);
  font-weight: 900;
  text-align: center;
  text-shadow: none;
}

.stage-gauge .stage-gauge-marker:not(.is-current) {
  color: #1f1724 !important;
}

.stage-gauge .stage-gauge-marker:not(.is-current) .stage-gauge-label {
  border-color: rgba(45, 30, 51, 0.4) !important;
  background: rgba(255, 246, 172, 0.98) !important;
  color: #1f1724 !important;
  text-shadow: none !important;
}

.stage-gauge-marker.is-current .stage-gauge-label {
  color: #211425;
  border-color: rgba(255, 91, 145, 0.9);
  background: linear-gradient(135deg, rgba(255, 239, 96, 0.98), rgba(255, 177, 218, 0.98));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72) inset,
    0 0 16px rgba(255, 91, 145, 0.42),
    0 8px 14px rgba(61, 45, 54, 0.18);
  text-shadow: none;
}

.stage-gauge-cursor {
  position: absolute;
  left: 0;
  color: #ff5b91;
  font-size: 1.25rem;
  font-weight: 1000;
  line-height: 1;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.9),
    0 0 16px rgba(255, 91, 145, 0.5);
  transform: translateY(50%);
  transition: bottom 350ms ease;
}

body[data-stage="sky"] .stage-sun,
body[data-stage="sky"] .stage-cloud,
body[data-stage="stratosphere"] .stage-cloud,
body[data-stage="space"] .stage-stars,
body[data-stage="heaven"] .stage-cloud,
body[data-stage="heaven"] .stage-gate {
  opacity: 0;
}

body[data-stage="ground"] .stage-layer {
  background-image: url("assets/stage-ground.png");
}

body[data-stage="sky"] .stage-layer {
  background-image: url("assets/stage-sky.png");
}

body[data-stage="stratosphere"] .stage-layer {
  background-image: url("assets/stage-stratosphere.png");
}

body[data-stage="space"] .stage-layer {
  background-image: url("assets/stage-space.png");
}

body[data-stage="heaven"] .stage-layer {
  background-image: url("assets/stage-heaven.png");
}

body[data-stage="dream"] .stage-layer,
body[data-stage="aurora"] .stage-layer {
  filter: saturate(1.08) brightness(1.02);
}

body[data-stage="dream"] .stage-layer {
  background-image: url("assets/stage-dream.png");
}

body[data-stage="aurora"] .stage-layer {
  background-image: url("assets/stage-aurora.png");
}

body[data-stage="galaxy"] .stage-layer {
  background-image: url("assets/stage-galaxy.png");
}

body[data-stage="nebula"] .stage-layer {
  background-image: url("assets/stage-nebula.png");
}

body[data-stage="cometSea"] .stage-layer {
  background-image: url("assets/stage-comet-sea.png");
}

body[data-stage="starlightPalace"] .stage-layer {
  background-image: url("assets/stage-starlight-palace.png");
}

body[data-stage="timeGarden"] .stage-layer {
  background-image: url("assets/stage-time-garden.png");
}

body[data-stage="nyanVerse"] .stage-layer {
  background-image: url("assets/stage-nyan-verse.png");
}

body[data-stage="infinityGate"] .stage-layer {
  background-image: url("assets/stage-infinity-gate.png");
}

body[data-stage="beyond"] .stage-layer {
  background-image: url("assets/stage-beyond.png");
}

body[data-stage="stratosphere"] .stage-cloud {
  transform: translateY(58px) scale(0.62);
  opacity: 0.42;
}

body[data-stage="space"] .play-panel,
body[data-stage="space"] .panel-block,
body[data-stage="galaxy"] .play-panel,
body[data-stage="galaxy"] .panel-block,
body[data-stage="nebula"] .play-panel,
body[data-stage="nebula"] .panel-block,
body[data-stage="cometSea"] .play-panel,
body[data-stage="cometSea"] .panel-block,
body[data-stage="nyanVerse"] .play-panel,
body[data-stage="nyanVerse"] .panel-block,
body[data-stage="infinityGate"] .play-panel,
body[data-stage="infinityGate"] .panel-block,
body[data-stage="beyond"] .play-panel,
body[data-stage="beyond"] .panel-block {
  background: rgba(22, 20, 49, 0.42);
  color: #fff7ff;
}

body[data-stage="space"] .stat,
body[data-stage="space"] .upgrade-card,
body[data-stage="space"] .save-chip,
body[data-stage="galaxy"] .stat,
body[data-stage="galaxy"] .upgrade-card,
body[data-stage="galaxy"] .save-chip,
body[data-stage="nebula"] .stat,
body[data-stage="nebula"] .upgrade-card,
body[data-stage="nebula"] .save-chip,
body[data-stage="cometSea"] .stat,
body[data-stage="cometSea"] .upgrade-card,
body[data-stage="cometSea"] .save-chip,
body[data-stage="nyanVerse"] .stat,
body[data-stage="nyanVerse"] .upgrade-card,
body[data-stage="nyanVerse"] .save-chip,
body[data-stage="infinityGate"] .stat,
body[data-stage="infinityGate"] .upgrade-card,
body[data-stage="infinityGate"] .save-chip,
body[data-stage="beyond"] .stat,
body[data-stage="beyond"] .upgrade-card,
body[data-stage="beyond"] .save-chip {
  background: rgba(255, 255, 255, 0.16);
  color: #fff7ff;
}

body[data-stage="space"] .cat-aura {
  background: radial-gradient(circle, rgba(210, 194, 255, 0.6), rgba(103, 203, 255, 0.18) 54%, transparent 72%);
}

body[data-stage="heaven"] .cat-aura {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.98), rgba(255, 233, 140, 0.42) 55%, transparent 72%);
}

body[data-stage="dream"] .cat-aura,
body[data-stage="aurora"] .cat-aura,
body[data-stage="starlightPalace"] .cat-aura,
body[data-stage="timeGarden"] .cat-aura {
  background: conic-gradient(from var(--aura-rotate, 0deg), rgba(255, 255, 255, 0.95), rgba(255, 91, 216, 0.28), rgba(88, 240, 255, 0.32), rgba(255, 245, 142, 0.34), rgba(255, 255, 255, 0.95));
}

body[data-stage="galaxy"] .cat-aura,
body[data-stage="nebula"] .cat-aura,
body[data-stage="cometSea"] .cat-aura,
body[data-stage="nyanVerse"] .cat-aura,
body[data-stage="infinityGate"] .cat-aura,
body[data-stage="beyond"] .cat-aura {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.82), rgba(255, 79, 216, 0.28) 34%, rgba(88, 240, 255, 0.18) 58%, transparent 74%);
}

body[data-stage="space"] .stage-badge,
body[data-stage="galaxy"] .stage-badge,
body[data-stage="nebula"] .stage-badge,
body[data-stage="cometSea"] .stage-badge,
body[data-stage="nyanVerse"] .stage-badge,
body[data-stage="infinityGate"] .stage-badge,
body[data-stage="beyond"] .stage-badge {
  color: #fff7ff;
}

body[data-stage="space"] .stage-gauge-label {
  border-color: rgba(45, 30, 51, 0.4);
  background: rgba(255, 246, 172, 0.98);
  color: #1f1724;
}

body[data-stage="space"] .stage-gauge-marker.is-current .stage-gauge-label {
  color: #211425;
  background: linear-gradient(135deg, rgba(255, 239, 96, 0.98), rgba(185, 231, 255, 0.98));
}

body[data-stage="space"] .stage-gauge-cursor {
  color: #ffd86f;
}

#cat {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 120ms ease;
}

#cat-button:active #cat,
#cat-button.is-popping #cat {
  transform: scale(0.985) rotate(-1deg);
}

.notice {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 70;
  width: min(92%, 520px);
  min-height: 0;
  transform: translateX(-50%);
  color: #6b4c28;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.notice.has-message {
  padding: 8px 12px;
  border: 2px solid rgba(255, 211, 106, 0.7);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.92);
}

.side-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.panel-block {
  padding: 8px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.upgrade-info {
  position: relative;
  display: block;
  margin: 0 0 10px;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(216, 155, 34, 0.72);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.72);
  color: #6b4c28;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  overflow: visible;
}

.upgrade-info-text {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.upgrade-info::before,
.upgrade-info::after {
  content: "";
  position: absolute;
  left: var(--bubble-tail-x, 24px);
  top: 100%;
  z-index: 2;
  transform: translateX(-50%);
  pointer-events: none;
}

.upgrade-info::before {
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 9px solid rgba(216, 155, 34, 0.72);
}

.upgrade-info::after {
  margin-top: -1px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(255, 250, 241, 0.92);
}

.upgrade-info.is-short {
  border-color: rgba(255, 91, 145, 0.7);
  background: rgba(255, 232, 241, 0.86);
  color: #b02f55;
}

.upgrade-info.is-short::before {
  border-top-color: rgba(255, 91, 145, 0.7);
}

.upgrade-info.is-short::after {
  border-top-color: rgba(255, 232, 241, 0.94);
}

#total-nyaan {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 0;
  max-width: 72%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.upgrade-list {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  padding: 4px 2px;
  overflow: visible;
}

.upgrade-card {
  position: relative;
  appearance: none;
  width: 100%;
  color: var(--ink);
  font: inherit;
  text-align: center;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 76px;
  padding: 5px 3px;
  border: 1px solid rgba(185, 231, 255, 0.78);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  user-select: none;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.upgrade-card.can-buy {
  border-color: rgba(255, 117, 157, 0.72);
  box-shadow: 0 10px 22px rgba(255, 117, 157, 0.14);
}

.upgrade-card.is-selected {
  border-color: rgba(255, 91, 145, 0.95);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 232, 241, 0.9)),
    rgba(255, 255, 255, 0.9);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.96),
    0 0 0 3px rgba(255, 91, 145, 0.58),
    0 12px 26px rgba(255, 91, 145, 0.24);
  transform: translateY(-1px) scale(1.025);
}

.upgrade-card.is-selected .upgrade-icon {
  transform: scale(1.08);
  filter: brightness(1.08) saturate(1.08);
}

.upgrade-card[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.72;
}

.upgrade-icon-wrap {
  position: relative;
  width: clamp(34px, 4vw, 48px);
  aspect-ratio: 1;
}

.upgrade-icon {
  width: 100%;
  height: 100%;
  border-radius: 13px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 8px 18px rgba(61, 45, 54, 0.18);
  object-fit: cover;
  display: block;
  transition: transform 160ms ease, filter 160ms ease;
}

.upgrade-card.can-buy:hover .upgrade-icon,
.upgrade-card.can-buy:focus-visible .upgrade-icon {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.06);
}

.upgrade-name {
  display: none;
  margin: 0;
  max-width: 100%;
  min-height: 2.1em;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  overflow: hidden;
}

.upgrade-desc {
  display: none;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.upgrade-count {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 26px;
  padding: 1px 4px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: linear-gradient(135deg, #fff4bf, #ffb8cc);
  color: #6b4c28;
  font-size: 0.5rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 5px 12px rgba(61, 45, 54, 0.16);
}

.upgrade-cost {
  display: none;
}

.buy-button,
.danger-button,
.debug-grid button {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 900;
}

.buy-button {
  min-height: 17px;
  max-width: 100%;
  padding: 2px 4px;
  background: linear-gradient(135deg, var(--pink), var(--gold));
  font-size: 0.44rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

.upgrade-card.is-selected .buy-button {
  min-width: min(100%, 48px);
  padding: 3px 6px;
  background: #111;
  color: #fff;
  font-size: 0.54rem;
  box-shadow: 0 5px 12px rgba(17, 17, 17, 0.18);
}

.danger-button {
  width: 100%;
  background: #ffe4eb;
  color: #8a3350;
  font-size: 0.76rem;
}

.purchase-ring,
.purchase-particle {
  position: fixed;
  z-index: 300;
  pointer-events: none;
}

.purchase-ring {
  width: 18px;
  aspect-ratio: 1;
  border: 3px solid rgba(255, 216, 79, 0.9);
  border-radius: 999px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.9),
    0 0 18px rgba(255, 91, 145, 0.65),
    0 0 28px rgba(69, 215, 255, 0.45);
  animation: purchase-ring 600ms ease-out forwards;
}

.purchase-particle {
  color: #ff5b91;
  color: var(--particle-color, #ff5b91);
  font-size: 0.72rem;
  font-weight: 1000;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 0 10px currentColor,
    0 0 18px rgba(255, 216, 111, 0.75);
  animation: purchase-pop 820ms cubic-bezier(0.16, 0.86, 0.32, 1) var(--particle-delay, 0ms) forwards;
}

details {
  margin-top: 8px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.debug-grid button {
  background: #e8f7ff;
}

.debug-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.nyaan-text {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 20;
  color: var(--nyaan-color, #ff5b91);
  font-weight: 1000;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.95),
    0 6px 14px rgba(92, 54, 72, 0.18);
  pointer-events: none;
  contain: layout style paint;
  backface-visibility: hidden;
  will-change: transform, opacity;
  animation: nyaan-fly var(--nyaan-duration, 1800ms) linear forwards;
}

.nyaan-text.is-burst {
  z-index: 19;
  opacity: 0.72;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8),
    0 4px 10px rgba(92, 54, 72, 0.12);
  animation-name: nyaan-burst-fly;
}

@keyframes nyaan-fly {
  0% {
    opacity: 1;
    transform: translate3d(var(--start-x), var(--start-y), 0) translate(-50%, -50%) rotate(var(--start-rotation));
  }

  100% {
    opacity: 1;
    transform: translate3d(var(--end-x), var(--end-y), 0) translate(-50%, -50%) rotate(var(--end-rotation));
  }
}

@keyframes nyaan-burst-fly {
  0% {
    opacity: 0.72;
    transform: translate3d(var(--start-x), var(--start-y), 0) translate(-50%, -50%) rotate(var(--start-rotation)) scale(0.82);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--end-x), var(--end-y), 0) translate(-50%, -50%) rotate(var(--end-rotation)) scale(0.92);
  }
}

@keyframes purchase-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.25) rotate(0deg);
  }

  14% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.25) rotate(var(--particle-rotation));
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--particle-x)), calc(-50% + var(--particle-y))) scale(0.72) rotate(var(--particle-rotation));
  }
}

@keyframes purchase-ring {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.3);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.8);
  }
}

@media (max-width: 860px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  #app {
    width: min(100% - 12px, 640px);
    padding-top: 6px;
  }

  .hero {
    align-items: start;
  }

  .header-actions {
    gap: 6px;
  }

  .share-button {
    min-height: 28px;
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .share-popover {
    width: 160px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .play-panel {
    height: 100%;
    min-height: 0;
  }

  .stat {
    min-height: 40px;
    padding: 6px 7px;
  }

  .stat strong {
    font-size: 0.92rem;
  }

  #cat-button {
    width: min(42vmin, 240px);
  }

  .stage-gauge {
    right: 8px;
    top: 74px;
    bottom: 62px;
    transform: scale(0.86);
    transform-origin: right center;
  }

  .section-title {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
  }

  .section-title h2 {
    font-size: 0.82rem;
  }

  #total-nyaan {
    font-size: 0.62rem;
  }

  .upgrade-info {
    min-height: 20px;
    margin-bottom: 4px;
    padding: 3px 7px;
    font-size: 0.58rem;
  }

  .upgrade-list {
    grid-template-columns: repeat(14, minmax(0, 1fr));
    gap: 3px;
    padding: 3px 1px;
    overflow: visible;
  }

  .upgrade-card {
    min-height: 44px;
    gap: 0;
    align-content: center;
    padding: 4px 2px;
    border-radius: 10px;
  }

  .upgrade-icon-wrap {
    width: min(5.6vw, 32px);
  }

  .upgrade-icon {
    border-radius: 11px;
  }

  .upgrade-name {
    display: none;
  }

  .upgrade-count {
    right: -6px;
    top: -6px;
    min-width: 28px;
    padding: 1px 4px;
    font-size: 0.52rem;
  }

  .upgrade-cost {
    display: none;
  }

  .buy-button {
    display: none;
  }

  .upgrade-card.is-selected .buy-button {
    display: block;
    min-height: 15px;
    padding: 2px 4px;
    font-size: 0.46rem;
  }

  .side-panel {
    gap: 5px;
  }

  .panel-block {
    padding: 6px;
  }

  .danger-button {
    min-height: 24px;
    font-size: 0.62rem;
  }
}

@media (max-width: 520px) {
  .hero {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  h1 {
    font-size: clamp(1.05rem, 5.2vw, 1.32rem);
  }

  .title-row {
    gap: 5px;
  }

  .version-badge {
    padding: 2px 5px;
    font-size: 0.54rem;
  }

  .save-chip {
    min-width: 0;
  }

  .share-button {
    min-height: 26px;
    padding: 6px 9px;
    font-size: 0.62rem;
  }

  .share-popover {
    width: 150px;
    padding: 8px;
  }

  .settings-menu summary {
    width: 26px;
    min-height: 26px;
    font-size: 0.8rem;
  }

  .settings-popover {
    width: 150px;
    padding: 7px;
  }

  .play-panel {
    height: 100%;
    min-height: 0;
    padding: 8px;
  }

  .upgrade-list {
    gap: 2px;
    padding: 3px 1px;
  }

  .upgrade-card {
    min-height: 36px;
    gap: 1px;
    padding: 4px 1px;
    border-radius: 9px;
  }

  .upgrade-icon-wrap {
    width: min(5.8vw, 26px);
  }

  .upgrade-icon {
    border-radius: 10px;
  }

  .upgrade-name {
    min-height: 1em;
    font-size: 0.44rem;
    line-height: 1.05;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .upgrade-count {
    right: -6px;
    top: -6px;
    min-width: 24px;
    padding: 1px 4px;
    font-size: 0.48rem;
  }

  .upgrade-cost {
    display: none;
  }

  .buy-button {
    min-height: 14px;
    padding: 1px 4px;
    font-size: 0.44rem;
  }

  .upgrade-card.is-selected .buy-button {
    display: block;
    min-height: 13px;
    padding: 1px 4px;
    font-size: 0.42rem;
  }

  .side-panel {
    gap: 4px;
  }

  .panel-block {
    padding: 5px;
  }

  .section-title {
    margin-bottom: 4px;
  }

  .section-title h2 {
    font-size: 0.78rem;
  }

  #total-nyaan {
    font-size: 0.58rem;
  }

  .upgrade-info {
    min-height: 18px;
    padding: 2px 6px;
    font-size: 0.52rem;
  }

  .danger-button {
    min-height: 22px;
    font-size: 0.58rem;
  }

  .stage-gauge {
    display: none;
  }
}
