@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Klee+One:wght@400;600&family=M+PLUS+Rounded+1c:wght@500;700;800;900&display=swap');

:root {
  --primary-color: #ff6b6b;
  --secondary-color: #4ecdc4;
  --accent-yellow: #ffe66d;
  --accent-purple: #a06cd5;
  --accent-orange: #ff9f43;
  --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #fef3c7 50%, #fce7f3 100%);
  --card-bg: #ffffff;
  --text-dark: #2d3748;
  --text-muted: #718096;
  /* 正しい日本語の文字（教科書体・硬筆体） */
  --font-hira: "UD デジタル 教科書体 N-R", "UD Digital Kyokasho-tai", "Yu Kyokasho", "游教科書体", "HG教科書体", "Klee One", "BIZ UDPGothic", sans-serif;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.08), 0 3px 6px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 15px 30px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.08);
  --border-radius-lg: 24px;
  --border-radius-md: 18px;
  --border-radius-sm: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'M PLUS Rounded 1c', 'Fredoka', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-dark);
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* 背景デコレーション */
.bg-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: 48px;
  opacity: 0.45;
  animation: floatCloud 25s linear infinite;
}

.cloud-1 { top: 8%; left: -10%; animation-duration: 35s; }
.cloud-2 { top: 25%; left: -15%; animation-duration: 45s; animation-delay: 10s; font-size: 64px; }
.cloud-3 { top: 60%; left: -10%; animation-duration: 30s; animation-delay: 5s; }

@keyframes floatCloud {
  0% { transform: translateX(-10vw); }
  100% { transform: translateX(110vw); }
}

.floating-star {
  position: absolute;
  font-size: 28px;
  animation: twinkle 3s ease-in-out infinite alternate;
}

.star-1 { top: 12%; right: 10%; animation-delay: 0.5s; font-size: 36px; }
.star-2 { top: 40%; left: 5%; animation-delay: 1.2s; }
.star-3 { top: 75%; right: 8%; animation-delay: 2s; font-size: 40px; }
.star-4 { top: 85%; left: 8%; animation-delay: 1.5s; font-size: 34px; }

@keyframes twinkle {
  0% { transform: scale(0.9) rotate(-10deg); opacity: 0.6; }
  100% { transform: scale(1.15) rotate(15deg); opacity: 1; }
}

/* ヘッダー */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 3px solid #ffde59;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  padding: 10px 16px 8px;
}

.header-container {
  max-width: 1100px;
  margin: 0 auto 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-area:hover {
  transform: scale(1.05);
}

.logo-icon {
  font-size: 36px;
  animation: bounceSlow 2s infinite ease-in-out;
}

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

.main-title {
  font-family: 'Fredoka', cursive;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(45deg, #ff6b6b, #ff9f43, #4ecdc4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.sub-title {
  font-size: 12px;
  font-weight: 800;
  color: #718096;
}

/* 科目トグル (えいご / ひらがな) */
.subject-toggle-wrapper {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 30px;
  border: 2px solid #e2e8f0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.subject-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 24px;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  color: #64748b;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.subject-btn.active {
  background: #ff6b6b;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(255, 107, 107, 0.4);
  transform: scale(1.04);
}

#btnHiragana.active {
  background: linear-gradient(135deg, #4ecdc4, #2ecc71);
  box-shadow: 0 3px 10px rgba(46, 204, 113, 0.4);
}

.star-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 3px solid #ffe66d;
  padding: 5px 14px;
  border-radius: 30px;
  box-shadow: var(--shadow-sm);
  font-size: 18px;
  font-weight: 900;
  color: #d97706;
}

.star-icon {
  font-size: 22px;
}

/* カテゴリナビゲーション */
.category-nav {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid transparent;
  border-radius: var(--border-radius-md);
  background: #f1f5f9;
  color: #475569;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.nav-btn:hover {
  transform: translateY(-2px);
  background: #e2e8f0;
}

.nav-btn.active {
  background: #ff6b6b;
  color: #ffffff;
  border-color: #ee5253;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  transform: scale(1.05);
}

/* ====================================================
   🍔 スマホ用ハンバーガーメニュー＆ドロワー
   ==================================================== */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4.5px;
  width: 40px;
  height: 40px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.hamburger-bar {
  width: 18px;
  height: 2.5px;
  background: #475569;
  border-radius: 2px;
  transition: all 0.25s ease;
}

.mobile-menu-btn.active .hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.active .hamburger-bar:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active .hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ドロワーオーバーレイ＆メニュー */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: min(300px, 82vw);
  height: 100%;
  background: #ffffff;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  transition: right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow-y: auto;
}

.drawer-overlay.open .drawer-menu {
  right: 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f1f5f9;
}

.drawer-title {
  font-size: 18px;
  font-weight: 900;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-close-btn {
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  font-weight: 900;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-links-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.drawer-link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 900;
  color: #334155;
  transition: all 0.2s;
}

.drawer-link-item:hover, .drawer-link-item.current {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  transform: translateX(-3px);
}

.drawer-link-icon {
  font-size: 22px;
}

.drawer-divider {
  height: 2px;
  background: #f1f5f9;
  margin: 8px 0 14px;
}

.drawer-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  border: none;
  margin-bottom: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* スマホ時のヘッダースリム化 */
@media (max-width: 680px) {
  .mobile-menu-btn {
    display: flex !important;
  }
  
  .sub-title {
    display: none !important;
  }

  .back-home-link {
    display: none !important;
  }

  .report-badge-btn {
    display: none !important;
  }

  .app-header {
    padding: 6px 12px 6px !important;
  }

  .header-container {
    margin-bottom: 4px !important;
    gap: 8px !important;
  }

  .main-title {
    font-size: 19px !important;
  }

  .logo-icon {
    font-size: 26px !important;
  }

  .star-badge {
    padding: 3px 10px !important;
    font-size: 14px !important;
  }

  .star-icon {
    font-size: 16px !important;
  }

  .category-nav {
    padding-bottom: 2px !important;
    gap: 6px !important;
  }

  .nav-btn {
    padding: 6px 10px !important;
    font-size: 12.5px !important;
    border-radius: 12px !important;
  }

  .mini-poster-cell, .key-poster-cell {
    width: 48px !important;
    height: 58px !important;
  }

  .mini-cell-char, .key-cell-char {
    font-size: 20px !important;
  }

  .mini-cell-icon, .key-cell-icon {
    font-size: 14px !important;
  }

  .canvas-char-delete-btn {
    width: 26px !important;
    height: 26px !important;
    font-size: 12px !important;
    top: 4px !important;
    right: 4px !important;
  }
}

#hiraganaNav .nav-btn.active {
  background: #4ecdc4;
  border-color: #2bcbba;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.trace-nav-btn {
  background: linear-gradient(135deg, #ff9f43, #ffe66d) !important;
  color: #78350f !important;
  border-color: #f59e0b !important;
}

.trace-nav-btn.active {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5) !important;
}

.chart-nav-btn {
  background: linear-gradient(135deg, #38ef7d, #11998e);
  color: #ffffff;
  border-color: #10ac84;
}

.chart-nav-btn.active {
  background: linear-gradient(135deg, #10ac84, #05c46b);
  box-shadow: 0 4px 14px rgba(16, 172, 132, 0.5);
}

.quiz-nav-btn {
  background: linear-gradient(135deg, #a06cd5, #ff6b6b);
  color: #ffffff;
  border-color: #8338ec;
}

.quiz-nav-btn.active {
  background: linear-gradient(135deg, #8338ec, #ff4757);
  box-shadow: 0 4px 14px rgba(131, 56, 236, 0.5);
}

.nav-emoji {
  font-size: 18px;
}

/* メインコンテンツ */
.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 12px;
  z-index: 10;
}

/* ====================================================
   📋 イラスト付きあいうえお表 (ポスターデザイン)
   ==================================================== */
.chart-section {
  max-width: 1060px;
  margin: 0 auto;
}

.poster-container {
  background: #fdfaf2;
  background-image: radial-gradient(#f0e6d2 1.5px, transparent 1.5px);
  background-size: 16px 16px;
  border: 8px solid #ffde59;
  border-radius: var(--border-radius-lg);
  padding: 18px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.poster-header {
  margin-bottom: 14px;
}

.poster-title {
  display: inline-block;
  background: #ffffff;
  border: 4px solid #ff9f43;
  padding: 6px 36px;
  border-radius: 30px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #e67e22;
  box-shadow: 0 4px 10px rgba(230, 126, 34, 0.2);
}

.poster-sub {
  font-size: 13px;
  font-weight: 800;
  color: #64748b;
  margin-top: 6px;
}

/* 右から左（わ行〜あ行）の本格あいうえおポスターグリッド */
.poster-board {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
}

.poster-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 各セル */
.poster-cell {
  width: 82px;
  height: 104px;
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.poster-cell:hover {
  transform: scale(1.08) translateY(-4px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
  border-color: #ffde59;
  z-index: 5;
}

.poster-cell:active {
  transform: scale(0.95);
}

.cell-char-box {
  flex: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-hira);
  text-shadow: 1px 2px 3px rgba(0,0,0,0.2);
  line-height: 1;
}

.cell-info-box {
  flex: 1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 2px 4px;
}

.cell-icon {
  font-size: 24px;
}

.cell-word {
  font-size: 11px;
  font-weight: 900;
  color: #334155;
  white-space: nowrap;
}

.cell-empty {
  width: 82px;
  height: 104px;
  background: transparent;
  border: none;
}

/* 列ごとのカラーテーマ */
.col-a .cell-char-box { background: #e74c3c; } /* あ行: 赤 */
.col-ka .cell-char-box { background: #e84393; } /* か行: ピンク */
.col-sa .cell-char-box { background: #fd79a8; } /* さ行: ライトピンク */
.col-ta .cell-char-box { background: #6c5ce7; } /* た行: 紫 */
.col-na .cell-char-box { background: #0984e3; } /* な行: 濃紺 */
.col-ha .cell-char-box { background: #00cec9; } /* は行: 水色 */
.col-ma .cell-char-box { background: #00b894; } /* ま行: 緑 */
.col-ya .cell-char-box { background: #a8e063; color: #2d3436; text-shadow: none; } /* や行: 黄緑 */
.col-ra .cell-char-box { background: #f1c40f; } /* ら行: 黄色 */
.col-wa .cell-char-box { background: #e67e22; } /* わ行: オレンジ */

/* ミニあいうえお表 (1文字＆じぶんでつくる両用) */
.char-picker-wrapper {
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 10px;
  width: 100%;
}

.poster-mini-board {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 5px;
  padding: 2px;
  width: max-content;
  margin: 0 auto;
}

.poster-mini-cell {
  width: 60px;
  height: 76px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.poster-mini-cell:hover {
  transform: scale(1.12);
  border-color: #ffde59;
  z-index: 5;
}

.poster-mini-cell:active {
  transform: scale(0.92);
}

.poster-mini-cell.active {
  transform: scale(1.18);
  border: 3px solid #ff4757;
  box-shadow: 0 0 12px rgba(255, 71, 87, 0.6);
  z-index: 10;
}

.poster-mini-cell .cell-char-box {
  font-size: 28px;
}

.poster-mini-cell .cell-icon {
  font-size: 17px;
}

.poster-mini-cell .cell-word {
  font-size: 9.5px;
}

.mini-cell-empty {
  width: 60px;
  height: 76px;
  flex-shrink: 0;
}

/* ====================================================
   ✍️ なぞり書きセクション
   ==================================================== */
.trace-section {
  max-width: 920px;
  margin: 0 auto;
}

.trace-container {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  padding: 18px 14px;
  box-shadow: var(--shadow-md);
  border: 5px solid #ff9f43;
  text-align: center;
}

.trace-submode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  background: #f8fafc;
  padding: 6px;
  border-radius: 30px;
  border: 2px solid #e2e8f0;
}

.submode-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 20px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.submode-tab-btn.active {
  background: #ff9f43;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(255, 159, 67, 0.4);
  transform: scale(1.04);
}

.trace-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 8px;
}

.trace-target-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.target-word-icon {
  font-size: 34px;
  animation: bounceSlow 1.5s infinite;
}

.target-word-text {
  font-size: 24px;
  font-weight: 900;
  color: #1e293b;
}

.sound-bubble-btn {
  background: linear-gradient(135deg, #ffe66d, #ffd166);
  border: 2px solid #f59e0b;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 900;
  color: #78350f;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.sound-bubble-btn:hover {
  transform: scale(1.05);
}

/* ====================================================
   📋 1文字モード用 あいうえお表ミニクイックピッカー
   ==================================================== */
.char-picker-wrapper {
  width: 100%;
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 12px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.poster-mini-board {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 6px;
  width: max-content;
  margin: 0 auto;
  padding: 2px 4px;
}

.mini-poster-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-poster-cell {
  width: 52px;
  height: 64px;
  background: #ffffff;
  border: 2.5px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 2px;
  user-select: none;
}

.mini-poster-cell:hover {
  transform: scale(1.12);
  border-color: #ff9f43;
  background: #fffbeb;
  z-index: 2;
}

.mini-poster-cell:active {
  transform: scale(0.92);
}

.mini-poster-cell.selected {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-color: #f59e0b !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4) !important;
  transform: scale(1.1);
  z-index: 3;
}

.mini-cell-char {
  font-family: var(--font-hira);
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}

.mini-poster-cell.selected .mini-cell-char {
  color: #b45309;
}

.mini-cell-icon {
  font-size: 16px;
  line-height: 1;
}

.mini-cell-empty {
  width: 52px;
  height: 64px;
  visibility: hidden;
}

/* 単語選択バー */
.char-picker-scroll-wrapper {
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 10px;
  scrollbar-width: thin;
}

.word-picker {
  display: flex;
  gap: 8px;
  width: max-content;
  padding: 0 4px;
}

.word-pick-btn {
  padding: 8px 14px;
  border-radius: 14px;
  border: 3px solid #e2e8f0;
  background: #f8fafc;
  font-family: var(--font-hira);
  font-size: 16px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.word-pick-btn:hover {
  transform: scale(1.06);
  background: #fef3c7;
}

.word-pick-btn.active {
  background: #4ecdc4;
  color: #fff;
  border-color: #2bcbba;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(78, 205, 196, 0.4);
}

/* じぶんでつくる パネル (変身ボタンツールバー付き) */
.custom-word-builder {
  background: #fdfaf2;
  border: 3px solid #ffde59;
  border-radius: var(--border-radius-md);
  padding: 14px;
  margin-bottom: 12px;
  width: 100%;
}

.custom-input-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.builder-label {
  font-size: 15px;
  font-weight: 800;
  color: #64748b;
}

.custom-word-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.custom-word-preview {
  font-family: var(--font-hira);
  font-size: 28px;
  font-weight: 700;
  color: #ff4757;
  background: #ffffff;
  padding: 6px 20px;
  border-radius: 16px;
  border: 3px solid #ffde59;
  min-width: 160px;
  letter-spacing: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
  text-align: center;
}

.custom-preview-clear-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  background: #ef4444;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

.custom-preview-clear-btn:hover {
  transform: scale(1.15);
  background: #dc2626;
}

.custom-preview-clear-btn:active {
  transform: scale(0.9);
}

.custom-word-preview.pop-anim {
  animation: charPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes charPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2) rotate(3deg); }
  100% { transform: scale(1); }
}

/* 変身ツールバー */
.transform-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.tool-btn span {
  font-size: 18px;
  line-height: 1;
}

.tenten-btn {
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  color: #d35400;
  border-color: #f39c12;
}

.maru-btn {
  background: linear-gradient(135deg, #fab1a0, #ff7675);
  color: #c0392b;
  border-color: #e74c3c;
}

.small-btn {
  background: linear-gradient(135deg, #81ecec, #74b9ff);
  color: #0984e3;
  border-color: #0984e3;
}

.chouon-btn {
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  color: #ffffff;
  border-color: #6c5ce7;
}

.tool-btn:hover {
  transform: scale(1.08) translateY(-2px);
}

.tool-btn:active {
  transform: scale(0.92);
}

.builder-action-btn {
  padding: 8px 14px;
  border-radius: 14px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s;
}

.delete-char-btn { background: #ffeaa7; color: #d63031; }
.clear-all-btn { background: #dfe6e9; color: #2d3436; }
.builder-action-btn:hover { transform: scale(1.05); }

/* ====================================================
   ⌨️ じぶんでつくる用 キーボードあいうえお表
   ==================================================== */
.keyboard-container-wrapper {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 6px;
  width: 100%;
  overflow-x: auto;
  padding: 6px 0 10px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.key-poster-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.key-poster-cell {
  width: 52px;
  height: 64px;
  background: #ffffff;
  border: 2.5px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 2px;
  user-select: none;
}

.key-poster-cell:hover {
  transform: scale(1.12);
  border-color: #3b82f6;
  background: #eff6ff;
}

.key-poster-cell:active {
  transform: scale(0.92);
  background: #dbeafe;
}

.key-cell-char {
  font-family: var(--font-hira);
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}

.key-cell-icon {
  font-size: 16px;
  line-height: 1;
}

.key-cell-empty {
  width: 52px;
  height: 64px;
  visibility: hidden;
}

/* マルチキャンバスエリア */
.trace-canvas-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.nav-arrow-btn {
  background: #f1f5f9;
  border: 3px solid #cbd5e1;
  color: #334155;
  font-size: 14px;
  font-weight: 900;
  padding: 12px 10px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.nav-arrow-btn span {
  font-size: 20px;
}

.nav-arrow-btn:hover {
  transform: scale(1.08);
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* マルチマスキャンバスコンテナ (最大3文字×2列の段組み対応) */
.multi-canvas-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
}

/* 4〜6文字のときに1行最大3マスで2列（2段）にするスタイル */
.multi-canvas-container.two-row-grid {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 10px;
  justify-content: center;
}

.canvas-box {
  position: relative;
  background: #ffffff;
  border: 5px solid #ffde59;
  border-radius: var(--border-radius-lg);
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.06), 0 6px 18px rgba(0,0,0,0.08);
  touch-action: none;
  overflow: hidden;
}

/* 1文字 */
.single-char-box {
  width: 380px;
  height: 380px;
  max-width: 75vw;
  max-height: 75vw;
}

/* 2文字 */
.double-char-box {
  width: 220px;
  height: 220px;
  max-width: 40vw;
  max-height: 40vw;
}

/* 3文字 */
.triple-char-box {
  width: 180px;
  height: 180px;
  max-width: 28vw;
  max-height: 28vw;
}

/* 4〜6文字（3文字×2列の段組み） */
.grid-char-box {
  width: 165px;
  height: 165px;
  max-width: 26vw;
  max-height: 26vw;
}

.grid-cross-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.cross-line-h {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0;
  border-top: 2px dashed #e2e8f0;
}

.cross-line-v {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 100%;
  border-left: 2px dashed #e2e8f0;
}

.trace-svg-guide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.3s;
}

.trace-svg-guide.hidden-guide {
  opacity: 0 !important;
}

.guide-stroke-path {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s;
}

.anim-stroke-path {
  fill: none;
  stroke-width: 7.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.trace-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  color: #e2e8f0;
  user-select: none;
  pointer-events: none;
  line-height: 1;
  font-family: var(--font-hira);
  z-index: 2;
  transition: opacity 0.3s;
}

.single-char-box .trace-guide { font-size: 250px; }
.double-char-box .trace-guide { font-size: 150px; }
.triple-char-box .trace-guide { font-size: 120px; }
.grid-char-box .trace-guide { font-size: 110px; }

.trace-guide.hidden-guide {
  opacity: 0 !important;
}

.trace-canvas-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  z-index: 3;
}

.hanamaru-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1.4) rotate(-10deg);
  font-size: 110px;
  pointer-events: none;
  z-index: 10;
  animation: stampPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 6px 14px rgba(255, 71, 87, 0.4));
}

/* ====================================================
   🔢 書き順（筆順）番号バッジ＆アニメーション
   ==================================================== */
.stroke-badge-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.3s;
}

.stroke-badge-layer.hidden-badges {
  opacity: 0 !important;
}

.stroke-number-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25), inset 0 -1px 2px rgba(0,0,0,0.2);
  border: 2.5px solid #ffffff;
  line-height: 1;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 6;
}

/* 今なぞる番の数字が大きくポップアップ！ */
.stroke-number-badge.highlight-active {
  transform: translate(-50%, -50%) scale(1.8) !important;
  box-shadow: 0 0 22px rgba(255, 222, 89, 1), 0 0 36px rgba(255, 107, 107, 0.8), 0 6px 14px rgba(0,0,0,0.4) !important;
  border-color: #ffde59 !important;
  z-index: 25 !important;
  animation: numberJump 0.6s infinite alternate ease-in-out !important;
}

/* 書き終わった数字 */
.stroke-number-badge.stroke-done {
  transform: translate(-50%, -50%) scale(0.85);
  opacity: 0.8;
  border-color: #2ed573;
}

@keyframes numberJump {
  0% { transform: translate(-50%, -50%) scale(1.6) rotate(-6deg); }
  100% { transform: translate(-50%, -50%) scale(1.95) rotate(6deg); }
}

.single-char-box .stroke-number-badge {
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.grid-char-box .stroke-number-badge {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

/* 画数ごとの色分け */
.stroke-badge-1 { background: linear-gradient(135deg, #ff4757, #ff6b81); }
.stroke-badge-2 { background: linear-gradient(135deg, #1e90ff, #70a1ff); }
.stroke-badge-3 { background: linear-gradient(135deg, #2ed573, #7bed9f); }
.stroke-badge-4 { background: linear-gradient(135deg, #a06cd5, #e056fd); }
.stroke-badge-5 { background: linear-gradient(135deg, #ffa502, #ff7f50); }

/* なぞり書き実演中のゆび・ペンポインター */
.stroke-anim-pointer {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  transform: translate(-30%, -85%);
  transition: transform 0.04s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pointer-hand-icon {
  font-size: 48px;
  filter: drop-shadow(2px 6px 10px rgba(0,0,0,0.4));
  animation: handWiggle 0.35s infinite alternate ease-in-out;
  transform-origin: 30% 90%;
}

.pointer-sparkle-dot {
  position: absolute;
  bottom: 6px;
  left: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 10%, rgba(255, 222, 89, 0.8) 60%, transparent 100%);
  box-shadow: 0 0 14px #ffe66d, 0 0 24px #ff6b6b;
  animation: glowPulse 0.3s infinite alternate;
  pointer-events: none;
}

@keyframes handWiggle {
  0% { transform: rotate(-8deg) scale(0.98); }
  100% { transform: rotate(4deg) scale(1.05); }
}

@keyframes glowPulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(1.4); opacity: 1; }
}

.single-char-box .pointer-hand-icon { font-size: 56px; }
.double-char-box .pointer-hand-icon { font-size: 42px; }
.grid-char-box .pointer-hand-icon { font-size: 32px; }

/* かきじゅん実演ボタン */
.play-stroke-btn {
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  color: #78350f;
  border: 2px solid #f59e0b;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.play-stroke-btn:hover {
  background: linear-gradient(135deg, #fdcb6e, #f39c12);
  color: #ffffff;
}

.toggle-stroke-btn {
  background: #f1f5f9;
  color: #334155;
  border: 2px solid #cbd5e1;
}

.toggle-stroke-btn.active {
  background: #0984e3;
  color: #ffffff;
  border-color: #00cec9;
  box-shadow: 0 3px 8px rgba(9, 132, 227, 0.4);
}

.single-char-box .hanamaru-stamp { font-size: 140px; }
.double-char-box .hanamaru-stamp { font-size: 100px; }
.triple-char-box .hanamaru-stamp { font-size: 80px; }
.grid-char-box .hanamaru-stamp { font-size: 75px; }

@keyframes stampPop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-45deg); opacity: 0; }
  80% { transform: translate(-50%, -50%) scale(1.6) rotate(-5deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.4) rotate(-10deg); opacity: 1; }
}

.trace-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.color-palette {
  display: flex;
  gap: 12px;
  align-items: center;
}

.color-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.2s;
}

.color-dot.active {
  transform: scale(1.25);
  box-shadow: 0 0 14px rgba(0,0,0,0.3);
  border-color: #334155;
}

.rainbow-dot {
  background: linear-gradient(45deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.trace-btn {
  padding: 10px 20px;
  border-radius: 28px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle-guide-btn {
  background: #f1f5f9;
  color: #334155;
  border: 2px solid #cbd5e1;
}

.clear-btn {
  background: #f8fafc;
  color: #475569;
  border: 2px solid #e2e8f0;
}

.done-btn {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 71, 87, 0.4);
  font-size: 18px;
  padding: 10px 28px;
}

.trace-btn:hover { transform: scale(1.06); }
.trace-btn:active { transform: scale(0.95); }

/* 単語カード一覧 */
.section-header {
  text-align: center;
  margin-bottom: 20px;
}

.category-title {
  font-size: 26px;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 6px;
}

.section-instruction {
  font-size: 15px;
  font-weight: 700;
  color: #64748b;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

@media (max-width: 600px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

.word-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 4px solid #ffffff;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.word-card::after {
  content: "🔊 タップできいてね";
  position: absolute;
  bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  opacity: 0.8;
}

.word-card:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: var(--shadow-card-hover);
  border-color: #ffe66d;
}

.word-card:active {
  transform: scale(0.95);
}

.word-card.animating {
  animation: cardBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-color: #4ecdc4 !important;
  box-shadow: 0 0 20px rgba(78, 205, 196, 0.6);
}

@keyframes cardBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.15) rotate(4deg); }
  60% { transform: scale(0.95) rotate(-3deg); }
  100% { transform: scale(1) rotate(0); }
}

.card-icon {
  font-size: 60px;
  margin-bottom: 8px;
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
}

.word-card:hover .card-icon {
  transform: scale(1.2);
}

.card-en {
  font-family: 'Fredoka', cursive;
  font-size: 22px;
  font-weight: 700;
  color: #ff6b6b;
  margin-bottom: 2px;
  line-height: 1.1;
}

.card-ja {
  font-size: 14px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 12px;
}

.hira-card-char {
  font-size: 48px;
  font-weight: 900;
  color: #4ecdc4;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 2px 2px 0px #e0f2fe;
}

.hira-card-word {
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 12px;
}

/* クイズ */
.quiz-section {
  max-width: 650px;
  margin: 0 auto;
}

.quiz-container {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  padding: 30px 20px;
  box-shadow: var(--shadow-md);
  border: 4px solid #a06cd5;
  text-align: center;
}

.quiz-badge {
  display: inline-block;
  background: #f3e8ff;
  color: #8338ec;
  font-weight: 900;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 16px;
  margin-bottom: 12px;
}

.quiz-prompt {
  font-size: 22px;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 16px;
}

.repeat-sound-btn {
  background: linear-gradient(135deg, #ffe66d, #ffd166);
  border: 3px solid #f59e0b;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 900;
  color: #78350f;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.repeat-sound-btn:hover { transform: scale(1.08); }
.repeat-sound-btn:active { transform: scale(0.95); }

.quiz-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 10px;
}

.quiz-choice-card {
  background: #f8fafc;
  border: 4px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  padding: 20px 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quiz-choice-card:hover {
  transform: scale(1.05);
  border-color: #a06cd5;
  background: #faf5ff;
}

.quiz-choice-card.correct {
  background: #dcfce7 !important;
  border-color: #22c55e !important;
  animation: correctPulse 0.5s ease-in-out;
}

.quiz-choice-card.wrong {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  animation: wrongShake 0.4s ease-in-out;
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* モーダル */
.result-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: #fff;
  border-radius: var(--border-radius-lg);
  padding: 36px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  border: 5px solid #ffe66d;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-stars {
  font-size: 48px;
  margin-bottom: 12px;
  animation: bounceSlow 1.5s infinite;
}

.modal-title {
  font-size: 26px;
  font-weight: 900;
  color: #ff6b6b;
  margin-bottom: 8px;
}

.modal-score {
  font-size: 18px;
  font-weight: 800;
  color: #475569;
  margin-bottom: 6px;
}

.modal-reward {
  font-size: 16px;
  font-weight: 900;
  color: #d97706;
  margin-bottom: 24px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-btn {
  padding: 14px 20px;
  border-radius: var(--border-radius-md);
  font-size: 18px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}

.play-again-btn {
  background: linear-gradient(135deg, #4ecdc4, #2ecc71);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.back-home-btn {
  background: #f1f5f9;
  color: #475569;
}

.modal-btn:hover { transform: scale(1.04); }

/* フッター */
.app-footer {
  background: rgba(255, 255, 255, 0.7);
  border-top: 2px solid #e2e8f0;
  padding: 16px;
  text-align: center;
  margin-top: auto;
  z-index: 10;
}

.parent-tip {
  font-size: 13px;
  color: #475569;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
}

/* キャンバス */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.hidden {
  display: none !important;
}

/* ====================================================
   📚 ひらがな・教科書体 フォント強化
   ==================================================== */
.hira-font,
.correct-hira-font,
.hira-card-char,
.target-word-text,
.quiz-choice-card .hira-card-char,
.mini-cell-char,
.builder-preview-char,
.col-label {
  font-family: var(--font-hira) !important;
}

/* ====================================================
   🌟 きっずランド トップポータル画面 (index.html)
   ==================================================== */
.portal-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 30px 16px 50px;
  width: 100%;
  position: relative;
  z-index: 2;
}

.portal-hero {
  text-align: center;
  margin-bottom: 36px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #ffe66d;
  padding: 6px 18px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 900;
  color: #b45309;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.portal-hero-title {
  font-size: 34px;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 10px;
  line-height: 1.3;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

.portal-hero-sub {
  font-size: 16px;
  font-weight: 800;
  color: #475569;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
  margin-bottom: 36px;
}

.portal-choice-card {
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 36px 24px 28px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 4px solid transparent;
  cursor: pointer;
}

.portal-choice-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: var(--shadow-card-hover);
}

.portal-choice-card:active {
  transform: scale(0.98);
}

/* ひらがなカード */
.card-hira {
  border-color: #4ecdc4;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
}

.card-hira:hover {
  border-color: #2ecc71;
  box-shadow: 0 16px 32px rgba(46, 204, 113, 0.25);
}

/* 英語カード */
.card-english {
  border-color: #ff6b6b;
  background: linear-gradient(180deg, #ffffff 0%, #fff1f2 100%);
}

.card-english:hover {
  border-color: #ff4757;
  box-shadow: 0 16px 32px rgba(255, 71, 87, 0.25);
}

/* かずカード */
.card-numbers, .card-math {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.card-numbers:hover, .card-math:hover {
  border-color: #2563eb;
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.25);
}

/* とけいカード */
.card-clock {
  border-color: #c084fc;
  background: linear-gradient(180deg, #ffffff 0%, #faf5ff 100%);
}

.card-clock:hover {
  border-color: #9333ea;
  box-shadow: 0 16px 32px rgba(147, 51, 234, 0.25);
}

.portal-card-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #ffde59;
  color: #78350f;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.portal-card-icon-wrap {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 58px;
  margin-bottom: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.portal-choice-card:hover .portal-card-icon-wrap {
  transform: scale(1.15) rotate(6deg);
}

.card-hira .portal-card-icon-wrap {
  background: linear-gradient(135deg, #e0f2fe, #ccfbf1);
  font-family: var(--font-hira);
  font-weight: 700;
  color: #0d9488;
}

.card-english .portal-card-icon-wrap {
  background: linear-gradient(135deg, #fee2e2, #fed7aa);
}

.card-numbers .portal-card-icon-wrap, .card-math .portal-card-icon-wrap {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}

.card-clock .portal-card-icon-wrap {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
}

.portal-card-title {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 8px;
  text-align: center;
}

.card-hira .portal-card-title {
  color: #0f766e;
  font-family: var(--font-hira);
}

.card-english .portal-card-title {
  color: #e11d48;
}

.card-numbers .portal-card-title, .card-math .portal-card-title {
  color: #1d4ed8;
}

.card-clock .portal-card-title {
  color: #7e22ce;
}

.portal-card-desc {
  font-size: 15px;
  color: #64748b;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
  font-weight: 700;
}

.portal-card-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  width: 100%;
}

.portal-tag {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.portal-card-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 30px;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}

.card-hira .portal-card-btn {
  background: linear-gradient(135deg, #2dd4bf, #059669);
}

.card-english .portal-card-btn {
  background: linear-gradient(135deg, #f87171, #e11d48);
}

.card-numbers .portal-card-btn, .card-math .portal-card-btn {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
}

.card-clock .portal-card-btn {
  background: linear-gradient(135deg, #c084fc, #9333ea);
}

.portal-choice-card:hover .portal-card-btn {
  transform: scale(1.04);
}

/* ポータルの保護者様向けガイドエリア */
.portal-guide-card {
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid #ffde59;
  border-radius: var(--border-radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.guide-icon {
  font-size: 40px;
  flex-shrink: 0;
}

.guide-text h4 {
  font-size: 16px;
  font-weight: 900;
  color: #78350f;
  margin-bottom: 4px;
}

.guide-text p {
  font-size: 13px;
  color: #475569;
  line-height: 1.6;
}

/* 戻るリンクボタン（個別ページ用） */
.back-home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  color: #334155;
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.back-home-link:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: scale(1.05);
}

.back-home-link:active {
  transform: scale(0.95);
}

/* ====================================================
   📊 きょうのがんばりカード（賞状モーダル＆ボタン）
   ==================================================== */
.report-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px solid #f97316;
  color: #c2410c;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(249, 115, 22, 0.2);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.report-badge-btn:hover {
  transform: scale(1.06);
  background: #ffedd5;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.3);
}

.report-badge-btn:active {
  transform: scale(0.95);
}

.report-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.certificate-card {
  background: #ffffff;
  border: 8px solid #f59e0b;
  outline: 4px solid #fef3c7;
  border-radius: 24px;
  padding: 30px 24px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  animation: certPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  background-image: radial-gradient(#fffbeb 15%, transparent 16%);
  background-size: 20px 20px;
}

@keyframes certPop {
  0% { transform: scale(0.7) translateY(40px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.cert-crown {
  font-size: 44px;
  margin-bottom: 4px;
  animation: crownFloat 2s ease-in-out infinite;
}

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

.cert-title {
  font-size: 26px;
  font-weight: 900;
  color: #78350f;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.cert-date {
  font-size: 14px;
  font-weight: 800;
  color: #92400e;
  margin-bottom: 16px;
}

.cert-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.cert-stat-item {
  background: #ffffff;
  border: 2px solid #fed7aa;
  border-radius: 16px;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.cert-stat-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.cert-stat-info {
  text-align: left;
}

.cert-stat-label {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
}

.cert-stat-value {
  font-size: 18px;
  font-weight: 900;
  color: #ea580c;
}

.cert-stamp {
  display: inline-block;
  background: rgba(239, 68, 68, 0.08);
  border: 3px dashed #ef4444;
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 20px;
  font-weight: 900;
  transform: rotate(-5deg);
  margin-bottom: 20px;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.15);
  animation: stampSlam 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes stampSlam {
  0% { transform: scale(2.5) rotate(15deg); opacity: 0; }
  100% { transform: scale(1) rotate(-5deg); opacity: 1; }
}

.cert-cheer-msg {
  background: #f0fdf4;
  border: 2px solid #86efac;
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #166534;
  margin-bottom: 20px;
}

.cert-actions-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.cert-share-btn {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  border: none;
  font-size: 15px;
  font-weight: 900;
  padding: 12px 24px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s;
}

.cert-share-btn:hover {
  transform: scale(1.05);
}

.cert-close-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  padding: 12px 28px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
  transition: all 0.2s;
}

.cert-close-btn:hover {
  transform: scale(1.05);
}

/* ====================================================
   📱 PWAホーム画面追加バナー＆ガイドモーダル
   ==================================================== */
.pwa-install-banner {
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border: 2px dashed #f59e0b;
  border-radius: 20px;
  padding: 12px 18px;
  margin: 16px auto;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.15);
}

.pwa-banner-text {
  font-size: 14px;
  font-weight: 800;
  color: #92400e;
  text-align: left;
}

.pwa-banner-btn {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  border: none;
  font-size: 13px;
  font-weight: 900;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
  transition: transform 0.2s;
}

.pwa-banner-btn:hover {
  transform: scale(1.06);
}

.pwa-banner-close-btn {
  background: rgba(146, 64, 14, 0.12);
  color: #92400e;
  border: none;
  font-size: 14px;
  font-weight: 900;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pwa-banner-close-btn:hover {
  background: rgba(146, 64, 14, 0.25);
  transform: scale(1.1);
}

.pwa-guide-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.pwa-guide-card {
  background: #ffffff;
  border: 6px solid #3b82f6;
  border-radius: 24px;
  padding: 28px 22px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  animation: certPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-step-box {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  margin: 12px 0;
  text-align: left;
  font-size: 13.5px;
  color: #334155;
  font-weight: 700;
  line-height: 1.6;
}

.pwa-step-box strong {
  color: #2563eb;
}

/* ====================================================
   🔢 かず・とけい ポータルカード
   ==================================================== */
.card-math {
  border-color: #8b5cf6;
}

.card-math:hover {
  border-color: #7c3aed;
}

.card-math .portal-card-icon-wrap {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #7c3aed;
}

.card-math .portal-card-title {
  color: #5b21b6;
}

.card-math .portal-card-btn {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
}

/* ====================================================
   ⏰ とけいマスター（アナログ時計盤 ＆ コントロール）
   ==================================================== */
.clock-section {
  max-width: 700px;
  margin: 0 auto;
}

.clock-card {
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 30px 20px;
  box-shadow: var(--shadow-md);
  border: 4px solid #8b5cf6;
  text-align: center;
}

/* ====================================================
   🎯 とけいあわせ ゲーム目標バナー
   ==================================================== */
.clock-target-banner {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 3px solid #f59e0b;
  border-radius: 20px;
  padding: 12px 14px;
  margin: 0 auto 16px;
  max-width: 440px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  text-align: center;
}

.clock-target-title {
  font-size: 14px;
  font-weight: 900;
  color: #92400e;
  margin-bottom: 6px;
}

.clock-target-time-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

#targetSceneIcon {
  font-size: min(36px, 9vw);
  line-height: 1;
  flex-shrink: 0;
}

#targetTimeLabel {
  font-family: 'Fredoka', 'M PLUS Rounded 1c', sans-serif;
  font-size: min(36px, 8.5vw);
  font-weight: 900;
  color: #ea580c;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.clock-dial-wrapper {
  position: relative;
  width: min(280px, 80vw);
  height: min(280px, 80vw);
  margin: 0 auto 20px;
}

.clock-dial {
  width: min(270px, 78vw);
  height: min(270px, 78vw);
  background: #ffffff;
  border: 10px solid #c4b5fd;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.08), 0 8px 24px rgba(139, 92, 246, 0.2);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.clock-dial:active {
  cursor: grabbing;
}

.clock-dial.dragging .clock-hand {
  transition: none !important;
}

/* 時計のドラッグガイドバッジ */
.clock-drag-hint {
  font-size: 14px;
  font-weight: 800;
  color: #7c3aed;
  background: #f5f3ff;
  border: 2px dashed #a78bfa;
  border-radius: 20px;
  padding: 6px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

/* 時計合わせゲーム用スタイル */
.clock-target-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 3px solid #f59e0b;
  border-radius: 24px;
  padding: 14px 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.clock-target-title {
  font-size: 16px;
  font-weight: 900;
  color: #92400e;
  margin-bottom: 4px;
}

.clock-target-time-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 32px;
  font-weight: 900;
  color: #78350f;
}

.clock-match-success-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 900;
  padding: 12px 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.2s;
  margin-top: 12px;
}

.quiz-clock-illustration {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 14px auto 18px;
  filter: drop-shadow(0 6px 14px rgba(139, 92, 246, 0.25));
  animation: clockFloat 3s ease-in-out infinite;
}

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

.clock-center-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: #f59e0b;
  border: 3px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.clock-number {
  position: absolute;
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 20px;
  font-weight: 900;
  color: #1e293b;
  text-align: center;
  transform: translate(-50%, -50%);
}

.clock-hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform-origin: bottom center;
  border-radius: 10px 10px 0 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: grab;
}

.clock-hand-hour {
  width: 10px;
  height: 72px;
  background: linear-gradient(to top, #2563eb, #3b82f6);
  border: 2px solid #1d4ed8;
  margin-left: -5px;
  z-index: 7;
}

.clock-hand-hour::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: #3b82f6;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.clock-hand-minute {
  width: 6px;
  height: 105px;
  background: linear-gradient(to top, #dc2626, #ef4444);
  border: 2px solid #b91c1c;
  margin-left: -3px;
  z-index: 8;
}

.clock-hand-minute::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: #ef4444;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}

.clock-hand.active-hand {
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.8)) !important;
}

.clock-digital-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  color: #38bdf8;
  font-family: 'Fredoka', monospace, sans-serif;
  font-size: 32px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin-bottom: 18px;
  letter-spacing: 2px;
}

.clock-speech-box {
  background: #ede9fe;
  border: 2px solid #c4b5fd;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 18px;
  font-weight: 900;
  color: #5b21b6;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  cursor: pointer;
  transition: transform 0.2s;
}

.clock-speech-box:hover {
  transform: scale(1.05);
}

.clock-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.clock-ctrl-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 900;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
}

.clock-ctrl-btn:hover {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6d28d9;
  transform: scale(1.05);
}

.clock-presets-title {
  font-size: 16px;
  font-weight: 900;
  color: #475569;
  margin-bottom: 12px;
}

.clock-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.preset-scene-card {
  background: #faf5ff;
  border: 2px solid #e9d5ff;
  border-radius: 14px;
  padding: 10px 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.preset-scene-card:hover {
  transform: translateY(-3px) scale(1.04);
  border-color: #a855f7;
  background: #f3e8ff;
}

.preset-scene-icon { font-size: 26px; }
.preset-scene-time { font-size: 13px; font-weight: 900; color: #7c3aed; }
.preset-scene-label { font-size: 12px; font-weight: 800; color: #475569; }

/* ====================================================
   🔢 かずをかぞえよう（Counting 1〜10）
   ==================================================== */
.count-section {
  max-width: 700px;
  margin: 0 auto;
}

.count-card {
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
  border: 4px solid #f59e0b;
  text-align: center;
}

.count-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  background: #fffbeb;
  padding: 10px 16px;
  border-radius: 16px;
}

.count-badge {
  font-size: 16px;
  font-weight: 900;
  color: #b45309;
}

.count-meter {
  font-size: 22px;
  font-weight: 900;
  color: #d97706;
}

.count-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  min-height: 180px;
  align-items: center;
  justify-items: center;
  padding: 20px;
  background: #fafaf9;
  border-radius: 20px;
  border: 2px dashed #e7e5e4;
}

.count-item-btn {
  width: 75px;
  height: 75px;
  border-radius: 20px;
  background: #ffffff;
  border: 3px solid #fed7aa;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  font-size: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.count-item-btn:hover {
  transform: scale(1.12);
  border-color: #f97316;
}

.count-item-btn.counted {
  background: #ffedd5;
  border-color: #ea580c;
  transform: scale(0.95);
}

.count-item-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ea580c;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.count-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ステージ選択ボタン (Lv.1〜10) */
.count-stage-picker {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.count-stage-btn {
  background: #ffffff;
  border: 2px solid #fed7aa;
  color: #c2410c;
  font-size: 13px;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.count-stage-btn:hover {
  transform: scale(1.08);
  border-color: #ea580c;
  background: #fff7ed;
}

.count-stage-btn.active {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  border-color: #ea580c;
  box-shadow: 0 3px 8px rgba(234, 88, 12, 0.35);
  transform: scale(1.06);
}

/* ダミーアイテムをタップしたときのシェイク */
.count-item-btn.shake-anim {
  animation: itemShake 0.4s ease-in-out;
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
}

@keyframes itemShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.count-hint-bubble {
  font-size: 15px;
  font-weight: 800;
  color: #c2410c;
  background: #fff7ed;
  border: 2px dashed #f97316;
  border-radius: 20px;
  padding: 8px 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.count-next-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  padding: 12px 28px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
  transition: all 0.2s;
}

.count-next-btn:hover {
  transform: scale(1.06);
}

/* ====================================================
   🔢 大きくて押しやすい数字セレクター (1〜10)
   ==================================================== */
.number-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 780px;
  margin: 0 auto 16px;
  padding: 4px;
}

@media (max-width: 650px) {
  .number-picker-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
}

.num-picker-card-btn {
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: 16px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 70px;
}

.num-picker-card-btn:hover {
  transform: translateY(-3px) scale(1.08);
  border-color: #8b5cf6;
  background: #f5f3ff;
}

.num-picker-card-btn:active {
  transform: scale(0.95);
}

.num-picker-card-btn.selected {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe) !important;
  border-color: #8b5cf6 !important;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35) !important;
  transform: scale(1.06);
}

.num-picker-digit {
  font-family: 'Fredoka', 'M PLUS Rounded 1c', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: #6d28d9;
  line-height: 1;
}

.num-picker-label {
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
  margin-top: 4px;
}

/* ====================================================
   ✍️ なぞり書きキャンバス用スタイル (共通)
   ==================================================== */
.canvas-workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 16px auto;
  width: 100%;
}

.canvas-multi-wrap {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.canvas-char-box {
  position: relative;
  background: #ffffff;
  border: 5px solid #ffde59;
  border-radius: 24px;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.08);
  touch-action: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-char-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: #ff4757;
  color: #ffffff;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(255, 71, 87, 0.45);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 25;
}

.canvas-char-delete-btn:hover {
  transform: scale(1.18);
  background: #ee5253;
}

.canvas-char-delete-btn:active {
  transform: scale(0.9);
}

.canvas-grid-cross {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.canvas-grid-cross::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  border-top: 2px dashed #e2e8f0;
}

.canvas-grid-cross::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  border-left: 2px dashed #e2e8f0;
}

.svg-stroke-guide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.3s;
}

.svg-stroke-guide.guide-hidden {
  opacity: 0 !important;
}

.guide-path {
  fill: none !important;
  stroke: #cbd5e1 !important;
  stroke-width: 7.5px !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.anim-stroke-path {
  fill: none !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.fallback-char-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 160px;
  font-weight: 700;
  color: #e2e8f0;
  user-select: none;
  pointer-events: none;
  z-index: 2;
  line-height: 1;
}

.fallback-char-guide.guide-hidden {
  opacity: 0 !important;
}

.stroke-badges-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.stroke-number-badge {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff4757;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  border: 2px solid #ffffff;
}

.trace-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  cursor: crosshair;
  touch-action: none;
}

.hanamaru-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-size: 120px;
  pointer-events: none;
  z-index: 10;
  animation: hanamaruPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hanamaruPop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 0; }
  70% { transform: translate(-50%, -50%) scale(1.15) rotate(10deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

.stroke-demo-pointer {
  position: absolute;
  font-size: 40px;
  pointer-events: none;
  z-index: 20;
  transform: translate(-20%, -80%);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
  transition: transform 0.05s ease-out;
}




