/* パタトレ：子どもが使う画面。タブレットで本文16px以上（ここでは18px）。色だけにたよらず、記号と文字でも示す。 */
:root {
  --bg: #f7f6f1;
  --paper: #ffffff;
  --ink: #1d2320;
  --muted: #5b625e;
  --line: #cfd3cc;
  --green: #2d6a3e;
  --green-soft: #e3f1e5;
  --red: #b3261e;
  --red-soft: #fbe6e4;
  --amber-soft: #fff3cd;
  --blue: #1f5fa8;
  --sel: #1f5fa8;
  --sel-soft: #e6effa;
  --radius: 12px;
  --font: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif;
}
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
html.big-text { font-size: 22px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.9; }
a { color: var(--blue); }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* ルビ・空欄・下線 */
ruby rt { font-size: 0.55em; line-height: 1; }
.under { text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 2px; }
.blank-box {
  display: inline-block; min-width: 2.2em; padding: 0 0.35em; margin: 0 0.15em;
  border: 2px solid var(--ink); text-align: center; line-height: 1.5; font-weight: bold; background: var(--paper);
}
.rich p { margin: 0 0 0.6em; }
.rich p:last-child { margin-bottom: 0; }
.quote { border: 2px solid var(--ink); border-radius: 6px; padding: 0.5em 0.8em; margin: 0.4em 0 0.8em; background: var(--paper); }

/* 全体 */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--green); color: #fff;
}
.logo { color: #fff; text-decoration: none; font-weight: bold; font-size: 1.1rem; letter-spacing: 0.05em; }
.size-toggle {
  background: #fff; color: var(--green); border: 0; border-radius: 999px; padding: 4px 14px;
  font-size: 0.9rem; font-weight: bold; cursor: pointer; min-height: 40px;
}
.size-toggle[aria-pressed="true"] { background: #ffe9a8; color: var(--ink); }
.page { max-width: 820px; margin: 0 auto; padding: 16px 16px 48px; }
.page-title { font-size: 1.4rem; line-height: 1.6; margin: 8px 0 12px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.card h2 { font-size: 1.15rem; margin: 0 0 8px; }
.notice { background: var(--amber-soft); border: 1px solid #e6c65c; border-radius: 8px; padding: 8px 12px; }
.error { color: var(--red); font-weight: bold; white-space: pre-line; }
.error-card { border-color: var(--red); }
.loading { color: var(--muted); padding: 24px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 6px 20px; border-radius: 999px; border: 2px solid var(--green);
  background: var(--paper); color: var(--green); font-weight: bold; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--green); color: #fff; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-button { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* 入口 */
.entry { max-width: 520px; }
.entry-title { text-align: center; font-size: 2rem; margin: 24px 0 8px; color: var(--green); }
.entry-sub { display: block; font-size: 1rem; color: var(--muted); font-weight: normal; }
.field-label { display: block; font-weight: bold; margin-bottom: 4px; }
.code-input {
  width: 100%; font-size: 1.4rem; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.08em; text-transform: uppercase;
}
.code-input:focus { outline: 3px solid var(--sel); border-color: var(--sel); }
.help { color: var(--muted); font-size: 0.9rem; margin: 6px 0 12px; }
.entry-foot { text-align: center; margin-top: 24px; }

/* メニュー */
.set-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; }
.set-card {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "badge title action" "badge sub action" "badge meta action";
  column-gap: 12px; align-items: center; background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; text-decoration: none; color: var(--ink);
}
.set-card:hover, .set-card:focus-visible { border-color: var(--green); }
.kind-badge { grid-area: badge; align-self: start; border-radius: 6px; padding: 2px 10px; font-size: 0.9rem; font-weight: bold; background: var(--green-soft); color: var(--green); }
.kind-moshi { background: #e8e4f7; color: #4b3a8f; }
.set-title { grid-area: title; font-weight: bold; font-size: 1.1rem; }
.set-sub { grid-area: sub; color: var(--muted); }
.set-meta { grid-area: meta; color: var(--muted); font-size: 0.9rem; }
.set-action { grid-area: action; font-weight: bold; color: var(--green); white-space: nowrap; }
.set-action.resume { color: #8a5a00; }
.set-action::after { content: " ›"; }
.menu-foot { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 12px; }
@media (max-width: 560px) {
  .set-card { grid-template-columns: 1fr auto; grid-template-areas: "badge action" "title title" "sub sub" "meta meta"; }
  .kind-badge { justify-self: start; }
}

/* 解く画面 */
.solve-bar { position: sticky; top: 0; z-index: 10; background: #fffdf5; border-bottom: 2px solid var(--line); }
.solve-bar-inner { max-width: 820px; margin: 0 auto; padding: 6px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar-back { text-decoration: none; font-size: 0.9rem; }
.bar-progress { font-size: 0.9rem; color: var(--muted); }
.save-state { font-size: 0.9rem; color: var(--muted); flex: 1; }
.save-state.error { color: var(--red); font-weight: bold; }
.solve-bar .btn { min-height: 44px; }
.timer { font-size: 1rem; padding: 2px 12px; border-radius: 8px; background: var(--green-soft); }
.timer strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red-soft); color: var(--red); }
.timer-note { margin-left: 6px; font-weight: bold; }
.subtitle { margin-top: -8px; color: var(--muted); font-weight: bold; }
.lead { margin: 12px 0; }
.note { font-size: 0.9rem; color: var(--muted); margin: 8px 0 16px; }
.section-head { font-size: 1.2rem; border-left: 6px solid var(--green); padding-left: 10px; margin: 32px 0 12px; }
.daimon { margin: 24px 0; }
.daimon-head { font-size: 1.25rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }
.daimon-num { display: inline-flex; align-items: center; justify-content: center; min-width: 2em; height: 2em; border: 2px solid var(--ink); font-weight: bold; }
.time-hint { font-size: 0.9rem; font-weight: normal; color: var(--muted); }
.intro { margin-bottom: 12px; }
.materials { display: grid; gap: 12px; margin-bottom: 16px; }
.material { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.material-label { margin: 0 0 6px; font-size: 1rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mtable { border-collapse: collapse; background: var(--paper); margin: 4px 0; }
.mtable th, .mtable td { border: 1px solid #8b918d; padding: 4px 12px; text-align: center; line-height: 1.7; }
.mtable thead th { background: #eef0ea; }
.mtable tbody th { background: #f6f7f3; }
.figure { margin: 0; }
.figure .svg svg { display: block; width: 100%; height: auto; max-width: 760px; }
.figure figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 4px; }
.talk { display: grid; gap: 8px; }
.talk-line { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; }
.talk-who { font-weight: bold; }
@media (max-width: 560px) { .talk-line { grid-template-columns: 1fr; gap: 0; } }

.item { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; scroll-margin-top: 80px; }
.item.is-checked { border-color: #b9c2bb; }
.item-head { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 1.05rem; }
.kata-badge { background: var(--green); color: #fff; border-radius: 6px; padding: 0 10px; font-size: 0.9rem; }
.q-num { font-weight: bold; font-size: 1.1rem; }
.q-points { font-size: 0.9rem; color: var(--muted); font-weight: normal; }
.stem { margin-bottom: 10px; }

/* 選択肢（マークシートの代わり） */
.choices { display: grid; gap: 8px; }
.choices.inline { display: flex; flex-wrap: wrap; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 52px; line-height: 1.8;
}
.choice.compact { width: auto; min-width: 52px; }
.choice:hover:not(:disabled) { border-color: var(--sel); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.selected):not([class*="mark-"]) { opacity: 0.45; }
.choice-key {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.9em; height: 1.9em; margin-top: 0.05em;
  border: 2px solid var(--ink); border-radius: 50%; font-weight: bold; background: var(--paper);
}
.choice-key.small { width: 1.6em; height: 1.6em; font-size: 0.9em; margin-right: 4px; }
.choice-text { flex: 1; }
.choice.selected { border-color: var(--sel); background: var(--sel-soft); box-shadow: inset 0 0 0 1px var(--sel); }
.choice.selected .choice-key { background: var(--ink); color: #fff; }
.choice-mark { flex: none; font-weight: bold; padding: 0 6px; border-radius: 6px; }
.choice.mark-ok { border-color: var(--green); background: var(--green-soft); }
.choice.mark-ok .choice-mark, .choice.mark-answer .choice-mark { color: var(--green); }
.choice.mark-answer { border-color: var(--green); border-style: dashed; }
.choice.mark-ng { border-color: var(--red); background: var(--red-soft); }
.choice.mark-ng .choice-mark { color: var(--red); font-size: 1.2em; }
.choice-table tbody tr { cursor: pointer; }
.choice-table tbody tr.selected td, .choice-table tbody tr.selected th { background: var(--sel-soft); }
.choice-table tbody tr.mark-ok td, .choice-table tbody tr.mark-ok th, .choice-table tbody tr.mark-answer td, .choice-table tbody tr.mark-answer th { background: var(--green-soft); }
.choice-table tbody tr.mark-ng td, .choice-table tbody tr.mark-ng th { background: var(--red-soft); }
.row-pick {
  width: 2.4em; height: 2.4em; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); font-weight: bold; cursor: pointer;
}
.row-pick.selected { background: var(--ink); color: #fff; }
.row-pick:disabled { cursor: default; }
.row-mark { margin-left: 4px; font-weight: bold; font-size: 0.9rem; }
.hint { font-size: 0.9rem; color: var(--muted); margin: 6px 0 0; }

.word-bank { border: 2px dashed var(--muted); border-radius: 8px; padding: 6px 12px; margin-bottom: 10px; background: #fbfbf8; }
.word-bank-title { font-size: 0.9rem; font-weight: bold; color: var(--muted); }
.word-bank ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.blank-row { border-top: 1px dashed var(--line); padding: 8px 0; }
.blank-row:first-of-type { border-top: 0; }
.blank-head { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.blank-stem { flex: 1; min-width: 12em; }
.blank-result { font-weight: bold; }
.blank-result.ok { color: var(--green); }
.blank-result.ng { color: var(--red); }

.item-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.btn.check { border-color: var(--sel); color: var(--sel); }

/* 解説 */
.feedback { margin-top: 14px; border-radius: 10px; padding: 12px 14px; border: 2px solid; }
.fb-ok { border-color: var(--green); background: #f3faf4; }
.fb-part { border-color: #c48a00; background: #fffaf0; }
.fb-ng { border-color: var(--red); background: #fff7f6; }
.fb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fb-mark { font-size: 1.25rem; font-weight: bold; }
.fb-ok .fb-mark { color: var(--green); }
.fb-part .fb-mark { color: #8a5a00; }
.fb-ng .fb-mark { color: var(--red); }
.fb-points { font-weight: bold; }
.fb-answers { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; margin: 6px 0; }
.fb-answers dt { color: var(--muted); }
.fb-answers dd { margin: 0; font-weight: bold; }
.fb-note, .fb-explain { background: var(--paper); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
.fb-note-label { font-size: 0.9rem; font-weight: bold; color: var(--muted); }
.fb-note.answer .fb-note-label { color: var(--green); }
.fb-point { margin-top: 8px; padding: 8px 12px; border-left: 6px solid #e0b100; background: #fffbe6; font-weight: bold; }

.solve-end { margin: 32px 0; }

/* 結果・記録 */
.score { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.score-num { font-size: 3rem; font-weight: bold; color: var(--green); line-height: 1.2; }
.score-max { font-size: 1.3rem; font-weight: bold; }
.score-pct { color: var(--muted); }
.weak { background: var(--amber-soft); border-radius: 8px; padding: 6px 12px; }
.rates, .summary { width: 100%; border-collapse: collapse; }
.rates th, .rates td, .summary th, .summary td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
.rates th { font-weight: normal; }
.rate-num { white-space: nowrap; font-weight: bold; }
.rate-bar-cell { width: 40%; }
.rate-bar { display: block; height: 12px; background: #e6e8e3; border-radius: 6px; overflow: hidden; }
.rate-bar span { display: block; height: 100%; background: var(--green); }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.rules { padding-left: 1.2em; }

/* 申請・規約のページ */
.doc { max-width: 760px; }
.doc h1 { font-size: 1.4rem; }
.doc h2 { font-size: 1.1rem; margin-top: 1.6em; }
.form-row { margin: 14px 0; }
.form-row label.block { display: block; font-weight: bold; }
.form-row input[type=text], .form-row input[type=email], .form-row select {
  width: 100%; font: inherit; padding: 8px 10px; border: 2px solid var(--line); border-radius: 8px; background: #fff;
}
.radio-line label { margin-right: 18px; }
.radio-line input, .agree input { width: 1.2em; height: 1.2em; vertical-align: middle; }
.placeholder { background: #fff3cd; }
