/* =============================================
   まなびの ほし — カービィ風がくしゅうアプリ
   ============================================= */

:root {
  /* パレット（カービィ・ドリームランド系パステル） */
  --pink-100: #ffe5ef;
  --pink-200: #ffc8dc;
  --pink-300: #ffa3c1;
  --pink-400: #ff7ba7;
  --pink-500: #ff5f8f;
  --pink-600: #e83a72;

  --blue-100: #e2f2ff;
  --blue-200: #b8ddff;
  --blue-300: #7fbfff;
  --blue-400: #4c9dff;
  --sky-top: #b8e3ff;
  --sky-bot: #ffd1e6;

  --yellow: #ffd952;
  --yellow-dark: #f0b800;
  --green: #7fd66a;
  --green-dark: #3fa93a;
  --purple: #b47cff;
  --red: #ff5757;

  --ink: #2b1e3f;
  --ink-soft: #55447a;
  --paper: #fffaf6;

  /* シャドウ */
  --shadow-sm: 0 2px 0 rgba(43, 30, 63, 0.15);
  --shadow-md: 0 6px 0 rgba(43, 30, 63, 0.18);
  --shadow-lg: 0 12px 30px rgba(43, 30, 63, 0.25);

  --radius: 20px;
  --radius-lg: 32px;

  --font-display: "Mochiy Pop One", "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui,
    sans-serif;
  --font-body: "Zen Maru Gothic", "Kosugi Maru", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
}

/* ---- リセット ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 100%);
  min-height: 100dvh;
  /* 縦は許可（背の低い画面でメニュー下端に届くように）。横は禁止 */
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  /* iOSのダブルタップズーム防止（連打前提のゲームなので必須） */
  touch-action: manipulation;
}

/* ---- そら（背景） ---- */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.cloud {
  position: absolute;
  width: 160px;
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  filter: blur(0.5px);
  animation: drift linear infinite;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 999px;
}
.cloud::before {
  width: 80px;
  height: 80px;
  top: -30px;
  left: 20px;
}
.cloud::after {
  width: 100px;
  height: 100px;
  top: -50px;
  right: 20px;
}
.c1 {
  top: 8%;
  left: -180px;
  animation-duration: 90s;
}
.c2 {
  top: 20%;
  left: -280px;
  transform: scale(0.7);
  opacity: 0.8;
  animation-duration: 130s;
  animation-delay: -30s;
}
.c3 {
  top: 40%;
  left: -220px;
  transform: scale(1.3);
  opacity: 0.6;
  animation-duration: 170s;
  animation-delay: -60s;
}
@keyframes drift {
  from {
    transform: translateX(0) scale(var(--s, 1));
  }
  to {
    transform: translateX(120vw) scale(var(--s, 1));
  }
}

.star {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff59a;
  clip-path: polygon(
    50% 0,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  filter: drop-shadow(0 0 6px #fff59a);
  animation: twinkle 3s ease-in-out infinite;
}
.s1 {
  top: 6%;
  left: 20%;
  animation-delay: -0.3s;
}
.s2 {
  top: 12%;
  left: 78%;
  animation-delay: -1.2s;
}
.s3 {
  top: 28%;
  left: 55%;
  animation-delay: -2s;
  transform: scale(0.7);
}
.s4 {
  top: 34%;
  left: 8%;
  animation-delay: -0.8s;
  transform: scale(0.6);
}
.s5 {
  top: 18%;
  left: 42%;
  animation-delay: -1.6s;
  transform: scale(0.9);
}
@keyframes twinkle {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.hill {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -40px;
  height: 220px;
  background: radial-gradient(50% 100% at 50% 100%, #a8e08a 0%, #7fd66a 60%, transparent 61%);
  filter: drop-shadow(0 -4px 0 rgba(43, 30, 63, 0.1));
}

/* ---- トップバー ---- */
.topbar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  border: 3px solid var(--ink);
}
.score-pill .ico-star {
  width: 20px;
  height: 20px;
  fill: var(--yellow);
}
.icon-btn {
  margin-left: auto;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}
.icon-btn + .icon-btn {
  margin-left: 0;
}
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* ---- ステージ／画面 ---- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 72px 16px 16px;
  overflow-x: hidden;
}

.screen {
  width: min(720px, 100%);
  max-width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeUp 0.35s ease both;
}
.screen.show {
  display: flex;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- ホーム ---- */
.title {
  font-family: var(--font-display);
  text-align: center;
  line-height: 1;
  letter-spacing: 0.02em;
  filter: drop-shadow(0 3px 0 rgba(43, 30, 63, 0.15));
}
.title .t1 {
  display: block;
  font-size: clamp(2rem, 6vw, 3rem);
  color: var(--pink-600);
  -webkit-text-stroke: 2px #fff;
  text-shadow:
    2px 2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px -2px 0 var(--ink);
}
.title .t2 {
  display: block;
  font-size: clamp(3rem, 10vw, 5rem);
  color: var(--yellow);
  -webkit-text-stroke: 2px #fff;
  text-shadow:
    3px 3px 0 var(--ink),
    -3px 3px 0 var(--ink),
    3px -3px 0 var(--ink),
    -3px -3px 0 var(--ink);
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.tagline {
  font-family: var(--font-display);
  color: var(--ink);
  background: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
}

.hero-kirby {
  display: grid;
  place-items: center;
  /* 帽子（最大でパラソルが頭上約87%張り出す）が上の星ピルに被らないヘッドルーム */
  padding-top: 72px;
  margin: -48px 0 8px;
}

/* ---- カービィ（キャラ） ---- */
.kirby {
  --size: 96px;
  position: relative;
  width: var(--size);
  height: var(--size);
  background: radial-gradient(
    circle at 30% 30%,
    #ffd6e5 0%,
    var(--pink-300) 55%,
    var(--pink-400) 100%
  );
  border-radius: 50%;
  border: 4px solid var(--ink);
  box-shadow:
    inset -8px -10px 0 rgba(232, 58, 114, 0.25),
    var(--shadow-md);
  animation: idle 2.4s ease-in-out infinite;
}
.kirby.big {
  --size: 160px;
}
.kirby .face {
  position: absolute;
  inset: 0;
}
.eye {
  position: absolute;
  top: 34%;
  width: 12%;
  aspect-ratio: 1/2.4;
  background: linear-gradient(to bottom, #2b1e3f 0%, #2b1e3f 55%, #6b9dff 55%, #6b9dff 100%);
  border-radius: 999px;
  border: 2px solid #2b1e3f;
}
.eye::after {
  content: "";
  position: absolute;
  top: 6%;
  left: 20%;
  width: 55%;
  height: 25%;
  background: #fff;
  border-radius: 50%;
}
.eye.left {
  left: 30%;
}
.eye.right {
  right: 30%;
}

.cheek {
  position: absolute;
  top: 58%;
  width: 18%;
  height: 8%;
  background: var(--pink-500);
  border-radius: 999px;
  opacity: 0.75;
}
.cheek.left {
  left: 18%;
}
.cheek.right {
  right: 18%;
}

.mouth {
  position: absolute;
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  width: 14%;
  height: 10%;
  background: #831c3a;
  border-radius: 0 0 999px 999px;
  border: 2px solid var(--ink);
  border-top: 0;
}

.foot {
  position: absolute;
  bottom: -8%;
  width: 30%;
  height: 22%;
  background: var(--pink-600);
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.foot.left {
  left: 10%;
  transform: rotate(-14deg);
}
.foot.right {
  right: 10%;
  transform: rotate(14deg);
}

.hand {
  position: absolute;
  top: 50%;
  width: 26%;
  height: 26%;
  background: inherit;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--pink-300);
}
.hand.left {
  left: -12%;
  transform: rotate(-20deg);
}
.hand.right {
  right: -12%;
  transform: rotate(20deg);
}

@keyframes idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* ---- メニュー ---- */
.menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 460px;
  margin-top: 8px;
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  padding: 16px 8px;
  font-family: var(--font-display);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  transition: transform 0.12s;
}
.menu-btn:active {
  transform: translateY(4px);
  box-shadow: var(--shadow-sm);
}
.menu-btn .menu-emoji {
  font-size: 2.4rem;
  line-height: 1;
}
.menu-btn .menu-label {
  font-size: 1.15rem;
  text-align: center;
}
.menu-btn .menu-label small {
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-family: var(--font-body);
}
.go-kanji {
  background: linear-gradient(180deg, #fff, #ffe5ef);
}
.go-calc {
  background: linear-gradient(180deg, #fff, #e2f2ff);
}
.go-word {
  background: linear-gradient(180deg, #fff, #fff2c8);
}
.go-shape {
  background: linear-gradient(180deg, #fff, #e6ffe0);
}

.link-btn {
  margin-top: 8px;
  font-family: var(--font-display);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
}

/* ---- ゲーム画面 ---- */
.hpbar {
  width: 100%;
  max-width: 640px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  font-family: var(--font-display);
  color: var(--ink);
  padding: 0 4px;
}
.hp-label {
  background: var(--ink);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}
.hp-track {
  height: 18px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.hp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green) 0%, var(--yellow) 60%, var(--pink-500) 100%);
  transition: width 0.4s cubic-bezier(0.4, 1.4, 0.5, 1);
}
.hp-count {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.9rem;
}

.battlefield {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: min(30dvh, 240px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 6%;
  margin-top: -8px;
  overflow: visible;
}
.battlefield::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 10px;
  height: 14px;
  background: rgba(43, 30, 63, 0.12);
  border-radius: 999px;
  filter: blur(3px);
}

.player {
  --size: 110px;
  animation: idle 2s ease-in-out infinite;
}

.enemy {
  --size: clamp(130px, 20vw, 180px);
  position: relative;
  width: var(--size);
  height: var(--size);
  animation: enemyIdle 2.6s ease-in-out infinite;
}
.enemy-body {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #6b5088 0%, #3d2a5f 100%);
  border: 4px solid var(--ink);
  border-radius: 24px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.enemy-face {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 1rem;
  filter: drop-shadow(0 2px 0 #000);
  opacity: 0.8;
}
.enemy-q {
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3vw, 1.6rem);
  text-shadow:
    2px 2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px -2px 0 var(--ink);
  padding: 6px;
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 90%;
  overflow: hidden;
}
.enemy-q.long {
  font-size: clamp(0.75rem, 2.4vw, 1.1rem);
}
/* 絵文字だけの問題（はじめてのかず）は数える対象なので大きく */
.enemy-q.emoji {
  font-size: clamp(1.3rem, 4.5vw, 1.9rem);
  line-height: 1.25;
  letter-spacing: 2px;
  text-shadow: none;
}
.enemy-shadow {
  position: absolute;
  bottom: -6px;
  left: 10%;
  right: 10%;
  height: 8px;
  background: rgba(43, 30, 63, 0.35);
  border-radius: 999px;
  filter: blur(3px);
}
@keyframes enemyIdle {
  0%,
  100% {
    transform: translateY(0) rotate(-1.5deg);
  }
  50% {
    transform: translateY(-4px) rotate(1.5deg);
  }
}

/* Kirby attack animation (吸い込み) */
.player.attack {
  animation:
    kirbyDash 0.35s ease forwards,
    kirbyReturn 0.35s 0.6s ease forwards;
}
@keyframes kirbyDash {
  to {
    transform: translateX(46vw) scale(1.15);
  }
}
@keyframes kirbyReturn {
  from {
    transform: translateX(46vw) scale(1.15);
  }
  to {
    transform: translateX(0) scale(1);
  }
}
.enemy.hit {
  animation: enemyHit 0.5s ease forwards;
}
@keyframes enemyHit {
  0% {
    transform: none;
  }
  30% {
    transform: translateX(-10px) rotate(-10deg);
  }
  60% {
    transform: translateX(10px) rotate(10deg);
  }
  100% {
    transform: translateY(20vh) rotate(180deg) scale(0.3);
    opacity: 0;
  }
}
.player.wrong {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-10px);
  }
  40% {
    transform: translateX(10px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}

/* ---- こたえ ---- */
.answers {
  width: 100%;
  max-width: 640px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 4px;
}
@media (min-width: 560px) {
  .answers {
    grid-template-columns: repeat(4, 1fr);
  }
}
.answer-btn {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 10px;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  transition:
    transform 0.1s,
    background 0.2s;
  min-height: 64px;
  word-break: keep-all;
  line-height: 1.25;
  text-align: center;
}
.answer-btn:active {
  transform: translateY(4px);
  box-shadow: var(--shadow-sm);
}
.answer-btn.correct {
  background: var(--green);
  color: #fff;
  animation: pop 0.5s ease;
}
.answer-btn.wrong {
  background: var(--red);
  color: #fff;
  animation: shake 0.4s ease;
}
.answer-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

.hint {
  font-family: var(--font-display);
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---- クリア画面 ---- */
#clear {
  text-align: center;
}
.clear-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.4rem);
  color: var(--yellow);
  -webkit-text-stroke: 2px #fff;
  text-shadow:
    3px 3px 0 var(--ink),
    -3px 3px 0 var(--ink),
    3px -3px 0 var(--ink),
    -3px -3px 0 var(--ink);
  animation: pop 0.7s ease;
}
.stars-earned {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.stars-earned span {
  width: 56px;
  height: 56px;
  background: var(--yellow);
  clip-path: polygon(
    50% 0,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  filter: drop-shadow(0 4px 0 var(--yellow-dark));
  animation: starPop 0.6s ease both;
}
.stars-earned span:nth-child(2) {
  animation-delay: 0.15s;
}
.stars-earned span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes starPop {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-90deg);
  }
  to {
    /* opacityはここに書かない：獲得星は1へ・未獲得星はinlineの0.2へ着地させる */
    transform: none;
  }
}
.clear-msg {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink);
  background: #fff;
  padding: 8px 20px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.clear-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.big-btn {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px 22px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  box-shadow: var(--shadow-md);
  transition: transform 0.1s;
}
.big-btn:active {
  transform: translateY(4px);
  box-shadow: var(--shadow-sm);
}
.big-btn.primary {
  background: var(--yellow);
}
.big-btn.ghost {
  background: transparent;
}

/* ---- おうちのかた ---- */
.parent-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink);
}
.parent-intro {
  color: var(--ink-soft);
  text-align: center;
  max-width: 560px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.parent-label {
  width: 100%;
  max-width: 640px;
  font-family: var(--font-display);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.parent-help {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: normal;
}
.parent-help code {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}
#customJson {
  width: 100%;
  max-width: 640px;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.9rem;
  color: var(--ink);
  min-height: 220px;
  box-shadow: var(--shadow-sm);
  resize: vertical;
}
.parent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.parent-tips {
  width: 100%;
  max-width: 640px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--ink);
}
.parent-tips summary {
  cursor: pointer;
  font-family: var(--font-display);
}
.parent-tips ul {
  margin-top: 8px;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ---- 効果レイヤー ---- */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}
.fx-star {
  position: absolute;
  width: 28px;
  height: 28px;
  background: var(--yellow);
  clip-path: polygon(
    50% 0,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  filter: drop-shadow(0 0 6px #fff);
  animation: flyStar 1s ease-out forwards;
}
@keyframes flyStar {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx, 0), var(--dy, -200px)) scale(0.3) rotate(360deg);
  }
}
.fx-toast {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  padding: 8px 24px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--pink-600);
  box-shadow: var(--shadow-lg);
  animation: toast 0.9s ease forwards;
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(1);
  }
}

.clear-burst {
  position: absolute;
  top: 20%;
  left: 50%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg, var(--yellow), var(--pink-300), var(--blue-300), var(--yellow));
  border-radius: 50%;
  opacity: 0.35;
  filter: blur(20px);
  animation: spin 6s linear infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ---- レスポンシブ ---- */
@media (max-width: 480px) {
  .menu {
    grid-template-columns: repeat(2, 1fr);
  }
  .menu-btn .menu-emoji {
    font-size: 1.8rem;
  }
  .menu-btn .menu-label {
    font-size: 1rem;
  }
  .battlefield {
    height: 24dvh;
    padding: 0 4%;
  }
  .kirby.big {
    --size: 130px;
  }
  .kirby.player {
    --size: 90px;
  }
  .hp-label {
    font-size: 0.75rem;
    padding: 3px 8px;
  }
  .hp-count {
    font-size: 0.75rem;
    padding: 2px 8px;
  }
  .answers {
    gap: 8px;
  }
  .answer-btn {
    min-height: 56px;
    padding: 10px 6px;
  }
  .stage {
    padding: 64px 8px 12px;
  }
  .topbar {
    padding: 8px 10px;
  }
}

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

/* =============================================
   進捗・パワーアップ（2026-07-17 追加）
   ============================================= */

/* ---- ホーム：あつめたほし ---- */
.total-stars {
  font-family: var(--font-display);
  background: linear-gradient(180deg, #fff, #fff3c4);
  color: var(--ink);
  padding: 4px 18px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  margin-top: -6px;
}
.total-stars strong {
  color: var(--yellow-dark);
  font-size: 1.15em;
}

/* ---- メニュー：さいこうきろく星バッジ ---- */
.menu-btn .menu-stars {
  display: block;
  min-height: 1.1em;
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--yellow-dark);
  font-family: var(--font-display);
  line-height: 1.1;
}

/* ---- メニュー：てつおスペシャル（5個目・横長） ---- */
.menu-btn.wide {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 14px;
  padding: 12px 8px;
}
.menu-btn.wide .menu-stars {
  display: inline-block;
}
.go-count {
  background: linear-gradient(180deg, #fff, #fff9d0);
}

/* ---- 読み上げボタン ---- */
.say-btn {
  font-family: var(--font-display);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 0.95rem;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}
.say-btn:active {
  transform: translateY(3px);
}

/* ---- 敵ブロック内のアナログ時計 ---- */
.enemy-clock {
  display: grid;
  place-items: center;
  padding-top: 8px;
}
.enemy-clock .clock-svg {
  width: clamp(84px, 16vw, 106px);
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 0 rgba(43, 30, 63, 0.25));
}
.enemy-clock[hidden] {
  display: none;
}

/* ---- コンボ（3れんぞく〜）：カービィがかがやく ----
   注意: ここでanimationを使うと .player.attack のダッシュを上書きして
   吸い込みモーションが消える（詳細度が同じでfeverが後勝ち）。静的filterのみにすること */
.kirby.fever {
  filter: drop-shadow(0 0 8px var(--yellow)) drop-shadow(0 0 18px var(--pink-300));
}

/* ---- クリア画面：しんきろく＆マイルストーン ---- */
.record-badge {
  font-family: var(--font-display);
  background: var(--yellow);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 20px;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  animation: pop 0.6s ease both;
}
.milestone {
  font-family: var(--font-display);
  background: linear-gradient(90deg, #ffe5ef, #fff3c4, #e6ffe0);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 20px;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  animation: pop 0.8s ease both;
}

/* =============================================
   すいこみコレクション（2026-07-17 追加）
   ============================================= */

/* ---- キラキラもんだい（金色の敵） ---- */
.enemy.lucky .enemy-body {
  background: linear-gradient(180deg, #f7ce46 0%, #c98f0a 100%);
  box-shadow:
    0 0 16px rgba(255, 217, 82, 0.85),
    var(--shadow-md);
}
.enemy.lucky .enemy-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.5) 50%, transparent 70%);
  animation: shimmer 1.6s linear infinite;
  pointer-events: none;
}
@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}
.enemy.lucky::before {
  content: "✨";
  position: absolute;
  top: -16px;
  right: -8px;
  font-size: 1.5rem;
  z-index: 2;
  /* 注意: 名前をtwinkleにすると既存の背景の星のkeyframesを上書きして壊す */
  animation: luckyTwinkle 0.9s ease-in-out infinite alternate;
}
@keyframes luckyTwinkle {
  from {
    opacity: 0.5;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ---- ぼうし（きせかえ）共通 ----
   .hatは位置箱。::before=本体シェイプ / ::after=アクセント。
   clip-pathは::before側に置く（親に置くと::afterまで切れる） */
.kirby .hat {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 2px 0 rgba(43, 30, 63, 0.4));
}

/* ソードぼうし（緑のとんがり＋白ブリム） */
.kirby.hat-sword .hat {
  display: block;
  top: -36%;
  width: 58%;
  height: 48%;
}
.kirby.hat-sword .hat::before {
  content: "";
  position: absolute;
  inset: 0 6% 16% 6%;
  background: linear-gradient(180deg, #6fd06f, #2f8f3f);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.kirby.hat-sword .hat::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2%;
  height: 18%;
  background: #fffaf6;
  border: 2px solid var(--ink);
  border-radius: 999px;
}

/* ビームぼうし（赤黄しましま＋玉） */
.kirby.hat-beam .hat {
  display: block;
  top: -38%;
  width: 56%;
  height: 50%;
}
.kirby.hat-beam .hat::before {
  content: "";
  position: absolute;
  inset: 10% 6% 0 6%;
  background: repeating-linear-gradient(90deg, #ff5757 0 20%, #ffd952 20% 40%);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.kirby.hat-beam .hat::after {
  content: "";
  position: absolute;
  top: -4%;
  left: 40%;
  width: 20%;
  aspect-ratio: 1;
  background: #ffd952;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

/* うたごえベレー（青ベレー＋おんぷ） */
.kirby.hat-mike .hat {
  display: block;
  top: -22%;
  width: 62%;
  height: 38%;
}
.kirby.hat-mike .hat::before {
  content: "";
  position: absolute;
  inset: 12% 4% 8% 4%;
  background: linear-gradient(180deg, #7fbfff, #4c9dff);
  border: 2px solid var(--ink);
  border-radius: 50% 50% 46% 46%;
  transform: rotate(-7deg);
}
.kirby.hat-mike .hat::after {
  content: "♪";
  position: absolute;
  top: 4%;
  right: 8%;
  font-size: 0.9rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 var(--ink);
}

/* ストーンかぶと（岩ヘルメット） */
.kirby.hat-stone .hat {
  display: block;
  top: -26%;
  width: 66%;
  height: 42%;
}
.kirby.hat-stone .hat::before {
  content: "";
  position: absolute;
  inset: 6%;
  background:
    radial-gradient(circle at 28% 30%, rgba(255, 255, 255, 0.25) 0 12%, transparent 13%),
    radial-gradient(circle at 68% 55%, rgba(43, 30, 63, 0.25) 0 10%, transparent 11%),
    linear-gradient(180deg, #b08968, #7a5a3d);
  border: 2px solid var(--ink);
  border-radius: 50% 50% 14% 14%;
}
.kirby.hat-stone .hat::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: 0;
  height: 14%;
  background: #5e4530;
  border: 2px solid var(--ink);
  border-radius: 999px;
}

/* パラソルぼうし（頭上のかさ） */
.kirby.hat-parasol .hat {
  display: block;
  top: -60%;
  width: 84%;
  height: 62%;
}
.kirby.hat-parasol .hat::before {
  content: "";
  position: absolute;
  inset: 0 0 48% 0;
  background: repeating-linear-gradient(90deg, #ff7ba7 0 25%, #fffaf6 25% 50%);
  border: 2px solid var(--ink);
  border-radius: 50% 50% 8% 8% / 96% 96% 8% 8%;
}
.kirby.hat-parasol .hat::after {
  content: "";
  position: absolute;
  top: 48%;
  bottom: 4%;
  left: 47.5%;
  width: 5%;
  background: #7a5a3d;
  border-radius: 999px;
}

/* スターのかんむり（金の星） */
.kirby.hat-star .hat {
  display: block;
  top: -40%;
  width: 44%;
  height: 46%;
}
.kirby.hat-star .hat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffe27a, #f0b800);
  clip-path: polygon(
    50% 0,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}
.kirby.hat-star .hat {
  filter: drop-shadow(0 0 6px #ffd952) drop-shadow(0 2px 0 rgba(43, 30, 63, 0.4));
}

/* ---- ホームのずかんボタン ---- */
.zukan-btn {
  font-family: var(--font-display);
  background: linear-gradient(180deg, #fff, #f0e6ff);
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 10px 34px;
  font-size: 1.05rem;
  color: var(--ink);
  box-shadow: var(--shadow-md);
  transition: transform 0.1s;
  margin-top: 2px;
}
.zukan-btn:active {
  transform: translateY(4px);
  box-shadow: var(--shadow-sm);
}

/* ---- ずかん画面 ---- */
.zukan-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink);
}
.zukan-count {
  font-family: var(--font-display);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 18px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.zukan-sub {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
  margin-top: 6px;
}
.zukan-sub small {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-left: 6px;
}
.zukan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 520px;
}
.zukan-grid.eggs {
  grid-template-columns: repeat(4, 1fr);
}
.zukan-cell {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 104px;
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display);
  color: var(--ink);
  transition: transform 0.1s;
}
button.zukan-cell:active {
  transform: translateY(3px);
}
.zukan-cell.locked {
  background: rgba(255, 255, 255, 0.55);
  border-style: dashed;
  color: var(--ink-soft);
  box-shadow: none;
}
.zukan-cell.equipped {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}
.zukan-cell .kirby.mini {
  margin-top: 20px;
}
.kirby.mini {
  --size: 52px;
}
/* ミニサイズでは固定値の飾りが破綻するので縮小・簡略化 */
.kirby.mini .hat {
  filter: none;
}
.kirby.mini.hat-sword .hat::after,
.kirby.mini.hat-beam .hat::after,
.kirby.mini.hat-stone .hat::before,
.kirby.mini.hat-stone .hat::after,
.kirby.mini.hat-mike .hat::before,
.kirby.mini.hat-parasol .hat::before {
  border-width: 1px;
}
.kirby.mini.hat-mike .hat::after {
  font-size: 0.55rem;
}
.kirby.mini.hat-parasol .hat {
  top: -46%;
  height: 52%;
}
.cell-q {
  font-size: 1.7rem;
  opacity: 0.55;
}
.cell-name {
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: center;
}
.cell-emoji {
  font-size: 2rem;
  line-height: 1;
}
.cell-badge {
  font-size: 0.6rem;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
}
.cell-badge.grow {
  background: var(--green);
  color: #fff;
}
.egg-cell.shiny {
  background: linear-gradient(135deg, #fff 0%, #fff3c4 55%, #ffe5ef 100%);
}
.egg-cell.shiny .cell-emoji {
  filter: drop-shadow(0 0 6px #ffd952);
}

/* ---- クリア画面：キラキラバッジ・たまご・ぼうし ---- */
.lucky-badge {
  font-family: var(--font-display);
  background: linear-gradient(90deg, #ffe27a, #f7ce46);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 20px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  animation: pop 0.6s ease both;
}
.egg-reveal[hidden] {
  /* display指定持ちの要素はhidden属性が効かない（.enemy-clockと同じ罠）ため明示 */
  display: none;
}
.egg-reveal {
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
}
.egg-shell {
  font-size: 2.8rem;
  display: inline-block;
  animation: eggWiggle 0.45s ease-in-out infinite;
}
@keyframes eggWiggle {
  0%,
  100% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(10deg);
  }
}
.egg-born {
  font-size: 3rem;
  line-height: 1;
  display: inline-block;
  animation: pop 0.5s ease both;
}
.egg-born.shiny {
  filter: drop-shadow(0 0 10px #ffd952);
}
.egg-label {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 16px;
  font-size: 0.9rem;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.hat-reveal {
  background: linear-gradient(180deg, #c9a0ff, var(--purple));
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 1rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: pop 0.6s ease both;
  text-shadow: 1px 1px 0 var(--ink);
}
