/* ============================================
   なぞって学ぼう！ — style.css
   4歳児向け学習Webアプリ
   ============================================ */

/* === Reset & Base === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* カラーパレット — ももか版 */
  --bg: #FDF4FF;
  --bg-card: #FFFFFF;
  --primary: #E879B0;
  --primary-light: #F9A8D4;
  --secondary: #A78BFA;
  --accent: #FDB7EA;
  --text: #4A1942;
  --text-light: #9D4EDD;
  --success: #EC4899;
  --shadow: rgba(167, 139, 250, 0.12);
  --shadow-strong: rgba(167, 139, 250, 0.22);

  /* キャラクターカラー — うさぎ */
  --char-body: #FFD6E7;
  --char-ear: #FFB0CC;
  --char-ear-inner: #FFE4EE;
  --char-eye-white: #FFFFFF;
  --char-pupil: #4A1942;
  --char-cheek: #FF8FB3;
  --char-mouth: #E879B0;
  --char-ribbon: #A78BFA;

  /* フォント */
  --font-main: 'Zen Maru Gothic', 'Hiragino Maru Gothic Pro', sans-serif;

  /* サイズ */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-round: 50%;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 16px;
  position: relative;
}

.hidden {
  display: none !important;
}

/* === キャラクター: もじモン === */
#character {
  position: relative;
  width: 100px;
  height: 90px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

/* === うさぎの耳 === */
#ears {
  position: absolute;
  top: -48px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  display: flex;
  justify-content: space-between;
}

.ear {
  width: 22px;
  height: 50px;
  background: var(--char-ear);
  border-radius: 11px 11px 8px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: ear-wiggle 3s ease-in-out infinite;
}

.ear.left {
  transform: rotate(-8deg);
  animation-delay: 0.2s;
}

.ear.right {
  transform: rotate(8deg);
}

.ear-inner {
  width: 10px;
  height: 34px;
  background: var(--char-ear-inner);
  border-radius: 5px;
}

#char-ribbon-ear {
  position: absolute;
  bottom: -4px;
  right: -8px;
  font-size: 1rem;
}

@keyframes ear-wiggle {

  0%,
  90%,
  100% {
    transform: rotate(-8deg);
  }

  95% {
    transform: rotate(-14deg);
  }
}

.ear.right {
  animation: ear-wiggle-right 3s ease-in-out infinite;
  animation-delay: 0.3s;
}

@keyframes ear-wiggle-right {

  0%,
  90%,
  100% {
    transform: rotate(8deg);
  }

  95% {
    transform: rotate(14deg);
  }
}

/* まつげ */
.lash {
  position: absolute;
  top: -1px;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 3px;
}

.lash::before,
.lash::after {
  content: '';
  width: 2px;
  height: 5px;
  background: var(--char-pupil);
  border-radius: 1px;
  transform: rotate(-15deg);
}

.lash::after {
  transform: rotate(15deg);
}

/* 成長アクセサリー */
.char-accessory {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 10;
}

#char-crown {
  top: -52px;
  left: 50%;
  transform: translateX(-50%);
  animation: crown-shine 2s ease-in-out infinite alternate;
}

#char-tiara {
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
}

#char-hat {
  top: -44px;
  left: 50%;
  transform: translateX(-50%);
}

@keyframes crown-shine {
  from {
    filter: drop-shadow(0 0 4px rgba(253, 203, 110, 0.5));
  }

  to {
    filter: drop-shadow(0 0 12px rgba(253, 203, 110, 1));
  }
}

/* 顔 */
#face {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 70px;
  background: var(--char-body);
  border-radius: 45px 45px 35px 35px;
  box-shadow: 0 4px 12px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 目 */
#eyes {
  display: flex;
  gap: 16px;
  margin-top: -2px;
}

.eye {
  width: 20px;
  height: 22px;
  background: var(--char-eye-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.pupil {
  width: 10px;
  height: 10px;
  background: var(--char-pupil);
  border-radius: 50%;
  position: relative;
  transition: transform 0.3s ease;
}

.pupil::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
}

/* 口 */
#mouth {
  width: 14px;
  height: 8px;
  background: var(--char-mouth);
  border-radius: 0 0 14px 14px;
  margin-top: 4px;
  transition: all 0.3s ease;
}

/* ほっぺ */
#cheeks {
  position: absolute;
  width: 100%;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
  pointer-events: none;
}

.cheek {
  width: 14px;
  height: 10px;
  background: var(--char-cheek);
  border-radius: 50%;
  opacity: 0.6;
}

/* キャラ表情: happy */
#character.happy #mouth {
  width: 20px;
  height: 12px;
  border-radius: 0 0 20px 20px;
}

#character.happy .cheek {
  opacity: 1;
}

/* キャラ表情: excited */
#character.excited #mouth {
  width: 24px;
  height: 16px;
  border-radius: 0 0 24px 24px;
}

#character.excited .eye {
  transform: scale(1.15);
}

#character.excited .cheek {
  opacity: 1;
  transform: scale(1.2);
}

#character.excited {
  animation: char-jump 0.5s ease;
}

@keyframes char-jump {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* キャラ表情: thinking */
#character.thinking .pupil {
  animation: look-around 2s ease-in-out infinite;
}

@keyframes look-around {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-3px);
  }
}

/* === 問題ラベル === */
#problem-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 6px;
  min-height: 1.5em;
}

/* === キャンバスエリア === */
#canvas-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 2 / 1.2;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px var(--shadow), 0 1px 4px var(--shadow);
  overflow: hidden;
  flex-shrink: 0;
}

#guide-canvas,
#draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#guide-canvas {
  z-index: 1;
  pointer-events: none;
}

#draw-canvas {
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}

/* === フィードバック === */
#feedback {
  font-size: 1.4rem;
  font-weight: 900;
  min-height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

#feedback.great {
  color: var(--primary);
  animation: feedback-pop 0.5s ease;
}

#feedback.good {
  color: var(--secondary);
  animation: feedback-pop 0.5s ease;
}

#feedback.try {
  color: var(--text-light);
}

#feedback.retry-banner {
  color: #ff6b35;
  font-size: 1.1em;
  font-weight: bold;
  animation: feedback-pop 0.5s ease;
}

/* === 学習パスガイド === */
#learning-path {
  text-align: center;
  margin: 0.5rem 0 1rem;
}
#learning-path-label {
  font-size: 0.75rem;
  color: #A78BFA;
  margin-bottom: 0.3rem;
  letter-spacing: 0.05em;
}
#learning-path-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.2rem;
  font-size: 0.7rem;
}
.path-step {
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.12);
  color: #7C5CBF;
  cursor: pointer;
  transition: background 0.2s;
}
.path-step.done { background: rgba(167, 139, 250, 0.35); color: #5B3FA0; }
.path-step.current { background: #A78BFA; color: white; font-weight: bold; }
.path-arrow { color: #D4B2FF; font-size: 0.65rem; }

/* === カテゴリ進捗バッジ === */
.cat-progress {
  display: block;
  font-size: 0.65rem;
  margin-top: 0.2rem;
  color: #A78BFA;
  min-height: 0.9rem;
}

/* === 数える足場 === */
#addition-scaffold { text-align: center; margin: 0.4rem 0; }
#scaffold-btn {
  background: rgba(167, 139, 250, 0.15);
  border: 1.5px solid rgba(167, 139, 250, 0.4);
  border-radius: 999px;
  padding: 0.3rem 1rem;
  font-size: 0.85rem;
  color: #7C5CBF;
  cursor: pointer;
  font-family: inherit;
}
#scaffold-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.dot-group { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: center; }
.scaffold-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255, 107, 157, 0.25);
  border: 2px solid rgba(255, 107, 157, 0.5);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: inline-block;
}
.scaffold-dot.tapped { background: #FF6B9D; border-color: #FF6B9D; transform: scale(1.15); }
.dot-plus { font-size: 1.4rem; color: #A78BFA; font-weight: bold; padding: 0 0.2rem; }

@keyframes feedback-pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  60% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* === ボタン === */
#actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 500px;
  margin-bottom: 4px;
}

#clear-btn,
#done-btn,
#next-btn {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#clear-btn:active,
#done-btn:active,
#next-btn:active {
  transform: scale(0.95);
}

#clear-btn {
  flex: 1;
  background: #DFE6E9;
  color: var(--text-light);
}

#done-btn {
  flex: 2;
  background: linear-gradient(135deg, var(--primary), #FF8E53);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

#done-btn:active {
  box-shadow: 0 2px 6px rgba(255, 107, 157, 0.2);
}

#next-btn {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(135deg, var(--secondary), #45B7AA);
  color: white;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
  animation: next-pulse 1.5s ease-in-out infinite;
}

@keyframes next-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }
}

/* === 下部バー === */
#bottom-bar {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  margin-top: auto;
}

#progress-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

#home-btn {
  font-size: 1.3rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
}
#home-btn:active {
  background: rgba(0,0,0,0.08);
}

#progress-wrap {
  flex: 1;
  height: 8px;
  background: #E8E8E8;
  border-radius: 4px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  border-radius: 4px;
  transition: width 0.4s ease;
  width: 0%;
}

#progress-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  white-space: nowrap;
}

#sticker-section {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.sticker-icon {
  font-size: 1.1rem;
}

#sticker-count {
  font-size: 1rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 1px 2px var(--shadow);
}

/* === スタート画面 === */
#start-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #FDF4FF 0%, #E9D5FF 50%, #F9A8D4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: start-fade-in 0.5s ease;
}

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

  to {
    opacity: 1;
  }
}

#start-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* スタート画面のキャラクター */
#start-character {
  width: 120px;
  height: 100px;
  background: var(--char-body);
  border-radius: 60px 60px 45px 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: start-bounce 2s ease-in-out infinite;
}

@keyframes start-bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

#start-eyes {
  display: flex;
  gap: 20px;
}

.start-eye {
  width: 24px;
  height: 26px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-pupil {
  width: 12px;
  height: 12px;
  background: var(--char-pupil);
  border-radius: 50%;
  position: relative;
}

.start-pupil::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 2px;
  width: 5px;
  height: 5px;
  background: white;
  border-radius: 50%;
}

#start-mouth {
  width: 20px;
  height: 12px;
  background: var(--char-mouth);
  border-radius: 0 0 20px 20px;
  margin-top: 6px;
}

#start-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  line-height: 1.3;
}

#start-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}

#api-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  margin-top: 6px;
}
#api-status-bar.ok {
  background: rgba(52, 199, 89, 0.35);
}
#api-status-bar.ng {
  background: rgba(255, 149, 0, 0.45);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
#api-status-label { flex: 1; }
#api-setup-open-btn {
  background: rgba(255,255,255,0.35);
  border: none;
  border-radius: 12px;
  padding: 3px 10px;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}
#api-setup-open-btn:active { background: rgba(255,255,255,0.55); }

#category-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: white;
  border: none;
  border-radius: var(--radius);
  padding: 18px 24px;
  min-width: 90px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease;
  font-family: var(--font-main);
}

.cat-btn:active {
  transform: scale(0.93);
}

.cat-icon {
  font-size: 2rem;
}

.cat-label {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text);
}

/* === 完了モーダル === */
#complete-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#modal-box {
  background: white;
  border-radius: 28px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: modal-pop 0.4s ease;
}

@keyframes modal-pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }

  80% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#modal-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

#modal-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 8px;
}

#modal-score {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 20px;
}

#modal-btn {
  font-family: var(--font-main);
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--secondary), #45B7AA);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
  transition: transform 0.15s ease;
}

#modal-btn:active {
  transform: scale(0.95);
}

/* === パーティクルレイヤー === */
#particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particle-fly 0.8s ease-out forwards;
}

@keyframes particle-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3);
  }
}

/* ハート＆星シャワー（成功時） */
.confetti-heart {
  position: absolute;
  pointer-events: none;
  animation: confetti-fall 1.5s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(var(--fall)) rotate(var(--rot));
  }
}

/* ハートトレイル（なぞり中） */
.trail-heart {
  position: absolute;
  font-size: 0.9rem;
  pointer-events: none;
  animation: heart-rise 0.8s ease-out forwards;
}

@keyframes heart-rise {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(var(--rise)) scale(0.5);
  }
}

/* === レスポンシブ === */
@media (max-height: 600px) {
  #character {
    width: 70px;
    height: 60px;
  }

  #face {
    width: 65px;
    height: 50px;
  }

  .eye {
    width: 16px;
    height: 18px;
  }

  .pupil {
    width: 8px;
    height: 8px;
  }

  #mouth {
    width: 10px;
    height: 6px;
  }

  #problem-label {
    font-size: 0.9rem;
  }

  #feedback {
    font-size: 1.1rem;
    min-height: 1.5em;
  }

  #ears {
    top: -36px;
  }

  .ear {
    height: 40px;
    width: 18px;
  }
}

/* === たしざん レベル選択画面 === */
#addition-level-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #FDF4FF 0%, #E9D5FF 50%, #F9A8D4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: start-fade-in 0.4s ease;
}

#level-screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#level-char-bubble {
  background: white;
  border-radius: 20px;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
  box-shadow: 0 4px 16px var(--shadow);
}

#level-cards {
  display: flex;
  gap: 14px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: white;
  border: 3px solid transparent;
  border-radius: var(--radius);
  padding: 16px 12px;
  min-width: 88px;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
  font-family: var(--font-main);
}

.level-card:active {
  transform: scale(0.92);
}

.level-card[data-level="1"] {
  border-color: #86EFAC;
}

.level-card[data-level="2"] {
  border-color: #FCA5A5;
}

.level-card[data-level="3"] {
  border-color: #C4B5FD;
}

.level-preview {
  font-size: 1.1rem;
  line-height: 1.5;
  min-height: 2.8em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.level-name {
  font-size: 1rem;
  font-weight: 900;
  color: var(--secondary);
}

.level-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
}

#level-all-btn {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 32px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.15s;
}

#level-all-btn:active {
  transform: scale(0.95);
}

/* === たしざん問題＋回答エリア（1画面統合） === */
#addition-problem {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 問題表示部分 */
#addition-question {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 4px 20px var(--shadow);
}

#addition-visual {
  font-size: 2rem;
  margin-bottom: 4px;
  letter-spacing: 2px;
  line-height: 1.5;
}

#addition-text {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
}

/* level 2/3 のテキストスタイル */
#addition-text.addition-text-formula {
  font-size: 1.6rem;
  color: var(--primary);
  letter-spacing: 2px;
}

#addition-text.addition-text-large {
  font-size: 2.8rem;
  color: var(--text);
  letter-spacing: 4px;
}

/* 回答エリア */
#addition-answer-area {
  text-align: center;
}

#addition-answer-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 4px;
}

/* 回答キャンバス — 白紙の回答欄 */
#addition-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1.2;
  background: white;
  border: 3px dashed #D4B2FF;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px var(--shadow), 0 1px 4px var(--shadow);
  overflow: hidden;
}

#addition-guide-canvas,
#addition-draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#addition-guide-canvas {
  z-index: 1;
  pointer-events: none;
  display: none !important;
}

#addition-draw-canvas {
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}

/* キャンバス中央ヒント（書き始める前のみ表示） */
#addition-canvas-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: rgba(200, 180, 255, 0.4);
  pointer-events: none;
  user-select: none;
  z-index: 3;
}

/* たしざん用アクションボタン */
#addition-recognition {
  min-height: 2.2rem;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #7c3aed;
  letter-spacing: 0.03em;
  padding: 4px 8px;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}

#addition-recognition.recognized-ok {
  background: rgba(52, 199, 89, 0.15);
  color: #1a7f40;
  font-size: 1.25rem;
}

#addition-recognition.recognized-ng {
  background: rgba(255, 59, 48, 0.12);
  color: #c0392b;
  font-size: 1.25rem;
}

#addition-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

#addition-clear-btn,
#addition-retry-btn,
#addition-done-btn {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#addition-clear-btn:active,
#addition-retry-btn:active,
#addition-done-btn:active {
  transform: scale(0.95);
}

#addition-clear-btn {
  flex: 1;
  background: #DFE6E9;
  color: var(--text-light);
}

#addition-retry-btn {
  flex: 1;
  background: linear-gradient(135deg, #FDB7EA, #E879B0);
  color: white;
}

#addition-done-btn {
  flex: 2;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

/* === アルバムボタン === */
#album-btn {
  font-size: 1.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  transition: transform 0.15s;
}

#album-btn:active {
  transform: scale(0.9);
}

/* === シールアルバム画面 === */
#album-screen {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  animation: start-fade-in 0.3s ease;
}

#album-content {
  background: white;
  border-radius: 28px;
  padding: 28px 32px;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: modal-pop 0.4s ease;
}

#album-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 16px;
}

#album-grid {
  margin-bottom: 16px;
}

/* スタンプカード */
.stamp-card {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #FFF8E7;
  border-radius: 16px;
  border: 2px dashed #FFD166;
}

.stamp-cell {
  aspect-ratio: 1;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.stamp-cell.earned {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  animation: stampIn 0.25s ease;
}

.stamp-cell.empty {
  background: rgba(0,0,0,0.04);
  border: 1.5px dashed #ddd;
}

@keyframes stampIn {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* 特別コレクションセクション */
.album-section-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  margin: 4px 0 10px;
}

.special-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.special-row .album-sticker {
  width: 54px;
  height: 54px;
  font-size: 1.6rem;
}

.album-sticker {
  aspect-ratio: 1;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: #F8F9FA;
  border: 2px solid #E8E8E8;
  transition: transform 0.2s;
}

.album-sticker.unlocked {
  background: linear-gradient(135deg, #FFF8E7, #FFE66D30);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(255, 230, 109, 0.3);
}

.album-sticker.rare {
  background: linear-gradient(135deg, #E8DAEF, #A29BFE30);
  border-color: #A29BFE;
  box-shadow: 0 2px 12px rgba(162, 155, 254, 0.4);
  animation: rare-glow 2s ease-in-out infinite alternate;
}

@keyframes rare-glow {
  from {
    box-shadow: 0 2px 8px rgba(162, 155, 254, 0.3);
  }

  to {
    box-shadow: 0 4px 16px rgba(162, 155, 254, 0.6);
  }
}

.album-sticker.locked {
  opacity: 0.4;
  filter: grayscale(1);
}

#album-stats {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 16px;
}

#album-close-btn {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  background: #DFE6E9;
  color: var(--text-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 32px;
  cursor: pointer;
  transition: transform 0.15s;
}

#album-close-btn:active {
  transform: scale(0.95);
}

/* === シール報酬表示 === */
#modal-sticker-reward {
  font-size: 1.2rem;
  margin-bottom: 12px;
  animation: feedback-pop 0.5s ease;
}

/* === 花びらパーティクル === */
.petal {
  position: absolute;
  font-size: 1.2rem;
  pointer-events: none;
  animation: petal-fall 2s ease-out forwards;
}

@keyframes petal-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(var(--fall)) rotate(var(--rot)) scale(0.5);
  }
}

/* === シャボン玉 === */
.bubble {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(232, 121, 176, 0.5);
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7), rgba(232, 121, 176, 0.1));
  pointer-events: none;
  animation: bubble-float 2.5s ease-out forwards;
}

@keyframes bubble-float {
  0% {
    opacity: 0.8;
    transform: translateY(0) scale(0.3);
  }

  50% {
    opacity: 0.6;
    transform: translateY(var(--rise)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(calc(var(--rise) * 1.5)) scale(1.2);
  }
}

/* === 設定モーダル === */
#settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#settings-box {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px var(--shadow-strong);
}

#settings-box h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
  color: var(--text);
}

#settings-box p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

#api-key-input,
#proxy-url-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 2px solid #E0D4F5;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  margin-top: 6px;
  font-family: monospace;
}

.settings-section {
  text-align: left;
  margin-bottom: 14px;
  padding: 12px;
  background: #FDF4FF;
  border-radius: var(--radius-sm);
}

.settings-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 6px;
}

.settings-section label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.settings-note {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
  font-style: italic;
}

#settings-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#api-key-save-btn,
#settings-close-btn {
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
}

#api-key-save-btn {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
}

#settings-close-btn {
  background: #DFE6E9;
  color: var(--text-light);
}

#api-key-status {
  font-size: 0.8rem;
  margin-top: 8px;
  color: var(--success);
}

#settings-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

/* === おすすめバッジ === */
.level-card .recommended-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, var(--success), var(--primary));
  color: white;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: badge-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes badge-pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.08);
  }
}

.level-card {
  position: relative;
}

/* === 不正解フィードバック === */
.wrong-answer {
  color: var(--text-light);
  font-size: 0.95rem;
}

.correct-answer {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 900;
  display: block;
  margin-top: 4px;
}