:root {
  --bg: #0b0a24;
  --ink: #3a2410;
  --paper: #f6e2bf;
  --cardboard: #d9a466;
  --cardboard-dark: #b57d42;
  --star: #ffd23f;
  --sky: #4fb3ff;
  --pink: #ff6fa8;
  --white: #fffaf0;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }
/* 場所は のこして 見えなくする（ならびが ずれないように） */
.invisible { visibility: hidden !important; pointer-events: none !important; }

button {
  font-family: inherit;
  font-weight: 900;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------------------------------------------------------------- HUD */

#hud { position: fixed; inset: 0; pointer-events: none; }

.topbar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 10px;
}

.stars {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 92px;
  padding: 4px 14px 4px 8px;
  border-radius: 999px;
  background: rgba(20, 14, 50, 0.6);
  border: 3px solid rgba(255, 255, 255, 0.25);
  font-size: 26px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stars.bump { animation: bump 0.25s ease-out; }
/* れんぞく（ぶつからずに ほしを とりつづけると ほしが 2 ばい・3 ばい） */
.stars { position: relative; }
.combo {
  /* ほしの かずの となりに ならべる（したに だすと ゾーンの ふだに、うえに だすと かずに かさなる） */
  position: relative;
  z-index: 2;
  margin-left: 4px;
  display: none;
  min-width: 34px;
  padding: 1px 7px 2px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: linear-gradient(#ffb04a, #ff6a2c);
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  box-shadow: 0 0 10px rgba(255, 150, 60, 0.8);
}
.combo.on { display: block; animation: popin 0.45s cubic-bezier(.2, 1.8, .4, 1), combopulse 1.2s 0.45s ease-in-out infinite; }
.combo.x3 { background: linear-gradient(90deg, #ff6b6b, #ffd23f, #7ed957, #4fc3f7, #b48cff); box-shadow: 0 0 14px rgba(255, 230, 120, 0.95); }
.combo.broke { display: block; animation: combobreak 0.7s ease-in forwards; }
@keyframes combopulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes combobreak { 0% { transform: none; opacity: 1; } 25% { transform: translateX(-5px) rotate(-10deg); } 50% { transform: translateX(5px) rotate(10deg); } 100% { transform: translateY(16px) rotate(20deg); opacity: 0; } }
/* とった 星が 上の 星の 数へ とんでいく */
.fly-star {
  position: fixed;
  left: -13px;
  top: -13px;
  width: 26px;
  height: 26px;
  z-index: 6;
  pointer-events: none;
  display: none;
  will-change: transform;
}
.fly-star svg { width: 100%; height: 100%; fill: #ffd23f; stroke: #3a2410; stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(255, 220, 90, 0.9)); }
.icon-star { width: 30px; height: 30px; fill: var(--star); stroke: #a86b00; stroke-width: 1.4; stroke-linejoin: round; }

.progress { position: relative; flex: 1; height: 34px; display: flex; align-items: center; padding-left: 20px; }
.progress .track {
  width: 100%;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, #7fdcff, var(--pink)); border-radius: 99px; }
#progressRocket { position: absolute; left: 0; top: 3px; width: 40px; height: 26px; transform: translateX(-50%); }
#progressRocket svg { width: 100%; height: 100%; }
.progress .flag { position: absolute; right: -6px; top: 0; font-size: 22px; }

#pauseBtn { margin-left: 16px; }
.nb { white-space: nowrap; }
.rw-paint.bump { animation: bump 0.4s ease-out; }
.round-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: rgba(20, 14, 50, 0.6);
  border: 3px solid rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  padding: 0;
}
.round-btn svg { width: 26px; height: 26px; fill: var(--white); stroke: var(--white); }
.round-btn .mute { display: none; }
.round-btn.muted .wave { display: none; }
.round-btn.muted .mute { display: inline; }
.round-btn:active { transform: scale(0.92); }

#formBtn {
  pointer-events: auto;
  /* こすり押しでも ブラウザに とりけされないように（なぞりは じぶんで 引きつぐ） */
  touch-action: none;
  position: absolute;
  right: calc(18px + var(--safe-right));
  bottom: calc(22px + var(--safe-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6dc, var(--cardboard) 70%);
  border: 5px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink), 0 0 24px rgba(127, 220, 255, 0.55);
  display: grid;
  place-items: center;
  padding: 10px 0 0;
  transition: transform 0.1s;
}
#formBtn:active, #formBtn.pressed { transform: translateY(4px) scale(0.96); box-shadow: 0 2px 0 var(--ink); }
#specialBtn.pressed { transform: translateY(3px) scale(0.95); }
#formBtn svg { width: 74px; height: 46px; margin-top: -6px; }
#formBtn .label {
  position: absolute;
  bottom: 12px;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.05em;
}
#formBtn .to-rocket { display: none; }
#formBtn.is-dolphin .to-rocket { display: block; }
#formBtn.is-dolphin .to-dolphin { display: none; }
#formBtn .ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 5px solid #7fdcff;
  opacity: 0;
}
#formBtn.hint .ring { animation: ring 1s ease-out infinite; }
#formBtn.hint { animation: wiggle 1s ease-in-out infinite; }
#formBtn.pop { animation: popin 0.6s cubic-bezier(.2, 1.6, .4, 1); }
/* つぎの ゲートが ちがう 形のとき「いまだ！」 */
#formBtn .now-tip {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  translate: -50% 0;
  padding: 3px 12px 4px;
  border-radius: 16px;
  background: #fffdf6;
  border: 4px solid var(--ink);
  color: #e0457b;
  font-size: 21px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  display: none;
}
#formBtn .now-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 9px solid transparent;
  border-top-color: var(--ink);
}
#formBtn.now .now-tip { display: block; animation: nowtip 0.5s ease-in-out infinite alternate; }
#formBtn.now { animation: wiggle 0.8s ease-in-out infinite; }
#formBtn.now .ring { animation: ring 0.8s ease-out infinite; border-color: #ff8fc0; }
@keyframes nowtip { from { transform: translateY(0) scale(1); } to { transform: translateY(-6px) scale(1.08); } }
#formBtn.cool { filter: saturate(0.4) brightness(0.8); }

/* ---------------------------------------------------------------- アタック・ひっさつ */

#attackBtn, #specialBtn {
  pointer-events: auto;
  position: absolute;
  border-radius: 50%;
  border: 5px solid var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: none;
}
#attackBtn {
  left: calc(18px + var(--safe-left));
  bottom: calc(22px + var(--safe-bottom));
  width: 112px;
  height: 112px;
  background: radial-gradient(circle at 35% 30%, #fff1d6, #ffb36b 70%);
  box-shadow: 0 6px 0 var(--ink), 0 0 20px rgba(255, 170, 80, 0.45);
}
#attackBtn .icon { width: 58px; height: 58px; margin-top: -12px; transition: transform 0.1s; }
/* すがたの わざ（たたかう ゾーンの そと）：イルカは ジャンプ・ロケットは ダッシュ */
#attackBtn .icon-jump, #attackBtn .icon-dash { display: none; }
#attackBtn.verb .icon-shot { display: none; }
#attackBtn.verb.jump .icon-jump, #attackBtn.verb.dash .icon-dash { display: block; }
#attackBtn.verb.jump { background: radial-gradient(circle at 50% 35%, #e6fbff, #7fd8ff 70%); }
#attackBtn.verb.dash { background: radial-gradient(circle at 50% 35%, #fff4d8, #ffb35a 70%); }
#attackBtn.verb.cool { filter: saturate(0.4) brightness(0.85); }
#attackBtn.verb.speed { background: radial-gradient(circle at 50% 35%, #f4ffd8, #b8f060 70%); }
#attackBtn.charging .icon { transform: scale(1.15) rotate(20deg); }
#attackBtn.full .icon { animation: spin 0.6s linear infinite; }
#attackBtn.full { box-shadow: 0 6px 0 var(--ink), 0 0 34px rgba(255, 230, 100, 0.95); }
#attackBtn:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--ink); }
#attackBtn .label, #specialBtn .label {
  position: absolute;
  bottom: 12px;
  font-size: 15px;
  color: var(--ink);
}
#attackBtn .ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 5px solid #ffd27a;
  opacity: 0;
}
#attackBtn.hint .ring { animation: ring 1s ease-out infinite; }
#attackBtn.hint { animation: wiggle 1s ease-in-out infinite; }
/* はじめての ときの おてほん：ゆびが ながおしして わが たまり、はなすと ぱっ */
#attackBtn .press-demo { display: none; position: absolute; left: 50%; top: 42%; width: 56px; height: 56px; pointer-events: none; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }
#attackBtn .press-demo svg { width: 100%; height: 100%; }
#attackBtn.demo { animation: none; }
#attackBtn.demo .press-demo { display: block; animation: pressdemo 2.4s ease-in-out infinite; }
#attackBtn.demo .gauge-fill.charge { animation: demofill 2.4s linear infinite; }
#attackBtn.demo .ring { animation: demoring 2.4s ease-out infinite; }
#attackBtn.demo.tap .press-demo { animation: tapdemo 1.2s ease-in-out infinite; }
#attackBtn.demo.tap .gauge-fill.charge, #attackBtn.demo.tap .ring { animation: none; }
@keyframes pressdemo {
  0% { transform: translate(14px, 22px) scale(1); opacity: 0; }
  10% { transform: translate(0, 4px) scale(1); opacity: 1; }
  18%, 66% { transform: translate(0, 10px) scale(0.86); opacity: 1; }
  78% { transform: translate(8px, -6px) scale(1); opacity: 1; }
  100% { transform: translate(14px, 22px) scale(1); opacity: 0; }
}
@keyframes tapdemo {
  0% { transform: translate(10px, 18px); opacity: 0; }
  25% { transform: translate(0, 4px); opacity: 1; }
  40% { transform: translate(0, 10px) scale(0.86); }
  55% { transform: translate(0, 2px) scale(1); }
  100% { transform: translate(10px, 18px); opacity: 0; }
}
@keyframes demofill { 0%, 18% { stroke-dashoffset: 276.5; } 66% { stroke-dashoffset: 0; } 72%, 100% { stroke-dashoffset: 276.5; } }
@keyframes demoring { 0%, 68% { transform: scale(0.9); opacity: 0; } 70% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
#attackBtn.pop, #specialBtn.pop { animation: popin 0.6s cubic-bezier(.2, 1.6, .4, 1); }
.gauge { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.gauge circle { fill: none; stroke-width: 7; }
.gauge-bg { stroke: rgba(255, 255, 255, 0.25); }
.gauge-fill { stroke: #8fe3ff; stroke-linecap: round; transition: stroke-dashoffset 0.15s; }
.gauge-fill.charge { stroke: #ffe066; transition: none; }
/* ひっさつの ゲージは ふとく（たまっていくのが よく見えるように） */
#specialBtn .gauge { inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); }
#specialBtn .gauge circle { stroke-width: 11; }
#specialBtn .gauge-bg { stroke: rgba(20, 24, 60, 0.55); }
#specialBtn .gauge-fill { stroke: #5fd4ff; filter: drop-shadow(0 0 3px rgba(95, 212, 255, 0.9)); }

#specialBtn {
  left: calc(32px + var(--safe-left));
  bottom: calc(166px + var(--safe-bottom));
  width: 84px;
  height: 84px;
  /* たまるまでは くすんだ 色。ゲージだけは あざやかに */
  background: radial-gradient(circle at 35% 30%, #e6edf3, #93a8c0 75%);
  box-shadow: 0 5px 0 var(--ink);
}
#specialBtn:not(.ready) .icon { opacity: 0.6; }
#specialBtn .icon { width: 44px; height: 44px; margin-top: -12px; }
#specialBtn .label { font-size: 13px; bottom: 9px; }
#specialBtn.ready {
  filter: none;
  background: conic-gradient(from 0deg, #ff6b6b, #ffd23f, #7ed957, #4fc3f7, #b48cff, #ff6b6b);
  animation: wiggle 0.9s ease-in-out infinite, glowpulse 0.9s ease-in-out infinite;
}
#specialBtn.ready .label { color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }

/* ---------------------------------------------------------------- ボス・スロット */

.boss-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}
.boss-name {
  font-size: 13px;
  color: #ffb3d6;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.boss-hp {
  position: relative;
  height: 14px;
  border-radius: 99px;
  background: rgba(20, 8, 31, 0.8);
  border: 3px solid #14081f;
  overflow: hidden;
}
#bossHpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #b04fff, #ff4fa8); transition: width 0.5s cubic-bezier(.2, 1.4, .4, 1); }
#bossHpTicks span { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(20, 8, 31, 0.8); }
.boss-bar.hit { animation: bump 0.3s ease-out; }
.boss-bar.pop { animation: popin 0.5s cubic-bezier(.2, 1.6, .4, 1); }

.subbar {
  position: absolute;
  top: calc(62px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
/* ずかんの おしらせ（左上に すべりこむ） */
/* 右上の「ひみつ」の マスや チャレンジの バーと かさならないように、その 下に 出す */
.ztoast { position: absolute; top: calc(104px + var(--safe-top)); left: calc(10px + var(--safe-left)); display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; background: rgba(26, 20, 66, 0.86); border: 3px solid #8fe3ff; border-radius: 14px; color: var(--white); max-width: calc(100vw - 20px); }
.ztoast svg { width: 62px; height: auto; border-radius: 8px; flex: 0 0 auto; }
.zt-name { font-size: 17px; line-height: 1.2; }
.zt-line { font-size: 14px; line-height: 1.25; color: #ffe27a; }
.zt-new { display: inline-block; background: #e53935; color: #fff; font-size: 11px; border-radius: 999px; padding: 0 6px; margin-right: 6px; vertical-align: 2px; }
.ztoast.in { animation: ztin 0.4s cubic-bezier(.2, 1.4, .4, 1); }
.ztoast.out { animation: ztout 0.4s ease-in forwards; }
@keyframes ztin { from { transform: translateX(-120%); } to { transform: none; } }
@keyframes ztout { to { transform: translateX(-120%); opacity: 0; } }
/* 惑星が 左に あるときは 右に 出す（惑星を かくさないように）。ひみつの ほしの マスの 下 */
.ztoast.right { left: auto; right: calc(10px + var(--safe-right)); top: calc(104px + var(--safe-top)); }
.ztoast.right.in { animation-name: ztinR; }
.ztoast.right.out { animation-name: ztoutR; }
@keyframes ztinR { from { transform: translateX(120%); } to { transform: none; } }
@keyframes ztoutR { to { transform: translateX(120%); opacity: 0; } }
/* おしらせが 出ている あいだは 上の 文字を 下げて かさならないように */
#message.with-toast { translate: 0 72px; }
/* せいざの えの あいだは「★ 2 / 3」の したに */
#message.under-count { top: calc(env(safe-area-inset-top, 0px) + 150px); }
/* うえから みる ところの チャレンジ */
.challenge {
  position: absolute;
  top: calc(60px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: rgba(26, 20, 66, 0.86);
  border: 3px solid #ffd23f;
  color: var(--white);
  font-size: 15px;
  white-space: nowrap;
  animation: popin 0.4s cubic-bezier(.2, 1.6, .4, 1);
}
.challenge .ch-label { color: #ffd23f; font-size: 13px; }
.challenge .ch-count { font-variant-numeric: tabular-nums; }
.challenge .ch-count b { font-size: 21px; color: #ffe680; }
.challenge .ch-bar { width: 62px; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.challenge .ch-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff6b6b, #ffd23f); transform-origin: left; }
.challenge.win { border-color: #7ed957; }
.challenge.win .ch-count b { color: #b9f6ca; }
.hearts { display: flex; gap: 2px; padding: 3px 8px; border-radius: 999px; background: rgba(20, 14, 50, 0.5); margin-right: 6px; }
.hearts svg { width: 26px; height: 26px; fill: #ff5a7a; stroke: #5a0f22; stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(0 0 3px rgba(255, 90, 122, 0.7)); }
.hearts svg.off { fill: rgba(255, 255, 255, 0.12); stroke: rgba(255, 255, 255, 0.45); filter: none; }
.hearts svg.lost { animation: heartlost 0.7s ease-out; }
.hearts svg.gain { animation: popin 0.45s cubic-bezier(.2, 1.8, .4, 1); }
.hearts.last svg:not(.off) { animation: heartbeat 0.8s ease-in-out infinite; }
@keyframes heartlost { 0% { transform: scale(1.5); fill: #fff; } 40% { transform: scale(0.7) rotate(-15deg); } 100% { transform: none; } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.22); } }
.zone-chip { display: flex; align-items: center; gap: 4px; padding: 3px 10px 3px 6px; border-radius: 999px; font-size: 15px; font-weight: 900; color: #fff; border: 2px solid rgba(255, 255, 255, 0.6); margin-right: auto; -webkit-text-stroke: 3px #1a1442; paint-order: stroke fill; }
.zone-chip svg { width: 22px; height: 22px; }
.zone-chip.collect { background: rgba(40, 120, 200, 0.75); }
.zone-chip.attack { background: rgba(200, 70, 60, 0.8); }
.zone-chip.ring { background: rgba(110, 160, 40, 0.8); }
.zone-chip.rescue { background: rgba(60, 140, 220, 0.85); }
.zone-chip.pop { animation: popin 0.45s cubic-bezier(.2, 1.8, .4, 1); }
#gameover { background: rgba(40, 6, 24, 0.6); }
#gameover .go-text { font-size: 22px; margin: 4px 0 14px; }
.const-slots, .secret-slots { display: flex; gap: 4px; padding: 3px 8px; border-radius: 999px; background: rgba(20, 14, 50, 0.5); }
.const-slots .slot svg, .secret-slots .slot svg { width: 22px; height: 22px; fill: rgba(255, 255, 255, 0.18); stroke: rgba(255, 255, 255, 0.45); stroke-width: 1.4; }
.const-slots .slot.on svg { fill: #bff3ff; stroke: #4fb3ff; filter: drop-shadow(0 0 4px #7fdcff); }
.const-slots.many { gap: 1px; padding: 3px 6px; }
.const-slots.many .slot svg { width: 15px; height: 15px; }
.subbar.tracing .zone-chip { display: none; }
.secret-slots { margin-left: auto; align-items: center; border: 2px solid rgba(255, 138, 216, 0.55); }
.slot-label { font-size: 11px; color: #ffc4ea; margin-right: 2px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.secret-slots .slot.on svg { fill: url(#none); fill: #ff8ad8; stroke: #fff; filter: drop-shadow(0 0 4px #ff8ad8); }
.slot { display: inline-grid; }
.slot.pop { animation: popin 0.6s cubic-bezier(.2, 1.8, .4, 1); }

/* ---------------------------------------------------------------- てびき */

.finger-ring {
  position: fixed;
  left: -28px;
  top: -28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 12px rgba(127, 220, 255, 0.8), inset 0 0 10px rgba(127, 220, 255, 0.6);
  pointer-events: none;
}
.hand-hint {
  position: fixed;
  left: 50%;
  top: 62%;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  pointer-events: none;
  animation: swipe 1.6s ease-in-out infinite;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}
.hand-hint svg { width: 100%; height: 100%; }
.tip-arrow {
  position: fixed;
  width: 40px;
  height: 40px;
  pointer-events: none;
  animation: bob 0.6s ease-in-out infinite alternate;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35));
}
.tip-arrow svg { width: 100%; height: 100%; }

.cutin {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.cutin-band {
  width: 120%;
  padding: 14px 0;
  transform: rotate(-6deg);
  background: linear-gradient(90deg, rgba(79, 179, 255, 0), rgba(79, 179, 255, 0.9) 20%, rgba(180, 140, 255, 0.9) 80%, rgba(180, 140, 255, 0));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
}
.cutin-pilot { width: clamp(76px, 22vw, 120px); height: auto; flex: none; filter: drop-shadow(0 4px 0 rgba(18, 58, 102, 0.6)); }
.cutin.play .cutin-pilot { animation: cutinbear 1.6s cubic-bezier(.2, 1.6, .4, 1) both; }
.cutin .cutin-rabbit, .cutin.rabbit .cutin-bear { display: none; }
.cutin.rabbit .cutin-rabbit { display: block; }
@keyframes cutinbear { 0% { transform: scale(0.2) rotate(-30deg); } 25% { transform: scale(1.1) rotate(6deg); } 35%, 100% { transform: scale(1) rotate(0); } }
.cutin-band span {
  display: inline-block;
  line-height: 1.1;
  font-size: clamp(30px, 9vw, 56px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 8px #123a66;
  paint-order: stroke fill;
}
.cutin.play .cutin-band { animation: cutin 1.6s cubic-bezier(.2, 1, .3, 1) forwards; }

/* ---------------------------------------------------------------- ぽんっと 出る 数字 */

.pop-num {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: 900;
  white-space: nowrap;
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  pointer-events: none;
  animation: popnum 0.9s cubic-bezier(.2, 1.4, .4, 1) forwards;
  z-index: 5;
}
@keyframes popnum {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20% { transform: translate(-50%, -80%) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -190%) scale(0.9); opacity: 0; }
}

/* メカの そばに 出る みじかい ことば */
.pop-say {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  white-space: pre;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
  pointer-events: none;
  animation: popsay 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards;
  z-index: 5;
}
/* ほめる ことば：ほしの マークつきの バッジ（よめなくても わかる） */
.pop-say.praise { padding-left: 1.25em; }
.pop-say.praise::before {
  content: '';
  position: absolute;
  left: -0.1em;
  top: 50%;
  width: 1.25em;
  height: 1.25em;
  transform: translateY(-50%) rotate(-12deg);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M24 2 L29.5 17 L45 17.5 L33 27 L37.5 43 L24 34 L10.5 43 L15 27 L3 17.5 L18.5 17 Z' fill='%23ffd23f' stroke='%232a1a50' stroke-width='3.5' stroke-linejoin='round'/%3E%3Cpath d='M17 18 L21 18' stroke='%23fff6c8' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 220, 90, 0.9));
  animation: praisestar 0.6s cubic-bezier(.2, 1.8, .4, 1);
}
@keyframes praisestar { 0% { transform: translateY(-50%) scale(0.2) rotate(-90deg); } 100% { transform: translateY(-50%) scale(1) rotate(-12deg); } }
/* かずの ばしょ（下の まんなか・ボタンの あいだ。上の 文字と かさならない。1 つ だけ） */
.counter-slot { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 128px); transform: translateX(-50%); z-index: 6; font-size: 26px; font-weight: 900; -webkit-text-stroke: 7px #2a1040; paint-order: stroke fill; white-space: nowrap; pointer-events: none; letter-spacing: 1px; }
.counter-slot.show { animation: counterpop 0.3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes counterpop { 0% { transform: translateX(-50%) scale(1.5); } 100% { transform: translateX(-50%) scale(1); } }
@media (max-height: 500px) and (orientation: landscape) {
  .counter-slot { bottom: calc(var(--safe-bottom) + 16px); font-size: 22px; }
}
@keyframes popsay {
  0% { transform: translate(-50%, -20%) scale(0.4); opacity: 0; }
  14% { transform: translate(-50%, -60%) scale(1.12); opacity: 1; }
  24% { transform: translate(-50%, -60%) scale(1); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(0.95); opacity: 0; }
}

/* ---------------------------------------------------------------- メッセージ */

/* 上の ボタンの すぐ下に 1 つだけ（前から くる いんせきを かくさないように） */
#message {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 100px);
  transition: translate 0.25s ease-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
  text-align: center;
}
.msg {
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-size: clamp(23px, 6.1vw, 38px);
  font-weight: 900;
  line-height: 1.25;
  color: var(--white);
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
  animation: msgin 0.45s cubic-bezier(.2, 1.5, .4, 1);
}
.msg.big { font-size: clamp(34px, 10vw, 64px); color: var(--star); }
.msg.blue { color: #8fe3ff; }
.msg.pink { color: #ffb3d6; }
.msg.small { font-size: clamp(18px, 4.6vw, 28px); -webkit-text-stroke-width: 6px; }
/* うえ視点・たて画面の よこ視点では 前（上）から ものが くるので、文字を 小さく */
#message.compact .msg { font-size: clamp(18px, 4.8vw, 26px); -webkit-text-stroke-width: 5px; }
#message.compact .msg.big { font-size: clamp(24px, 6.4vw, 34px); }
/* 前が 画面の 上の 視点では、よんだ ころに 文字を うすく して、うしろの てきや いわを 見せる */
#message.compact .msg:not(.out) { animation-name: msgin, msgdim; animation-duration: 0.45s, 0.5s; animation-delay: 0s, 3s; animation-timing-function: cubic-bezier(.2, 1.5, .4, 1), ease; animation-fill-mode: none, forwards; }
@keyframes msgdim { to { opacity: 0.7; } }
/* よこ画面（ひくい）では さらに 小さく */
@media (max-height: 430px) {
  #message.compact .msg { font-size: 17px; -webkit-text-stroke-width: 4px; }
  #message.compact .msg.big { font-size: 21px; }
}
/* 前が 画面の 上の 視点では、ずかんの おしらせを 小さく 1 ぎょうに（前を ふさがない） */
.ztoast.low { padding: 2px 10px 2px 4px; gap: 4px; }
.ztoast.low svg { width: 30px; }
.ztoast.low .zt-line { display: none; }
.ztoast.low .zt-name { font-size: 14px; }
.msg.out { position: absolute; left: 16px; right: 16px; top: 0; animation: msgout 0.22s ease-in forwards; }

#countdown {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(90px, 30vw, 180px);
  font-weight: 900;
  color: var(--star);
  -webkit-text-stroke: 12px var(--ink);
  paint-order: stroke fill;
}
#countdown .num { animation: count 0.9s ease-out forwards; }

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

/* ---------------------------------------------------------------- 画面 */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  text-align: center;
  overflow-y: auto;
  touch-action: pan-y;
}
.overlay > .panel { margin: auto 0; }

#title { background: radial-gradient(ellipse at 50% 110%, rgba(11, 10, 36, 0) 30%, rgba(11, 10, 36, 0.55) 100%); justify-content: space-between; }

.title-top, .title-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.logo { margin-top: 3vh; transform: rotate(-4deg); animation: float 3s ease-in-out infinite; }
.logo-small, .logo-big {
  font-weight: 900;
  -webkit-text-stroke: 9px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink);
  line-height: 1.05;
}
.logo-small {
  display: inline-block;
  font-size: clamp(26px, 8vw, 44px);
  color: var(--paper);
  background: var(--cardboard);
  padding: 2px 16px 6px;
  border: 4px solid var(--ink);
  border-radius: 6px;
  -webkit-text-stroke-width: 7px;
  transform: rotate(3deg);
  box-shadow: 0 5px 0 var(--ink);
}
.logo-big { font-size: clamp(50px, 16vw, 96px); color: var(--star); margin-top: 6px; }

.story {
  margin: 0;
  font-size: clamp(17px, 4.6vw, 24px);
  line-height: 1.5;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
}

.howto {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: clamp(14px, 3.8vw, 18px);
}
.howto > div { background: rgba(20, 14, 50, 0.6); padding: 6px 12px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.2); }
.pill { margin-right: 2px; }

.big-btn {
  font-size: clamp(26px, 7.5vw, 38px);
  color: var(--ink);
  background: linear-gradient(#ffe680, var(--star));
  padding: 14px 44px 16px;
  border-radius: 999px;
  border: 5px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink);
  transition: transform 0.08s;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
#startBtn { animation: pulse 1.4s ease-in-out infinite; }
.sub-btn {
  font-size: 20px;
  color: var(--white);
  background: transparent;
  padding: 10px 24px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.5);
}
.title-best {
  font-size: 18px;
  color: var(--star);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
}
.hint-small { margin: 0 0 2vh; font-size: 14px; opacity: 0.8; }

.panel {
  width: min(420px, 100%);
  background: var(--paper);
  color: var(--ink);
  border: 5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background-image:
    repeating-linear-gradient(90deg, rgba(150, 100, 50, 0.06) 0 6px, rgba(255, 255, 255, 0.05) 6px 12px);
  animation: popin 0.5s cubic-bezier(.2, 1.4, .4, 1);
}
.panel h2 { margin: 0; font-size: 30px; }
#fail { background: rgba(11, 10, 36, 0.9); }
#fail p { margin: 0; font-size: 18px; line-height: 1.6; }
#pause, #result { background: rgba(11, 10, 36, 0.55); justify-content: flex-start; }

.result-panel { gap: 8px; padding: 14px 14px 16px; }
.medal-row { display: flex; align-items: center; gap: 14px; }
.goal-title {
  margin: -2px 0 0;
  font-size: 42px !important;
  color: var(--star);
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}
.result-stars { display: flex; align-items: center; gap: 6px; font-size: 44px; }
.result-stars .icon-star { width: 46px; height: 46px; }
.result-stars .of { font-size: 22px; opacity: 0.7; }
.rank {
  font-size: 24px;
  color: #e53935;
  border: 4px solid #e53935;
  border-radius: 14px;
  padding: 0 14px 2px;
  transform: rotate(-6deg);
  animation: stamp 0.5s 0.6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.best { font-size: 16px; min-height: 1em; }
.best.new { color: #e53935; animation: wiggle 0.8s ease-in-out infinite; }

.zukan {
  position: relative;
  width: 100%;
  background: #1a1442;
  color: var(--white);
  border-radius: 16px;
  border: 4px solid var(--ink);
  padding: 8px 10px 8px;
}
.zukan-head {
  display: inline-block;
  font-size: 15px;
  color: var(--ink);
  background: var(--star);
  border-radius: 999px;
  padding: 2px 12px;
}
.card-hint { font-size: 13px; opacity: 0.8; margin-top: 2px; }
#zukanSvg { width: 100%; max-width: 280px; height: auto; display: block; margin: 4px auto 0; }
.zukan-name { font-size: 24px; color: #8fe3ff; }
.zukan-text { margin: 4px 0 0; font-size: 14px; line-height: 1.6; font-weight: 700; text-align: left; }

#debug {
  position: fixed;
  left: 6px;
  bottom: 6px;
  font: 12px/1.3 ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 6px;
  pointer-events: none;
  white-space: pre;
}

/* ---------------------------------------------------------------- タイトル：むずかしさ・ずかん */

.mode-select { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.mode-btn {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 10px 18px 12px 12px;
  border-radius: 22px;
  border: 5px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink);
  color: var(--ink);
  text-align: left;
  transition: transform 0.08s;
}
.mode-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.mode-btn svg { grid-row: 1 / 3; width: 46px; height: 46px; }
.mode-btn .mode-name { font-size: clamp(24px, 7vw, 32px); line-height: 1.1; }
.mode-btn .mode-sub { font-size: 12px; font-weight: 800; opacity: 0.85; }
.mode-btn.easy { background: linear-gradient(#d9ffc9, #8fe07a); }
.mode-btn { position: relative; }
/* じこベストを ボタンの かどに 小さく */
.mode-best { position: absolute; bottom: -17px; right: 10px; background: var(--ink); color: var(--star); font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.mode-btn.normal { background: linear-gradient(#ffe680, var(--star)); }
.mode-btn.hard { position: relative; background: linear-gradient(#ffb199, #ff7043); }
.mode-new { position: absolute; top: -10px; right: -8px; background: #e53935; color: #fff; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 2px solid var(--ink); transform: rotate(8deg); }
/* むずかしいが ふえたら 3 つを すこし 小さく */
.mode-select.three { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 8px; width: min(390px, calc(100vw - 16px)); }
.mode-select.three .mode-btn { padding: 6px 8px 8px 8px; column-gap: 5px; border-radius: 18px; }
.mode-select.three .mode-btn svg { width: 32px; height: 32px; }
.mode-select.three .mode-btn .mode-name { font-size: clamp(20px, 5.8vw, 26px); }
.mode-select.three .mode-btn .mode-sub { font-size: 11px; white-space: nowrap; }
.mode-select.three .mode-btn.hard { grid-column: 1 / -1; justify-self: center; padding: 6px 22px 8px 12px; }
#title .title-best { display: none; }
/* いろの えらびかた：ロケット・イルカの どちらで 見るか */
.paint-tabs { display: flex; gap: 8px; }
/* いろ と シールの きりかえ（大きな タブ） */
.paint-modes { display: flex; gap: 10px; }
.paint-mode { font: inherit; font-size: 22px; font-weight: 900; padding: 4px 22px 6px; border-radius: 14px; border: 4px solid var(--ink); background: #e9dcc0; color: var(--ink); opacity: 0.7; }
.paint-mode.on { background: #fff; opacity: 1; box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.paint-sw .dot.st { background: #fffaf0; display: grid; place-items: center; }
.rw-sticker svg { width: 26px; height: 26px; vertical-align: -7px; margin-right: 4px; }
.paint-sw .dot.st svg { width: 30px; height: 30px; }
.paint-tab { font: inherit; font-size: 16px; padding: 4px 16px; border-radius: 999px; border: 3px solid var(--ink); background: #fff; color: var(--ink); }
.paint-tab.on { background: var(--star); box-shadow: 0 3px 0 var(--ink); }
/* まえに えらんだ ほう（はじめての ひとは やさしい）を ぴかぴか */
.mode-btn.suggest { animation: pulse 1.4s ease-in-out infinite; }

/* だれが あそぶ？ */
.who { display: flex; align-items: center; gap: 8px; background: rgba(20, 14, 50, 0.55); border-radius: 999px; padding: 4px 8px 4px 14px; }
.who-label { font-size: 15px; color: var(--white); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.who-btn { font: inherit; display: flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px; border-radius: 999px; border: 3px solid transparent; background: rgba(255, 255, 255, 0.15); color: var(--white); opacity: 0.6; }
.who-btn svg { width: 38px; height: 38px; }
.who-btn.on { opacity: 1; background: #fff6dc; color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.who-stars { font-size: 14px; }
.title-sub { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.zukan-btn, .paint-btn, .sky-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(20, 14, 50, 0.6); position: relative; }
.zukan-btn svg, .paint-btn svg, .sky-btn svg { width: 24px; height: 24px; }
#title .sub-btn { font-size: 18px; padding: 8px 14px; }
#title .title-sub { gap: 8px; }
.sky-count { font-size: 13px; color: #9fe4ff; margin-left: -2px; }
.sky-count:empty { display: none; }
.badge { position: absolute; top: -10px; right: -8px; background: #e53935; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px; transform: rotate(8deg); border: 2px solid var(--ink); }

/* タイトルの おはなし 3 コマ */
.story-strip { display: flex; align-items: center; gap: 4px; margin-top: -4px; }
/* ステージを えらぶ カード（ステージ 1 を クリアしたら） */
.story-strip.pick { gap: 12px; pointer-events: auto; }
.stage-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 6px 4px; background: rgba(26, 20, 66, 0.82); border: 3px solid var(--ink); border-radius: 14px; color: var(--white); font: inherit; cursor: pointer; opacity: 0.72; transform: scale(0.94); transition: transform 0.15s, opacity 0.15s; touch-action: manipulation; }
.stage-card svg { width: min(100px, 26vw); height: auto; aspect-ratio: 200 / 120; border-radius: 9px; background: #1a1442; display: block; }
.stage-card .sc-name { font-size: clamp(12px, 3.6vw, 15px); font-weight: 900; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.stage-card .sc-num { position: absolute; left: -8px; top: -8px; width: 30px; height: 30px; border-radius: 50%; background: var(--star); color: var(--ink); border: 3px solid var(--ink); font-size: 17px; font-weight: 900; line-height: 24px; }
.stage-card .mode-new { top: -10px; right: -8px; }
.stage-card.on { opacity: 1; transform: scale(1); border-color: var(--star); box-shadow: 0 0 0 3px var(--ink), 0 0 16px rgba(255, 210, 63, 0.7); }
.stage-card.pressed { transform: scale(0.9); }
/* ステージを えらぶ ときは ひとことを かくして、カードを ロゴの すぐ 下に（メカに かからないように） */
#title.picking .story { display: none; }
/* コースの ちず（1-1 〜 2-3） */
.story-strip.course-map { flex-direction: column; align-items: stretch; gap: 6px; }
.cm-row { display: flex; align-items: center; gap: 5px; justify-content: center; }
.cm-world { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--star); color: var(--ink); border: 3px solid var(--ink); font-size: 15px; font-weight: 900; display: grid; place-items: center; }
.cm-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; flex: 0 1 70px; padding: 4px 4px 3px; background: rgba(26, 20, 66, 0.85); border: 3px solid var(--ink); border-radius: 12px; color: var(--white); font: inherit; cursor: pointer; touch-action: manipulation; transition: transform 0.15s; }
.cm-card .cm-num { font-size: 17px; font-weight: 900; color: var(--star); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; line-height: 1.1; }
.cm-caption { text-align: center; font-size: 17px; font-weight: 900; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; line-height: 1.25; }
.cm-caption b { color: var(--star); }
.cm-caption small { display: block; font-size: 13px; color: #cfe8ff; }
.cm-card .cm-medal i { font-style: normal; font-size: 12px; color: rgba(255, 255, 255, 0.25); }
.cm-card .cm-medal i.on { color: var(--star); text-shadow: 0 0 4px rgba(255, 210, 63, 0.8); }
.cm-card .cm-lock { width: 24px; height: 24px; }
.cm-card.locked { opacity: 1; cursor: default; background: rgba(20, 16, 44, 0.92); color: rgba(255, 255, 255, 0.45); }
.cm-card.locked .cm-num { color: #8a84b0; }
.cm-card.locked .cm-lock { opacity: 0.6; }
.cm-card.on { border-color: var(--star); box-shadow: 0 0 0 3px var(--ink), 0 0 14px rgba(255, 210, 63, 0.75); transform: scale(1.06); }
.cm-card.new::after { content: 'NEW'; position: absolute; bottom: -9px; right: -6px; background: #ff5a7a; color: #fff; font-size: 10px; font-weight: 900; padding: 1px 5px; border-radius: 8px; border: 2px solid var(--ink); }
.cm-card.pressed { transform: scale(0.92); }
body.leaving #title { opacity: 0; transition: opacity 0.18s; pointer-events: none; }
/* きょうの イベント（日に ちで かわる） */
.today-event { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 6px; align-items: center; font-size: 12px; font-weight: 800; line-height: 1.2; color: var(--ink); background: var(--ev, #ffd23f); border: 2.5px solid var(--ink); border-radius: 14px; padding: 2px 12px 3px; box-shadow: 0 2px 0 var(--ink); max-width: calc(100vw - 24px); }
.today-event b { font-size: 14px; }
.ss-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ss-cell svg { width: min(96px, 24vw); height: auto; aspect-ratio: 200 / 120; background: #1a1442; border: 3px solid var(--ink); border-radius: 10px; }
.ss-cell span { font-size: clamp(10px, 3.3vw, 13px); font-weight: 900; color: var(--white); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.ss-arrow { color: var(--star); font-size: 16px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; margin-bottom: 14px; }

/* はじめての オープニングの おはなしカード */
.story-card {
  position: fixed;
  /* まんなかに おく（transform は 出てくる アニメに つかうので つかわない） */
  left: 0;
  right: 0;
  margin: 0 auto;
  top: 24%;
  width: min(340px, 86vw);
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 10px 12px 12px;
  text-align: center;
  pointer-events: none;
  animation: popin 0.5s cubic-bezier(.2, 1.6, .4, 1);
  z-index: 6;
}
.story-card.out { animation: msgout 0.3s ease-in forwards; }
.sc-pic svg { width: 100%; height: auto; background: #1a1442; border: 3px solid var(--ink); border-radius: 12px; }
.sc-text { margin: 8px 0 0; font-size: 19px; font-weight: 900; line-height: 1.4; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
/* エンディングの カードは 下に 小さく（夜空の こぐまざと いるかざが 見えるように） */
.story-card.end { top: auto; bottom: calc(14px + var(--safe-bottom)); width: min(300px, 78vw); padding: 8px 10px 10px; }
.story-card.end .sc-text { font-size: 17px; }
@media (orientation: landscape) {
  .story-card.end { left: auto; right: calc(12px + var(--safe-right)); margin: 0; width: min(270px, 36vw); }
  .story-card.end .sc-pic svg { max-height: 30vh; }
}
/* タッチで つぎの カードへ（すこし たってから そっと 出る） */
.sc-next { display: none; margin-top: 6px; font-size: 14px; font-weight: 900; color: #8a5a2b; }
.story-card.tap .sc-next { display: block; animation: scnext 1.2s ease-in-out 1.4s infinite both; }
@keyframes scnext { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- ロケットの いろ */

#title.painting .title-top, #title.painting .title-bottom { visibility: hidden; }
#paint { justify-content: flex-end; background: linear-gradient(rgba(11, 10, 36, 0), rgba(11, 10, 36, 0.5)); }
.paint-panel { gap: 8px; padding: 12px 12px 14px !important; margin: 0 0 calc(10px + var(--safe-bottom)) !important; }
.paint-panel h2 { font-size: 24px !important; }
/* 12 しょくを 4 れつ × 3 だんに（上に メカが 見えるように ひくく） */
.paint-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; width: 100%; }
.paint-sw {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 2px 4px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: #fffaf0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.1;
  white-space: nowrap;
}
.paint-sw .dot { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--ink); background: var(--sw); box-shadow: inset -6px -6px 0 rgba(0, 0, 0, 0.12); }
.paint-sw.on { background: #ffe680; transform: scale(1.06); box-shadow: 0 4px 0 var(--ink); }
.paint-sw.locked { opacity: 0.55; background: #e9e4da; }
.paint-sw.locked .dot { background: #bdb6a8; display: grid; place-items: center; }
.paint-sw.locked .dot svg { width: 18px; height: 18px; }
.paint-sw .need { font-size: 11px; }
.paint-info { margin: 0; font-size: 15px; text-align: center; word-break: keep-all; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- スタンプ */

.stamp-head { margin: 6px 0 0; font-size: 18px; }
.stamp-card { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; width: 100%; background: #fff6e0; border: 3px dashed #c9a46a; border-radius: 14px; padding: 8px 6px; }
.stamp { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stamp-face {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px dashed #c9b28a;
  display: grid;
  place-items: center;
  color: #c9b28a;
  font-size: 20px;
}
.stamp.got .stamp-face { border: 3px solid var(--stamp); background: var(--stamp); transform: rotate(-8deg); box-shadow: 0 0 0 3px #fff6e0, 0 0 0 5px var(--stamp); }
.stamp.got .stamp-face svg { width: 30px; height: 30px; }
.stamp.fresh .stamp-face { animation: stamp 0.6s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: 0.8s; }
/* ことばの とちゅうで おれないように、くぎりの 空白でだけ 改行する */
.stamp-label { margin-top: 4px; font-size: 12px; line-height: 1.15; text-align: center; min-height: 2.3em; word-break: keep-all; overflow-wrap: normal; }
.stamp-q { font-weight: 900; }

/* けっか画面の ごほうび */
.rewards { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.rewards:empty { display: none; }
.rw-stamps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
/* 名前の ながさで ならびが ずれないように おなじ はばに */
.rw-stamps > * { flex: 0 0 78px; }
.rw-stamps .stamp-face { width: 42px; height: 42px; }
.rw-stamps .stamp-label { font-size: 11px; max-width: 76px; }
/* たくさん もらったときは 5 れつで 何だんかに（なまえも 小さく のこす） */
.rw-stamps.many { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px 2px; width: 100%; }
.rw-stamps.many .stamp-label { font-size: 11px; max-width: none; min-height: 0; }
.rw-stamps.many .stamp-face { width: 34px; height: 34px; }
.rw-stamps.many .stamp.got .stamp-face svg { width: 22px; height: 22px; }
.rw-head { font-size: 15px; color: #c62828; }
.rw-bonus { font-size: 13px; color: #8a5a00; background: #fff0b8; border-radius: 999px; padding: 1px 12px; }
.rw-paint { width: 100%; display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; justify-content: center; }
.rw-paint .rw-bar { flex: 1 1 100%; }
.rw-paint .dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); background: var(--sw); flex: none; }
.rw-bar { flex: 1; height: 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.12); overflow: hidden; border: 2px solid var(--ink); }
.rw-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ffd23f, #ff9f43); transition: width 1.2s ease-out; }
.rw-near { font-size: 15px; color: #4e342e; word-break: keep-all; overflow-wrap: anywhere; background: rgba(255, 255, 255, 0.55); border-radius: 999px; padding: 2px 12px; }
.rw-near b { color: #e65100; }
/* スタンプの すすみぐあい */
.stamp-prog { width: 54px; height: 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.12); overflow: hidden; }
.stamp-prog span { display: block; height: 100%; background: var(--stamp); }
.stamp-ptext { font-size: 10px; line-height: 1.1; opacity: 0.75; white-space: nowrap; }
.rw-new { word-break: keep-all; overflow-wrap: anywhere; font-size: 15px; color: #1e6fd0; margin: 2px 0 4px; animation: pulse 1s ease-in-out infinite; }
.card-fact { word-break: keep-all; overflow-wrap: anywhere; width: 100%; font-size: 15.5px; line-height: 1.45; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 8px; text-align: left; }
.card-fact b { color: #1e6fd0; }
/* まめちしきは カードの れつの かわりに 出す（ボタンの いちが ずれないように おなじ たかさ） */
.zukan .card-fact { display: none; margin-top: 6px; overflow-y: auto; cursor: pointer; animation: popin 0.25s ease-out; }
.zukan.fact-open .card-fact { display: block; }
.zukan.fact-open .result-cards, .zukan.fact-open .card-hint { display: none; }
.card-fact svg { float: left; width: 60px; height: auto; margin: 3px 8px 2px 0; border-radius: 8px; background: #1a1442; }
.zukan.fact-open { cursor: pointer; }
/* まめちしきを とじる しるし（はこの どこを タッチしても もどる） */
.zukan.fact-open::after { content: '✕'; position: absolute; top: 5px; right: 7px; width: 26px; height: 26px; border-radius: 50%; background: var(--white); color: var(--ink); border: 2px solid var(--ink); font-size: 14px; line-height: 23px; text-align: center; }
.sub-btn.dark { color: var(--ink); border-color: var(--ink); }
.big-btn.small { font-size: 22px; padding: 8px 30px 10px; }

#zukan { background: rgba(11, 10, 36, 0.6); }
.zukan-panel { position: relative; width: min(520px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; }
/* とじる ✕（スクロールしなくても いつも 見える） */
.zukan-x {
  position: sticky;
  z-index: 5;
  top: 0;
  align-self: flex-end;
  margin: -8px -6px 0 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font: 900 22px/1 inherit;
  display: grid;
  place-items: center;
  z-index: 2;
  box-shadow: 0 3px 0 var(--ink);
}
.zukan-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.zcard {
  position: relative;
  background: #1a1442;
  color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 4px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font: inherit;
}
.zcard svg { width: 100%; height: auto; }
.zcard.locked { background: #3a3358; color: rgba(255, 255, 255, 0.6); min-height: 84px; justify-content: center; }
.zq { font-size: 34px; line-height: 1; }
.card-name { font-size: 14px; line-height: 1.15; text-align: center; word-break: keep-all; overflow-wrap: normal; }
.card-name.long { font-size: 12px; }
.card-kind { font-size: 10px; opacity: 0.8; font-weight: 700; }
/* まだ 会えていない カードの ヒント */
.zcard .zhint { font-size: 10.5px; line-height: 1.25; color: #ffe27a; opacity: 0.9; padding: 0 2px; word-break: keep-all; overflow-wrap: anywhere; }
.zmore { grid-column: 1 / -1; font-size: 14px; color: #6a4aa8; padding: 4px 0 2px; }
.zdetail { grid-column: 1 / -1; position: sticky; bottom: 6px; z-index: 2; box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.35); background: #1a1442; color: var(--white); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px 12px; }
.zdetail svg { width: 100%; max-width: 260px; display: block; margin: 0 auto; }
.zd-name { font-size: 22px; color: #8fe3ff; }
.zd-name span { font-size: 12px; margin-left: 8px; color: var(--white); opacity: 0.8; }
.zdetail p { margin: 4px 0 0; font-size: 15px; line-height: 1.6; font-weight: 700; text-align: left; }
.records { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.rec { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 18px; }
.rec.small { font-size: 13px; opacity: 0.85; }
.rec-s .mini svg { width: 18px; height: 18px; fill: rgba(0, 0, 0, 0.15); stroke: var(--ink); stroke-width: 1.2; }
.rec-s .mini.on svg { fill: #ff8ad8; }

/* ---------------------------------------------------------------- けっか */

.medal { display: flex; gap: 6px; }
.stage-label { font-size: 14px; color: var(--ink); background: var(--star); border-radius: 999px; padding: 1px 12px; }
.medal-star svg { width: 38px; height: 38px; fill: rgba(0, 0, 0, 0.12); stroke: var(--ink); stroke-width: 1.2; }
.medal-star.on svg { fill: var(--star); stroke: #a86b00; animation: stamp 0.5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: inherit; }
.result-stars .of { font-size: 22px; opacity: 0.8; margin-left: 2px; }
.next-goal { font-size: 15px; color: #1e6fd0; }
.highlights { display: flex; gap: 6px; justify-content: center; width: 100%; }
.hl { flex: 1; display: flex; flex-direction: column; align-items: center; background: rgba(0, 0, 0, 0.06); border-radius: 12px; padding: 2px 4px; }
.hl-n { font-size: 20px; line-height: 1.1; }
.hl-l { font-size: 12px; font-weight: 800; white-space: nowrap; }
/* ずかんの カードは 1 れつ（おおいときは よこに すべらせる） */
.result-cards { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; margin-top: 6px; padding: 8px 2px 2px; scrollbar-width: none; width: 100%; min-width: 0; align-self: stretch; }
.result-cards .card { position: relative; flex: 0 0 86px; font: inherit; color: inherit; border: none; background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 2px 2px 4px; }
.result-cards .card .card-name { font-size: 13px; overflow-wrap: normal; }
.result-cards .card .card-name.long { font-size: 12px; letter-spacing: -0.06em; }
.zukan .card-fact { color: var(--ink); }
.result-cards .card svg { width: 100%; height: auto; }
.result-cards .card.new { outline: 3px solid var(--star); }
.card-new { position: absolute; top: -8px; right: -6px; background: #e53935; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px; transform: rotate(8deg); }
.result-buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
/* けっかは うえから じゅんばんに 出る */
.rv { animation: rvin 0.45s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes rvin { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
/* 「もういちど！」は いつも 画面の 下に 見える */
#result .result-buttons {
  position: sticky;
  bottom: calc(-16px - var(--safe-bottom));
  z-index: 3;
  width: calc(100% + 28px);
  margin: 0 -14px -16px;
  padding: 10px 14px calc(14px + var(--safe-bottom));
  border-radius: 0 0 20px 20px;
  background: linear-gradient(rgba(246, 226, 191, 0), var(--paper) 22%);
}
#result .result-buttons { flex-wrap: nowrap; gap: 8px; }
#nextGoal { word-break: keep-all; overflow-wrap: anywhere; }
/* 「つぎの コースへ」が ある ときは 2 だんに（うえに 大きく） */
#result .result-buttons:has(#nextCourseBtn:not(.hidden)) { flex-wrap: wrap; }
#result .result-buttons #nextCourseBtn { flex: 1 0 100%; padding-left: 10px; padding-right: 10px; }
#result .result-buttons .big-btn { font-size: clamp(22px, 6.6vw, 30px); padding: 9px 22px 11px; white-space: nowrap; }
#result .result-buttons .sub-btn { font-size: 16px; padding: 8px 12px; white-space: nowrap; background: rgba(255, 255, 255, 0.55); }
#rewards, #resultZukan { scroll-margin-bottom: 96px; }
/* まめちしきの あとの クイズ */
.quiz { margin-top: 10px; padding: 8px; border-radius: 12px; background: rgba(255, 210, 63, 0.18); border: 2px dashed #e0a800; text-align: center; }
.quiz-q { font-size: 16px; font-weight: 900; color: #c62828; margin-bottom: 6px; }
.quiz-a { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.quiz-btn { font: inherit; font-size: 17px; font-weight: 900; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 6px 14px; box-shadow: 0 4px 0 var(--ink); min-width: 96px; }
.quiz-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.quiz-btn.right { background: #b9f6ca; }
.quiz-btn.wrong { background: #ffcdd2; }
.quiz.done .quiz-btn:not(.right):not(.wrong) { opacity: 0.5; }
.quiz-r { margin-top: 6px; font-size: 16px; font-weight: 900; min-height: 1.2em; }
.quiz-r.right { color: #2e7d32; animation: popin 0.4s cubic-bezier(.2, 1.6, .4, 1); }
.quiz-r.wrong { color: #c62828; }
.lost-text { margin: 0; font-size: 16px; }

/* メカが うしろに いるときは すきとおる */
#formBtn, #attackBtn, #specialBtn { transition: transform 0.1s, opacity 0.2s; }
#formBtn.see-through, #attackBtn.see-through, #specialBtn.see-through { opacity: 0.35; }

/* たてが みじかい スマホ（iPhone SE など）：けっかを 1 画面に おさめる */
/* ひくい たて画面（375x667 など）：タイトルの 文を はぶき、ボタンを すこし 小さく */
@media (max-height: 700px) and (max-aspect-ratio: 9/10) {
  .story { display: none; }
  .logo-big { font-size: clamp(44px, 14vw, 60px); }
  /* むずかしさの ボタンを よこに ならべて、まんなかに メカが 見える すきまを つくる */
  .mode-select { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 8px; width: min(390px, calc(100vw - 20px)); }
  .mode-select .mode-btn { padding: 6px 8px 8px 8px; column-gap: 5px; border-radius: 18px; }
  .mode-select .mode-btn svg { width: 32px; height: 32px; }
  .mode-select .mode-btn .mode-name { font-size: clamp(20px, 5.8vw, 26px); }
  .mode-select .mode-btn .mode-sub { font-size: 11px; white-space: nowrap; }
  .mode-select .mode-btn.hard { grid-column: 1 / -1; justify-self: center; padding: 6px 22px 8px 12px; }
  .mode-select .mode-btn .mode-sub { overflow: hidden; text-overflow: clip; }
  .story-strip { transform: scale(0.86); transform-origin: 50% 0; margin-bottom: -10px; }
  #formBtn, #attackBtn { width: 96px; height: 96px; }
  #specialBtn { width: 72px; height: 72px; bottom: calc(146px + var(--safe-bottom)); }
}
/* 600〜700px の たかさでは、あらすじを 1 ぎょうだけ 出す */
@media (max-height: 700px) and (min-height: 600px) and (max-aspect-ratio: 9/10) {
  .story { display: block; font-size: 13px; margin: -6px 0 0; }
  .story br { display: none; }
}
/* とても ほそい 画面（320 はば）：ボタンの 小さい 文字を 2 ぎょうに */
@media (max-height: 700px) and (max-width: 340px) {
  .mode-select .mode-btn .mode-sub { white-space: normal; word-break: keep-all; font-size: 10px; line-height: 1.15; }
  .mode-select .mode-btn svg { width: 28px; height: 28px; }
}
@media (max-height: 760px) and (min-aspect-ratio: 1/3) and (max-aspect-ratio: 9/10) {
  .result-panel { gap: 5px; padding: 10px 12px 12px; }
  .stage-label { display: none; }
  .goal-title { font-size: 34px !important; }
  .medal-star svg { width: 30px; height: 30px; }
  .result-stars { font-size: 34px; }
  .result-stars .icon-star { width: 34px; height: 34px; }
  .rank { font-size: 19px; border-width: 3px; }
  .next-goal { font-size: 13px; }
  .hl-n { font-size: 17px; }
  .best { font-size: 13px; }
  .rw-head { font-size: 13px; }
  .rw-stamps .stamp-face { width: 32px; height: 32px; }
  .rw-stamps .stamp.got .stamp-face svg { width: 22px; height: 22px; }
  .result-cards .card { flex-basis: 74px; }
  .result-cards .card .card-name, .result-cards .card .card-name.long { font-size: 11px; letter-spacing: -0.06em; }
  .result-buttons .big-btn { font-size: 24px; padding: 6px 28px 8px; }
  .result-buttons .sub-btn { padding: 6px 18px; }
}

/* ---------------------------------------------------------------- 横長の画面 */

@media (max-height: 400px) {
  /* とても ひくい よこ画面：文を はぶいて ロゴが 切れないように */
  #title .story { display: none; }
  #title .title-top, #title .title-bottom { gap: 3px; }
  .logo-big { font-size: 38px !important; }
  .story-strip { transform: scale(0.82); transform-origin: 0 0; margin-bottom: -12px; }
  .mode-btn { padding-top: 4px !important; padding-bottom: 5px !important; }
  .sub-btn { padding-top: 5px !important; padding-bottom: 5px !important; }
  #title { padding-top: 4px !important; padding-bottom: 4px !important; }
}
@media (max-height: 500px) {
  .today-event { flex-direction: row; gap: 6px; font-size: 11px; padding: 1px 10px 2px; }
  .today-event b { font-size: 12px; }
  .logo { margin-top: 0; }
  .logo-big { font-size: 42px; }
  .logo-small { font-size: 20px; }
  /* よこ画面は たかさが みじかいので、文の かわりに 3 コマで おはなしを 見せる */
  .story { display: none; }
  .big-btn { font-size: 26px; padding: 8px 32px 10px; }
  #formBtn, #attackBtn { width: 88px; height: 88px; }
  #formBtn svg { width: 56px; height: 36px; margin-top: -10px; }
  #formBtn .label, #attackBtn .label, #specialBtn .label { font-size: 12px; bottom: 9px; }
  #attackBtn .icon { width: 44px; height: 44px; margin-top: -10px; }
  #specialBtn { width: 70px; height: 70px; bottom: calc(118px + var(--safe-bottom)); }
  #message { top: calc(var(--safe-top) + 60px); }
  .msg { font-size: 24px; -webkit-text-stroke-width: 6px; }
  .msg.big { font-size: 36px; }
  .msg.small { font-size: 20px; }
  .pop-say { font-size: 22px; }
  .zukan-text { display: none; }
  .story-strip { margin-top: 0; }
  .ss-cell svg { width: 62px; height: 37px; border-width: 2px; }
  .ss-cell span { font-size: 11px; }
  .who { padding: 2px 6px 2px 10px; }
  .who-btn svg { width: 30px; height: 30px; }
  .who-label { font-size: 13px; }
  .story-card { top: 8%; width: min(300px, 60vw); }
  .sc-text { font-size: 16px; }

  /* 横向き：タイトルは左に寄せて、右にメカを見せる */
  #title { align-items: flex-start; justify-content: safe center; gap: 4px; padding-left: calc(24px + var(--safe-left)); }
  /* ステージの カードは 小さく（ロゴが きれないように） */
  .stage-card svg { width: 86px; }
  .stage-card .sc-name { font-size: 11px; }
  #title .title-top, #title .title-bottom { align-items: flex-start; gap: 5px; }
  #title .logo { margin-left: 8px; }
  #title .story { text-align: left; }
  /* だれが あそぶ・きょうの イベントは 右下（メカの 下）へ。ひだりの れつが 画面に おさまるように */
  #title .who { position: fixed; right: calc(14px + var(--safe-right)); bottom: calc(10px + var(--safe-bottom)); }
  #title .today-event { position: fixed; right: calc(14px + var(--safe-right)); bottom: calc(76px + var(--safe-bottom)); max-width: 46vw; }
  #title .hint-small { display: none; }

  /* 横向き：けっかは 2 列 */
  .result-panel {
    width: min(760px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-areas: "label zukan" "title zukan" "medal zukan" "rank zukan" "next zukan" "hl rew" "best rew" "btns rew";
    justify-items: center;
    align-items: center;
    gap: 2px 16px;
    padding: 10px 16px;
  }
  .goal-title { grid-area: title; font-size: 30px !important; }
  .stage-label { grid-area: label; }
  .medal-row { grid-area: medal; }
  .rewards { grid-area: rew; min-width: 0; }
  .zukan { min-width: 0; }
  .rw-stamps .stamp-face { width: 34px; height: 34px; }
  .medal { grid-area: medal; }
  .medal-star svg { width: 34px; height: 34px; }
  .result-stars { grid-area: stars; font-size: 30px; }
  .result-stars .icon-star { width: 30px; height: 30px; }
  .rank { grid-area: rank; font-size: 18px; margin: 4px 0; }
  .next-goal { grid-area: next; font-size: 13px; }
  .highlights { grid-area: hl; }
  .hl { padding: 2px 8px; min-width: 64px; }
  .hl-n { font-size: 18px; }
  .best { grid-area: best; font-size: 13px; }
  .zukan { grid-area: zukan; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .result-buttons { grid-area: btns; }
  .result-buttons .big-btn { font-size: 22px; padding: 6px 22px 8px; }
  /* たて画面用の 下に はりつく ボタンの 指定を、よこ画面では もとに もどす（はみ出し・かさなりを ふせぐ） */
  #result .result-buttons { position: static; width: 100%; margin: 0; padding: 4px 0; background: none; }
  #result .result-buttons .big-btn { font-size: 22px; padding: 6px 18px 8px; }
  #result .result-buttons .sub-btn { font-size: 15px; padding: 6px 10px; }
  .mode-btn { padding: 6px 14px 8px 10px; }
  .mode-btn svg { width: 36px; height: 36px; }
  .mode-btn .mode-name { font-size: 22px; }
  .subbar { top: calc(56px + var(--safe-top)); }
  /* よこ画面の まんなかは メッセージが かさなるので、せいざの マスは「あつめる」の となりに */
  .subbar .zone-chip { margin-right: 8px; }
  .subbar .const-slots { margin-right: auto; }
}

/* ---------------------------------------------------------------- 動き */

@keyframes bump { 50% { transform: scale(1.18); } }
@keyframes loss { 0%, 100% { transform: translateX(0); background: rgba(20, 14, 50, 0.7); } 20% { transform: translateX(-6px); background: rgba(200, 40, 40, 0.8); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.loss { animation: loss 0.5s ease-out; }
/* まだ つかえない ボタンを おしたとき（ぷるぷる） */
@keyframes deny { 0%, 100% { translate: 0 0; } 20% { translate: -7px 0; } 40% { translate: 7px 0; } 60% { translate: -5px 0; } 80% { translate: 4px 0; } }
.deny { animation: deny 0.35s ease-out; }
@keyframes ring { 0% { opacity: 0.9; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 25% { rotate: -6deg; } 75% { rotate: 6deg; } }
@keyframes popin { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes msgin { 0% { transform: scale(0.4) translateY(20px); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes msgout { to { transform: translateY(-20px) scale(0.9); opacity: 0; } }
@keyframes count { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(0.8); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.07); } }
@keyframes float { 50% { translate: 0 -8px; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowpulse { 50% { box-shadow: 0 5px 0 var(--ink), 0 0 30px rgba(255, 255, 255, 0.95); } }
@keyframes swipe { 0% { transform: translate(-60px, 0) rotate(-10deg); opacity: 0; } 15% { opacity: 1; } 50% { transform: translate(60px, -30px) rotate(10deg); } 85% { opacity: 1; } 100% { transform: translate(-60px, 0) rotate(-10deg); opacity: 0; } }
@keyframes bob { to { transform: translateY(10px); } }
@keyframes cutin { 0% { transform: translateX(110%) rotate(-6deg); } 20% { transform: translateX(0) rotate(-6deg); } 80% { transform: translateX(0) rotate(-6deg); opacity: 1; } 100% { transform: translateX(-110%) rotate(-6deg); opacity: 0; } }
@keyframes stamp { 0% { transform: rotate(-6deg) scale(2.5); opacity: 0; } 100% { transform: rotate(-6deg) scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .logo, #startBtn, #formBtn.hint, #formBtn.now, #formBtn.now .now-tip, .story-card.tap .sc-next, .combo.on, #attackBtn.demo .press-demo { animation: none; }
}

/* けっかは 2 まい：1 まいめ（クリア・メダル・スタンプ）→ 2 まいめ（ずかん・いろ・シール） */
.result-panel:not(.page2) .p2 { display: none !important; }
.result-panel.page2 .p1 { display: none !important; }
.result-panel.page2 .goal-title { font-size: 0.8em; }
.res-back { position: absolute; left: 10px; top: 10px; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; color: var(--ink); font: 900 18px/1 inherit; display: grid; place-items: center; z-index: 3; }
.result-panel { position: relative; }
/* チャレンジの のこり じかん（とけいの しるしと あおい バー：とった かずと まちがえないように） */
.ch-clock { display: inline-flex; width: 20px; height: 20px; margin-left: 4px; }
.ch-clock svg { width: 100%; height: 100%; }
.ch-bar i { background: linear-gradient(90deg, #4fc3f7, #81d4fa) !important; }
/* チャレンジの 表示が「ひみつ」に かさならないように：バーを みじかく、せまい 画面では 「チャレンジ」の 字を かくす */
.challenge .ch-bar { width: 44px; }
@media (max-width: 400px) { .challenge .ch-label { display: none; } }
/* よこ画面：ひっさつと アタックの あいだを あける */
@media (max-height: 500px) { #specialBtn { bottom: calc(176px + var(--safe-bottom)); } }

/* コースの ちずの ひみつのほし */
.cm-secret { display: block; font-size: 10px; letter-spacing: 1px; color: #ff9ad0; line-height: 1; margin-top: 1px; }

/* R22：スタンプが おおい ときは 3 れつで 名前を おりかえす（となりと かさならない） */
.rw-stamps.many { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rw-stamps.many .stamp-label { word-break: normal; overflow-wrap: anywhere; width: 100%; }
/* コースの ちずの しるしを 大きく。NEW は カードの うえの そとへ */
.cm-card .cm-medal i { font-size: 15px; }
.cm-secret { font-size: 13px; }
.cm-card.new::after { bottom: auto; top: -11px; right: -8px; }
/* せまい 画面では ゾーンの ひょうじを みじかく */
@media (max-width: 360px) {
  .zone-chip { font-size: 12px; padding: 2px 6px 2px 4px; white-space: nowrap; }
  #secretSlots { white-space: nowrap; }
}
.rw-stamps.many .stamp-label { word-break: keep-all; overflow-wrap: normal; }

/* R24：ゾーンの ひょうじと ひみつは いつも 1 ぎょう。ハート 5 こ（やさしい）は すこし 小さく */
.zone-chip { white-space: nowrap; }
#secretSlots { white-space: nowrap; }
.hearts.five svg { width: 22px; height: 22px; }

/* わっかの フィーバー中 */
.zone-chip.fever { background: linear-gradient(90deg, #ff5fa2, #ffd23f, #5fe08a, #5fb4ff, #b07aff); background-size: 300% 100%; animation: feverbg 1.2s linear infinite; box-shadow: 0 0 14px rgba(255, 230, 120, 0.9); }
.zone-chip.fever .rc::after { content: ' フィーバー！'; }
@keyframes feverbg { to { background-position: 300% 0; } }

/* よるの うらばんの ボタン（コースの カードの よこ） */
.cm-ura { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 0 0 auto; min-width: 40px; padding: 3px 4px; margin-left: -4px; background: linear-gradient(180deg, #2a2f7a, #120f3a); border: 3px solid var(--ink); border-radius: 10px; color: #ffe9a8; font: inherit; font-size: 12px; font-weight: 900; cursor: pointer; touch-action: manipulation; box-shadow: 0 0 10px rgba(140, 160, 255, 0.6); }
.cm-ura .cm-medal i { font-size: 9px; font-style: normal; color: rgba(255, 255, 255, 0.25); }
.cm-ura .cm-medal i.on { color: var(--star); text-shadow: 0 0 4px rgba(255, 210, 63, 0.8); }
.cm-ura.on { border-color: var(--star); box-shadow: 0 0 0 3px var(--ink), 0 0 14px rgba(255, 210, 63, 0.75); }
.cm-ura.new::after { content: 'NEW'; position: absolute; top: -11px; right: -8px; background: #ff5a7a; color: #fff; font-size: 9px; font-weight: 900; padding: 1px 4px; border-radius: 8px; border: 2px solid var(--ink); }
.cm-ura { min-width: 34px; font-size: 11px; margin-left: -6px; padding: 2px 3px; }

/* よるの うらばんは カードの したの れつ（はみ出さない・ゆびで おしやすい） */
.cm-ura-row { margin-top: -2px; }
.cm-ura-row .cm-ura, .cm-ura-row .cm-ura-gap { flex: 0 1 70px; min-width: 0; margin-left: 0; min-height: 44px; white-space: nowrap; }
.cm-ura-row .cm-ura { font-size: 14px; flex-direction: row; gap: 2px; }
.cm-moon { background: none !important; border: none !important; font-size: 18px; }
.zone-chip.fever[data-zone='attack'] .rc::after, .zone-chip.fever:not([data-zone='ring'])::after { content: ' パワー！'; }
.cm-ura-row .cm-ura .cm-medal i { font-size: 10px; }
/* コースの ちずの メカの パーツ（カードの ひだりうえ。とったら きいろ） */
.cm-card { position: relative; }
.cm-gear { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; }
.cm-gear polygon { fill: #6f6a88; stroke: #2a2442; stroke-width: 1.6; }
.cm-gear circle { fill: #2a2442; }
.cm-gear.on polygon { fill: #ffb84a; }
/* パーツ「バリア」が のこって いる：ハートの よこに あわ */
.hearts.shield { position: relative; padding-right: 30px; }
.hearts.shield::after { content: ''; position: absolute; right: 6px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0 18%, #bff3ff 30%, rgba(120, 210, 255, 0.55) 70%); border: 2px solid #7fd8ff; box-shadow: 0 0 8px #7fd8ff; }
/* タイトルの「つける パーツ」（もって いる なかから 2 こ まで） */
.part-bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 2px 8px 6px; pointer-events: auto; }
.part-bar.hidden { display: none; }
.pb-label { font-weight: 900; font-size: 14px; color: #fff; text-shadow: 0 2px 0 #2a2442; margin-right: 2px; }
.pb-label small { margin-left: 4px; font-size: 13px; color: #ffd36b; }
.pb-chip { min-height: 38px; padding: 4px 10px 4px 30px; border-radius: 19px; border: 3px solid #2a2442; background: #ece8f6 no-repeat 6px 50% / 20px 20px; color: #2a2442; font: 900 14px/1.1 inherit; opacity: 0.75;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='%236f6a88' stroke='%232a2442' stroke-width='2' stroke-dasharray='3 2'/%3E%3Ccircle cx='12' cy='12' r='3' fill='%232a2442'/%3E%3C/svg%3E"); }
.pb-chip.on { background-color: #ffe6a8; opacity: 1; box-shadow: 0 0 0 3px #ffb84a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='%23ffb84a' stroke='%232a2442' stroke-width='2' stroke-dasharray='3 2'/%3E%3Ccircle cx='12' cy='12' r='3' fill='%232a2442'/%3E%3C/svg%3E"); }
/* パーツが ふえても 1 れつ（よこに すべらせて えらぶ） */
.part-bar { flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; scrollbar-width: none; padding: 4px 6px; }
.part-bar::-webkit-scrollbar { display: none; }
.pb-chip, .pb-label { flex: 0 0 auto; white-space: nowrap; }
.part-bar { width: 100%; max-width: calc(100vw - 16px); box-sizing: border-box; min-width: 0; }
.part-bar.more { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
/* R31：パーツは ぜんぶ 見える ように 2 だんで（よこに ながさない） */
.part-bar { flex-wrap: wrap; overflow: visible; gap: 4px 5px; }
.part-bar.more { -webkit-mask-image: none; mask-image: none; }
.part-bar .pb-label { flex-basis: 100%; text-align: center; font-size: 13px; }
.pb-chip { min-height: 34px; padding: 3px 8px 3px 26px; font-size: 13px; background-position: 5px 50%; background-size: 18px 18px; }
/* R31：パーツは ふだん 1 ぎょう（つけて いる もの）。「かえる」で いちらん */
.part-bar { position: relative; flex-wrap: nowrap; overflow: visible; gap: 6px; }
.part-bar .pb-label { flex-basis: auto; font-size: 14px; }
.pb-worn { padding: 4px 10px; border-radius: 14px; background: #ffe6a8; border: 2px solid #2a2442; color: #2a2442; font: 900 13px/1.2 inherit; white-space: nowrap; }
.pb-worn.none { background: #ece8f6; opacity: 0.8; }
.pb-change { min-height: 36px; padding: 4px 12px; border-radius: 18px; border: 3px solid #2a2442; background: #fff; color: #2a2442; font: 900 14px/1 inherit; }
.pb-panel { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); width: min(340px, calc(100vw - 24px)); z-index: 20; background: #fff8e8; border: 4px solid #2a2442; border-radius: 18px; padding: 10px; box-shadow: 0 6px 0 rgba(0,0,0,0.3); }
.pb-title { font-weight: 900; font-size: 15px; color: #2a2442; text-align: center; margin-bottom: 8px; }
.pb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pb-grid .pb-chip { width: 100%; text-align: left; }
.pb-close { display: block; margin: 10px auto 0; min-width: 120px; min-height: 44px; border-radius: 22px; border: 3px solid #2a2442; background: #ffd23f; font: 900 18px/1 inherit; color: #2a2442; }
.pb-change, .pb-label { white-space: nowrap; flex: 0 0 auto; }
.pb-worn { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 4px 8px; }
.pb-worn, .pb-chip, .pb-change { font-family: inherit; font-weight: 900; line-height: 1.2; }
.pb-worn { font-size: 13px; }
.pb-chip { font-size: 14px; }
.pb-change { font-size: 14px; }
.pb-close { font-family: inherit; font-weight: 900; font-size: 18px; line-height: 1; }
/* R32：パーツの いちらんは 1 れつ・なまえと こうか */
.pb-grid { grid-template-columns: 1fr; gap: 5px; }
.pb-grid .pb-chip { display: flex; flex-direction: column; align-items: flex-start; padding: 5px 10px 5px 32px; min-height: 44px; border-radius: 14px; background-position: 7px 50%; }
.pb-chip b { font-size: 15px; }
.pb-chip small { font-size: 12px; font-weight: 700; opacity: 0.85; white-space: normal; }
.pb-note { text-align: center; font-weight: 900; font-size: 14px; color: #c0392b; margin-top: 6px; }
.pb-panel { position: fixed; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); max-height: calc(100vh - 24px); overflow-y: auto; z-index: 50; }
.pb-grid .pb-chip { min-height: 40px; padding-top: 3px; padding-bottom: 3px; }
#nextGoal { white-space: pre-line; }
.cm-world-gap { visibility: hidden; }
/* よこ画面（スマホ）：ひだりに ロゴと ちず、その みぎに あそぶ ボタン・パーツ・ずかん の れつ（したで きれない）。メカは いちばん みぎ */
@media (max-height: 500px) and (orientation: landscape) {
  .story-strip.course-map { transform: none; zoom: 0.68; margin-bottom: 0; }
  .story-strip.course-map .cm-caption { display: none; }
  #title .logo-big { font-size: 34px; }
  #title .logo-small { font-size: 16px; }
  #title .title-bottom { display: grid; grid-template-columns: auto min(232px, 30vw); grid-template-rows: auto auto 1fr; column-gap: 20px; row-gap: 8px; align-items: start; }
  #title #storyStrip { grid-column: 1; grid-row: 1 / 4; }
  #title #partBar { grid-column: 2; grid-row: 1; width: 100%; max-width: none; justify-content: flex-start; margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
  #title .mode-select, #title .mode-select.three { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; flex-wrap: nowrap; gap: 12px; width: 100%; margin: 0; }
  #title .mode-btn { width: 100%; padding: 5px 12px 7px 10px; border-radius: 18px; }
  #title .mode-btn svg { width: 34px; height: 34px; }
  #title .mode-btn .mode-name { font-size: 24px; }
  #title .title-sub { grid-column: 2; grid-row: 3; display: flex; gap: 8px; margin-top: 4px; }
  #title .sub-btn { font-size: 16px; padding: 6px 14px; }
}

/* タイトルの そら：よみがえった せいざが ずっと ひかる */
.title-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.title-sky svg { position: absolute; transform: translate(-50%, -50%); height: auto; overflow: visible; animation: tsTwinkle 4s ease-in-out infinite; }
.title-sky .ts-lines line { stroke: #9fe4ff; stroke-width: 1.5; stroke-linecap: round; opacity: 0.6; }
.title-sky svg.new { animation: tsPop 1.8s ease-out 0.5s both, tsTwinkle 4s ease-in-out 2.3s infinite; }
#title.painting .title-sky { visibility: hidden; }
@keyframes tsTwinkle { 0%, 100% { opacity: 0.85; } 50% { opacity: 0.55; } }
@keyframes tsPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); filter: drop-shadow(0 0 0 rgba(255, 230, 128, 0)); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(1.35); filter: drop-shadow(0 0 12px rgba(255, 230, 128, 0.95)); }
  100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); filter: drop-shadow(0 0 0 rgba(255, 230, 128, 0)); }
}

/* ちずの カードの せいざの しるし（よみがえったら ひかる） */
.cm-sky { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); display: flex; gap: 1px; padding: 0 4px; background: #1a1442; border: 2px solid var(--ink); border-radius: 8px; font-size: 10px; line-height: 13px; color: rgba(159, 228, 255, 0.35); white-space: nowrap; pointer-events: none; }
.cm-sky i { font-style: normal; }
.cm-sky i.on { color: #bff0ff; text-shadow: 0 0 4px rgba(127, 220, 255, 0.95); }
.cm-ura { position: relative; }
.cm-ura .cm-sky { bottom: -9px; font-size: 9px; line-height: 11px; }

/* よぞらの ちず */
#sky { background: rgba(11, 10, 36, 0.6); }
.sky-panel { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; gap: 8px !important; }
.sky-panel h2 { margin-top: -30px; }
.sky-info { margin: -6px 0 0; font-size: 15px; font-weight: 900; }
.sky-chart { width: 100%; height: auto; flex: none; background: radial-gradient(ellipse at 50% 25%, #2c2c80, #120e3a 78%); border-radius: 14px; border: 3px solid var(--ink); }
.sky-chart .sk-set { font-size: 10.5px; font-weight: 900; fill: rgba(220, 230, 255, 0.75); }
.sky-chart .sk-set.done { fill: #ffe680; }
.sky-chart .sk-item { cursor: pointer; }
.sky-chart .sk-item line { stroke: #8fdcff; stroke-width: 2; stroke-linecap: round; }
.sky-chart .sk-item.pick line { stroke: #ffe680; }
/* できばえ：★2 は あかるく、★3 は きんいろ */
.sky-chart .sk-item.g2 line { stroke: #c8f2ff; stroke-width: 2.6; filter: drop-shadow(0 0 2px #8fdcff); }
.sky-chart .sk-item.g3 line { stroke: #ffe680; stroke-width: 2.8; filter: drop-shadow(0 0 3px #ffd23f); }
.sky-chart .sk-grade { font-size: 8px; font-weight: 900; fill: #ffd23f; stroke: #120e3a; stroke-width: 2px; paint-order: stroke; text-anchor: middle; letter-spacing: 0.5px; }
.sc-grade .sc-stars { color: #ffd23f; font-size: 18px; letter-spacing: 1px; margin-right: 4px; -webkit-text-stroke: 3px #2a1a50; paint-order: stroke fill; }
.sc-grade .kira.on { background: #ffe680; color: #5a3a00; }
.ss-power { font-size: 12px; font-weight: 900; color: rgba(60, 50, 90, 0.5); margin-top: 2px; }
.ss-power.on { color: #b05a00; }
.sky-chart .sk-name { font-size: 11px; font-weight: 900; fill: #eafaff; stroke: #120e3a; stroke-width: 3px; paint-order: stroke; text-anchor: middle; }
.sky-chart .sk-name.dim { fill: rgba(255, 255, 255, 0.45); font-size: 10px; }
.sky-chart .sk-item.pick .sk-name { fill: #ffe680; }
.sky-chart .sk-dim { fill: rgba(255, 255, 255, 0.42); }
.sky-chart .sk-item.fresh { animation: skFresh 0.9s ease-in-out 4; }
@keyframes skFresh { 50% { opacity: 0.35; } }
.sky-card { width: 100%; min-height: 70px; background: #1a1442; color: var(--white); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; display: flex; gap: 10px; align-items: center; text-align: left; flex: none; }
.sky-card > svg { width: 80px; flex: none; }
.sky-card .ts-lines line { stroke: #9fe4ff; stroke-width: 1.6; stroke-linecap: round; }
.sky-card .sc-body { min-width: 0; }
.sky-card .sc-name { font-size: 19px; font-weight: 900; color: #ffe680; }
.sky-card .sc-name.dim { color: rgba(255, 255, 255, 0.6); }
.sky-card p { margin: 3px 0 0; font-size: 14px; line-height: 1.45; }
.sky-card .sky-tip { margin: 0 auto; font-size: 15px; text-align: center; opacity: 0.85; }
.sky-card .sc-q { width: 60px; height: 60px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #3a3358; font-size: 30px; font-weight: 900; color: rgba(255, 255, 255, 0.6); }
.sky-card .sc-grade { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 2px; }
.sky-card .sc-grade span { font-size: 12px; font-weight: 900; padding: 0 8px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.45); white-space: nowrap; }
.sky-card .sc-grade span.on { background: #ffd23f; color: var(--ink); border-color: var(--ink); }
.sky-sets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; flex: none; }
.sky-set { display: flex; gap: 8px; align-items: center; background: rgba(255, 255, 255, 0.5); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 8px; text-align: left; }
.sky-set > svg { width: 42px; height: 42px; flex: none; }
.sky-set.done { background: #fff3c4; }
.sky-set .ss-name { font-size: 15px; font-weight: 900; }
.sky-set .ss-name span { font-size: 13px; color: #6a5a30; margin-left: 6px; }
.sky-set .ss-mem { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 11px; font-weight: 900; color: rgba(42, 36, 66, 0.45); }
.sky-set .ss-mem span.on { color: #2a5bd0; }
.sky-set .ss-note { font-size: 12px; line-height: 1.35; margin-top: 2px; }
@media (max-width: 460px) { .sky-sets { grid-template-columns: 1fr; } }
.sky-body { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.sky-left, .sky-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* よこ画面：ちずを ひだり、カードと くみを みぎに */
@media (max-height: 500px) and (orientation: landscape) {
  .sky-panel { width: min(900px, 100%); padding-top: 8px !important; padding-bottom: 10px !important; }
  .sky-panel h2 { margin-top: -38px; font-size: 24px !important; }
  .sky-body { flex-direction: row; align-items: flex-start; }
  .sky-left { flex: 1.25 1 0; }
  .sky-right { flex: 1 1 0; max-height: calc(100vh - 128px); max-height: calc(100dvh - 128px); overflow-y: auto; }
  .sky-chart { max-height: calc(100vh - 128px); max-height: calc(100dvh - 128px); }
  .sky-sets { grid-template-columns: 1fr; }
  .sky-panel #skyClose { display: none; }
  /* タイトルの ちいさな ボタンは え の したに もじ（3 つ ならぶように） */
  #title .title-sub .sub-btn { flex-direction: column; gap: 0; font-size: 13px; padding: 3px 10px 4px; line-height: 1.15; }
  #title .title-sub .sub-btn svg { width: 22px; height: 22px; }
  #title .title-sub .sky-count { display: none; }
}
.zd-grade { display: flex; gap: 6px; justify-content: center; margin: 2px 0 4px; }
.zd-grade span { font-size: 13px; font-weight: 900; padding: 0 10px; border-radius: 999px; border: 2px solid rgba(42, 36, 66, 0.3); color: rgba(42, 36, 66, 0.45); }
.zd-grade span.on { background: #ffd23f; color: var(--ink); border-color: var(--ink); }

/* せいざの えの かず（大きく） */
.canvas-count { position: fixed; left: 50%; top: calc(var(--safe-top) + 96px); transform: translateX(-50%); z-index: 6; font-size: 34px; font-weight: 900; color: #dff6ff; -webkit-text-stroke: 8px #14205a; paint-order: stroke fill; letter-spacing: 2px; pointer-events: none; text-shadow: 0 0 14px rgba(127, 220, 255, 0.8); }
@media (max-height: 500px) and (orientation: landscape) {
  .canvas-count { top: calc(var(--safe-top) + 10px); font-size: 28px; }
  #hud.drawing .progress { visibility: hidden; }
  #message.under-count { top: calc(var(--safe-top) + 60px); }
}

/* まきもどし（ハートが なくなった とき）：まどは ださずに すこし まえへ もどる */
#game.rewinding { animation: rewind 0.8s linear; }
@keyframes rewind {
  0% { filter: none; }
  30% { filter: saturate(0.2) hue-rotate(160deg) blur(1px); transform: scale(1.03); }
  100% { filter: saturate(0.4) brightness(1.3) blur(2px); transform: scale(1); }
}

/* ボスが ひるんで いる あいだの れんだ メーター */
.rush-meter { position: fixed; transform: translate(-50%, -50%); z-index: 6; font-size: 24px; font-weight: 900; color: #fff3b0; -webkit-text-stroke: 6px #2a1040; paint-order: stroke fill; white-space: nowrap; pointer-events: none; letter-spacing: 1px; }
.rush-meter b { color: #ffd23f; font-size: 22px; letter-spacing: 0; }
.rush-meter.bump { animation: rushbump 0.25s ease-out; }
@keyframes rushbump { 0% { transform: translate(-50%, -50%) scale(1.3); } 100% { transform: translate(-50%, -50%) scale(1); } }

/* せいざの え（ゆびで ほしを つなぐ）。ゲームの うえ・HUD の した（DOM の じゅんばんで かさなる） */
.draw-board { position: fixed; inset: 0; touch-action: none; }
.draw-board canvas { position: absolute; left: 0; top: 0; animation: boardin 0.35s cubic-bezier(.2, 1.3, .4, 1); transform-origin: 50% 40%; }
.draw-board.leave canvas { animation: boardout 0.75s ease-in forwards; }
@keyframes boardin { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes boardout { 0% { transform: scale(1); opacity: 1; } 100% { transform: translateY(-38%) scale(0.35); opacity: 0; } }

/* R43：せいざの えの あいだは ボタンを かくす（えの わくに かからない。えは ゆびで かく） */
#hud.drawing #formBtn, #hud.drawing #attackBtn, #hud.drawing #specialBtn { visibility: hidden; }
