/* 使える漢字：「黒板」と「国語ノートのマス目」が基調。スマホ縦向きを基準に、1画面1テーマで大きく見せる。
 * 見た目の方針：学校の持ち物の色（黒板の緑・朱ペン・ノートのクリーム・名札の黄）で、温かく手ざわりのある画面にする。
 * 立体感は「下に厚みのある影」（押せそうに見える）で統一する。
 *
 * アクセシビリティとUIの基準は、デジタル庁デザインシステム（https://design.digital.go.jp/dads/）の
 * ガイドラインを参考にした（フォーカス表示、リンク、コントラスト比、文字の大きさ・行の高さ、操作部品の大きさ）。
 *   - 文字と背景のコントラスト比 4.5:1 以上、入力欄やマス目の枠など操作部品の境界 3:1 以上
 *   - 本文・UIの文字は 16px 以上（14px はフッターなど付随情報のみ）、本文の行の高さ 1.7、文字間隔 0.02em
 *   - フォーカスは黒 4px と黄 2px の二重表示（ガイドラインどおり、テーマに関係なく同じ）
 *   - 本文中のリンクは色と下線で示し、訪問済みは色を変える（カード型のリンクは枠と影で押せると分かる形にする）
 *   - ボタン・入力欄は高さ 48px 以上
 */
/* Klee One（SIL OFL 1.1、fonts/OFL.txt）。サイトで使う字だけのサブセット（scripts/subset-font.sh） */
@font-face {
  font-family: "Klee One Sub";
  src: url("fonts/KleeOne-Regular.sub.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  /* 配色は明るい色だけ。ブラウザの自動のダーク表示もさせない */
  color-scheme: only light;
  --paper: #fbf6ea;      /* ノートのクリーム */
  --card: #ffffff;
  --ink: #2b2620;        /* 本文 14:1 */
  --muted: #675c50;      /* 補足文字 5.9:1（クリーム上 5.4:1） */
  --line: #eadfca;       /* 飾りの罫線（操作部品には使わない） */
  --masu: #8a7b68;       /* マス目・入力欄の枠 3.9:1 */
  --masu-guide: #e9a58a; /* マス目の十字（練習帳の朱の点線） */
  --board: #24574a;      /* 黒板。白文字 8.3:1 */
  --board-deep: #1a4337;
  --on-board: #ffffff;
  --chalk: #fff3c4;      /* 黒板の上の黄チョーク 7.6:1 */
  --accent: #b84a12;     /* 朱。ボタンの地（白文字 5.2:1） */
  --accent-deep: #8a360b;
  --on-accent: #ffffff;
  --accent-ink: #b44a17; /* 書き順の番号など朱の文字 5.3:1 */
  --sun: #f6c445;        /* 名札の黄（飾り） */
  --stamp: #d6362b;      /* 丸つけの朱 */
  --mark: #24574a;       /* 一覧の印の緑。白との比 8.3:1 */
  --gold: #b57d00;       /* 一覧の金の はなまる */
  --learned: #cfe8d2;    /* 一覧で「おぼえる」を終えた字のマスの地。字との比 11:1 */
  --on-chip: #1b4f8a;    /* おんよみ（カタカナ）の青 7.4:1 */
  --on-chip-bg: #e4eefa;
  --kun-chip: #9a3d0d;   /* くんよみの朱 6.9:1 */
  --kun-chip-bg: #fdeadd;
  --shadow: #e2d5bb;     /* 厚みの影 */
  --link: #00118f;
  --link-hover: #0017c1;
  --link-visited: #8b008b;
  --link-active: #c74700;
  --focus-ring: #000000;
  --focus-fill: #ffd43d;
  --g1: #fde2d2; --g2: #fff0bf; --g3: #dff1d8; --g4: #d9ecf7; --g5: #e8e1f6; --g6: #f9dde6;
  --font-kanji: "Klee One Sub", "UD デジタル 教科書体 N-R", "UD Digi Kyokasho N-R", "YuKyokasho", serif;
  --font-body: "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font-body);
  font-size: 18px; line-height: 1.7; letter-spacing: 0.02em;
  background: var(--paper);
}
main, .crumb {padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main { max-width: 792px; margin: 0 auto; padding-block: 8px 48px; }

/* リンク：色＋下線。訪問済みは色を変える */
a { color: var(--link); text-decoration: underline 1px; text-underline-offset: 3px; }
a:visited { color: var(--link-visited); }
@media (hover: hover) { a:hover { color: var(--link-hover); text-decoration-thickness: 3px; } }
a:active { color: var(--link-active); }

/* フォーカス：黒と黄の二重表示 */
:focus-visible {
  outline: 4px solid var(--focus-ring); outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--focus-fill); border-radius: 4px;
}
a:focus-visible { background-color: var(--focus-fill); color: #000; }

.skip { position: absolute; left: 8px; top: -100px; z-index: 20; background: var(--focus-fill); color: #000; padding: 8px 14px; }
.skip:focus { top: 8px; }

rt { font-size: max(0.5em, 11px); font-weight: 400; line-height: 1.1; color: var(--muted); font-family: var(--font-body); letter-spacing: 0; }
/* 色の付いた地の上では、ふりがなも地の文字の色にする */
.play rt, h2 rt, .drill b rt, .sub-btn.is-right rt, .sub-btn[aria-pressed="true"] rt, .pager .to-list rt { color: inherit; }
h1 { font-weight: 700; font-size: 26px; line-height: 1.9; margin: 12px 0 8px; text-wrap: balance; }
/* 見出しは「名札」：色のついたラベル */
h2 {
  display: inline-block; font-size: 16px; font-weight: 700; line-height: 1.9; letter-spacing: 0.1em;
  margin: 0 0 10px; padding: 2px 12px; border-radius: 999px; background: var(--board); color: var(--on-board);
}
.lead { color: var(--muted); margin: 0 0 12px; }

/* ヘッダー：黒板 */
header.site {
  background: var(--board); color: var(--on-board);
  border-bottom: 6px solid #9a6b3f; /* 黒板のふち（木） */
  padding: 10px max(16px, env(safe-area-inset-left, 0px));
}
/* ロゴ：共通アイコン＋「使える漢字」の横組み（logo.svg、黒板の地用） */
.logo { display: block; width: fit-content; margin-left: max(0px, calc(50% - 380px)); }
.logo img { display: block; }
.logo:focus-visible { background-color: transparent; } /* 白い文字が黄色の地に沈まないようにする */

/* パンくず：<main> の外。折り返しても崩れない */
.crumb { max-width: 792px; margin: 0 auto; padding-block: 8px 0; font-size: 16px; }
.crumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; } /* ふりがなの有無で高さがずれないように下端でそろえる */
.crumb li { display: inline-flex; align-items: baseline; gap: 4px; }
.crumb li + li::before { content: "›"; color: var(--muted); font-weight: 700; padding-inline: 2px; }
.crumb a { display: inline-block; padding-block: 10px; }
.crumb [aria-current] { color: var(--ink); font-weight: 700; }

/* 押せるカード共通：白地＋枠＋下の厚み */
.card-like { background: var(--card); border: 2px solid var(--masu); border-radius: 14px; box-shadow: 0 4px 0 var(--shadow); }

/* ---- トップ ---- */
.hero { position: relative; margin: 8px 0 28px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* いえの画面（static/tanuki.js）。ドットがにじまないように、絵の大きさは スクリプトが 画面の点の 整数倍にする（docs/PIXEL_RULES.md） */
.room { display: block; width: fit-content; margin: 0 auto 16px; padding: 0; border: 4px solid #5b4a35; border-radius: 14px; overflow: hidden; line-height: 0; background: none; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.room canvas { width: 272px; height: 128px; image-rendering: pixelated; }
.to-next { margin: 0 0 20px; text-align: center; }
.to-next rt { color: inherit; }

/* 学年の入口：左に丸い数字の札、右に学年と字数。学年の色（--g*）の地に、濃い色（--c）の数字と枠 */
.grades { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grade {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 10px; align-content: center; align-items: center; height: 100%; min-height: 80px; padding: 12px;
  border-radius: 16px; border: 2px solid var(--c); text-decoration: none; font-weight: 700; font-size: 18px; line-height: 1.4; color: var(--ink);
  background: var(--bg); box-shadow: 0 4px 0 var(--c);
}
.grade:visited { color: var(--ink); }
.grade b {
  grid-row: 1 / 3; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--card); color: var(--c); font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: 0;
}
.grade .name { line-height: 1.8; }
.grade small { font-weight: 400; font-size: 16px; line-height: 1.8; color: var(--muted); }
.grades li:nth-child(1) { --bg: var(--g1); --c: #a8441c; }
.grades li:nth-child(2) { --bg: var(--g2); --c: #8a6300; }
.grades li:nth-child(3) { --bg: var(--g3); --c: #2f6b34; }
.grades li:nth-child(4) { --bg: var(--g4); --c: #1f5f8b; }
.grades li:nth-child(5) { --bg: var(--g5); --c: #5b4294; }
.grades li:nth-child(6) { --bg: var(--g6); --c: #9c3358; }
.grade.on small::after { content: " ›"; }
@media (hover: hover) { .grade.on:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 6px 0 var(--c); } }
.grade.on:active { color: var(--ink); transform: translateY(3px); box-shadow: 0 1px 0 var(--c); }
.grade.off { border-color: transparent; box-shadow: none; color: var(--muted); }
.grade.off b { color: var(--muted); opacity: .5; }
@media (max-width: 389px) { .grade { grid-template-columns: 40px minmax(0, 1fr); column-gap: 8px; padding-inline: 8px; } .grade b { width: 40px; height: 40px; font-size: 24px; } }
@media (max-width: 349px) { /* せまい画面では数字の札を上に置く */
  .grade { grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 2px; }
  .grade b { grid-row: auto; }
}
@media (min-width: 600px) { .grades { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- 検索 ---- */
.search { display: grid; gap: 6px; margin: 16px 0 20px; position: relative; }
.search label { font-weight: 700; }
.search input {
  font: inherit; font-size: 20px; min-height: 58px; padding: 10px 16px 10px 48px; border-radius: 14px; border: 2px solid var(--masu);
  color: var(--ink); width: 100%; box-shadow: inset 0 3px 0 rgba(0,0,0,.04);
  /* 虫めがね（飾り） */
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a7b68' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E") 16px center / 22px no-repeat;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.results { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.results a {
  display: grid; place-items: center; width: 64px; height: 64px; font-family: var(--font-kanji); font-size: 40px; text-decoration: none;
  color: var(--ink); border: 2px solid var(--masu); border-radius: 10px; background: var(--card); box-shadow: 0 3px 0 var(--shadow);
}
.results .none { color: var(--muted); font-size: 16px; }
/* Klee One は字の中心が行の中心より約 0.075em 下にある。正方形のマスでは下の余白を足して中央に見せる。
 * 行の高さは 1 にする（本文の 1.7 のままだと行がマスからはみ出し、さらに下がる） */
.results a, .masu { line-height: 1; letter-spacing: 0; padding: 0 0 .15em; }

/* ---- マス目 ---- */
.masu {
  display: grid; place-items: center; font-family: var(--font-kanji); line-height: 1; color: var(--ink); letter-spacing: 0;
  border: 2px solid var(--masu);
  /* 練習帳の十字の点線 */
  background:
    repeating-linear-gradient(to bottom, var(--masu-guide) 0 4px, transparent 4px 8px) center / 1px 100% no-repeat,
    repeating-linear-gradient(to right, var(--masu-guide) 0 4px, transparent 4px 8px) center / 100% 1px no-repeat,
    var(--card);
}
.masu-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 10px; }
.masu-grid a { display: grid; gap: 4px; justify-items: center; text-decoration: none; color: var(--ink); }
.masu-grid .masu { width: 100%; aspect-ratio: 1; max-width: 100%; font-size: 46px; border-radius: 10px; box-shadow: 0 4px 0 var(--shadow); transition: transform .12s, box-shadow .12s; }
@media (hover: hover) { .masu-grid a:hover .masu { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 0 var(--shadow); } }
.masu-grid a:active .masu { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
/* 学年別一覧：マス目・よみとかきの印・読みを1組にして、段の間を広くとる（印がどの字のものか分かるように） */
.masu-grid.marks { gap: 20px 10px; }
.frame { position: relative; display: block; width: 100%; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 100%; }
/* 印の段階：なし（薄い枠）→ 1回（緑の枠）→ 2回（緑の塗り） */
.mark {
  display: inline-flex; align-items: center; justify-content: center; min-width: 0; height: 24px; border-radius: 6px;
  font-size: 14px; font-weight: 700; line-height: 1; letter-spacing: 0; white-space: nowrap;
  color: transparent; background: var(--card); box-shadow: inset 0 0 0 2px var(--line);
}
.mark.l1 { color: var(--mark); box-shadow: inset 0 0 0 2px var(--mark); }
.mark.l2 { color: var(--card); background: var(--mark); box-shadow: none; }
.flower { position: absolute; right: -9px; bottom: -11px; width: 42px; height: 42px; pointer-events: none; }
.flower path { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.flower circle { fill: var(--card); opacity: .85; }
.legend { font-size: 16px; line-height: 2.2; color: var(--muted); margin: 0 0 16px; }
.legend summary { min-height: 48px; padding-block: 6px; cursor: pointer; font-weight: 700; color: var(--ink); }
.legend ul { margin: 0; padding-left: 1.2em; }
.legend .mark { width: 48px; margin-inline: 4px; vertical-align: middle; }
/* おぼえるを終えた字：マスの地を緑にする（色だけに頼らないよう、読み上げ用の言葉も添える） */
.masu-grid.marks a.learned .masu, .learned-sample { background-color: var(--learned); }
.learned-sample { padding: 1px 6px; border-radius: 4px; color: var(--ink); }
.kk-progress { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 14px; margin: 0 0 10px; font-weight: 700; }
.kk-progress[hidden] { display: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rep { font-size: 16px; color: var(--muted); }
.okuri { color: var(--muted); }
/* 一覧の読みも漢字ページと同じく、漢字の読みは濃い太字、送り仮名はうすい細字（テスト結果の .rep は変えない） */
.marks .rep { color: var(--ink); font-weight: 700; }
.marks .rep .okuri { color: var(--muted); font-weight: 400; }

/* ---- 漢字ページ ---- */
.kanji { display: grid; gap: 22px; }
.big-wrap { display: grid; justify-items: center; gap: 18px; margin-top: 8px; padding: 22px 16px 18px; background: var(--board); border-radius: 20px; border: 6px solid #9a6b3f; }
/* 大きな字と書き順は同じマス。書き順の再生中（.writing）だけ、字の上に書き順の絵を重ねる */
.big-box { position: relative; width: min(68vw, 260px); aspect-ratio: 1; }
.big { width: 100%; height: 100%; font-weight: 400; font-size: min(50vw, 190px); margin: 0; border-width: 3px; border-color: var(--board-deep); border-radius: 8px; box-shadow: 0 6px 0 rgba(0,0,0,.3); }
.block { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 16px 18px 18px; box-shadow: 0 4px 0 var(--shadow); }
/* 基本の情報の表：左が項目の名前、右が中身 */
.info { background: var(--card); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--shadow); overflow: hidden; }
.info table { width: 100%; border-collapse: collapse; }
.info th, .info td { padding: 6px 12px 4px; text-align: left; vertical-align: middle; line-height: 2.2; border-top: 2px solid var(--line); }
.info tr:first-child > * { border-top: 0; }
.info th { width: 1%; white-space: nowrap; font-size: 16px; color: var(--muted); background: var(--paper); border-right: 2px solid var(--line); }
.info td { font-size: 20px; }
.info td.yomi { padding-block: 8px; line-height: 1.7; }
.yomi .chip { display: inline-block; margin: 3px 8px 3px 0; }
.chip { border-radius: 10px; padding: 3px 14px; font-size: 22px; font-weight: 700; }
.yomi.on .chip { background: var(--on-chip-bg); color: var(--on-chip); }
.yomi.kun .chip { background: var(--kun-chip-bg); color: var(--kun-chip); }
.yomi.kun .chip .okuri { color: var(--muted); font-weight: 400; }
.yomi.special .chip { font-size: 17px; font-weight: 400; background: transparent; color: var(--muted); border: 1px dashed var(--masu); }
.rad { font-family: var(--font-kanji); font-size: 32px; line-height: 1.3; margin-right: 10px; vertical-align: middle; }
.other { margin: 0; font-size: 16px; color: var(--muted); line-height: 1.7; }
.hint { font-size: 16px; color: var(--muted); margin: 10px 0 0; }
.hint:empty { display: none; }
.info .hint { margin: 0; padding: 6px 12px 8px; border-top: 2px solid var(--line); line-height: 2.2; }
.strokes { position: absolute; inset: 0; display: none; width: 100%; height: 100%; border: 3px solid var(--board-deep); border-radius: 8px; background:
  repeating-linear-gradient(to bottom, var(--masu-guide) 0 4px, transparent 4px 8px) center / 1px 100% no-repeat,
  repeating-linear-gradient(to right, var(--masu-guide) 0 4px, transparent 4px 8px) center / 100% 1px no-repeat, var(--card); }
.writing .strokes { display: block; }
.strokes path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.strokes .guide path { stroke: var(--line); stroke-width: 3.5; }
.strokes .draw path { stroke: var(--ink); stroke-width: 3.5; stroke-dasharray: 1 2; stroke-dashoffset: 0; }
.strokes .num text { font-size: 7px; fill: var(--accent-ink); font-family: system-ui, sans-serif; font-weight: 700; }
.strokes.playing .draw path { stroke-dashoffset: 1.01; animation: draw 0.6s ease-in-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .strokes.playing .draw path { animation-duration: 0.01s; } }
.play {
  font: inherit; font-weight: 700; font-size: 18px; min-height: 56px; min-width: 200px; padding: 12px 28px;
  border-radius: 999px; cursor: pointer; border: none; background: var(--accent); color: var(--on-accent);
  box-shadow: 0 5px 0 var(--accent-deep); transition: transform .08s, box-shadow .08s;
}
@media (hover: hover) { .play:hover { filter: brightness(1.08); } }
.play:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-deep); }
.words { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; }
.words li {
  font-family: var(--font-kanji); font-size: 30px; line-height: 2; white-space: nowrap; letter-spacing: 0;
  padding: 12px 14px 0; border-radius: 12px; background: var(--paper); border: 2px solid var(--line);
}
/* ふりがなは行の上半分の余白に出る。下の余白とそろうぶんを上の padding で足す。rt の行の高さはブラウザごとに差が出ないように固定する */
.words rt { line-height: 1; }
/* 漢字ページの下の移動ボタン。どこまで読んでも指が届くように、画面の下に残す */
.pager {
  position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 8px;
  margin: 0 -16px; padding: 4px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  /* 帯は押す操作を受けず、後ろのものを押せる（ボタンは .pager a で受ける） */
  pointer-events: none; font-size: 20px;
}
/* 帯の地はすりガラス：後ろがぼけて透ける。線は引かない。上の端のぼかしはボタンの上端（上の余白の4px）で終える（長いと帯が凹んで見える） */
.pager::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: rgb(251 246 234 / .6);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 4px); mask-image: linear-gradient(to bottom, transparent, #000 4px);
}
.pager a:first-child { justify-self: start; }
.pager a:last-child { justify-self: end; }
.pager .to-list { justify-content: center; font-family: var(--font-body); font-size: 15px; font-weight: 700; background: var(--board); border-color: var(--board); color: var(--on-board); }
.pager .to-list:visited { color: var(--on-board); }
main:has(.pager) { padding-bottom: 0; }
/* 一覧に戻ったとき：見ていた字を画面の中ほどに出して、枠を太くする */
.masu-grid.marks li { scroll-margin-top: 35vh; }
.masu-grid.marks li:target .masu { border: 4px solid var(--accent); }
.pager a {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 2px 12px; line-height: 1.7; text-decoration: none; white-space: nowrap;
  color: var(--ink); font-family: var(--font-kanji); font-size: 22px; background: var(--card);
  border: 2px solid var(--masu); border-radius: 999px; box-shadow: 0 4px 0 var(--shadow);
}
.pager a:visited { color: var(--ink); }
.pager a:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
@media (max-width: 359px) { /* せまい画面でも3つを1列に収める */
  .pager { gap: 6px; padding-inline: 12px; margin-inline: -16px; }
  .pager a { padding-inline: 8px; font-size: 20px; }
  .pager .to-list { font-size: 14px; }
}

/* ---- かきとり ---- */
[hidden] { display: none !important; }
/* ボタンの見た目のリンク */
a.play, a.play:visited { display: inline-grid; place-items: center; color: var(--on-accent); text-decoration: none; }
.sub-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 6px 20px;
  font: inherit; font-weight: 700; font-size: 18px; text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--card); border: 2px solid var(--masu); border-radius: 999px; box-shadow: 0 4px 0 var(--shadow);
}
.sub-btn:visited { color: var(--ink); }
.sub-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.sub-btn[aria-pressed="true"] { background: var(--board); border-color: var(--board); color: var(--on-board); }
/* 学年別一覧のテストの入口。左の名札（よみ・かき）から右へ、同じ段がひと続きに見えるカード。にがてがない段は右を空ける */
.drills { display: grid; gap: 12px; margin: 0 0 20px; }
.drill { display: grid; grid-template-columns: 60px minmax(0, 1fr); overflow: hidden; background: var(--card); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--shadow); }
.drill b { display: grid; place-items: center; background: var(--board); color: var(--on-board); }
.drill div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px 10px 14px; }
.drill .play, .drill .sub-btn { min-width: 0; min-height: 56px; padding: 4px 6px; }
.drill .sub-btn { font-size: 16px; line-height: 1.8; text-align: center; word-break: keep-all; } /* せまい画面では「にがて」と字数の間で折り返す */
/* よみのテスト：熟語のカードと、3つの選択肢 */
.yq { position: relative; display: grid; justify-items: center; width: min(100%, 420px); padding: 20px 16px 12px; background: var(--card); border: 2px solid var(--masu); border-radius: 16px; box-shadow: 0 4px 0 var(--shadow); }
.yq .kk-word { font-size: 44px; }
.yq-ask { margin: 0; font-weight: 700; }
.yq-target { color: var(--accent-ink); border-bottom: 5px solid var(--sun); }
.yq-flower { position: absolute; right: 4px; bottom: 4px; width: 96px; height: 96px; opacity: .85; pointer-events: none; animation: stamp .35s ease-in; }
.yq-flower path { fill: none; stroke: var(--stamp); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { .yq-flower { animation: none; } }
.yq-choices { display: grid; gap: 12px; width: min(100%, 320px); margin-top: 6px; }
.yq-choices .sub-btn { min-height: 60px; font-size: 24px; }
.yq-choices .sub-btn[aria-disabled="true"] { cursor: default; }
.yq-choices .sub-btn.is-right { background: var(--board); border-color: var(--board); color: var(--on-board); }
.yq-choices .sub-btn.is-right::after { content: "○"; margin-left: 12px; }
.yq-choices .sub-btn.is-wrong { border-style: dashed; color: var(--muted); }
.yq-choices .sub-btn.is-wrong::after { content: "×"; margin-left: 12px; }
.kk-body, .kk-writer { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 10px; }
.kk-body > .lead { margin: 0; }
.kk-steps, .kk-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
/* 書き取りの画面は文字を選べないようにする（iPhone で選択の縦線が出ると、次のタップが選択の解除に使われる） */
body:has(#kakitori) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.play, .sub-btn { touch-action: manipulation; } /* 続けて押しても拡大の操作にしない */
/* iPhone の下のツールバーに「つぎへ」が重ならない位置まで送れるように、余白をとる */
main:has(#kakitori) { padding-bottom: 45vh; }
.kk-next { scroll-margin-bottom: 120px; }
/* 1画面に問題と書くマスが入るように、見出しと段の切り替えは小さくする */
#kk-title { font-size: 22px; margin: 0 0 4px; scroll-margin-top: 48px; }
.kk-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: min(100%, 420px); }
.kk-steps .sub-btn { padding: 4px; font-size: 16px; line-height: 1.8; letter-spacing: 0; }
.kk-next:empty { display: none; }
.kk-word { margin: 0; font-family: var(--font-kanji); font-size: 32px; line-height: 1.9; letter-spacing: 0; }
.kk-word rt { font-size: 0.55em; color: var(--ink); }
.blank { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; margin-inline: 2px; border: 3px solid var(--accent); border-radius: 4px; background: var(--card); }
/* 書くマス。指でなぞっても画面が動かないようにする */
.pad, .note-ink {
  height: auto; aspect-ratio: 1; border: 2px solid var(--masu); border-radius: 10px; background:
  repeating-linear-gradient(to bottom, var(--masu-guide) 0 4px, transparent 4px 8px) center / 1px 100% no-repeat,
  repeating-linear-gradient(to right, var(--masu-guide) 0 4px, transparent 4px 8px) center / 100% 1px no-repeat, var(--card);
}
.pad { width: min(86vw, 340px, 46vh); min-width: 240px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.pad path, .pad polyline, .note-ink polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.note-ink polyline { stroke: var(--ink); }
/* かんじノート：マス目を詰めて並べる */
.to-note { margin: 24px 0 0; text-align: center; }
.note-grid { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.note-grid a { display: block; }
.note-ink { display: block; width: 100%; }
/* 練習の画面のノート：書くマスの下に5ますずつ詰めて並べる。なぞった字は薄い色 */
.kk-slot { display: grid; grid-template-columns: minmax(0, 1fr); justify-self: stretch; justify-items: center; }
.kk-note { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(100%, 320px); }
.kk-note .note-ink { border-width: 1px; border-radius: 0; }
.kk-note .trace polyline { stroke: var(--masu); }
.kk-note.hide polyline, .kk-note.hide .stamp { visibility: hidden; }
/* 丸つけのスタンプ（朱の判子）。ぺたっと押す */
svg .stamp path, svg .stamp circle { fill: none; stroke: var(--stamp); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.stamp { opacity: .85; }
.pad .stamp { animation: stamp .35s ease-in; pointer-events: none; }
.note-ink .stamp { opacity: .65; }
@keyframes stamp { from { transform: scale(2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pad .stamp { animation: none; } }
.pad .model path { visibility: hidden; stroke: var(--masu); opacity: .35; }
.pad.guide .model path { visibility: visible; }
.pad.done .model path { visibility: visible; stroke: var(--accent); opacity: .45; }
.pad .ink polyline { stroke: var(--ink); }
.pad .ink polyline.ng { opacity: .3; }
.pad .next-line { stroke: var(--accent); stroke-dasharray: 1 2; visibility: hidden; }
.pad .next-line.on { visibility: visible; stroke-dashoffset: 1.01; animation: draw 0.6s ease-in-out forwards; }
.pad .start { fill: var(--accent); pointer-events: none; }
.pad.done .start { display: none; }
@media (prefers-reduced-motion: reduce) { .pad .next-line.on { animation-duration: 0.01s; } }
.kk-msg { margin: 0; min-height: 1.7em; font-weight: 700; font-size: 20px; text-align: center; }
.kk-msg small { display: block; font-weight: 400; font-size: 16px; color: var(--muted); }
.kk-score { margin: 8px 0; font-weight: 700; font-size: 22px; line-height: 2; text-align: center; }
.kk-words { display: grid; grid-template-columns: minmax(0, 1fr); justify-self: stretch; justify-items: center; gap: 8px; }
.kk-words .pad { width: min(80vw, 320px, 36vh); }
.kk-words .kk-tools .play { min-width: 150px; }
.kk-cells { list-style: none; display: flex; justify-content: center; gap: 4px; width: 100%; margin: 0; padding: 0; }
.kk-cells li { flex: 1 1 0; min-width: 0; max-width: 48px; }
.kk-cells .note-ink { border-width: 2px; border-radius: 6px; }
.kk-cells .now .note-ink { border-color: var(--accent); }
.kk-ask { text-align: center; }
.kk-reading { margin: 0; font-family: var(--font-kanji); font-size: 34px; line-height: 1.4; }
.kk-hint { margin: 0; font-size: 15px; color: var(--muted); }
.kk-answer { position: relative; padding: 0 12px; text-align: center; }
.kk-answer .yq-flower { right: -64px; bottom: -8px; width: 72px; height: 72px; }
.kk-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; justify-self: stretch; margin: 0 0 12px; padding: 0; }
.kk-list a { display: grid; justify-items: center; align-content: center; height: 100%; padding: 4px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; text-decoration: none; }
.kk-list .kk-word { font-size: 24px; }
.kk-more { font-size: 15px; }
.kk-body .masu-grid { justify-self: stretch; grid-template-columns: repeat(auto-fit, 88px); justify-content: center; }

/* ---- おぼえる：よみ → かき → ことば ---- */
.to-learn { margin: 16px 0 0; text-align: center; }
.kk-flow { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: min(100%, 420px); margin: 0; padding: 0; }
.kk-flow li { font-size: 16px; font-weight: 700; line-height: 1.9; text-align: center; color: var(--muted); border-bottom: 6px solid var(--line); }
.kk-flow li.past { border-bottom-color: var(--learned); }
.kk-flow li[aria-current] { color: var(--ink); border-bottom-color: var(--board); }
.kk-big { margin: 0; font-family: var(--font-kanji); font-size: 72px; line-height: 1.2; }
.kk-readings, .kk-examples { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 0; }
/* 読みと送り仮名は、漢字ページの読み（.chip）と同じ見せ方にする */
.kk-readings li { padding: 0 14px; font-size: 22px; font-weight: 700; background: var(--card); border: 2px solid var(--line); border-radius: 10px; }
.kk-readings .okuri { font-weight: 400; }
/* ふりがなのぶんの余白は、漢字ページの言葉（.words）とそろえる */
.kk-examples li { padding: 12px 14px 0; background: var(--card); border: 2px solid var(--line); border-radius: 12px; }
.kk-examples .kk-word { font-size: 28px; line-height: 2; }
.kk-examples rt { line-height: 1; }
/* おぼえるの終わりに出す「くみ」の5字。緑は学年別一覧の「おぼえる」を終えたマスと同じ、朱の枠はいまの字 */
.kk-set { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 52px)); justify-content: center; justify-self: stretch; gap: 8px; margin: 0; padding: 0; }
.kk-set li { aspect-ratio: 1; display: grid; place-items: center; font-family: var(--font-kanji); font-size: 32px; line-height: 1; letter-spacing: 0; padding-bottom: .15em; background: var(--card); border: 2px solid var(--masu); border-radius: 10px; box-shadow: 0 3px 0 var(--shadow); }
.kk-set li.learned { background: var(--learned); }
.kk-set li[aria-current] { border: 4px solid var(--accent); }
.kk-left { margin: 0; font-weight: 700; font-size: 22px; }
/* 画面の下のボタン：大きいボタンは1つ、ほかは横に2つ、戻る先は文字のリンク（おしまいの画面も同じ） */
.kk-next, .kk-end { display: grid; grid-template-columns: minmax(0, 1fr); text-align: center; }
.kk-next { gap: 12px; justify-self: stretch; width: min(100%, 420px); margin-inline: auto; }
.kk-end { gap: 16px; width: min(100%, 420px); line-height: 2; }
.kk-next .play, .kk-end .play { width: 100%; min-height: 72px; font-size: 22px; line-height: 2; padding-block: 8px; }
.kk-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.kk-next .sub-btn, .kk-two .sub-btn { min-height: 60px; padding-inline: 8px; line-height: 1.8; }
.kk-back { justify-self: center; padding: 4px 16px; line-height: 2; }
.kk-done { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 20px; margin: 0; padding: 10px 20px 12px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 16px; }
.kk-done dt { color: var(--muted); }
.kk-done dd { margin: 0; font-weight: 700; }
#kakitori:has(.kk-end) #kk-title { margin-block: 8px; font-size: 28px; text-align: center; }

/* ---- フッター（トップだけ）：ヘッダーと同じ黒板と木のふち。ライセンスへのリンクはここの1つだけ ---- */
main:has(~ footer.site) { padding-bottom: 36px; }
footer.site {
  background: var(--board); color: var(--on-board); border-top: 6px solid #9a6b3f; text-align: center;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
footer.site img { display: block; margin: 0 auto 8px; }
footer.site nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 28px; font-size: 16px; }
footer.site a, footer.site a:visited, footer.site a:active { display: inline-block; padding: 10px 4px; color: var(--on-board); }
footer.site a:focus-visible { color: #000; }
.prose { max-width: 62ch; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: 0 4px 0 var(--shadow); }
.prose ul { padding-left: 1.2em; }
