/* ===== カラーパレット & フォント（Phase 5：きらきらパステル） ===== */
:root {
  /* メインカラー：ピンク〜マゼンタ */
  --color-primary:        #ff4a99;
  --color-primary-light:  #ffb3d1;
  --color-primary-dark:   #c8267a;

  /* サブカラー：パステル */
  --color-lavender: #c8a4ff;
  --color-skyblue:  #a0d8ff;
  --color-mint:     #b8f2d8;
  --color-lemon:    #fff5a0;

  /* アクセント */
  --color-gold:   #ffd700;
  --color-silver: #e0e0f0;

  /* テキスト */
  --color-text:        #4a3568;  /* 深い紫 */
  --color-text-light:  #8a7aa8;
  --color-text-on-primary: #ffffff;

  /* グラデーション */
  --gradient-bg:        linear-gradient(180deg, #ffe4f1 0%, #f3d9ff 50%, #d4f1ff 100%);
  --gradient-primary:   linear-gradient(135deg, #ff8ec7 0%, #c8a4ff 100%);
  --gradient-button:    linear-gradient(180deg, #ff6fb5 0%, #ff4a99 100%);
  --gradient-magic:     linear-gradient(135deg, #ffd700 0%, #ff8ec7 50%, #c8a4ff 100%);

  /* フォント */
  --font-display: 'Mochiy Pop One', 'M PLUS Rounded 1c', "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --font-body:    'M PLUS Rounded 1c', "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

/* ===== Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  /* dvh で iOS Safari のツールバー伸縮にも追従。古いブラウザは vh にフォールバック */
  height: 100vh;
  height: 100dvh;
}
body {
  height: 100%;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
  background: var(--gradient-bg);
  background-attachment: fixed;
}

/* ===== 背景キラキラ装飾 ===== */
.bg-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
/* スパークル基本（位置・サイズ・delay/durationは JS でインライン設定） */
.sparkle {
  position: absolute;
  pointer-events: none;
  line-height: 1;
  animation: twinkle 4s ease-in-out infinite;
  will-change: transform, opacity;
}
/* 丸タイプ：背景色 + glow */
.sparkle.circle { border-radius: 50%; }
.sparkle.circle.white { background: #ffffff; box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.85); }
.sparkle.circle.gold  { background: #fff2a8; box-shadow: 0 0 8px 2px rgba(255, 215, 100, 0.8); }
.sparkle.circle.pink  { background: #ffd6e8; box-shadow: 0 0 8px 2px rgba(255, 180, 220, 0.8); }
/* 星タイプ：Unicode文字 + text-shadow で発光 */
.sparkle.star {
  display: inline-block;
  font-weight: normal;
  text-align: center;
}
.sparkle.star.white { color: #ffffff; text-shadow: 0 0 6px rgba(255, 255, 255, 0.95), 0 0 10px rgba(255, 255, 255, 0.6); }
.sparkle.star.gold  { color: #ffe680; text-shadow: 0 0 6px rgba(255, 215, 100, 0.95), 0 0 10px rgba(255, 215, 100, 0.6); }
.sparkle.star.pink  { color: #ffc6dc; text-shadow: 0 0 6px rgba(255, 180, 220, 0.95), 0 0 10px rgba(255, 180, 220, 0.6); }

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .sparkle { animation: none; opacity: 0.7; }
}

/* #app の z-index は既存ブロックで設定済み（下記） */

#app {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}

/* ===== Screen ===== */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  padding: 20px;
  flex-direction: column;
  overflow: hidden; /* 各画面はレイアウト範囲内に収める */
}
.screen.active {
  display: flex;
  animation: screen-in 0.25s ease-out;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.screen-header h2 {
  font-family: var(--font-display);
  font-weight: normal; /* Mochiy Pop One はウェイト固定 */
  /* 画面幅に応じて自動調整：1.05rem 〜 1.5rem */
  font-size: clamp(1.05rem, 4.6vw, 1.5rem);
  flex: 1;
  min-width: 0;                /* flex 子で text-overflow を効かせるために必須 */
  text-align: center;
  padding-right: 74px;         /* 戻るボタン分のオフセット（視覚的中央寄せ） */
  color: var(--color-primary-dark);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 2px 4px rgba(200, 80, 160, 0.15);
  /* 日本語タイトルは原則 1 行：改行可能位置（空白）以外では折り返さない。
     仮に幅が足りなくても末尾省略でクリーンに収める */
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* ===== Buttons ===== */
.btn {
  display: block;
  width: 100%;
  padding: 16px 18px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.3rem;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: translateY(3px); }

/* プライマリ：濃いピンクグラデ + 上部グロス */
.btn-primary {
  background: linear-gradient(180deg, #ff7ab6 0%, #ff4a99 60%, #e6338a 100%);
  color: #fff;
  padding: 20px 18px;
  font-size: 1.5rem;
  box-shadow:
    0 5px 0 #b01f6b,
    0 10px 22px rgba(200, 40, 120, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 2px 3px rgba(150, 30, 90, 0.45);
}
.btn-primary::after {
  content: '';
  position: absolute;
  top: 10%;
  left: 12%;
  width: 45%;
  height: 36%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
}
.btn-primary:active {
  box-shadow:
    0 1px 0 #b01f6b,
    0 4px 10px rgba(200, 40, 120, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

/* サブ：白〜淡ピンクのグラデ + ピンク縁取り */
.btn-sub {
  background: linear-gradient(180deg, #ffffff 0%, #ffeaf3 100%);
  color: var(--color-primary-dark);
  border: 3px solid var(--color-primary-light);
  padding: 14px 18px;
  font-size: 1.15rem;
  box-shadow:
    0 3px 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.btn-sub:active {
  box-shadow:
    0 1px 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* 戻るボタン：ピル型 */
.btn-back {
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid var(--color-primary-light);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-primary-dark);
  font-weight: 700;
  cursor: pointer;
  padding: 6px 12px;
}
.btn-back:active { transform: scale(0.95); background: rgba(255, 234, 243, 0.9); }

/* ===== ホーム画面 ===== */
#screen-home {
  justify-content: center;
  align-items: center;
  text-align: center;
}
.title {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 3.2rem;
  line-height: 1.05;
  margin-bottom: 44px;
  background: linear-gradient(180deg, #ffb3d9 0%, #ff4a99 45%, #c8267a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 6px 14px rgba(200, 38, 122, 0.35));
  position: relative;
  animation: title-bob 3.8s ease-in-out infinite;
}
@keyframes title-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.title::before,
.title::after {
  position: absolute;
  font-size: 1.8rem;
  color: var(--color-gold);
  -webkit-text-fill-color: var(--color-gold);
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.85));
  animation: sparkle-spin 4s linear infinite;
}
.title::before { content: '✨'; top: -6px; left: -22px; }
.title::after  { content: '✨'; bottom: -4px; right: -22px; animation-delay: -2s; animation-direction: reverse; }
@keyframes sparkle-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.menu {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== モード選択 ===== */
.mode-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 4px 2px 8px;
}
.mode-card {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  padding: 14px 16px 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  color: var(--color-text);
  box-shadow:
    0 6px 16px rgba(200, 80, 160, 0.18),
    inset 0 0 24px rgba(255, 255, 255, 0.28);
  transition: transform 0.1s, box-shadow 0.15s;
}
.mode-card:active {
  transform: scale(0.98);
  box-shadow: 0 3px 8px rgba(200, 80, 160, 0.2);
}
/* 上部の光沢ハイライト */
.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  border-radius: 19px 19px 0 0;
}
/* レベルごとのジュエルカラー */
.mode-card[data-level="1"] { background: linear-gradient(135deg, #ffc6dc 0%, #ff9dc3 100%); } /* ピンク */
.mode-card[data-level="2"] { background: linear-gradient(135deg, #b7e2ff 0%, #82c3f0 100%); } /* 水色 */
.mode-card[data-level="3"] { background: linear-gradient(135deg, #c6f3df 0%, #8adfba 100%); } /* 薄い緑 */
.mode-card[data-level="4"] { background: linear-gradient(135deg, #dcdce5 0%, #a5a5b3 100%); } /* グレー */
.mode-card[data-level="5"] { background: linear-gradient(135deg, #ffe98f 0%, #ffc94a 100%); } /* 黄 */

.mode-card-title {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.45rem;
  color: var(--color-primary-dark);
  margin-bottom: 2px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
}
.mode-card-desc {
  font-size: 0.88rem;
  color: rgba(74, 53, 104, 0.85);
  margin-bottom: 8px;
  font-weight: 700;
  line-height: 1.3;
}
.mode-card-best {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 3px 12px;
  color: var(--color-text);
  white-space: nowrap;
  max-width: 100%;
}
.mode-card-best .best-star {
  display: inline-block;
  margin-right: 4px;
  color: var(--color-gold);
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.7);
}
.mode-card-best strong {
  color: var(--color-primary-dark);
  font-weight: normal;
  font-family: var(--font-display);
  margin-left: 2px;
  font-size: 1.05em;
}

/* 「間違えた問題に挑戦」バッジ（モード選択カード内、右下に配置） */
.mode-retry-badge {
  display: block;
  margin-top: 10px;
  padding: 8px 14px;
  width: 100%;
  background: linear-gradient(180deg, #fff7d6 0%, #ffd96b 100%);
  border: 2px solid #ffb84d;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.92rem;
  color: #8b4a1a;
  cursor: pointer;
  text-align: center;
  box-shadow:
    0 2px 0 #c87b1a,
    0 4px 10px rgba(255, 184, 77, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
  position: relative;
  z-index: 1;
}
.mode-retry-badge:active {
  transform: translateY(1px);
  box-shadow:
    0 0 0 #c87b1a,
    0 2px 6px rgba(255, 184, 77, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ===== プレイ画面 ===== */
#screen-play {
  padding: 14px;
}
/* マスコット用の常時確保スペース（プレイ画面専用）
   画面高さに応じて clamp で動的調整。最小75pxで小型端末も保証 */
.play-mascot-zone {
  flex-shrink: 0;
  height: 105px;                       /* フォールバック値 */
  height: clamp(75px, 13vh, 130px);    /* モダンブラウザでは画面高に追従 */
  margin-top: -6px;
  pointer-events: none;
}
/* ヘッダー：ガラス風、ピンク枠 */
.play-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(6px, 2vw, 10px);
  padding: clamp(5px, 1.6vw, 8px) clamp(8px, 3vw, 14px);
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid var(--color-primary-light);
  border-radius: 18px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(200, 80, 160, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.play-progress {
  color: var(--color-text-light);
  font-size: clamp(0.82rem, 2.8vw, 1rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  word-break: keep-all;
  /* 中央配置：左右の要素より優先度を下げて潰さない */
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
}
.play-timer {
  font-family: var(--font-display);
  font-weight: normal;
  color: var(--color-primary);
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  flex-shrink: 0;
}

/* やめるボタン：控えめな警告色 */
.btn-quit {
  background: linear-gradient(180deg, #fff 0%, #ffe6e6 100%);
  border: 2px solid #ff9bb0;
  color: #e03a6f;
  padding: clamp(5px, 1.5vw, 6px) clamp(8px, 2.8vw, 14px);
  font-family: var(--font-body);
  font-size: clamp(0.78rem, 2.6vw, 0.88rem);
  font-weight: 900;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(224, 58, 111, 0.18);
  white-space: nowrap;
  word-break: keep-all;
  flex-shrink: 0;
}
.btn-quit:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(224, 58, 111, 0.18); }

/* やめる + いちじていし のボタングループ（ヘッダー左端） */
.play-header-actions {
  display: flex;
  gap: clamp(4px, 1.5vw, 6px);
  align-items: center;
  flex-shrink: 0;
}

/* いちじていしボタン：やめると統一感のある形だが配色は青系で対比 */
.btn-pause {
  background: linear-gradient(180deg, #ffffff 0%, #e6f0ff 100%);
  border: 2px solid #9bbcff;
  color: #2962a8;
  padding: clamp(5px, 1.5vw, 6px) clamp(8px, 2.5vw, 12px);
  font-family: var(--font-body);
  font-size: clamp(0.78rem, 2.6vw, 0.88rem);
  font-weight: 900;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(58, 110, 224, 0.18);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  word-break: keep-all;
  flex-shrink: 0;
}
.btn-pause:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(58, 110, 224, 0.18);
}
.btn-pause-icon { font-size: 0.95em; line-height: 1; }

/* 約400px 以下では「いちじていし」ラベルを隠してアイコン⏸のみに（ヘッダー混雑回避） */
@media (max-width: 410px) {
  .btn-pause-label { display: none; }
  .btn-pause-icon  { font-size: 1.15em; }
}

/* いちじていし オーバーレイ（プレイ中に画面全体を覆う） */
.pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(255, 228, 241, 0.92) 0%, rgba(243, 217, 255, 0.92) 50%, rgba(212, 241, 255, 0.92) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: pause-fade-in 0.2s ease-out;
}
.pause-overlay.hidden { display: none; }
@keyframes pause-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.pause-overlay-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 240, 248, 0.88) 100%);
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  box-shadow:
    0 10px 30px rgba(200, 80, 160, 0.25),
    0 0 30px rgba(255, 215, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
  animation: pop-in 0.35s ease-out;
}

.pause-overlay-icon {
  font-size: clamp(2.6rem, 12vw, 4rem);
  line-height: 1;
  color: var(--color-primary-dark);
  text-shadow: 0 2px 0 #fff, 0 4px 12px rgba(200, 38, 122, 0.3);
}

.pause-overlay-text {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.4rem, 6.5vw, 2rem);
  background: linear-gradient(180deg, #ff8ec7 0%, #ff4a99 50%, #c8267a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 4px 10px rgba(200, 38, 122, 0.25));
  text-align: center;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.2;
}

.pause-resume-btn {
  width: auto;
  min-width: 220px;
  padding: 18px 36px;
  font-size: 1.4rem;
}

/* 問題エリア：内容に合わせた高さ（content-sized）。numpad に残りスペースを譲る */
.question-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(10px, 2.5vh, 22px);
  padding: clamp(8px, 1.5vh, 16px) 0;
}
.question {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 2.4rem;                    /* fallback */
  font-size: clamp(1.9rem, 5vh, 3.4rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #6e4f9e 0%, #4a3568 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.9)) drop-shadow(0 4px 10px rgba(74, 53, 104, 0.2));
}

/* 回答表示：パステル枠＋内側グロー */
.answer-display {
  min-height: 60px;                     /* fallback */
  min-height: clamp(50px, 8vh, 72px);
  min-width: 200px;
  padding: clamp(6px, 1.2vh, 10px) 24px;
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  border: 3px solid var(--color-primary-light);
  border-radius: 18px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 2rem;                      /* fallback */
  font-size: clamp(1.6rem, 4vh, 2.4rem);
  text-align: center;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 4px 14px rgba(255, 74, 153, 0.2),
    inset 0 0 18px rgba(255, 179, 209, 0.25);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.answer-display.wrong {
  background: linear-gradient(180deg, #ffe0e0 0%, #ffc0c0 100%);
  border-color: #ff5a5a;
  color: #d63030;
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}

/* ===== 数字パッド ===== */
/* flex:1 で残りの縦スペースを全て使い、grid-rows で 4 段に均等分割 */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0; /* flex item が縮小可能になる重要な指定 */
}
.numpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;                  /* グリッドセル高さに追従させる */
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.4rem;            /* fallback */
  font-size: clamp(1rem, 3.2vh, 1.7rem);
  color: var(--color-primary-dark);
  background: linear-gradient(180deg, #ffffff 0%, #ffeaf3 100%);
  border: 2px solid var(--color-primary-light);
  border-radius: 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 3px 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.06s, box-shadow 0.06s, background 0.1s;
}
/* 上部の光沢 */
.numpad-btn::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 12%;
  right: 12%;
  height: 30%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 40% 40% 60% 60% / 100% 100% 0 0;
  pointer-events: none;
}
.numpad-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, #fff0f6 0%, #ffd6e8 100%);
}
/* C（クリア）：赤系 */
.numpad-clear {
  background: linear-gradient(180deg, #fff0f0 0%, #ffd4d4 100%);
  border-color: #ff9bb0;
  color: #d63030;
  box-shadow:
    0 3px 0 rgba(214, 48, 48, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.numpad-clear:active {
  box-shadow:
    0 1px 0 rgba(214, 48, 48, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, #ffdada 0%, #ffb8b8 100%);
}
/* けってい：ミントグリーン */
.numpad-enter {
  background: linear-gradient(180deg, #b8f2d8 0%, #6fd4a5 55%, #4abf8b 100%);
  border-color: #6fd4a5;
  color: #fff;
  font-size: 1.05rem;            /* fallback */
  font-size: clamp(0.85rem, 2.5vh, 1.25rem);
  text-shadow: 0 1px 2px rgba(30, 110, 70, 0.35);
  box-shadow:
    0 3px 0 #3a9a6e,
    0 6px 14px rgba(74, 191, 139, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.numpad-enter:active {
  box-shadow:
    0 1px 0 #3a9a6e,
    0 3px 8px rgba(74, 191, 139, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ===== コレクション画面 ===== */
/* 統計表示：あつめた数 */
.collection-stats {
  text-align: center;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.3rem;
  color: var(--color-primary-dark);
  margin-bottom: 14px;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}
.collection-stats strong {
  color: var(--color-primary);
  font-family: var(--font-display);
  font-weight: normal;
  margin: 0 4px;
}
.collection-stats .stats-sep {
  color: var(--color-text-light);
  margin: 0 2px;
}

.collection-grid {
  display: grid;
  /* minmax(0, 1fr) にして画像の intrinsic サイズがトラック幅を押し広げるのを防ぐ */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  align-content: start;
  padding: 4px 2px 8px;
}

/* コレクションセクション見出し */
.collection-section-heading {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  font-weight: 700;
  color: #b0a090;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding: 12px 4px 6px;
  margin-top: 4px;
}
.collection-section-heading:first-child {
  margin-top: 0;
}
.collection-section-heading .section-count {
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 6px;
  opacity: 0.75;
}

/* コレクションケース：獲得済みは金色、未獲得は淡いグレー */
.collection-cell {
  position: relative;
  border-radius: 18px;
  padding: 10px 8px 8px;
  text-align: center;
  transition: transform 0.15s;
}
.collection-cell::before {
  /* 上部光沢 */
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 15px 15px 0 0;
  pointer-events: none;
}
.collection-cell.owned {
  background: linear-gradient(180deg, #fff9dc 0%, #ffe896 60%, #ffd855 100%);
  border: 3px solid #ffd700;
  box-shadow:
    0 4px 14px rgba(255, 184, 77, 0.45),
    0 0 18px rgba(255, 215, 0, 0.35),
    inset 0 0 20px rgba(255, 255, 255, 0.3);
}
.collection-cell.owned::after {
  /* 獲得済みマーク（右上に✨） */
  content: '✨';
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 1.1rem;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.9));
  animation: sparkle-spin 5s linear infinite;
}
.collection-cell.locked {
  background: linear-gradient(180deg, #efeaf0 0%, #d9d2dc 100%);
  border: 3px solid #c8bfd0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 画像エリア：全レア度で固定サイズ（正方形）。内部の画像サイズだけレア度で変える */
.collection-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.collection-img {
  /* デフォルトは画像エリアを100%埋める（☆3以上で採用） */
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* レア度別：画像エリア内での描画サイズを変えて余白で階層感を出す
   （セル枠・名前サイズ・名前位置は全レア度で同一） */
.collection-cell.rarity-1 .collection-img { width: 65%; height: 65%; }
.collection-cell.rarity-2 .collection-img { width: 82%; height: 82%; }
.collection-cell.rarity-3 .collection-img { width: 100%; height: 100%; }
.collection-cell.rarity-4 .collection-img { width: 100%; height: 100%; }
.collection-cell.rarity-5 .collection-img { width: 100%; height: 100%; }

/* ===== 獲得回数オーラ（3以上=銀、9以上=金） ===== */
/* オーラは「中心から外へ広がる放射波」で表現。::before と ::after の2本を
   半周期ズラして連続波紋にする。キャラ本体の明滅は控えめ。 */

/* キャラ画像をオーラより手前に重ねる（オーラ z:0、画像 z:1、星 z:2） */
.collection-img-wrap {
  position: relative;
  z-index: 1;
}

/* ===== 背景マトリクス：レア度 × 獲得回数ステージ =====
   - ベース背景は .owned.rarity-X で決定（銅・銀ステージ共通）
   - 金ステージ（count>=9）は全レア度で虹色グラデに上書き */

/* ベース背景：獲得済みの銅・銀ステージ（未獲得 .locked は従来のグレーを維持） */
.collection-cell.owned.rarity-1 { background: #ffffff; }
.collection-cell.owned.rarity-2 { background: #fff8e0; }
.collection-cell.owned.rarity-3 { background: #fff0b0; }
/* ☆4：濃いゴールドの放射グラデ（中心明るく外側深く） */
.collection-cell.owned.rarity-4 {
  background: radial-gradient(circle at 30% 30%,
    #fff7c0 0%, #ffd86b 30%, #ffb84d 70%, #d68a2a 100%);
}
/* ☆5：虹色グラデが一目で判別できるビビッドな彩度に。
   中央に薄い白の放射グラデを重ねてキャラの視認性を確保（2層background） */
.collection-cell.owned.rarity-5 {
  background:
    radial-gradient(circle at center,
      rgba(255, 255, 255, 0.65) 0%,
      rgba(255, 255, 255, 0.30) 38%,
      transparent 72%),
    linear-gradient(135deg,
      #ff5ea6 0%,    /* ピンク */
      #ff9b3a 17%,   /* オレンジ */
      #ffd24d 33%,   /* イエロー */
      #58d275 50%,   /* グリーン */
      #52a8f5 67%,   /* ブルー */
      #a86bff 83%,   /* パープル */
      #ff5ea6 100%   /* ピンクに戻る */
    );
  background-size: 100% 100%, 200% 200%;
  background-repeat: no-repeat;
  animation: holographic-shift 5s ease-in-out infinite;
}
@keyframes holographic-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ===== 銀ステージ：控えめな演出（背景色はベースのまま） ===== */
/* セル全体に軽い銀のグローと影 */
.collection-cell.stage-silver {
  box-shadow:
    0 0 0 2px rgba(200, 220, 255, 0.6),
    0 4px 20px rgba(180, 200, 255, 0.4),
    inset 0 0 20px rgba(220, 235, 255, 0.3);
  border-color: rgba(200, 220, 255, 0.7);
}

/* キャラ本体：控えめに浮遊（金より弱め、2pxだけ） */
.collection-cell.stage-silver .collection-img {
  animation: float-silver-soft 3.5s ease-in-out infinite;
}
@keyframes float-silver-soft {
  0%, 100% {
    transform: translateY(0);
    filter: brightness(1);
  }
  50% {
    transform: translateY(-2px);
    filter: brightness(1.05) drop-shadow(0 4px 8px rgba(180, 200, 255, 0.5));
  }
}

/* 粒子：銀白色の星 8個、14px、text-shadowでグロー（配置とkeyframeは下の粒子セクションで定義） */
.collection-cell.stage-silver .sparkle-dot {
  font-size: 14px;
  color: #a0c5ff;
  text-shadow:
    0 0 4px #fff,
    0 0 8px rgba(200, 220, 255, 0.8);
  animation: sparkle-blink-silver 2.5s ease-in-out infinite;
}

/* 金ステージ：虹色グラデが流動。ただし ☆4/☆5 はそれぞれの特別背景を維持するためスコープ除外 */
.collection-cell.stage-gold:not(.rarity-4):not(.rarity-5) {
  background: linear-gradient(135deg,
    #ffccee 0%,
    #fff2c0 20%,
    #d4f0d4 40%,
    #c8e0ff 60%,
    #e0c8ff 80%,
    #ffccee 100%
  ) !important;
  background-size: 200% 200%;
  animation: rainbow-flow 6s ease-in-out infinite;
}
.collection-cell.stage-gold { border-color: #ffd700; }
/* ☆4/☆5 の金ステージは追加の発光で豪華さアップ（背景はレア度ベースを維持） */
.collection-cell.stage-gold.rarity-4 {
  box-shadow:
    0 0 0 2px rgba(255, 215, 0, 0.7),
    0 6px 26px rgba(255, 184, 77, 0.6),
    0 0 40px rgba(255, 215, 0, 0.45);
}
.collection-cell.stage-gold.rarity-5 {
  box-shadow:
    0 0 0 2px rgba(255, 200, 240, 0.8),
    0 6px 30px rgba(200, 130, 255, 0.55),
    0 0 50px rgba(255, 200, 240, 0.5);
}
@keyframes rainbow-flow {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* 金ステージだけキャラが浮遊（6px） */
.collection-cell.stage-gold .collection-img {
  animation: float-gold 2.5s ease-in-out infinite;
}
@keyframes float-gold {
  0%, 100% {
    transform: translateY(0);
    filter: brightness(1) drop-shadow(0 4px 4px rgba(0, 0, 0, 0.10));
  }
  50% {
    transform: translateY(-6px);
    filter: brightness(1.1) drop-shadow(0 10px 8px rgba(0, 0, 0, 0.12));
  }
}

/* ===== キラキラ粒子（銀ステージ:8個 / 金ステージ:14個） ===== */
.aura-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.sparkle-dot {
  position: absolute;
  display: inline-block;
  line-height: 1;
  opacity: 0;
  text-align: center;
  /* サイズ（font-size）・色・アニメは stage-silver / stage-gold で個別指定 */
}
/* 星型の文字を ::before で挿入。デフォルト ★ に加えて 3個ごとに ✦ / ✧ を混在 */
.sparkle-dot::before            { content: '★'; display: inline-block; }
.sparkle-dot:nth-child(3n+1)::before { content: '✦'; }
.sparkle-dot:nth-child(3n+2)::before { content: '✧'; }

/* --- 銀ステージ：8個の位置と delay、強めの明滅 --- */
.collection-cell.stage-silver .sparkle-dot:nth-child(1) { top: 10%; left: 20%; animation-delay: 0s;   }
.collection-cell.stage-silver .sparkle-dot:nth-child(2) { top: 15%; left: 80%; animation-delay: 0.3s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(3) { top: 40%; left: 10%; animation-delay: 0.6s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(4) { top: 45%; left: 90%; animation-delay: 0.9s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(5) { top: 70%; left: 25%; animation-delay: 1.2s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(6) { top: 75%; left: 75%; animation-delay: 1.5s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(7) { top: 55%; left: 50%; animation-delay: 1.8s; }
.collection-cell.stage-silver .sparkle-dot:nth-child(8) { top: 30%; left: 50%; animation-delay: 2.1s; }
@keyframes sparkle-blink-silver {
  0%, 100% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.5) rotate(180deg);
  }
}

/* --- 金ステージ：14個の星、18px、虹色サイクル、回転付き超派手な明滅 --- */
.collection-cell.stage-gold .sparkle-dot {
  font-size: 18px;
  text-shadow:
    0 0 6px #fff,
    0 0 12px currentColor,
    0 0 20px rgba(255, 215, 0, 0.5);
  animation: sparkle-blink-gold 2s ease-in-out infinite;
}
.collection-cell.stage-gold .sparkle-dot:nth-child(1)  { top: 8%;  left: 15%; animation-delay: 0s;   }
.collection-cell.stage-gold .sparkle-dot:nth-child(2)  { top: 12%; left: 50%; animation-delay: 0.2s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(3)  { top: 10%; left: 85%; animation-delay: 0.4s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(4)  { top: 30%; left: 8%;  animation-delay: 0.6s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(5)  { top: 35%; left: 92%; animation-delay: 0.8s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(6)  { top: 50%; left: 5%;  animation-delay: 1.0s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7)  { top: 55%; left: 95%; animation-delay: 1.2s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(8)  { top: 65%; left: 20%; animation-delay: 1.4s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(9)  { top: 70%; left: 80%; animation-delay: 1.6s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(10) { top: 85%; left: 30%; animation-delay: 1.8s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(11) { top: 88%; left: 60%; animation-delay: 2.0s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(12) { top: 90%; left: 85%; animation-delay: 2.2s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(13) { top: 45%; left: 50%; animation-delay: 2.4s; }
.collection-cell.stage-gold .sparkle-dot:nth-child(14) { top: 25%; left: 65%; animation-delay: 1.1s; }
/* 虹7色サイクル（星の塗り色のみ） */
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+1) { color: #ff6bb5; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+2) { color: #ffc84d; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+3) { color: #ffd700; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+4) { color: #6bc56b; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+5) { color: #6bb5ff; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n+6) { color: #b56bff; }
.collection-cell.stage-gold .sparkle-dot:nth-child(7n)   { color: #ff9b6b; }
@keyframes sparkle-blink-gold {
  0%, 100% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.8) rotate(180deg);
  }
}

/* 動きを減らす設定：背景流動・浮遊・粒子すべて停止 */
@media (prefers-reduced-motion: reduce) {
  .collection-cell.stage-gold { animation: none; background-position: 0% 50%; }
  .collection-cell.stage-gold .collection-img,
  .collection-cell.stage-silver .collection-img { animation: none; transform: none; }
  .sparkle-dot { animation: none; opacity: 0.5; transform: scale(1); }
}
.collection-cell.owned .collection-img {
  filter: drop-shadow(0 3px 6px rgba(180, 120, 30, 0.35));
}
/* 未獲得シルエット：明るくぼかして「光のかたまり」風に */
.collection-cell.locked .collection-img {
  filter: brightness(1.3) contrast(0.3) blur(4px) opacity(0.5);
}

.collection-name {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;
  margin-top: 4px;
  color: var(--color-primary-dark);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}
.collection-cell.locked .collection-name {
  color: #8a7e92;
  font-family: var(--font-body);
  font-weight: 900;
  text-shadow: none;
}

/* ===== 獲得回数の星マーク（コレクション左上＋結果画面） ===== */
/* レアリティごとにサイズを変える：金 > 銀 > 銅 の順に大きく */
.star {
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}
/* コレクション画面のデフォルトサイズ */
.star.bronze {
  font-size: 14px;
  color: #CD7F32;
  text-shadow: 0 0 2px #fff, 0 1px 1px rgba(0, 0, 0, 0.3);
}
.star.silver {
  font-size: 18px;
  color: #C0C0C0;
  text-shadow: 0 0 2px #fff, 0 0 4px rgba(192, 192, 192, 0.6), 0 1px 1px rgba(0, 0, 0, 0.3);
}
.star.gold {
  font-size: 22px;
  color: #FFD700;
  text-shadow: 0 0 2px #fff, 0 0 5px rgba(255, 215, 0, 0.9), 0 1px 1px rgba(0, 0, 0, 0.3);
  animation: star-gold-glow 2.2s ease-in-out infinite;
}
@keyframes star-gold-glow {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.25); }
}

/* コレクションセル下部：キャラのレア度表示（結果画面の配色を流用、サイズ小さめ） */
.collection-rarity {
  text-align: center;
  line-height: 1;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.collection-rarity.rarity-1 {
  font-size: 0.9rem;
  color: #CD7F32;
  text-shadow: 0 0 2px #fff, 0 2px 3px rgba(0, 0, 0, 0.3);
}
.collection-rarity.rarity-2 {
  font-size: 1.0rem;
  background: linear-gradient(135deg,
    #e0e0f0 0%, #ffffff 30%, #c0c8ff 60%, #b8a8ff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 3px rgba(192, 200, 255, 0.9))
    drop-shadow(0 0 6px rgba(180, 168, 255, 0.5))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
  animation: silver-shimmer 2.5s ease-in-out infinite;
}
/* ☆3：落ち着いた黄色（ゴールド寄り）+ 軽いグロー（脈動なし） */
.collection-rarity.rarity-3 {
  font-size: 1.1rem;
  color: #ffd24d;
  text-shadow:
    0 0 3px #fff,
    0 0 7px rgba(255, 210, 77, 0.8),
    0 1px 2px rgba(0, 0, 0, 0.25);
}
/* ☆4：レインボー + 脈動（旧☆3の演出を継承） */
.collection-rarity.rarity-4 {
  font-size: 1.2rem;
  background: linear-gradient(90deg,
    #ff4a99 0%,
    #ffb84d 20%,
    #ffd700 40%,
    #7fc55a 60%,
    #a0d8ff 80%,
    #c8a4ff 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 4px rgba(255, 215, 0, 0.85))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  animation:
    rainbow-flow 3s linear infinite,
    star-glow-pulse 1.5s ease-in-out infinite;
}

/* ☆5：レインボーホログラム + 強い発光 + 大きめ脈動 */
.collection-rarity.rarity-5 {
  font-size: 1.3rem;
  background: linear-gradient(90deg,
    #ff4a99 0%, #ffb84d 17%, #ffd700 33%, #7fc55a 50%,
    #a0d8ff 67%, #c8a4ff 83%, #ff4a99 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 5px rgba(255, 215, 0, 0.95))
    drop-shadow(0 0 10px rgba(255, 100, 200, 0.6))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  animation:
    rainbow-flow 2.8s linear infinite,
    star-glow-pulse 1.3s ease-in-out infinite;
}

/* 未獲得は装飾を落ち着かせる */
.collection-cell.locked .collection-rarity {
  opacity: 0.5;
  animation: none;
}

/* コレクションセル左上：横並び折返し＋ベースライン揃え */
.collection-stars {
  position: absolute;
  top: 2px;
  left: 4px;
  right: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center; /* サイズ違いでも縦位置を揃える */
  gap: 1px;
  z-index: 2;
  line-height: 1;
  pointer-events: none;
}

/* ===== ご褒美エリア（結果画面内） =====
   結果画面のFlexboxレイアウトで残りスペースを優先的に占有する */
.reward-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #fffce6 0%, #fff3a8 100%);
  border: 3px solid var(--color-gold);
  border-radius: 24px;
  padding: 14px 20px;
  margin-bottom: 12px;
  box-shadow:
    0 8px 26px rgba(255, 184, 77, 0.4),
    0 0 40px rgba(255, 215, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  animation: pop-in 0.5s ease-out, reward-glow 2.4s ease-in-out infinite 0.5s;
  overflow: visible;
}
.reward-area.hidden { display: none; }
/* 周囲のキラキラ（疑似要素） */
.reward-area::before, .reward-area::after {
  content: '✨';
  position: absolute;
  font-size: 1.6rem;
  color: var(--color-gold);
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
  animation: sparkle-spin 3s linear infinite;
}
.reward-area::before { top: -12px; left: -10px; }
.reward-area::after  { bottom: -6px; right: -8px; animation-delay: -1.5s; animation-direction: reverse; }
@keyframes reward-glow {
  0%, 100% { box-shadow: 0 8px 26px rgba(255, 184, 77, 0.4), 0 0 40px rgba(255, 215, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.7); }
  50%      { box-shadow: 0 8px 26px rgba(255, 184, 77, 0.55), 0 0 60px rgba(255, 215, 0, 0.5),  inset 0 2px 0 rgba(255, 255, 255, 0.7); }
}

/* ===== ☆4 獲得時の特別演出（ゴールド後光） ===== */
.reward-area.rarity-4 {
  background: radial-gradient(circle at center,
    #fffce0 0%, #ffe89a 40%, #ffc54a 80%, #f5a524 100%);
  border-color: #f5a524;
  box-shadow:
    0 8px 30px rgba(255, 184, 77, 0.55),
    0 0 80px rgba(255, 215, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  animation: pop-in 0.5s ease-out, reward-glow-r4 1.8s ease-in-out infinite 0.4s;
}
@keyframes reward-glow-r4 {
  0%, 100% {
    box-shadow:
      0 8px 30px rgba(255, 184, 77, 0.55),
      0 0 80px rgba(255, 215, 0, 0.55),
      inset 0 2px 0 rgba(255, 255, 255, 0.7);
  }
  50% {
    box-shadow:
      0 8px 36px rgba(255, 184, 77, 0.75),
      0 0 110px rgba(255, 215, 0, 0.85),
      inset 0 2px 0 rgba(255, 255, 255, 0.7);
  }
}
.reward-area.rarity-4 .reward-image {
  filter:
    drop-shadow(0 0 18px rgba(255, 215, 0, 1))
    drop-shadow(0 0 32px rgba(255, 184, 77, 0.7))
    drop-shadow(0 6px 14px rgba(180, 120, 30, 0.45));
  animation: chara-float-r4 3s ease-in-out infinite;
}
@keyframes chara-float-r4 {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ===== ☆5 獲得時の究極演出（ホログラム + プリズム後光） ===== */
.reward-area.rarity-5 {
  background: linear-gradient(135deg,
    #ffd4f0, #fff2c0, #d0f0d0, #c8e0ff, #e8d0ff, #ffd4f0);
  background-size: 200% 200%;
  border-color: rgba(255, 215, 0, 0.85);
  box-shadow:
    0 0 0 3px rgba(255, 215, 0, 0.6),
    0 8px 40px rgba(200, 100, 200, 0.55),
    0 0 100px rgba(255, 200, 240, 0.6),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  animation:
    pop-in 0.5s ease-out,
    holographic-shift 4s ease-in-out infinite,
    reward-glow-r5 1.5s ease-in-out infinite 0.3s;
}
/* ☆5 の追加プリズム後光：::after 既存の✨を残しつつ、画像の裏に円形の虹光を */
.reward-area.rarity-5 .reward-image {
  position: relative;
  z-index: 1;
}
@keyframes reward-glow-r5 {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(255, 215, 0, 0.6),
      0 8px 40px rgba(200, 100, 200, 0.55),
      0 0 100px rgba(255, 200, 240, 0.6),
      inset 0 2px 0 rgba(255, 255, 255, 0.7);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 215, 0, 0.9),
      0 8px 50px rgba(200, 100, 200, 0.8),
      0 0 140px rgba(255, 200, 240, 0.9),
      inset 0 2px 0 rgba(255, 255, 255, 0.7);
  }
}
.reward-area.rarity-5 .reward-image {
  filter:
    drop-shadow(0 0 18px rgba(255, 200, 240, 1))
    drop-shadow(0 0 32px rgba(200, 100, 200, 0.85))
    drop-shadow(0 0 50px rgba(255, 215, 100, 0.6))
    drop-shadow(0 6px 14px rgba(120, 60, 140, 0.45));
  animation: chara-float-r5 3.6s ease-in-out infinite;
}
@keyframes chara-float-r5 {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  25%      { transform: translateY(-4px) rotate(-2deg); }
  50%      { transform: translateY(-8px) rotate(0deg); }
  75%      { transform: translateY(-4px) rotate(2deg); }
}
.reward-label {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;            /* キャラを主役にするため小さめに */
  color: var(--color-primary-dark);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  margin-bottom: -2px;
}
.reward-image {
  /* reward-area の flex 配下で残りスペースに収まるよう、min-height:0 + max を組み合わせる */
  flex: 0 1 auto;
  min-height: 0;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 200px;                         /* fallback */
  max-height: clamp(110px, 26vh, 220px);
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(200, 150, 40, 0.35));
}
.reward-image.hidden { display: none; }
.reward-name {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.5rem;
  color: var(--color-primary-dark);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

/* レア度星（結果画面の名前下）。レア度ごとに色・演出を切り替えて差別化 */
.reward-stars {
  line-height: 1;
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.1em;
}
.reward-stars.hidden { display: none; }

/* ☆1：ブロンズ、シンプル */
.reward-stars.rarity-1 {
  font-size: 1.8rem;
  color: #CD7F32;
  text-shadow:
    0 0 2px #fff,
    0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ☆2：シルバー〜水色〜紫の微グラデ、強めの発光＋シマーで上品な特別感 */
.reward-stars.rarity-2 {
  font-size: 2.2rem;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg,
    #e0e0f0 0%,
    #ffffff 30%,
    #c0c8ff 60%,
    #b8a8ff 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 4px rgba(192, 200, 255, 0.9))
    drop-shadow(0 0 10px rgba(180, 168, 255, 0.5))
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  animation: silver-shimmer 2.5s ease-in-out infinite;
}

@keyframes silver-shimmer {
  0%, 100% {
    background-position: 0% center;
    transform: scale(1);
  }
  50% {
    background-position: 100% center;
    transform: scale(1.06);
  }
}

/* ☆3：落ち着いた黄色（ゴールド寄り）+ 軽いグロー、脈動なし */
.reward-stars.rarity-3 {
  font-size: 2.5rem;
  letter-spacing: 0.15em;
  color: #ffd24d;
  text-shadow:
    0 0 5px #fff,
    0 0 12px rgba(255, 210, 77, 0.85),
    0 2px 4px rgba(0, 0, 0, 0.25);
}

@keyframes rainbow-flow {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* ☆4：レインボー + 脈動（旧☆3の演出を継承） */
.reward-stars.rarity-4 {
  font-size: 2.7rem;
  letter-spacing: 0.15em;
  background: linear-gradient(90deg,
    #ff4a99 0%,    /* ピンク */
    #ffb84d 20%,   /* オレンジ */
    #ffd700 40%,   /* ゴールド */
    #7fc55a 60%,   /* グリーン */
    #a0d8ff 80%,   /* スカイブルー */
    #c8a4ff 100%   /* ラベンダー */
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 6px rgba(255, 215, 0, 0.85))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  animation:
    rainbow-flow 3s linear infinite,
    star-glow-pulse 1.5s ease-in-out infinite;
}

/* ☆5：レインボーホログラム + 多重発光 + ダイナミック回転 */
.reward-stars.rarity-5 {
  font-size: 2.4rem;
  letter-spacing: 0.16em;
  background: linear-gradient(90deg,
    #ff4a99 0%, #ffb84d 17%, #ffd700 33%, #7fc55a 50%,
    #a0d8ff 67%, #c8a4ff 83%, #ff4a99 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter:
    drop-shadow(0 0 8px rgba(255, 215, 0, 1))
    drop-shadow(0 0 18px rgba(255, 100, 200, 0.85))
    drop-shadow(0 0 28px rgba(160, 200, 255, 0.55))
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
  animation:
    rainbow-flow 2.5s linear infinite,
    reward-stars-r5 1.3s ease-in-out infinite;
}
@keyframes reward-stars-r5 {
  0%, 100% { transform: scale(1)    rotate(0deg);  }
  50%      { transform: scale(1.14) rotate(-6deg); }
}

/* 結果画面：重複獲得時のお星様カウント表示 */
.reward-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.reward-stats.hidden { display: none; }
.reward-stats-label {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1rem;
  color: var(--color-primary-dark);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
  text-align: center;
}
.reward-stats-stars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  max-width: 260px;
}
/* 結果画面ではコレクションより一段大きく表示 */
.reward-stats-stars .star.bronze { font-size: 18px; }
.reward-stats-stars .star.silver { font-size: 22px; }
.reward-stats-stars .star.gold   { font-size: 26px; }

@keyframes star-sparkle {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.07); }
}
@keyframes star-glow-pulse {
  0%, 100% {
    transform: scale(1);
    filter:
      drop-shadow(0 0 6px rgba(255, 215, 0, 1))
      drop-shadow(0 0 12px rgba(255, 184, 77, 0.7));
  }
  50% {
    transform: scale(1.1);
    filter:
      drop-shadow(0 0 10px rgba(255, 215, 0, 1))
      drop-shadow(0 0 20px rgba(255, 184, 77, 1));
  }
}

/* ===== 結果画面 =====
   プレイ画面と同じFlexbox方式で画面高さに収める（縦スクロール禁止）。
   構成: タイトル(固定) / バッジ(固定) / ご褒美(flex:1) / 結果カード(固定) / ボタン(固定) */
#screen-result {
  justify-content: flex-start;
  align-items: center;
  padding: 12px;
  gap: 10px;
  overflow: hidden;
}
.result-title {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 2.6rem;                         /* fallback */
  font-size: clamp(1.4rem, 5.5vh, 2.6rem);
  /* 空白を含むタイトル（例：「○もん れんぞくチャレンジ クリア！」）は
     語句の途中で折れないように、空白でのみ改行する */
  word-break: keep-all;
  overflow-wrap: break-word;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  padding: 0 8px;
  margin-bottom: 0;
  background: linear-gradient(180deg, #ff8ec7 0%, #ff4a99 50%, #c8267a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 5px 10px rgba(200, 38, 122, 0.3));
  animation: pop-in 0.5s ease-out;
}
.result-badge {
  flex-shrink: 0;
  background: linear-gradient(135deg, #ffd700 0%, #ff8ec7 50%, #c8a4ff 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.2rem;
  padding: 10px 24px;
  border-radius: 999px;
  margin-bottom: 0;
  box-shadow:
    0 4px 14px rgba(255, 107, 157, 0.4),
    0 0 24px rgba(255, 215, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 2px 3px rgba(150, 30, 90, 0.4);
  animation: pop-in 0.4s ease-out, badge-pulse 1.8s ease-in-out infinite 0.5s;
}
.result-badge.hidden { display: none; }
@keyframes pop-in {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
/* 結果カード：ガラス風パステル */
.result-card {
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 240, 248, 0.85) 100%);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  padding: 14px 22px;
  margin-bottom: 0;
  box-shadow:
    0 8px 26px rgba(200, 80, 160, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 2px dashed rgba(255, 179, 209, 0.7);
}
.result-row:last-child { border-bottom: none; }
.result-label {
  font-size: 1rem;
  color: var(--color-text-light);
  font-weight: 900;
}
.result-value {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.7rem;
  color: var(--color-primary-dark);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}
.result-actions {
  flex-shrink: 0;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== きろく画面（グラフ） ===== */
#screen-history { padding: 16px; }

.history-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding: 2px 2px 6px;
}
/* ピル型タブ：非アクティブは淡く、アクティブは濃ピンクで浮き上がる */
.history-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.92rem;
  background: linear-gradient(180deg, #ffffff 0%, #ffeaf3 100%);
  border: 2px solid var(--color-primary-light);
  border-radius: 999px;
  color: var(--color-primary-dark);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(255, 74, 153, 0.15);
  transition: transform 0.08s, box-shadow 0.1s;
}
.history-tab:active { transform: translateY(1px); }
.history-tab.active {
  background: linear-gradient(180deg, #ff7ab6 0%, #ff4a99 100%);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow:
    0 3px 0 #b01f6b,
    0 5px 12px rgba(255, 74, 153, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 2px rgba(150, 30, 90, 0.3);
}

.history-note {
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text-light);
  font-weight: 900;
  margin-bottom: 8px;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* グラフカード：ガラス風パステル。グラフ本体は視認性最優先で装飾を抑える */
.history-graph-wrap {
  flex: 1;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  overflow: auto;
  box-shadow:
    0 6px 18px rgba(200, 80, 160, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.history-graph {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* SVG は viewBox = 実コンテナ幅 にして 1:1 描画。height は JS でインライン指定 */
.history-svg {
  display: block;
  width: 100%;
}
.history-svg .grid-line  { stroke: #f3dae8; stroke-width: 1; }
.history-svg .axis-line  { stroke: #a89cb8; stroke-width: 1.5; }
.history-svg .axis-label { fill: #6e5a82; font-family: inherit; }
.history-svg .axis-date  { fill: #8a7aa8; font-family: inherit; }
.history-svg .data-line  { stroke: var(--color-primary); stroke-width: 2.5; fill: none; }
.history-svg .data-point { cursor: pointer; }

.history-empty {
  text-align: center;
  color: var(--color-text-light);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 900;
  padding: 30px 0;
}

.history-delete { margin-top: 10px; flex-shrink: 0; }
.history-delete.hidden { display: none; }

/* ===== 設定画面 ===== */
.settings-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 12px;
}

/* 見出し：ピンクで分類を示す */
.settings-section {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1rem;
  color: var(--color-primary-dark);
  margin: 14px 4px 4px;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}
.settings-section-danger { color: #d63a5e; }

/* 設定項目カード：ガラス風パステル */
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 240, 248, 0.85) 100%);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 10px 14px;
  box-shadow:
    0 3px 10px rgba(200, 80, 160, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.settings-label {
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 900;
  color: var(--color-text);
}

/* ステッパー：ピンク系ボタン */
.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stepper-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--color-primary-light);
  background: linear-gradient(180deg, #fff 0%, #ffeaf3 100%);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow:
    0 2px 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.08s, box-shadow 0.08s;
}
.stepper-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 rgba(255, 74, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, #ffeaf3 0%, #ffd6e8 100%);
}
.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.stepper-value {
  min-width: 70px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.25rem;
  color: var(--color-primary-dark);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* 危険ゾーン */
.settings-danger {
  border-color: #ffb3c0;
  background: linear-gradient(180deg, rgba(255, 240, 240, 0.9) 0%, rgba(255, 220, 228, 0.85) 100%);
  justify-content: center;
  padding: 8px 14px;
}

/* 危険ボタン（履歴画面でも使用） */
.btn-danger {
  background: linear-gradient(180deg, #fff 0%, #ffe0e6 100%);
  color: #d63a5e;
  border: 3px solid #ffa0b3;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.05rem;
  padding: 12px;
  margin: 0;
  border-radius: 18px;
  cursor: pointer;
  box-shadow:
    0 3px 0 rgba(214, 58, 94, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.btn-danger:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 rgba(214, 58, 94, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, #ffe6ec 0%, #ffc8d3 100%);
}

/* ===== 「間違えた問題に挑戦」リトライ結果画面 ===== */
/* リトライ結果画面：タイトル・もらえたカード・ミニゲーム・ボタンを画面内に収める */
#screen-retry-result {
  justify-content: flex-start;
  align-items: center;
  padding: 12px;
  gap: 10px;
  overflow: hidden;
}
#screen-retry-result .result-title { flex-shrink: 0; }

.retry-rewards-block {
  flex-shrink: 0;
  width: 100%;
  max-width: 400px;
  margin-bottom: 0;
  text-align: center;
}
.retry-rewards-label {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.15rem;
  color: var(--color-primary-dark);
  margin-bottom: 10px;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}
.retry-cards-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.reward-card-mini {
  width: 130px;
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  border: 3px solid var(--color-primary-light);
  border-radius: 18px;
  padding: 10px 8px 12px;
  box-shadow: 0 4px 14px rgba(200, 80, 160, 0.18);
  text-align: center;
  animation: pop-in 0.4s ease-out;
}
.reward-card-mini img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}
.reward-card-mini-name {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;
  color: var(--color-primary-dark);
  margin-top: 4px;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* ===== ミニゲーム（3枚から1枚選ぶ） ===== */
.retry-minigame-block {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin-bottom: 0;
}
.minigame-prompt {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.15rem;
  color: var(--color-primary-dark);
  margin-bottom: 12px;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}
.minigame-cards {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.minigame-card {
  width: 100px;
  aspect-ratio: 0.72;
  border-radius: 14px;
  border: 3px solid #fff;
  cursor: pointer;
  font-family: var(--font-display);
  position: relative;
  overflow: hidden;
  padding: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.minigame-card.face-down {
  background: linear-gradient(135deg,
    var(--color-primary) 0%,
    var(--color-lavender) 100%);
  color: #fff;
  font-size: 2.2rem;
  box-shadow: 0 4px 14px rgba(200, 80, 160, 0.35);
  animation: minigame-bob 1.6s ease-in-out infinite;
}
.minigame-card.face-down:active { transform: translateY(2px) scale(0.98); }
.minigame-card.face-down:hover { box-shadow: 0 6px 18px rgba(200, 80, 160, 0.45); }
@keyframes minigame-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

.minigame-card.revealed {
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  animation: card-flip 0.5s ease-out;
  cursor: default;
  padding: 6px;
}
.minigame-card.revealed.chosen {
  border-color: #ffd700;
  box-shadow:
    0 0 0 3px rgba(255, 215, 0, 0.6),
    0 6px 18px rgba(255, 184, 77, 0.5);
}
/* ☆4 がミニゲームで当たった時：強烈な金グロー */
.minigame-card.revealed.chosen.rarity-4 {
  border-color: #ffd700;
  box-shadow:
    0 0 0 3px rgba(255, 215, 0, 0.85),
    0 6px 24px rgba(255, 184, 77, 0.75),
    0 0 50px rgba(255, 215, 0, 0.6);
  animation: card-flip 0.5s ease-out, reward-glow-r4 1.8s ease-in-out infinite 0.5s;
}
/* ☆5 がミニゲームで当たった時：レインボーホログラム + 多重発光 */
.minigame-card.revealed.chosen.rarity-5 {
  border-color: rgba(255, 215, 0, 0.9);
  background: linear-gradient(135deg,
    #ffd4f0, #fff2c0, #d0f0d0, #c8e0ff, #e8d0ff, #ffd4f0);
  background-size: 200% 200%;
  box-shadow:
    0 0 0 3px rgba(255, 215, 0, 0.85),
    0 6px 28px rgba(200, 100, 200, 0.7),
    0 0 60px rgba(255, 200, 240, 0.7);
  animation:
    card-flip 0.5s ease-out,
    holographic-shift 4s ease-in-out infinite,
    reward-glow-r5 1.5s ease-in-out infinite 0.5s;
}
.minigame-card.revealed img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}
.minigame-card-name {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.78rem;
  color: var(--color-primary-dark);
  margin-top: 2px;
  text-align: center;
  line-height: 1.1;
}
@keyframes card-flip {
  0%   { transform: rotateY(180deg) scale(0.8); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1);     opacity: 1; }
}

/* ミニゲーム/リワード内のレア度星：既存 .collection-rarity を流用するが
   サイズだけ若干調整 */
.reward-card-mini .collection-rarity { font-size: 0.9rem; margin-top: 2px; }
.minigame-card .collection-rarity { font-size: 0.85rem; margin-top: 1px; }

/* ===== キャラ拡大モーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 53, 104, 0.78);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modal-fade-in 0.2s ease-out;
}
.modal-overlay.hidden { display: none; }
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 1.6rem;
  font-family: var(--font-display);
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.modal-close:active { transform: scale(0.95); }

.modal-card-wrap {
  width: 80vw;
  max-width: 340px;
  animation: pop-in 0.4s ease-out;
}

/* モーダル内の collection-cell：通常セルより大きく */
.modal-card-wrap .collection-cell {
  cursor: default;
  padding: 24px 20px;
  border-radius: 28px;
  border-width: 4px;
}
.modal-card-wrap .collection-name {
  font-size: 1.5rem;
  margin-top: 16px;
}
.modal-card-wrap .collection-rarity { margin-top: 12px; }
.modal-card-wrap .collection-rarity.rarity-1 { font-size: 1.6rem; }
.modal-card-wrap .collection-rarity.rarity-2 { font-size: 1.8rem; }
.modal-card-wrap .collection-rarity.rarity-3 { font-size: 2.2rem; }

/* 獲得回数の星をモーダル内では大きく表示 */
.modal-card-wrap .collection-stars {
  top: 10px;
  left: 10px;
  gap: 2px;
}
.modal-card-wrap .collection-stars .star.bronze { font-size: 18px; }
.modal-card-wrap .collection-stars .star.silver { font-size: 22px; }
.modal-card-wrap .collection-stars .star.gold   { font-size: 26px; }

/* スクロールロック */
body.modal-open { overflow: hidden; }

/* ===== シマエナガマスコット ===== */
/* 位置：画面右上寄りに固定。
   プレイ画面では .play-mascot-zone がヘッダー直下にスペースを確保しているので
   マスコットはそのゾーン内に収まる。他画面は画面上部なので右寄せでも支障が少ない */
.mascot {
  position: fixed;
  top: 70px;
  right: 8px;
  z-index: 500;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}
.mascot.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.mascot-img {
  width: 100px;                                     /* fallback */
  width: clamp(70px, 12vh, 120px);
  height: 100px;                                    /* fallback */
  height: clamp(70px, 12vh, 120px);
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
}
.mascot-bubble {
  position: relative;
  background: #fff;
  border: 2px solid var(--color-primary-light);
  border-radius: 14px;
  padding: 7px 10px;                                /* fallback */
  padding: clamp(6px, 1.2vh, 9px) clamp(8px, 2vw, 12px);
  font-family: var(--font-body);
  font-size: 0.86rem;                               /* fallback */
  font-size: clamp(0.78rem, 2vh, 0.95rem);
  color: var(--color-text);
  font-weight: 900;
  max-width: 150px;                                 /* fallback */
  max-width: clamp(120px, 35vw, 170px);
  min-width: 70px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(200, 80, 160, 0.22);
  line-height: 1.3;
}
/* 吹き出しの三角（先端がマスコット＝右側を指す） */
.mascot-bubble::after {
  /* 枠色の三角（外側） */
  content: '';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 12px solid var(--color-primary-light);
}
.mascot-bubble::before {
  /* 白い三角（内側、外側の三角の上に重ねる） */
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid #fff;
  z-index: 1;
}

/* 動きを減らす設定 */
@media (prefers-reduced-motion: reduce) {
  .mascot { transition: opacity 0.2s ease; transform: none; }
  .mascot.visible { transform: none; }
}

/* ===== 設定画面：ON/OFF トグル ===== */
.settings-toggle {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;
  padding: 6px 18px;
  border-radius: 999px;
  border: 2px solid var(--color-primary-light);
  background: linear-gradient(180deg, #fff 0%, #ffeaf3 100%);
  color: var(--color-primary-dark);
  cursor: pointer;
  min-width: 70px;
  box-shadow: 0 2px 0 rgba(255, 74, 153, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.08s, box-shadow 0.08s;
}
.settings-toggle:active { transform: translateY(1px); }
.settings-toggle.on {
  background: linear-gradient(180deg, #b8f2d8 0%, #6fd4a5 100%);
  border-color: #6fd4a5;
  color: #1e6e46;
  box-shadow: 0 2px 0 #3a9a6e, inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ===== Responsive ===== */
/* clamp(vh) ベースで動的調整するため、固定 font-size の上書きは原則不要。
   ここでは min-height 700px 時の question の上限を引き上げるのみ */
@media (min-height: 700px) {
  .question { font-size: 3.5rem; }
}

/* 狭い画面（〜375px：一般的なスマホの下限帯） */
@media (max-width: 375px) {
  .screen            { padding: 12px; }
  #screen-play       { padding: 10px; }
  #screen-history    { padding: 12px; }
  #screen-result     { padding: 12px; }

  /* ヘッダー：戻るボタンとタイトルを両方コンパクト化 */
  .screen-header { gap: 6px; }
  .screen-header h2 {
    font-size: 1.2rem;
    padding-right: 58px;
  }
  .btn-back {
    font-size: 0.82rem;
    padding: 5px 10px;
  }

  /* ホームタイトル */
  .title { font-size: 2.8rem; margin-bottom: 36px; }
  .title::before, .title::after { font-size: 1.5rem; }

  /* モードカード */
  .mode-card { padding: 12px 12px 12px; }
  .mode-card-title { font-size: 1.3rem; }
  .mode-card-desc  { font-size: 0.82rem; }
  .mode-card-best  { font-size: 0.88rem; padding: 2px 10px; }

  /* 連続チャレンジボタン：縁取りと内側余白を一段コンパクトに */
  .mode-card-challenge { border-width: 3px; padding: 14px 12px; gap: 2px; }

  /* 問題数選択画面：表示と入力を一段コンパクトに */
  .challenge-count-display { padding: 10px 12px; margin: 4px 0; }
  .challenge-count-controls { gap: 8px; }
  .challenge-count-rule    { padding: 8px 10px; margin: 8px 0 6px; }

  /* プレイヘッダー：ボタン2つ並べると狭くなるので一段詰める */
  .play-header        { padding: 6px 10px; gap: 6px; }
  .play-header-actions { gap: 4px; }
  .btn-quit           { padding: 5px 10px; font-size: 0.82rem; }
  .btn-pause          { padding: 5px 10px; font-size: 0.82rem; }
  .btn-pause-label    { display: none; }
  .btn-pause-icon     { font-size: 1.1em; }

  /* 問題・回答 */
  .question        { font-size: 2.6rem; }
  .answer-display  { font-size: 2rem; min-width: 180px; min-height: 64px; padding: 8px 18px; }

  /* 数字パッド：clamp が高さベースで動的サイズ管理するため、
     ここでは gap と無改行・字詰めだけ指定（font-size は clamp に委ねる） */
  .numpad          { gap: 6px; }
  .numpad-enter    { white-space: nowrap; letter-spacing: -0.02em; }

  /* 結果画面 */
  .result-title    { font-size: 2.2rem; }
  .result-badge    { font-size: 1.05rem; padding: 8px 18px; }
  .result-card     { padding: 12px 18px; }
  .result-value    { font-size: 1.5rem; }
  .reward-area     { padding: 12px 16px; }
  .reward-name     { font-size: 1.2rem; }
  .reward-stars.rarity-1 { font-size: 1.5rem; }
  .reward-stars.rarity-2 { font-size: 1.8rem; }
  .reward-stars.rarity-3 { font-size: 2rem; }
  .reward-stars.rarity-4 { font-size: 2.2rem; }
  .reward-stars.rarity-5 { font-size: 2rem; }

  /* 設定画面 */
  .settings-section { font-size: 0.9rem; }
  .settings-item    { padding: 8px 12px; }
  .settings-label   { font-size: 0.9rem; }
  .stepper          { gap: 8px; }
  .stepper-btn      { width: 34px; height: 34px; font-size: 1.3rem; }
  .stepper-value    { min-width: 60px; font-size: 1.1rem; }
  .btn-danger       { font-size: 0.98rem; padding: 11px; }

  /* マスコット：375px 用の位置のみ調整（サイズは clamp に委ねる） */
  .mascot          { top: 58px; right: 6px; }
}

/* 極端に狭い画面（〜340px：iPhone SE 第1世代・古いAndroid等） */
@media (max-width: 340px) {
  .screen         { padding: 8px; }
  #screen-play    { padding: 8px; }
  #screen-history { padding: 8px; }
  #screen-result  { padding: 8px; }

  .screen-header h2 {
    font-size: 1.05rem;
    padding-right: 48px;
  }
  .btn-back {
    font-size: 0.76rem;
    padding: 4px 8px;
  }

  .title { font-size: 2.4rem; margin-bottom: 28px; }

  .mode-list { gap: 10px; }
  .mode-card { padding: 10px 10px 10px; }
  .mode-card-title { font-size: 1.15rem; }
  .mode-card-desc  { font-size: 0.76rem; margin-bottom: 6px; }
  .mode-card-best  { font-size: 0.82rem; padding: 2px 8px; }

  /* 連続チャレンジボタン：超狭幅でも崩れないように内側を更に詰める */
  .mode-card-challenge { border-width: 3px; border-radius: 20px; padding: 11px 10px; gap: 2px; }

  /* 問題数選択画面：超狭幅は更にコンパクト */
  .challenge-count-display { padding: 8px 10px; margin: 2px 0; border-width: 3px; }
  .challenge-count-controls { gap: 6px; }
  .challenge-count-rule    { padding: 6px 8px; margin: 6px 0 4px; }
  .challenge-intro         { font-size: 0.92rem; margin-bottom: 8px; }

  /* プレイヘッダー：超狭幅は更に詰める */
  .play-header        { padding: 5px 8px; gap: 4px; }
  .btn-quit           { padding: 4px 8px; font-size: 0.76rem; }
  .btn-pause          { padding: 4px 8px; font-size: 0.76rem; }
  .play-progress      { font-size: 0.88rem; }
  .play-timer         { font-size: 1.2rem; }

  .question       { font-size: 2.2rem; }
  .answer-display { font-size: 1.8rem; min-width: 150px; min-height: 58px; }

  .numpad         { gap: 5px; }
  .numpad-btn     { border-radius: 12px; }

  .result-title   { font-size: 2rem; }
  .result-badge   { font-size: 0.95rem; padding: 6px 14px; }
  .result-card    { padding: 10px 14px; }
  .result-value   { font-size: 1.35rem; }
  .result-row     { padding: 6px 0; }
  .reward-area    { padding: 10px 14px; }
  .reward-name    { font-size: 1.1rem; }
  .reward-stars.rarity-1 { font-size: 1.4rem; }
  .reward-stars.rarity-2 { font-size: 1.6rem; }
  .reward-stars.rarity-3 { font-size: 1.8rem; }
  .reward-stars.rarity-4 { font-size: 2rem; }
  .reward-stars.rarity-5 { font-size: 1.8rem; }

  /* マスコット：340px 以下の位置のみ */
  .mascot          { top: 50px; right: 4px; }

  /* 設定画面 */
  .settings-section { font-size: 0.85rem; margin: 10px 2px 2px; }
  .settings-item    { padding: 7px 10px; border-radius: 14px; }
  .settings-label   { font-size: 0.84rem; }
  .stepper          { gap: 6px; }
  .stepper-btn      { width: 30px; height: 30px; font-size: 1.15rem; }
  .stepper-value    { min-width: 52px; font-size: 1rem; }
  .btn-danger       { font-size: 0.92rem; padding: 10px; }
}

/* ===== 子供向け確認ダイアログ（はい / いいえ） ===== */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(74, 53, 104, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: modal-fade-in 0.18s ease-out;
}
.confirm-modal.hidden { display: none; }
.confirm-modal-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 22px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 240, 248, 0.92) 100%);
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  box-shadow:
    0 12px 30px rgba(200, 80, 160, 0.3),
    0 0 24px rgba(255, 215, 0, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
  animation: pop-in 0.3s ease-out;
}
.confirm-modal-message {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.05rem, 4.5vw, 1.3rem);
  color: var(--color-primary-dark);
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.85);
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.4;
  padding: 4px 2px;
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
}
.confirm-modal-actions .btn {
  flex: 1;
  padding: 14px 12px;
  font-size: 1.15rem;
}

/* ===== 日本語タイトル類の共通折り返し制御 =====
   空白を含む見出しが狭い画面で語句の途中で折れないようにする。
   このプロジェクトでは「ことば」と「ことば」の間に半角空白を入れて
   自然な区切りを示しているため、その空白でだけ折り返すのが望ましい。 */
.minigame-prompt,
.retry-rewards-label,
.challenge-reward-progress,
.challenge-result-progress,
.challenge-result-cards-label,
.challenge-perfect-badge,
.history-note,
.challenge-history-flag,
.challenge-history-perfect-mark {
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.3;
}

/* ===== 連続チャレンジモード ===== */

/* モード選択画面の連続チャレンジボタン（既存 mode-card より大きく特別感） */
.mode-card-challenge {
  position: relative;
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 26px;
  padding: clamp(14px, 4vw, 22px) clamp(10px, 4vw, 18px);
  cursor: pointer;
  text-align: center;
  font-family: var(--font-body);
  color: var(--color-text);
  background: linear-gradient(135deg, #ff8ec7 0%, #ffd700 50%, #c8a4ff 100%);
  background-size: 200% 200%;
  animation: holographic-shift 6s ease-in-out infinite;
  box-shadow:
    0 8px 22px rgba(200, 80, 160, 0.3),
    0 0 30px rgba(255, 215, 0, 0.35),
    inset 0 0 26px rgba(255, 255, 255, 0.4);
  transition: transform 0.1s, box-shadow 0.15s;
  margin-top: 6px;
  min-width: 0;            /* flex子で文字を折り返せるように */
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.mode-card-challenge:active {
  transform: scale(0.98);
  box-shadow: 0 4px 10px rgba(200, 80, 160, 0.3);
}
.mode-card-challenge::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  border-radius: 22px 22px 0 0;
}
/* 日本語混在文の折り返し制御：原則「空白でのみ折り返す」(keep-all)。
   さらに極端に長い英数字や絵文字続きでもはみ出さないように break-word も併用。 */
.mode-card-challenge .mode-card-challenge-title,
.mode-card-challenge .mode-card-challenge-sub {
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.25;
}
.mode-card-challenge .mode-card-challenge-title {
  font-family: var(--font-display);
  font-weight: normal;
  /* 1.0rem 〜 1.7rem の範囲で画面幅に応じて自動調整 */
  font-size: clamp(1.05rem, 5.2vw, 1.7rem);
  color: var(--color-primary-dark);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.95), 0 2px 3px rgba(200, 38, 122, 0.3);
}
.mode-card-challenge .mode-card-challenge-sub {
  font-size: clamp(0.78rem, 3vw, 0.95rem);
  font-weight: 700;
  color: var(--color-text);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}
.mode-card-challenge .mode-card-challenge-icon {
  font-size: clamp(1.1rem, 4.2vw, 1.6rem);
  line-height: 1;
}

/* チャレンジ：レベル選択／問題数選択画面 */
.challenge-intro {
  flex-shrink: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: normal;
  color: var(--color-primary-dark);
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  margin-bottom: 12px;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  /* 「レベルを えらんでね」「なんもんに ちょうせんする？」など空白を含む見出しは
     語句の途中で折り返さないように、空白でのみ改行する */
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.3;
}
.challenge-level-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 4px 2px 8px;
}
.challenge-level-list .mode-card {
  /* レベル選択画面の mode-card は通常リストより少しコンパクト */
  padding: 12px 14px;
}
/* 問題数表示（中央の大きな数字） */
.challenge-count-display {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  padding: 14px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 240, 248, 0.85) 100%);
  border: 4px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(200, 80, 160, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.85);
}
.challenge-count-num {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(3rem, 16vw, 5rem);
  line-height: 1;
  background: linear-gradient(180deg, #ff8ec7 0%, #ff4a99 50%, #c8267a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 4px 10px rgba(200, 38, 122, 0.25));
  font-variant-numeric: tabular-nums;
  min-width: 1.6em;
  text-align: center;
}
.challenge-count-unit {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  color: var(--color-primary-dark);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}

/* スライダー＋−／＋ボタン */
.challenge-count-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}
.challenge-count-step-btn {
  flex-shrink: 0;
  width: clamp(44px, 12vw, 56px);
  height: clamp(44px, 12vw, 56px);
  border-radius: 50%;
  border: 3px solid var(--color-primary-light);
  background: linear-gradient(180deg, #ffffff 0%, #ffeaf3 100%);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(255, 74, 153, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.challenge-count-step-btn:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(255, 74, 153, 0.18); }

.challenge-count-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd9ea 0%, #ff8ec7 50%, #c8a4ff 100%);
  outline: none;
  cursor: pointer;
  margin: 0;
}
.challenge-count-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #ffd6e8 100%);
  border: 3px solid var(--color-primary);
  box-shadow: 0 2px 6px rgba(200, 80, 160, 0.45);
  cursor: pointer;
}
.challenge-count-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #ffd6e8 100%);
  border: 3px solid var(--color-primary);
  box-shadow: 0 2px 6px rgba(200, 80, 160, 0.45);
  cursor: pointer;
}

.challenge-count-range {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-top: 2px;
}

.challenge-count-rule {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 12px 0 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed var(--color-primary-light);
  border-radius: 16px;
  font-size: clamp(0.82rem, 3vw, 0.95rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-align: center;
}
.challenge-count-rule strong {
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: normal;
}

/* レア度確定アナウンス（中央オーバーレイ） */
.rarity-announce {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(74, 53, 104, 0.45) 0%, rgba(74, 53, 104, 0) 70%);
}
.rarity-announce.visible {
  animation: rarity-announce-fade 2s ease-in-out forwards;
}
.rarity-announce.hidden { display: none; }
.rarity-announce-text {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 2.4rem;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  background: linear-gradient(135deg, #ffd700 0%, #ff8ec7 50%, #c8a4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 4px 14px rgba(200, 38, 122, 0.5));
  text-align: center;
  position: relative;
  z-index: 2;
}
.rarity-announce-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.6) 0, transparent 4px),
    radial-gradient(circle at 70% 25%, rgba(255, 255, 255, 0.7) 0, transparent 3px),
    radial-gradient(circle at 80% 60%, rgba(255, 180, 220, 0.6) 0, transparent 4px),
    radial-gradient(circle at 30% 70%, rgba(200, 164, 255, 0.6) 0, transparent 4px),
    radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.4) 0, transparent 5px),
    radial-gradient(circle at 15% 80%, rgba(255, 255, 255, 0.7) 0, transparent 3px),
    radial-gradient(circle at 85% 80%, rgba(255, 215, 0, 0.5) 0, transparent 3px);
  animation: rarity-sparkle-twinkle 1.6s ease-in-out infinite;
}
@keyframes rarity-announce-fade {
  0%   { opacity: 0; transform: scale(0.7); }
  20%  { opacity: 1; transform: scale(1.05); }
  35%  { transform: scale(1); }
  85%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95); }
}
@keyframes rarity-sparkle-twinkle {
  0%, 100% { opacity: 0.5; transform: scale(0.95); }
  50%      { opacity: 1; transform: scale(1.05); }
}

/* チャレンジ ご褒美画面（プレイ中） */
#screen-challenge-reward {
  justify-content: flex-start;
  align-items: center;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
}
.challenge-reward-progress {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.4rem;
  color: var(--color-primary-dark);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.95);
  margin-top: 6px;
}

/* チャレンジ結果画面 */
#screen-challenge-result {
  justify-content: flex-start;
  align-items: center;
  padding: 12px;
  gap: 8px;
  overflow: hidden;
}
.challenge-result-card {
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 240, 248, 0.85) 100%);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 8px 18px;
  box-shadow: 0 6px 20px rgba(200, 80, 160, 0.18);
}
.challenge-result-progress {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.5rem;
  text-align: center;
  color: var(--color-primary-dark);
  padding: 6px 0;
  border-bottom: 2px dashed rgba(255, 179, 209, 0.7);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.85);
}
.challenge-sub-value { font-size: 1.2rem; }
.challenge-perfect-badge {
  flex-shrink: 0;
  background: linear-gradient(135deg, #ffd700 0%, #ff8ec7 50%, #c8a4ff 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.2rem;
  padding: 8px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255, 107, 157, 0.4), 0 0 24px rgba(255, 215, 0, 0.35);
  text-shadow: 0 2px 3px rgba(150, 30, 90, 0.4);
  animation: pop-in 0.4s ease-out, badge-pulse 1.8s ease-in-out infinite 0.5s;
}
.challenge-perfect-badge.hidden { display: none; }
.challenge-result-cards-label {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1rem;
  color: var(--color-primary-dark);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}
.challenge-result-cards {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 420px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  padding: 4px;
}
.challenge-reward-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  border: 2px solid var(--color-primary-light);
  border-radius: 12px;
  padding: 4px;
}
.challenge-reward-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}
.challenge-reward-thumb-stars {
  font-size: 0.7rem;
  margin-top: 2px;
}
.challenge-reward-thumb.rarity-3 { border-color: #ffd700; }
.challenge-reward-thumb.rarity-4 {
  border-color: #ff8ec7;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}
.challenge-reward-thumb.rarity-5 {
  border-color: rgba(255, 215, 0, 0.85);
  background: linear-gradient(135deg, #ffd4f0, #fff2c0, #d0f0d0, #c8e0ff, #e8d0ff, #ffd4f0);
  background-size: 200% 200%;
  animation: holographic-shift 4s ease-in-out infinite;
}

/* 履歴：モードタブ */
.history-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.history-mode-tab {
  flex: 1;
  padding: 10px 8px;
  border: 3px solid var(--color-primary-light);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}
.history-mode-tab:active { transform: translateY(1px); }
.history-mode-tab.active {
  background: linear-gradient(180deg, #ff7ab6 0%, #ff4a99 100%);
  color: #fff;
  border-color: var(--color-primary-dark);
  text-shadow: 0 2px 3px rgba(150, 30, 90, 0.5);
}
.history-mode-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.history-mode-pane.hidden { display: none; }

/* チャレンジ履歴一覧 */
.challenge-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 8px;
}
.challenge-history-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--color-text-light);
  font-size: 0.95rem;
}
.challenge-history-entry {
  position: relative;             /* 削除ボタンの absolute 配置基準 */
  background: linear-gradient(180deg, #fff 0%, #fff0f6 100%);
  border: 3px solid var(--color-primary-light);
  border-radius: 16px;
  padding: 10px 44px 10px 12px;   /* 右側に削除ボタン分のスペース */
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-text);
  box-shadow: 0 3px 10px rgba(200, 80, 160, 0.15);
}

/* エントリー個別削除ボタン（× アイコン） */
.challenge-history-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ff9bb0;
  background: rgba(255, 255, 255, 0.9);
  color: #e03a6f;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 0 rgba(224, 58, 111, 0.18);
  transition: background 0.15s, transform 0.08s;
}
.challenge-history-delete-btn:hover { background: #ffe6ec; }
.challenge-history-delete-btn:active {
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 0 0 rgba(224, 58, 111, 0.18);
  background: #ffd4dd;
}
.challenge-history-entry:active { transform: translateY(1px); }
.challenge-history-entry.completed {
  border-color: var(--color-gold);
  background: linear-gradient(180deg, #fff8e0 0%, #fff0f6 100%);
}
.challenge-history-entry.perfect {
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
  background: linear-gradient(135deg, #fff7e0 0%, #ffe9f5 100%);
}
.challenge-history-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.challenge-history-date {
  font-size: 0.92rem;
  color: var(--color-text-light);
}
.challenge-history-level {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.1rem;
  color: var(--color-primary-dark);
}
.challenge-history-progress {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.2rem;
  color: var(--color-primary-dark);
}
.challenge-history-flag {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.92rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.85);
  color: #5a3a14;
}
.challenge-history-flag.in-progress {
  background: rgba(160, 160, 200, 0.6);
  color: #fff;
}
.challenge-history-row2 {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 0.92rem;
  flex-wrap: wrap;
}
.challenge-history-perfect-mark {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 0.95rem;
  color: #d2691e;
  margin-top: 4px;
}
.challenge-history-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px dashed rgba(255, 179, 209, 0.7);
  font-size: 0.88rem;
  display: none;
}
.challenge-history-entry.expanded .challenge-history-detail {
  display: block;
}
.challenge-history-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.challenge-history-rarity-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.challenge-history-rarity-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid var(--color-primary-light);
  font-size: 0.85rem;
}

/* ===== Level 6〜10 モードカード色 ===== */
.mode-card[data-level="6"]  { background: linear-gradient(135deg, #ffd0a0 0%, #ffaa50 100%); } /* オレンジ */
.mode-card[data-level="7"]  { background: linear-gradient(135deg, #ddd0f8 0%, #b8a0e8 100%); } /* 薄いラベンダー */
.mode-card[data-level="8"]  { background: linear-gradient(135deg, #e8d4c0 0%, #c8a888 100%); } /* 薄い茶色 */
.mode-card[data-level="9"]  { background: linear-gradient(135deg, #ff8fa0 0%, #e83060 100%); } /* 濃いピンク（rose） */
.mode-card[data-level="10"] { background: linear-gradient(135deg, #80dede 0%, #30baba 100%); } /* ターコイズ */

/* ===== 筆算（縦式）問題表示 ===== */

/* .question が縦式の時：コンテナのグラデテキスト・filter をリセットして中央揃え */
.question.question-vertical {
  font-size: 1rem;
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: unset;
  color: var(--color-text);
  filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* 縦式コンテナ */
.v-calc {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: clamp(10px, 2.5vh, 18px) clamp(14px, 4vw, 24px);
  box-shadow:
    0 6px 20px rgba(200, 80, 160, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.v-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
}

/* 演算子セル（+/−）とブランクスペーサー */
.v-op, .v-op-sp {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: clamp(1.8rem, 5vw, 2.2rem);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.3rem, 3.8vh, 1.9rem);
  color: var(--color-primary-dark);
  flex-shrink: 0;
  padding-right: 2px;
}

/* 数字セル（通常・ブランク） */
.v-d, .v-d-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(2rem, 5.5vw, 2.5rem);
  height: clamp(2rem, 5.5vh, 2.8rem);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.3rem, 3.8vh, 1.9rem);
  color: var(--color-text);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* 穴セル：ピンクハイライト＋点線枠 */
.v-d-hole {
  background: linear-gradient(180deg, #fff0fb 0%, #ffd6ef 100%);
  border: 2.5px dashed var(--color-primary);
  border-radius: 10px;
  color: var(--color-primary);
  box-shadow:
    0 0 10px rgba(255, 74, 153, 0.25),
    inset 0 0 6px rgba(255, 200, 230, 0.2);
  animation: hole-pulse 1.5s ease-in-out infinite;
}

.v-d-hole.wrong {
  background: linear-gradient(180deg, #ffe0e0 0%, #ffb8b8 100%);
  border-color: #ff5a5a;
  color: #d63030;
  animation: shake 0.4s;
}

@keyframes hole-pulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 74, 153, 0.25), inset 0 0 6px rgba(255, 200, 230, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 74, 153, 0.5), inset 0 0 10px rgba(255, 180, 220, 0.35);
  }
}

/* 区切り横線 */
.v-rule {
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--color-primary) 15%,
    var(--color-primary) 85%,
    transparent 100%);
  border-radius: 2px;
  margin: 4px 0;
  align-self: stretch;
}

/* ===== データ保護（きろくの「だいじな データ」エリア＋ダイアログ） ===== */
.data-area {
  margin-top: 22px;
  padding-bottom: 8px;
  text-align: center;
}
.data-sep {
  height: 0;
  border-top: 2px dashed rgba(200, 164, 255, 0.5);
  margin: 0 0 14px;
}
.data-title {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-text-light);
}
.data-note {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--color-text-light);
  margin: 4px 0 10px;
  line-height: 1.5;
}
.data-note-pwa {
  font-size: 0.72rem;
  margin-top: -4px;
}
.data-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.data-buttons .btn-sub {
  flex: 1;
  max-width: 180px;
  font-size: 1rem;
  padding: 12px 10px;
}
.data-lastbackup {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 8px;
}

/* リマインド（ホーム・控えめ） */
.backup-remind {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 6px 8px 6px 14px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--color-primary-dark);
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid var(--color-primary-light);
  border-radius: 999px;
}
.backup-remind.hidden { display: none; }
.remind-close {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(200, 164, 255, 0.22);
  color: var(--color-text-light);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

/* データ操作ダイアログ（確認・エラー・コピー） */
.data-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(74, 53, 104, 0.45);
}
.data-dialog {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, #ffffff 0%, #fff0f8 100%);
  border: 3px solid var(--color-primary-light);
  border-radius: 22px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(200, 38, 122, 0.35);
}
.data-dialog-title {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.35rem;
  color: var(--color-primary-dark);
  margin-bottom: 8px;
}
.data-dialog-msg {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.6;
}
.data-dialog-sub {
  font-size: 0.78rem;
  color: var(--color-text-light);
}
.data-dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.data-dialog-actions .btn {
  flex: 1;
  font-size: 1.05rem;
  padding: 14px 8px;
}
.data-copy-text {
  width: 100%;
  height: 120px;
  margin-top: 12px;
  font-size: 0.7rem;
  font-family: monospace;
  border: 1.5px solid var(--color-primary-light);
  border-radius: 10px;
  padding: 8px;
  resize: none;
}
