/* =========================================
   漢字ドリル
   算数ドリル（drill/style.css）のデザイン体系を再現した専用CSS
   （drill の style.css は読み込まず、このファイルで完結させる）
========================================= */

:root {
  --purple: #7656db;
  --purple-dark: #5739b7;
  --purple-light: #f0eaff;
  --yellow: #ffdc62;
  --orange: #ff985e;
  --orange-light: #fff0e5;
  --green: #63cfa7;
  --green-light: #e6f9ef;
  --blue: #70b8ed;
  --pink: #ff91b8;
  --text: #40395e;
  --text-light: #89839d;
  --background: #f8f5ff;
  --white: #ffffff;
  --radius-large: 28px;
  --radius-medium: 18px;
  --shadow: 0 10px 30px rgba(91, 67, 156, 0.09);
  --ok: #2f9e6e;
  --ok-bg: #e7f9ef;
  --ng: #e05260;
  --ng-bg: #fdeef0;
  --line-soft: #eae5f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "M PLUS Rounded 1c", sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.8;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
/* hidden 属性は display 指定のあるクラス（.hw-toggle / .feedback-box / .choice-answer 等）に
   勝てないため、明示的に最優先で効かせる。これが無いと「非表示にしたはずのUIが出続ける」
   バグになる（2026-11-27 実機報告：手書き切替が全モードで表示・フィードバック残留）。 */
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
main { width: 100%; }

/* 背景装飾 */
.background-decoration { position: absolute; pointer-events: none; z-index: 0; font-weight: 900; }
.decoration-one { top: 430px; left: 3%; color: #ffd96d; font-size: 48px; }
.decoration-two { top: 1050px; right: 4%; color: #ffb2cc; font-size: 35px; }
.decoration-three { top: 1850px; left: 2%; color: #9c8be9; font-size: 40px; }

/* ヘッダー */
.site-header { background: rgba(255,255,255,0.95); border-bottom: 1px solid #eee9fb; position: relative; z-index: 5; }
.header-inner { max-width: 1160px; margin: auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.site-logo { display: flex; align-items: center; gap: 11px; }
.logo-icon { font-size: 30px; font-weight: 900; color: var(--purple-dark); background: #fff1b8; width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; }
.logo-text { display: flex; flex-direction: column; line-height: 1.4; }
.logo-text strong { font-size: 17px; font-weight: 900; color: var(--purple-dark); }
.logo-text small { font-size: 9px; letter-spacing: 1.5px; font-weight: 800; color: #aaa1c7; }
.header-nav { display: flex; gap: 30px; font-size: 13px; font-weight: 800; }
.header-nav a { transition: color .2s; }
.header-nav a:hover { color: var(--purple); }
.header-badge { background: #fff6d9; color: #9e771f; padding: 8px 16px; border-radius: 30px; font-size: 12px; font-weight: 800; }

/* ヒーロー */
.hero { max-width: 1160px; margin: auto; padding: 85px 30px 75px; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 50px; position: relative; }
.hero-content { position: relative; z-index: 1; }
.hero-label { display: inline-block; background: #fff0ba; color: #9c7218; border-radius: 30px; padding: 7px 18px; font-size: 13px; font-weight: 900; margin-bottom: 20px; }
.hero h1 { font-size: clamp(38px, 5vw, 61px); line-height: 1.4; letter-spacing: -2px; font-weight: 900; }
.hero-highlight { color: var(--purple); position: relative; }
.hero-highlight::after { content: ""; position: absolute; left: 0; right: 0; bottom: 1px; height: 9px; background: #ffe18b; border-radius: 10px; z-index: -1; }
.hero-description { color: #827b9a; font-size: 14px; font-weight: 700; margin: 22px 0 28px; line-height: 2.1; }
.hero-button { display: inline-flex; align-items: center; justify-content: center; gap: 13px; background: var(--purple); color: white; padding: 17px 30px; border-radius: 17px; font-size: 16px; font-weight: 900; box-shadow: 0 7px 0 var(--purple-dark); transition: transform .2s, box-shadow .2s; }
.hero-button:hover { transform: translateY(3px); box-shadow: 0 4px 0 var(--purple-dark); }
.hero-features { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 25px; color: #80799a; font-size: 11px; font-weight: 800; }
.hero-visual { min-height: 380px; position: relative; display: grid; place-items: center; background: radial-gradient(circle at 50% 50%, #eee5ff 0%, #e9e1ff 48%, transparent 72%); }
.hero-kanji-card { width: 330px; max-width: 85%; background: white; border: 5px solid white; border-radius: 30px; padding: 24px; box-shadow: 0 18px 40px rgba(88, 65, 150, .15); transform: rotate(-4deg); position: relative; z-index: 2; text-align: center; }
.math-card-top { display: flex; justify-content: space-between; color: var(--purple); font-size: 11px; font-weight: 900; }
.hero-kanji-big { font-size: 110px; font-weight: 900; line-height: 1.3; color: var(--text); }
.hero-kanji-read { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--green-light); color: #31a77d; border-radius: 18px; padding: 9px; font-size: 22px; font-weight: 900; }
.hero-card-message { color: #38a980; text-align: center; font-size: 13px; font-weight: 900; margin-top: 13px; }
.hero-sun { position: absolute; top: 12px; right: 10%; font-size: 55px; }
.hero-star { position: absolute; font-size: 40px; color: #ffc94c; }
.star-a { left: 8%; top: 22%; }
.star-b { right: 10%; bottom: 20%; color: #ff9ab9; }
.hero-floating-badge { position: absolute; z-index: 3; background: white; border-radius: 30px; padding: 10px 15px; font-size: 11px; font-weight: 900; box-shadow: var(--shadow); }
.badge-left { left: 0; top: 22%; transform: rotate(-8deg); }
.badge-right { right: -5px; bottom: 10%; transform: rotate(5deg); }

/* ポイント */
.point-section { max-width: 1160px; margin: 0 auto; padding: 0 24px 70px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.point-card { background: white; border-radius: 20px; padding: 20px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow); }
.point-icon { width: 55px; height: 55px; flex-shrink: 0; border-radius: 17px; display: grid; place-items: center; font-size: 27px; }
.point-orange .point-icon { background: var(--orange-light); }
.point-green .point-icon { background: var(--green-light); }
.point-purple .point-icon { background: var(--purple-light); }
.point-card div { display: flex; flex-direction: column; }
.point-card strong { font-size: 13px; font-weight: 900; }
.point-card small { color: var(--text-light); font-size: 10px; font-weight: 700; }

/* セクション共通 */
.section-heading { text-align: center; margin-bottom: 35px; }
.section-kicker { display: inline-block; color: var(--purple); font-size: 11px; letter-spacing: 2px; font-weight: 900; background: var(--purple-light); padding: 5px 15px; border-radius: 30px; margin-bottom: 12px; }
.section-heading h2 { font-size: clamp(23px, 3vw, 32px); font-weight: 900; letter-spacing: -1px; }
.section-heading p { color: var(--text-light); font-size: 13px; font-weight: 700; margin-top: 7px; }

/* 設定カード */
.challenge-section { padding: 80px 24px 95px; background: #eee9ff; }
.settings-card { max-width: 850px; margin: auto; background: white; border-radius: 28px; overflow: hidden; box-shadow: 0 18px 50px rgba(81, 57, 145, .1); }
.settings-header { background: var(--purple); color: white; display: flex; align-items: center; gap: 15px; padding: 24px 32px; position: relative; overflow: hidden; }
.settings-header::after { content: "✦"; position: absolute; right: 35px; top: -30px; font-size: 110px; opacity: .12; }
.settings-header-icon { width: 55px; height: 55px; background: rgba(255,255,255,.18); border-radius: 17px; display: grid; place-items: center; font-size: 29px; }
.settings-header h3 { font-size: 20px; font-weight: 900; }
.settings-header p { font-size: 11px; opacity: .8; }
.settings-body { padding: 32px; }
.setting-group { margin-bottom: 33px; }
.setting-label { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; font-size: 15px; font-weight: 900; }
.setting-number { width: 29px; height: 29px; background: var(--purple-light); color: var(--purple); border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 900; }
.custom-select { width: 100%; padding: 15px 17px; border: 2px solid #eae5f6; border-radius: 14px; color: var(--text); background: #fcfbff; font-size: 14px; font-weight: 800; outline: none; cursor: pointer; }
.custom-select:focus { border-color: var(--purple); }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 360px; }
.choice-card { position: relative; cursor: pointer; border: 2px solid #eeeaf7; background: #fcfbff; border-radius: 15px; padding: 13px 5px; display: flex; flex-direction: column; align-items: center; transition: .2s; }
.choice-card:hover { border-color: #c6b5ff; transform: translateY(-2px); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card:has(input:checked) { border-color: var(--purple); background: #f3eeff; box-shadow: 0 3px 0 rgba(118,86,219,.12); }
.choice-card span { font-size: 17px; font-weight: 900; color: var(--purple); }
.choice-card small { color: var(--text-light); font-size: 9px; font-weight: 700; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mode-card { position: relative; cursor: pointer; border: 2px solid #eeeaf7; border-radius: 17px; background: white; padding: 19px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; transition: .2s; }
.mode-card:hover { transform: translateY(-3px); }
.mode-card input { position: absolute; opacity: 0; }
.mode-card:has(input:checked) { border-color: var(--purple); background: #f6f2ff; }
.mode-icon { font-size: 30px; margin-bottom: 6px; }
.mode-card strong { font-size: 13px; font-weight: 900; }
.mode-card small { font-size: 10px; color: var(--text-light); margin-top: 4px; line-height: 1.6; }
.start-area { text-align: center; padding: 25px 0 5px; border-top: 1px dashed #e9e3f6; }
.start-area p { font-size: 12px; color: var(--text-light); font-weight: 800; margin-bottom: 17px; }
.start-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: stretch; }
.start-button { width: min(100%, 370px); padding: 17px 22px; background: var(--orange); color: white; border: none; border-radius: 17px; font-size: 17px; font-weight: 900; box-shadow: 0 6px 0 #df7540; transition: .2s; }
.start-button:hover { transform: translateY(3px); box-shadow: 0 3px 0 #df7540; }
.review-link-button { display: inline-flex; align-items: center; gap: 7px; padding: 12px 18px; background: white; color: var(--purple-dark); border: 2px solid var(--purple); border-radius: 17px; font-size: 14px; font-weight: 800; transition: .2s; }
.review-link-button small { font-size: 11px; font-weight: 700; color: var(--purple); background: var(--purple-light); border-radius: 999px; padding: 2px 8px; }
.review-link-button:hover { background: var(--purple-light); }
.review-link-button:disabled { opacity: .45; cursor: default; }
.start-note { font-size: 10px; color: #b0a9c3; margin-top: 16px; font-weight: 700; }
.data-note { max-width: 850px; margin: 18px auto 0; background: #fff6d9; color: #7c6414; border-radius: 14px; padding: 12px 18px; font-size: 12px; font-weight: 700; text-align: center; }

/* 問題エリア */
.game-section { padding: 90px 24px; }
.game-card { max-width: 760px; margin: auto; background: white; border-radius: 27px; box-shadow: var(--shadow); overflow: hidden; padding: 28px; }
.game-topbar { display: flex; align-items: center; justify-content: space-between; }
.game-level { background: #fff2d1; color: #a87b19; border-radius: 30px; padding: 7px 14px; font-size: 11px; font-weight: 900; }
.game-status { color: var(--purple); font-size: 10px; font-weight: 900; letter-spacing: 1.5px; }
.game-progress-area { margin-top: 25px; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; margin-bottom: 9px; }
.progress-label strong { color: var(--purple); }
.progress-track { height: 11px; border-radius: 20px; background: #eeeaf6; overflow: hidden; }
.progress-value { width: 0; height: 100%; border-radius: 20px; background: linear-gradient(90deg, #9a83f1, #7453dc); transition: width .3s; }
.question-area { background: #f2edff; border-radius: 23px; padding: 28px 20px; margin-top: 25px; text-align: center; position: relative; overflow: hidden; }
.question-prompt-label { color: var(--purple); font-size: 13px; font-weight: 900; letter-spacing: 1px; }
.question-prompt { font-size: clamp(34px, 6vw, 52px); font-weight: 900; line-height: 1.5; color: var(--purple); }
.question-prompt.is-kanji { font-size: clamp(72px, 14vw, 120px); line-height: 1.35; color: var(--text); }
.question-prompt.is-word { font-size: clamp(46px, 11vw, 88px); line-height: 1.4; letter-spacing: .04em; color: var(--text); }
.question-prompt.is-sentence { font-size: clamp(24px, 4.6vw, 36px); line-height: 1.7; color: var(--text); }
.question-example { margin-top: 10px; font-size: clamp(17px, 3.4vw, 22px); font-weight: 700; line-height: 1.7; color: var(--text); }
.ex-mark { color: var(--purple); background: #f2edff; border-radius: 6px; padding: 0 4px; font-weight: 900; }
/* 言葉読みモード：言葉全体が対象であることを示すマーカー（プロンプト用） */
.word-mark { color: var(--purple); background: #f2edff; border-radius: 12px; padding: 0 12px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
/* 表記（ひらがな／漢字＋ルビ／漢字）：算数ドリルから移植 */
.choice-grid.notation-grid { grid-template-columns: repeat(3, 1fr); max-width: 480px; }
ruby { ruby-align: center; }
rt { font-size: .52em; font-weight: 700; letter-spacing: 0; }
/* ルビ表示のときは、ふりがなの分だけ行間を広げて重なりを防ぐ */
body[data-notation="ruby"] .question-prompt { line-height: 1.9; }
body[data-notation="ruby"] .question-example { line-height: 2.1; }
/* 手書き入力・なぞり練習 */
.hw-toggle { display: flex; gap: 8px; justify-content: center; margin: 4px 0 12px; }
.hw-mode-btn {
  font: inherit; font-size: 15px; font-weight: 800; color: var(--text-light);
  background: var(--white); border: 2px solid #e3dcff; border-radius: 999px;
  padding: 7px 16px; cursor: pointer;
}
.hw-mode-btn.active { color: var(--white); background: var(--purple); border-color: var(--purple); }
#hwCanvas, #traceCanvas {
  width: 280px; max-width: 86vw; height: auto; aspect-ratio: 1 / 1;
  border: 2px solid #e3dcff; border-radius: 14px; touch-action: none;
  display: block; margin: 0 auto;
  /* 描画中のテキスト選択・長押しコールアウト抑止（JS側の preventDefault と併用） */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
/* 手書きモード中はプレイエリア全体で選択・コールアウトを抑止（キャンバス周辺の事故防止） */
.hw-on, .hw-on * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#hwCanvas { background: var(--white); }
#traceCanvas { background: transparent; position: relative; }
.hw-buttons { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.hw-note { font-size: 13px; color: var(--text-light); text-align: center; margin: 8px 0 0; }
/* 読み→言葉ぜんぶ（入力）の手書き：字ごとのマス。かな部分は文字でそのまま出す */
.hw-cells { display: flex; gap: 10px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.hw-cell { text-align: center; }
.hw-cell canvas {
  width: 200px; max-width: 42vw; height: auto; aspect-ratio: 1 / 1;
  border: 2px solid #e3dcff; border-radius: 14px; touch-action: none;
  display: block; margin: 0 auto; background: var(--white);
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.hw-cell-buttons { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.hw-kana {
  font-size: 56px; font-weight: 900; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; height: 200px; max-height: 42vw;
}
.trace-area { margin-top: 26px; text-align: center; }
.trace-title { font-size: 18px; margin: 0 0 4px; }
.trace-note { font-size: 13.5px; color: var(--text-light); margin: 0 0 12px; }
.trace-wrap { position: relative; width: 280px; max-width: 86vw; margin: 0 auto; }
.trace-bg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 225px; font-weight: 900; line-height: 1; color: #ece8fa; pointer-events: none;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}
.answer-area { padding: 25px 0 5px; text-align: center; }
.choice-answer { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.choice-answer .choice { background: white; border: 2px solid #eae5f5; border-radius: 14px; padding: 15px 5px; font-size: 19px; font-weight: 900; color: var(--text); transition: .2s; }
.choice-answer .choice:hover { border-color: var(--purple); background: #f2edff; color: var(--purple); }
.choice-answer .choice.sel { border-color: var(--purple); background: #f2edff; color: var(--purple); }
.choice-answer .choice:disabled { cursor: default; opacity: .8; }
.free-answer { display: flex; align-items: center; justify-content: center; gap: 12px; }
.free-answer input { width: min(280px, 70vw); height: 58px; border: 3px solid #e6defb; border-radius: 14px; background: #fcfbff; text-align: center; font-size: 24px; font-weight: 900; color: var(--purple); outline: none; }
.free-answer input:focus { border-color: var(--purple); }
.answer-button { width: min(100%, 320px); margin-top: 23px; padding: 15px; border: none; border-radius: 15px; background: var(--green); color: white; font-size: 16px; font-weight: 900; box-shadow: 0 5px 0 #3aa77e; transition: .2s; }
.answer-button:hover { transform: translateY(3px); box-shadow: 0 2px 0 #3aa77e; }
.feedback-box { display: flex; align-items: center; gap: 15px; padding: 17px; border-radius: 16px; margin-top: 22px; text-align: left; }
.feedback-box.ok { background: var(--ok-bg); border: 1px solid #c8efda; }
.feedback-box.ng { background: var(--ng-bg); border: 1px solid #f6c3c9; }
.feedback-icon { font-size: 34px; }
.feedback-content { flex: 1; }
.feedback-content strong { font-size: 14px; font-weight: 900; }
.feedback-box.ok .feedback-content strong { color: #299a70; }
.feedback-box.ng .feedback-content strong { color: #c23a47; }
.feedback-content p { font-size: 12px; font-weight: 700; color: var(--text); }
.next-question { text-align: center; margin-top: 18px; }
.next-question button { background: var(--purple); color: white; border: none; border-radius: 30px; padding: 12px 30px; font-size: 13px; font-weight: 900; }

/* 結果 */
.result { display: none; max-width: 570px; margin: 45px auto 0; padding: 35px; background: white; border-radius: 30px; box-shadow: 0 15px 40px rgba(168, 126, 44, .12); text-align: center; }
.result.show { display: block; }
.result-confetti { color: #f3c04f; font-size: 22px; letter-spacing: 9px; margin-bottom: 10px; }
.result-trophy { font-size: 74px; line-height: 1.5; }
.result-message span { color: #e5a633; font-size: 10px; letter-spacing: 2px; font-weight: 900; }
.result-message h3 { font-size: 22px; font-weight: 900; margin-top: 5px; }
.result-score { margin: 25px auto; padding: 20px; max-width: 260px; background: #fff6df; border-radius: 20px; }
.result-score small { color: #a88a49; font-size: 11px; font-weight: 900; }
.score-number { color: #e7a936; font-size: 63px; line-height: 1.4; font-weight: 900; }
.score-number span { font-size: 20px; margin-left: 5px; }
.score-detail { font-size: 11px; color: #ad935d; font-weight: 800; }
.result-rank { display: flex; align-items: center; justify-content: center; gap: 16px; background: #f1ebff; border-radius: 17px; padding: 17px; margin-bottom: 22px; text-align: left; }
.rank-icon { font-size: 40px; }
.result-rank div { display: flex; flex-direction: column; }
.result-rank small { font-size: 9px; color: #9788c0; font-weight: 800; }
.result-rank strong { color: var(--purple); font-size: 19px; font-weight: 900; }
.result-wrong { font-size: 13px; font-weight: 800; margin-bottom: 20px; }
.retry-button { width: 100%; padding: 16px; border: none; border-radius: 16px; background: var(--orange); color: white; font-size: 15px; font-weight: 900; box-shadow: 0 5px 0 #df7540; transition: .2s; }
.retry-button:hover { transform: translateY(3px); box-shadow: 0 2px 0 #df7540; }
.result-encourage { color: #b09a6a; font-size: 11px; font-weight: 800; margin-top: 18px; }

/* 字の一覧・書き順 */
.list-section { padding: 85px 24px; background: #ffffff; }
.list-wrap { max-width: 1000px; margin: auto; }
.list-controls { display: flex; gap: 12px; align-items: center; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.list-controls label { font-size: 13px; font-weight: 900; }
.list-controls .custom-select { width: auto; min-width: 190px; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.grid-kanji { background: #fcfbff; border: 2px solid #eeeaf7; border-radius: 13px; padding: 8px 0; font-size: 24px; font-weight: 900; color: var(--text); transition: .15s; }
.grid-kanji:hover { border-color: var(--purple); background: #f2edff; color: var(--purple); transform: translateY(-2px); }
.viewer-card { max-width: 760px; margin: 34px auto 0; background: white; border-radius: 27px; box-shadow: var(--shadow); padding: 28px; text-align: center; }
.viewer-head { display: flex; align-items: baseline; justify-content: center; gap: 16px; flex-wrap: wrap; }
.viewer-char { font-size: 44px; font-weight: 900; }
.viewer-info { font-size: 13px; font-weight: 800; color: var(--text-light); }
.stroke-stage { margin: 18px auto 6px; width: min(300px, 78vw); aspect-ratio: 1 / 1; background: #fcfbff; border: 2px solid #eeeaf7; border-radius: 20px; display: grid; place-items: center; position: relative; overflow: hidden; }
.stroke-stage::before, .stroke-stage::after { content: ""; position: absolute; background: #e7e1f5; }
.stroke-stage::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.stroke-stage::after { top: 50%; left: 0; right: 0; height: 1px; }
.stroke-svg { width: 92%; height: 92%; position: relative; z-index: 1; }
.stroke-loading { font-size: 13px; font-weight: 800; color: var(--text-light); position: relative; z-index: 1; }
.stroke-fallback { position: relative; z-index: 1; padding: 16px; }
.stroke-fallback-char { font-size: 110px; font-weight: 900; line-height: 1.3; }
.stroke-fallback p { font-size: 12px; font-weight: 700; color: var(--text-light); }
.stroke-controls { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.stroke-step-label { font-size: 14px; font-weight: 900; color: var(--purple); min-width: 74px; }
.btn { border: 0; border-radius: 15px; padding: 12px 22px; cursor: pointer; font-weight: 900; font-size: 14px; transition: .2s; }
.btn-main { background: var(--purple); color: white; box-shadow: 0 5px 0 var(--purple-dark); }
.btn-main:hover { transform: translateY(3px); box-shadow: 0 2px 0 var(--purple-dark); }
.btn-sub { background: white; border: 2px solid var(--line-soft); color: var(--text); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* 学習記録 */
.record-section { padding: 85px 24px; background: #f0edff; }
.record-card { max-width: 900px; margin: auto; background: white; border-radius: 27px; box-shadow: var(--shadow); padding: 28px; }
.rec-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
.rec-stat { background: #f8f6fc; border-radius: 15px; padding: 14px 5px; display: flex; flex-direction: column; align-items: center; }
.rec-stat small { color: var(--text-light); font-size: 10px; font-weight: 800; }
.rec-stat strong { font-size: 22px; font-weight: 900; color: var(--purple-dark); }
.rec-block { margin-bottom: 24px; }
.rec-block h4 { font-size: 15px; font-weight: 900; margin-bottom: 12px; }
.rec-empty { color: var(--text-light); font-size: 12px; font-weight: 700; }
.weak-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.weak-chip { background: #fcfbff; border: 2px solid #eeeaf7; border-radius: 13px; padding: 7px 14px; font-size: 21px; font-weight: 900; color: var(--text); display: inline-flex; align-items: center; gap: 8px; transition: .15s; }
.weak-chip small { font-size: 10px; font-weight: 800; color: var(--ng); }
.weak-chip:hover { border-color: var(--purple); background: #f2edff; }
.build-note { color: var(--text-light); font-size: 11px; font-weight: 700; line-height: 1.9; margin-bottom: 14px; }

/* 学年別ページへの導線 */
.grade-links { max-width: 1000px; margin: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grade-link-card { background: white; border-radius: 20px; padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.grade-link-card strong { font-size: 17px; font-weight: 900; }
.grade-link-card small { color: var(--text-light); font-size: 11px; font-weight: 700; }
.grade-link-card .go { color: var(--purple); font-weight: 900; font-size: 13px; margin-top: 8px; }
.grade-link-card.disabled { opacity: .55; }

/* 学年別ページの字セル */
.kanji-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-width: 1000px; margin: auto; }
.kanji-cell { background: white; border-radius: 18px; box-shadow: var(--shadow); padding: 14px; text-align: center; }
.kanji-cell-char { background: none; border: none; font-size: 46px; font-weight: 900; color: var(--text); line-height: 1.3; }
.kanji-cell-char:hover { color: var(--purple); }
.kanji-cell-read { display: flex; flex-direction: column; font-size: 11px; font-weight: 800; color: var(--text-light); line-height: 1.7; }
.kanji-cell-sub { font-size: 11px; font-weight: 800; color: var(--text-light); margin-top: 6px; }
.kanji-cell-sub a { color: var(--purple); text-decoration: underline; }

/* 使い方 */
.howto-section { padding: 85px 24px; background: #f0edff; }
.howto-grid { max-width: 1000px; margin: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.howto-card { background: white; border-radius: 22px; padding: 25px; text-align: center; box-shadow: var(--shadow); }
.howto-number { color: #aaa0c6; font-size: 10px; font-weight: 900; letter-spacing: 2px; }
.howto-icon { width: 85px; height: 85px; margin: 15px auto; display: grid; place-items: center; border-radius: 28px; font-size: 42px; }
.howto-purple { background: #eee8ff; }
.howto-orange { background: #fff0e4; }
.howto-green { background: #e4f9ed; }
.howto-card h3 { font-size: 15px; font-weight: 900; margin-bottom: 9px; }
.howto-card p { color: var(--text-light); font-size: 11px; line-height: 2; font-weight: 700; }

/* CTA・フッター */
.bottom-cta { background: var(--purple); color: white; text-align: center; padding: 70px 24px; position: relative; overflow: hidden; }
.bottom-cta > span { color: #e3d9ff; font-size: 10px; letter-spacing: 3px; font-weight: 900; }
.bottom-cta h2 { font-size: clamp(24px, 4vw, 36px); font-weight: 900; margin: 12px 0; }
.bottom-cta p { color: #e4dcff; font-size: 12px; font-weight: 700; margin-bottom: 25px; }
.bottom-cta-button { display: inline-block; background: var(--yellow); color: #77551b; padding: 15px 30px; border-radius: 15px; font-size: 14px; font-weight: 900; box-shadow: 0 5px 0 #c69b37; transition: .2s; }
.bottom-cta-button:hover { transform: translateY(3px); box-shadow: 0 2px 0 #c69b37; }
.site-footer { background: #37304f; color: white; }
.footer-inner { max-width: 1100px; margin: auto; padding: 35px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand > span { font-size: 30px; }
.footer-brand div { display: flex; flex-direction: column; }
.footer-brand strong { font-size: 15px; font-weight: 900; }
.footer-brand small { color: #b9b2ca; font-size: 10px; }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: #d1c9e4; font-size: 11px; font-weight: 700; }
.footer-links a:hover { color: white; text-decoration: underline; }
.footer-license { width: 100%; color: #b9b2ca; font-size: 10.5px; line-height: 1.9; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; }
.copyright { width: 100%; text-align: center; padding-top: 14px; color: #a9a2bb; font-size: 10px; }
.footer-updated { width: 100%; text-align: center; padding-top: 4px; color: #a9a2bb; font-size: 10px; }

/* レスポンシブ */
@media (max-width: 768px) {
  .header-inner { padding: 12px 17px; flex-wrap: wrap; row-gap: 8px; }
  .header-nav { order: 3; width: 100%; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; }
  .header-badge { display: none; }
  .hero { padding: 55px 22px 50px; grid-template-columns: 1fr; gap: 25px; }
  .hero-content { text-align: center; }
  .hero h1 { font-size: 43px; }
  .hero-features { justify-content: center; }
  .hero-visual { min-height: 330px; }
  .point-section { grid-template-columns: 1fr; gap: 12px; padding-bottom: 55px; }
  .challenge-section, .game-section, .list-section, .record-section, .howto-section { padding: 65px 17px; }
  .settings-body { padding: 23px 17px; }
  .mode-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode-card strong { font-size: 11px; }
  .game-card, .viewer-card, .record-card { padding: 20px 15px; }
  .howto-grid, .grade-links { grid-template-columns: 1fr; max-width: 450px; }
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-links { justify-content: center; flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .logo-icon { width: 41px; height: 41px; font-size: 24px; }
  .logo-text strong { font-size: 14px; }
  .hero h1 { font-size: 36px; }
  .choice-answer { grid-template-columns: 1fr; }
  .result { padding: 25px 18px; }
  .score-number { font-size: 55px; }
}

/* =========================================
   算数ドリルから移植した機能のスタイル（2026-11-28）
   今日の冒険／レベル・パス報酬・ポイント交換／スタンプ／リザルト画面／効果音設定
   ========================================= */

/* ---------- フレームテーマ（body[data-frame] で CSS 変数を差し替え） ---------- */
body[data-frame="sky"] { --purple: #2f8fd0; --purple-dark: #1d6ea8; --purple-light: #e3f2fd; --background: #f2f9ff; }
body[data-frame="sunset"] { --purple: #ef7d54; --purple-dark: #c85a2e; --purple-light: #ffeee3; --background: #fff7f0; }
body[data-frame="forest"] { --purple: #3d9e63; --purple-dark: #2a7a49; --purple-light: #e4f6ea; --background: #f3fbf5; }
body[data-frame="night"] { --purple: #5a54b8; --purple-dark: #403a8f; --purple-light: #e6e4ff; --background: #efefff; }
body[data-frame="sakura"] { --purple: #e86a9e; --purple-dark: #c2477d; --purple-light: #ffe7f1; --background: #fff5f9; }
body[data-frame="lemon"] { --purple: #c9930a; --purple-dark: #a17607; --purple-light: #fff6d9; --background: #fffdf2; }

/* ---------- 今日の冒険 ---------- */
.today-section { max-width: 1160px; margin: 0 auto; padding: 2px 24px 30px; }
.today-head { text-align: center; margin-bottom: 16px; }
.today-head h2 { font-size: clamp(20px, 2.6vw, 26px); font-weight: 900; letter-spacing: -.5px; }
.today-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.today-card { background: white; border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.today-top { display: flex; align-items: center; gap: 10px; }
.today-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
.today-challenge .today-icon { background: var(--orange-light); }
.today-review .today-icon { background: var(--green-light); }
.today-recommend .today-icon { background: var(--purple-light); }
.today-top strong { font-size: 14px; font-weight: 900; line-height: 1.45; }
.today-note { color: var(--text-light); font-size: 11.5px; font-weight: 700; line-height: 1.55; display: block; }
.today-controls { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.today-controls .btn { flex: 1; padding: 10px 14px; font-size: 13px; }
.today-controls .sound-select { max-width: 108px; font-size: 12.5px; padding: 8px 6px; }
@media (max-width: 640px) {
  .today-section { padding: 0 14px 22px; }
  .today-head { margin-bottom: 11px; }
  .today-grid { grid-template-columns: 1fr; gap: 9px; }
  .today-card { padding: 10px 13px; gap: 6px; }
  .today-icon { width: 34px; height: 34px; font-size: 17px; border-radius: 11px; }
}

/* ---------- レベル帯（今日の冒険の下） ---------- */
.level-strip { margin-top: 14px; background: white; border-radius: 20px; box-shadow: var(--shadow); padding: 14px 18px; display: flex; align-items: center; gap: 16px; }
.level-badge { flex-shrink: 0; background: var(--purple); color: #fff; font-weight: 900; font-size: 17px; border-radius: 14px; padding: 10px 14px; text-align: center; line-height: 1.3; }
.level-main { flex: 1; min-width: 0; }
.level-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 14px; font-weight: 900; }
.level-points { color: var(--purple); }
.level-bar { margin-top: 7px; height: 12px; background: var(--purple-light); border-radius: 999px; overflow: hidden; }
.level-fill { height: 100%; background: var(--purple); border-radius: 999px; transition: width .4s ease; }
.level-note { display: block; margin-top: 5px; color: var(--text-light); font-size: 11.5px; font-weight: 700; }
@media (max-width: 640px) {
  .level-strip { padding: 11px 13px; gap: 11px; }
  .level-badge { font-size: 15px; padding: 8px 10px; }
  .level-line { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .level-fill { transition: none; }
  .level-up-pop { animation: none; }
}

/* ---------- 経験値・レベルアップ表示 ---------- */
.xp-gain { margin-top: 12px; font-weight: 900; color: var(--purple-dark); }
.level-up-pop { margin-top: 10px; padding: 12px; background: var(--purple-light); border: 2px solid var(--purple); border-radius: 14px; font-weight: 900; font-size: 17px; color: var(--purple-dark); animation: levelPop .45s ease; }
@keyframes levelPop { 0% { transform: scale(.92); opacity: 0; } 60% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }

/* ---------- スタンプ ---------- */
.stamp-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.stamp { flex: 1 1 140px; max-width: 190px; border: 2px solid #eae5f6; border-radius: 14px; background: #fcfbff; padding: 10px 12px; text-align: center; opacity: .5; filter: grayscale(1); line-height: 1.5; }
.stamp.got { opacity: 1; filter: none; background: #fff8e6; border-color: #e5c15c; }
.stamp-icon { display: block; font-size: 24px; }
.stamp-name { display: block; font-size: 12.5px; font-weight: 900; }
.stamp small { display: block; color: var(--text-light); font-size: 10.5px; font-weight: 700; }
.stamp-gain { margin-top: 14px; padding: 12px; background: #fff8e6; border: 2px solid #e5c15c; border-radius: 14px; font-weight: 900; line-height: 1.9; }
.stamp-gain-item { display: inline-block; background: white; border: 1.5px solid #e5c15c; border-radius: 999px; padding: 2px 12px; margin: 2px; font-size: 13px; }

/* ---------- レベル・称号・パス報酬 ---------- */
.rank-line { font-weight: 900; font-size: 15px; color: var(--purple-dark); margin-bottom: 10px; }
.rank-list { display: flex; flex-direction: column; gap: 5px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 5px 12px; border: 1.5px solid #eae5f6; border-radius: 11px; background: #fcfbff; font-size: 12.5px; opacity: .6; }
.rank-row.current { opacity: 1; background: var(--purple-light); border-color: var(--purple); }
.rank-band { font-weight: 900; color: var(--purple-dark); flex-shrink: 0; min-width: 74px; }
.rank-name { flex: 1; font-weight: 800; }
.pass-list { display: flex; flex-direction: column; gap: 6px; }
.pass-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1.5px solid #eae5f6; border-radius: 12px; background: #fcfbff; font-size: 13px; opacity: .55; }
.pass-row.got { opacity: 1; background: #fff8e6; border-color: #e5c15c; }
.pass-lv { font-weight: 900; color: var(--purple-dark); flex-shrink: 0; }
.pass-name { flex: 1; font-weight: 800; min-width: 0; }
.pass-chip { flex-shrink: 0; font-size: 11px; font-weight: 900; background: white; border: 1.5px solid #e5c15c; border-radius: 999px; padding: 1px 10px; }
@media (max-width: 640px) {
  .rank-band { min-width: 62px; }
  .rank-row { font-size: 11.5px; padding: 5px 9px; gap: 7px; }
  .pass-row { font-size: 12px; padding: 6px 9px; gap: 7px; }
}

/* ---------- フレーム・シール ---------- */
.frame-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.frame-chip { flex: 1 1 130px; max-width: 180px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 8px; border: 2px solid #eae5f6; border-radius: 14px; background: #fcfbff; cursor: pointer; font: inherit; line-height: 1.4; }
.frame-chip.active { border-color: var(--purple); background: var(--purple-light); }
.frame-chip:disabled { cursor: default; opacity: .65; }
.frame-chip:not(:disabled):hover { border-color: var(--purple); }
.frame-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.08); }
.frame-name { font-size: 12.5px; font-weight: 900; }
.frame-chip small { color: var(--text-light); font-size: 10.5px; font-weight: 700; }
.seal-palette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 20px; }
.seal-chip, .seal-on-board { border: 2px solid #eae5f6; background: #fcfbff; border-radius: 12px; cursor: pointer; line-height: 1; }
.seal-chip { font-size: 22px; padding: 6px 9px; }
.seal-chip small { display: block; font-size: 9.5px; font-weight: 700; color: var(--text-light); margin-top: 3px; }
.seal-chip.on { border-color: #e5c15c; background: #fff8e6; }
.seal-board { min-height: 74px; border: 2px dashed #d9d2f2; border-radius: 14px; background: #fffdf5; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seal-on-board { font-size: 34px; padding: 5px 8px; border-color: transparent; background: transparent; }
.seal-on-board:hover { border-color: #e5c15c; }
@media (max-width: 640px) {
  .frame-chip { flex-basis: 100px; }
  .seal-on-board { font-size: 28px; }
}

/* ---------- ポイント交換 ---------- */
.shop-balance { font-weight: 900; font-size: 14px; margin-bottom: 10px; color: var(--purple-dark); }
.shop-grid { display: flex; flex-direction: column; gap: 8px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1.5px solid #eae5f6; border-radius: 12px; background: #fcfbff; font-size: 13px; flex-wrap: wrap; }
.shop-name { flex: 1; font-weight: 800; min-width: 120px; }
.shop-price { font-weight: 900; color: var(--purple-dark); }
.shop-owned { flex-shrink: 0; font-size: 11px; font-weight: 900; background: white; border: 1.5px solid #e5c15c; border-radius: 999px; padding: 1px 10px; }
.shop-item .btn { padding: 7px 14px; font-size: 12.5px; }
.shop-msg { margin-top: 10px; font-weight: 900; color: var(--purple-dark); font-size: 13.5px; min-height: 1em; }
@media (max-width: 640px) { .shop-item { font-size: 12.5px; } }

/* ---------- 最近の記録 ---------- */
.rec-day { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-bottom: 1.5px dashed #eae5f6; font-size: 13.5px; }
.rec-summary { margin-top: 18px; font-weight: 800; font-size: 14px; }

/* ---------- 効果音設定（設定セクション 05） ---------- */
.sound-settings { display: flex; flex-direction: column; gap: 10px; }
.sound-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fcfbff; border: 2px solid #eae5f6; border-radius: 14px; padding: 10px 14px; cursor: pointer; }
.sound-row-text { font-weight: 900; font-size: 13.5px; line-height: 1.5; }
.sound-row-text small { display: block; color: var(--text-light); font-size: 10.5px; font-weight: 700; }
.toggle-switch { width: 45px; height: 25px; position: relative; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #d8d4e2; border-radius: 30px; cursor: pointer; transition: .2s; }
.toggle-slider::before { content: ""; position: absolute; width: 19px; height: 19px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.sound-select { border: 2px solid #eeeaf7; background: white; border-radius: 10px; padding: 7px 9px; font-size: 11px; font-weight: 800; color: var(--text); outline: none; cursor: pointer; }

/* ---------- リザルト画面（モーダル） ---------- */
.title-badge { display: inline-block; background: #f1ebff; border: 2px solid #d9cff7; color: var(--purple); border-radius: 999px; padding: 5px 20px; font-weight: 900; font-size: 17px; margin-bottom: 8px; }
.result-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.result-modal[hidden] { display: none; }
.result-modal-backdrop { position: absolute; inset: 0; background: rgba(43, 32, 84, .55); }
.result-modal-card { position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; background: white; border-radius: 27px; box-shadow: 0 20px 50px rgba(43, 32, 84, .35); padding: 28px 26px 24px; text-align: center; line-height: 1.9; animation: levelPop .35s ease; }
.result-modal-card .result-confetti { margin-bottom: 2px; }
.result-modal-card .result-trophy { font-size: 56px; line-height: 1.3; }
.rm-title { font-size: 22px; font-weight: 900; color: var(--purple-dark); margin: 2px 0 8px; }
.rm-body .score { font-size: 26px; font-weight: 900; color: var(--purple-dark); }
.rm-body .rm-time { font-weight: 800; color: var(--text-light); }
.rm-body .rm-msg { margin-top: 6px; font-weight: 800; }
.rm-body .perfect-note { margin-top: 10px; font-weight: 900; color: var(--purple); }
.rm-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.rm-buttons .btn { flex: 1 1 auto; min-width: 120px; }
@media (max-width: 480px) {
  .result-modal { padding: 10px; }
  .result-modal-card { padding: 22px 16px 18px; border-radius: 22px; }
  .rm-body .score { font-size: 22px; }
  .rm-buttons .btn { min-width: 0; flex: 1 1 42%; padding: 12px 8px; font-size: 13px; }
  .rm-buttons .btn-main { flex-basis: 100%; order: -1; }
}
@media (prefers-reduced-motion: reduce) { .result-modal-card { animation: none; } }
@media print { .result-modal { display: none !important; } }

/* ---------- トップへ戻るボタン（全ページ共通・右下固定） ----------
   出現/非表示は app.js が .is-visible を付け外しする（スクロール 400px 超で出現）。
   z-index はリザルトモーダル（200）より下なので、モーダル表示中は背面に隠れて邪魔しない。 */
.to-top-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 52px; height: 52px; padding: 0 15px;
  border: 0; border-radius: 999px;
  background: var(--purple); color: #fff;
  font-size: 13px; font-weight: 900; line-height: 1;
  box-shadow: 0 8px 20px rgba(91, 67, 156, .35);
  cursor: pointer; touch-action: manipulation;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .25s, transform .25s, visibility .25s;
}
.to-top-btn .to-top-arrow { font-size: 17px; font-weight: 900; }
.to-top-btn.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top-btn:active { background: var(--purple-dark); }
@media (prefers-reduced-motion: reduce) { .to-top-btn { transition: none; } }
@media print { .to-top-btn { display: none !important; } }

/* 間違えた問題の一覧（リザルト内） */
.rm-wrong { text-align: left; margin-top: 14px; line-height: 1.8; font-size: 14px; scroll-margin-top: 8px; }
.rm-wrong-item { border: 1.5px solid #eae5f6; border-radius: 12px; background: #fcfbff; padding: 10px 12px; margin-top: 8px; }
.rm-wrong-main { font-weight: 900; font-size: 16px; }
.rm-wrong-sub { color: var(--text); font-size: 13px; }
.rm-wrong-ex { color: var(--text-light); font-size: 12.5px; margin-top: 2px; }
.rm-wrong-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rm-wrong-btns .btn { padding: 7px 14px; font-size: 12.5px; }
