/* 大学受験アプリ 共通の見た目
   デザイン案A「赤ペンノート」がもと（docs/デザイン案_2026-10-23.html）：方眼ノート・青インク・赤ペンの丸つけ。
   手書き風の文字（Klee One）は見出しだけ。本文は案より太め（500、問題文は 700）。
   科目の色（--subject）は、上の「見出しの付箋」と下の「ほかの科目」の印にだけ使う。 */

:root {
  --paper: #f8fafc; --grid: #dfe7ef; --ink: #1f3a5f; --ink-soft: #5b6f86; --red: #d23a2f; --tint: #eef3f8;
  --subject: var(--subject-light); --on-subject: #ffffff;
  --f-hand: "Klee One", "Zen Kaku Gothic New", "Hiragino Mincho ProN", serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151c25; --grid: #223042; --ink: #dce6f1; --ink-soft: #8fa3b9; --red: #ff6f62; --tint: #1c2633;
    --subject: var(--subject-dark); --on-subject: #10161d;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--f-body); font-weight: 500;
  font-size: 16px; line-height: 1.7;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
h2 { margin: 0; }

.page {
  max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px;
  padding: 0 max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
#app { display: flex; flex-direction: column; gap: 18px; }
#app:focus { outline: none; }

/* ── 見出し（科目の付箋） ── */
.site { display: grid; gap: 6px; }
.tab {
  justify-self: start; text-decoration: none; background: var(--subject); color: var(--on-subject);
  font-family: var(--f-hand); font-weight: 600; font-size: 18px; line-height: 1.2;
  padding: 10px 16px 7px; border-radius: 0 0 6px 6px; box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}
.title { margin: 6px 0 0; font-family: var(--f-hand); font-weight: 600; font-size: 27px; line-height: 1.3; }
.lead { margin: 0; color: var(--ink-soft); font-size: 14px; }
.lead .sub { display: block; font-size: 13px; }
.in-quiz .lead { display: none; }
.in-quiz .title { font-size: 20px; margin-top: 2px; }

/* ── 押すところ ── */
.big, .next, .choice, .group, .link, .counts button {
  -webkit-tap-highlight-color: transparent; cursor: pointer; border: 0; background: none; text-align: left; padding: 0;
}
:is(.big, .next, .choice, .group, .link, .counts button):focus-visible { outline: 3px solid var(--subject); outline-offset: 2px; }

.big {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  border: 2px solid var(--ink); border-radius: 4px; background: var(--paper);
  padding: 12px 16px; font-family: var(--f-hand); font-weight: 600; font-size: 19px; line-height: 1.4;
}
.big.red { border-color: var(--red); color: var(--red); }
.big:disabled { opacity: .45; cursor: default; }
.big:not(:disabled):active, .next:active { transform: translateY(1px); }

.next {
  display: block; width: 100%; text-align: center; border: 2px solid var(--ink); border-radius: 4px;
  background: var(--ink); color: var(--paper); padding: 13px; font-family: var(--f-hand); font-weight: 600; font-size: 19px;
}
.link { text-decoration: underline; text-underline-offset: 3px; color: var(--ink-soft); font-size: 14px; }

/* ── 最初の画面 ── */
.start { display: grid; gap: 12px; }
.counts { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.counts span { margin-right: 4px; }
.counts button {
  border: 1.5px solid var(--ink-soft); border-radius: 999px; background: var(--paper); color: var(--ink);
  padding: 3px 14px; font-size: 14px; font-weight: 700;
}
.counts button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13px; color: var(--ink-soft); }
.stats b { font-family: var(--f-hand); font-weight: 600; font-size: 26px; color: var(--ink); margin-right: 3px; font-variant-numeric: tabular-nums; }

.groups h2 { font-family: var(--f-hand); font-weight: 600; font-size: 19px; margin-bottom: 4px; }
.groups h2 small { display: block; font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--ink-soft); }
.groups ul { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink-soft); background: var(--paper); }
.groups li { border-bottom: 1px dashed var(--grid); }
.group {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; width: 100%; padding: 9px 2px 11px;
}
.group:hover { background: var(--tint); }
.gname { font-size: 15px; font-weight: 700; }
.section > details > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 11px 2px 12px 22px; cursor: pointer; list-style: none; position: relative;
}
.section > details > summary::-webkit-details-marker { display: none; }
.section > details > summary::before {
  content: "▸"; position: absolute; left: 4px; top: 11px; color: var(--ink-soft); transition: transform .15s;
}
.section > details[open] > summary::before { transform: rotate(90deg); }
.section > details > summary .gname { font-family: var(--f-hand); font-weight: 600; font-size: 17px; }
.section > details > summary:hover { background: var(--tint); }
.section > details > summary:focus-visible { outline: 3px solid var(--subject); outline-offset: 2px; }
.sec-body { display: grid; gap: 8px; padding: 0 0 12px 18px; }
.sec-body ul { border-top: 1px dashed var(--grid); }
.big.small { font-size: 16px; padding: 8px 14px; }
.groups em { font-style: normal; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.groups em strong { color: var(--ink); font-size: 15px; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--tint); overflow: hidden; }
.bar b { display: block; height: 100%; background: var(--ink); border-radius: 4px; }

/* ── 問題の画面 ── */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-soft); }
.qhead span:nth-child(2) { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; border-radius: 3px; background: var(--tint); overflow: hidden; margin-top: -8px; }
.progress b { display: block; height: 100%; background: var(--ink); opacity: .7; transition: width .25s; }
.qno { font-family: var(--f-hand); font-weight: 600; font-size: 16px; color: var(--ink-soft); }
.qtext { margin: -12px 0 0; font-size: 19px; line-height: 1.8; font-weight: 700; background: var(--paper); }
.qtext:focus { outline: none; }

.choices { display: grid; gap: 12px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px;
  padding: 12px 40px 12px 12px; border-bottom: 2px solid var(--ink); background: var(--paper);
  font-size: 17px; font-weight: 700; line-height: 1.5;
}
.choice:not(:disabled):hover { background: var(--tint); }
.choice:disabled { cursor: default; }
.mark {
  flex: none; position: relative; width: 32px; height: 32px; display: grid; place-items: center;
  font-family: var(--f-hand); font-weight: 600; font-size: 19px;
}
.choice.is-correct .mark::after {
  content: ""; position: absolute; inset: -7px -9px; border: 3px solid var(--red); border-radius: 50%;
  transform: rotate(-12deg); animation: draw .35s ease-out;
}
.choice.is-wrong .label { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.choice.is-wrong::after {
  content: "×"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--red); font-family: var(--f-hand); font-weight: 600; font-size: 28px;
}
@keyframes draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.feedback-slot { display: grid; gap: 14px; }
.feedback-slot:empty { display: none; }
.feedback { background: var(--tint); border-left: 3px solid var(--red); padding: 10px 14px; font-size: 15px; }
.feedback p { margin: 0; }
.feedback .result { font-family: var(--f-hand); font-weight: 600; font-size: 22px; color: var(--red); }
.feedback .answer { font-weight: 700; }
.feedback .note { margin-top: 4px; white-space: pre-line; }
.qtext.en { font-size: 28px; line-height: 1.4; letter-spacing: .01em; }

/* 瞬間英作文：答えの英語と、自分でつける○× */
.reveal { background: var(--tint); border-left: 3px solid var(--ink); padding: 12px 14px; display: grid; gap: 6px; }
.reveal p { margin: 0; }
.en-answer { font-size: 21px; font-weight: 700; line-height: 1.5; }
.reveal .note { font-size: 14px; color: var(--ink-soft); white-space: pre-line; }
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade .big { justify-content: center; }
.self { margin: 0; font-family: var(--f-hand); font-weight: 600; font-size: 21px; color: var(--red); }
.self.ok { color: var(--red); }
.self.ng { color: var(--ink); }

/* ── 正解の演出（続けて正解すると大きく・派手に。押すのの邪魔はしない） ── */
.combo-now { margin-right: 8px; color: var(--red); font-family: var(--f-hand); font-weight: 600; font-size: 14px; }
.fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.fx-pop {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 2px;
  font-family: var(--f-hand); font-weight: 600; color: var(--red); white-space: nowrap; line-height: 1.1;
  padding: 8px 22px 10px; border-radius: 14px; background: var(--paper); background: color-mix(in srgb, var(--paper) 90%, transparent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
  animation: fx-pop 1s cubic-bezier(.2, 1.4, .4, 1) both;
}
.fx-pop b { font-weight: 600; font-size: 44px; font-variant-numeric: tabular-nums; }
.fx-pop small { font-size: .5em; margin-left: 4px; }
.fx-pop span { font-size: 22px; color: var(--ink); }
.fx-pop .maru { font-size: 84px; opacity: .85; }
.fx-pop.lv0 { background: none; box-shadow: none; }
.fx-pop.lv0 { animation-duration: .7s; }
.fx-pop.lv2 b { font-size: 58px; }
.fx-pop.lv3 b { font-size: 72px; }
.fx-pop.lv3 span, .fx-pop.lv4 span { font-size: 28px; color: var(--red); }
.fx-pop.lv4 { animation: fx-pop 1.4s cubic-bezier(.2, 1.4, .4, 1) both, fx-wiggle .5s ease-in-out .25s 2; }
.fx-pop.lv4 b {
  font-size: 88px; color: transparent; -webkit-background-clip: text; background-clip: text;
  background-image: linear-gradient(100deg, var(--red), #f2b705 45%, var(--subject));
}
.fx-pop.lvoff { animation-duration: 1s; }
.fx-pop.lvoff span { font-size: 18px; color: var(--ink-soft); }
.fx i {
  position: absolute; left: 50%; top: 38%; width: 8px; height: 13px; border-radius: 2px;
  animation: fx-bit var(--d) cubic-bezier(.15, .7, .4, 1) forwards;
}
.fx i:nth-child(3n) { width: 10px; height: 10px; border-radius: 50%; }
@keyframes fx-pop {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -62%) scale(1); opacity: 0; }
}
@keyframes fx-wiggle { 25% { rotate: -5deg; } 75% { rotate: 5deg; } }
@keyframes fx-bit {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  35% { transform: translate(var(--x), var(--y)) rotate(calc(var(--r) * .4)); opacity: 1; }
  100% { transform: translate(calc(var(--x) * 1.3), calc(var(--y) + 260px)) rotate(var(--r)); opacity: 0; }
}
#app.shake { animation: fx-shake .35s ease-in-out; }
@keyframes fx-shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.choice.is-correct { animation: fx-good .35s ease-out; }
@keyframes fx-good { 40% { transform: scale(1.03); } }
.best { margin-top: 4px !important; font-size: 15px; color: var(--ink-soft); }
.best b { font-family: var(--f-hand); font-weight: 600; font-size: 24px; color: var(--red); }
.best span { margin-left: 8px; color: var(--red); font-weight: 700; }

/* ── 結果の画面 ── */
.result-box { display: grid; justify-items: center; gap: 4px; padding: 18px 0 6px; text-align: center; }
.result-box p { margin: 0; }
.result-box .label { font-size: 14px; color: var(--ink-soft); }
.score { font-family: var(--f-hand); font-weight: 600; font-size: 22px; }
.ring { position: relative; display: inline-block; padding: 0 14px; color: var(--red); }
.ring b { font-size: 54px; line-height: 1.2; font-weight: 600; }
.ring::after {
  content: ""; position: absolute; inset: -2px -4px; border: 3px solid var(--red); border-radius: 50%;
  transform: rotate(-10deg); animation: draw .5s ease-out;
}
.msg { font-family: var(--f-hand); font-weight: 600; font-size: 20px; }
.msg.perfect { color: var(--red); }

.misses h2 { font-family: var(--f-hand); font-weight: 600; font-size: 19px; margin-bottom: 4px; }
.misses ol { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink-soft); background: var(--paper); }
.misses li { display: grid; gap: 2px; padding: 10px 2px; border-bottom: 1px dashed var(--grid); font-size: 15px; }
.misses .qno { font-size: 14px; }
.misses .answer { color: var(--red); font-weight: 700; }
.after { display: grid; gap: 12px; }

/* ── 下の欄 ── */
.site-foot { display: grid; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1.5px solid var(--ink-soft); font-size: 13px; color: var(--ink-soft); }
.site-foot p { margin: 0; }
.promos h2, .subjects h2 { font-family: var(--f-hand); font-weight: 600; font-size: 16px; color: var(--ink); margin-bottom: 4px; }
.subjects ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 12px; }
.subjects a { display: flex; align-items: center; gap: 8px; padding: 5px 0; text-decoration: none; color: var(--ink); font-size: 14px; }
.subjects a[aria-current] { font-weight: 700; }
.subjects i { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
@media (prefers-color-scheme: dark) { .subjects i { background: var(--cd); } }
.promos ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.promos a {
  display: grid; gap: 2px; padding: 10px 14px; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--ink-soft); border-radius: 4px;
}
.promos a:hover { background: var(--tint); }
.promos b { font-size: 15px; }
.promos span { font-size: 13px; color: var(--ink-soft); }
.keep .link { font-size: 13px; margin-left: 4px; }
.legal { display: grid; gap: 6px; margin-top: 4px; padding-top: 12px; border-top: 1.5px solid var(--ink-soft); }
.copy { text-align: right; } /* 本文を読む視線の邪魔にならないよう右端に */
.info { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.notice { background: var(--tint); padding: 12px 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 問題を解いている間は、下の欄はコピーライトだけにする（上の線で問題と分ける） */
.in-quiz .site-foot { margin-top: 28px; padding-top: 0; border-top: 0; }
.in-quiz .site-foot > :not(.legal), .in-quiz .info { display: none; }

/* 瞬間英作文の使い方の案内 */
.howto { margin: 0; font-size: 14px; color: var(--ink-soft); background: var(--paper); }
.hint { margin: -4px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* 最初の画面：間違えた問題があるときだけ出す、上の1行の復習リンク */
.review-link {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  border: 0; border-bottom: 2px solid var(--red); background: var(--paper); color: var(--red);
  padding: 8px 4px; font-family: var(--f-hand); font-weight: 600; font-size: 17px; cursor: pointer; text-align: left;
}
.review-link:focus-visible { outline: 3px solid var(--subject); outline-offset: 2px; }
.start h2 { font-family: var(--f-hand); font-weight: 600; font-size: 19px; margin: 0; }
.settings { display: grid; gap: 6px; padding-top: 14px; border-top: 1px dashed var(--ink-soft); }
.settings h2 { font-family: var(--f-hand); font-weight: 600; font-size: 17px; margin: 0; }
.settings .small { margin: 0; font-size: 12px; color: var(--ink-soft); }

/* 広告（最初の画面の一覧の下と、結果の画面だけ） */
.ad-box { display: grid; gap: 2px; min-height: 100px; }
.ad-label { font-size: 11px; color: var(--ink-soft); letter-spacing: .1em; }
