/* WEBテストマスター — 白地・黒線・角のある四角だけで組むシンプルなデザイン */
:root {
  --bg: #fff; --ink: #111111; --muted: #8A8A8A; --hair: #E3E3E3; --fill: #F5F5F5;
  --ok: #1E8E3E; --ok-soft: #E8F5EC; --ng: #D93025; --ng-soft: #FCEBEA;
  --border: 1.5px;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, "Segoe UI", sans-serif;
  --serif: "New York", "Iowan Old Style", Georgia, "Times New Roman", "Hiragino Mincho ProN", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; color-scheme: light;
}
body.locked { overflow: hidden; }
p, h1, ol, ul, pre { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; border-radius: 0; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* 文字 */
.t-title { font-size: 28px; line-height: 1.25; }
.t-title2 { font-size: 22px; line-height: 1.3; }
.t-title3 { font-size: 20px; line-height: 1.35; }
.t-headline { font-size: 17px; font-weight: 600; line-height: 1.45; }
.t-body { font-size: 17px; }
.t-sub { font-size: 15px; line-height: 1.6; }
.t-foot { font-size: 13px; line-height: 1.55; }
.t-caption { font-size: 12px; line-height: 1.45; }
.t-caption2 { font-size: 11px; line-height: 1.5; }
.heavy { font-weight: 800; }
.bold { font-weight: 700; }
.muted { color: var(--muted); }
.dim { opacity: .75; }
.ok { color: var(--ok); }
.ng { color: var(--ng); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.right { text-align: right; }
.en-serif { font-family: var(--serif); }
.lh-loose { line-height: 1.85; }
.caption { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--muted); width: 100%; }
.caption.center { text-align: center; }

/* レイアウト */
.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.row { display: flex; align-items: center; }
.row.baseline { align-items: baseline; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1 1 auto; }
.flex1 { flex: 1 1 0; min-width: 0; }
.gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.stack4 > * + * { margin-top: 4px; } .stack6 > * + * { margin-top: 6px; } .stack8 > * + * { margin-top: 8px; }
.stack10 > * + * { margin-top: 10px; } .stack12 > * + * { margin-top: 12px; } .stack14 > * + * { margin-top: 14px; }
.stack16 > * + * { margin-top: 16px; } .stack18 > * + * { margin-top: 18px; } .stack20 > * + * { margin-top: 20px; }
.stack28 > * + * { margin-top: 28px; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; } .mb16 { margin-bottom: 16px; } .ml8 { margin-left: 8px; }
.w36 { width: 36px; flex: none; } .w40 { width: 40px; flex: none; } .w140 { max-width: 140px; } .w240 { max-width: 240px; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; }
.center-row { justify-content: center; }
.head { min-height: 44px; }
.foot-note { font-size: 11px; color: var(--muted); text-align: center; padding-top: 4px; }

/* 押したときに薄くなる */
.press { transition: opacity .08s; }
.press:active:not(:disabled) { opacity: .55; }
@media (hover: hover) { .press:hover:not(:disabled) { opacity: .8; } }
.plain { display: block; width: 100%; }

/* 枠 */
.box { border: 1px solid var(--hair); padding: 16px; background: #fff; width: 100%; }
.box.strong { border: var(--border) solid var(--ink); }
.box.pad12 { padding: 12px; }

/* ボタン */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 56px; padding: 0 16px;
  font-size: 17px; font-weight: 600; background: var(--ink); color: #fff; border: var(--border) solid var(--ink);
  text-decoration: none; text-align: center; transition: opacity .08s; user-select: none;
}
.btn:active:not(:disabled) { opacity: .55; }
@media (hover: hover) { .btn:hover:not(:disabled) { opacity: .85; } }
.btn.outline { background: #fff; color: var(--ink); }
.btn.danger { color: var(--ng); border-color: var(--ng); }
.btn:disabled { opacity: .35; }
.btn.auto { width: auto; flex: none; padding: 0 14px; font-size: 15px; font-weight: 700; }
.h40 { min-height: 40px; } .h44 { min-height: 44px; } .h48 { min-height: 48px; } .h52 { min-height: 52px; }
.h60 { min-height: 60px; } .h64 { min-height: 64px; } .h76 { min-height: 76px; }
.next-btn { justify-content: space-between; padding: 0 20px; text-align: left; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn.left { justify-content: flex-start; }
.badge { font-size: 11px; font-weight: 700; color: #fff; background: var(--ink); padding: 2px 5px; }

/* ホーム */
.welcome { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 24px; }
.welcome-title { font-size: clamp(30px, 10vw, 40px); font-weight: 800; line-height: 1.15; white-space: nowrap; }
.score-big { font-size: 64px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.delta { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.delta.up { color: var(--ok); } .delta.down { color: var(--ng); }
.week { display: flex; align-items: center; gap: 6px; }
.week .day { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stamp { width: 100%; aspect-ratio: 1; border: 1px solid var(--hair); display: flex; align-items: center; justify-content: center; color: #fff; }
.stamp.today { border: var(--border) solid var(--ink); }
.stamp.done { background: var(--ink); border-color: var(--ink); }
.streak { width: 52px; flex: none; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.tiles3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tile .tint { display: block; width: 16px; height: 4px; }
.segs { display: flex; gap: 2px; }
.segs i { flex: 1; height: 4px; }

/* 科目 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile2 { padding: 12px; min-height: 96px; display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; height: 100%; }
.tile2.hl { border: 2px solid var(--ink); }
.tile2.mode { border: var(--border) solid var(--ink); }
.tile2.filled { background: var(--ink); color: #fff; }
.two-lines { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.2em; line-height: 1.6; }
[data-long] { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.meter { display: inline-flex; gap: 3px; vertical-align: middle; }
.meter i { display: block; border: 1px solid; box-sizing: border-box; }

/* 演習 */
#exam { position: fixed; inset: 0; z-index: 40; background: #fff; display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#exam.appear { animation: up .22s ease-out; }
.topbar { display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 6px; flex: none; width: 100%; max-width: 760px; margin: 0 auto; }
.timer { font-size: 15px; font-weight: 600; padding-right: 6px; }
.timer.mono { font-size: 17px; }
.progress { height: 3px; background: var(--hair); flex: none; }
.progress i { display: block; height: 100%; background: var(--ink); transition: width .2s; }
.q-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.q-body.enter { animation: slide .18s ease-out; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.inner { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; }
.inner.pad20 { padding: 20px; }
#exam.memo-open .scroll .inner { padding-bottom: calc(50vh + 24px); padding-bottom: calc(50dvh + 24px); }
.answer-panel { flex: none; background: #fff; border-top: var(--border) solid var(--ink); max-height: 62vh; max-height: 62dvh; overflow-y: auto; padding-bottom: var(--safe-b); }
.passage.ja { font-size: 17px; line-height: 1.95; }
.passage.en { font-family: var(--serif); font-size: 18px; line-height: 1.75; }
.passage.small.ja { font-size: 15px; line-height: 1.8; }
.passage.small.en { font-size: 16px; line-height: 1.65; }
.statement.ja { font-size: 17px; font-weight: 700; line-height: 1.6; }
.statement.en { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.55; }
.w { cursor: pointer; border-radius: 0; }
@media (hover: hover) { .w:hover { background: var(--fill); text-decoration: underline; text-underline-offset: 3px; } }
.w:active { background: var(--hair); }
mark.ev { color: var(--ink); background: var(--fill); padding: 1px 0; }
mark.ev.decisive { color: var(--ng); background: var(--ng-soft); font-weight: 700; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 10px; }
.legend i { width: 12px; height: 12px; background: var(--fill); border: 1px solid var(--muted); }
.legend.decisive { color: var(--ng); }
.legend.decisive i { background: var(--ng-soft); border-color: var(--ng); }

/* 選択肢 */
.verdicts { display: flex; gap: 8px; }
.verdict { flex: 1 1 0; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; border: var(--border) solid var(--ink); background: #fff; padding: 4px 2px; }
.verdict .letter { font-size: 22px; font-weight: 700; line-height: 1.1; }
.verdict .lab { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nchoice { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 12px; border: 1px solid var(--ink); background: #fff; }
.nchoice .letter { width: 30px; height: 30px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid currentColor; font-size: 15px; font-weight: 700; }
.nchoice .txt { font-size: 17px; font-weight: 600; }
.st-selected { background: var(--ink); color: #fff; }
.st-correct { background: var(--ok-soft); color: var(--ok); border: 2px solid var(--ok); }
.st-wrong { background: var(--ng-soft); color: var(--ng); border: 2px solid var(--ng); }
.st-dimmed { color: var(--muted); border-color: var(--hair); }
.verdict:disabled, .nchoice:disabled { cursor: default; }
.trap { display: flex; gap: 6px; align-items: flex-start; font-size: 15px; color: var(--ng); }
.trap .ic { flex: none; margin-top: 3px; }

/* 表・グラフ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dt { border-collapse: collapse; border: 1px solid var(--ink); font-variant-numeric: tabular-nums; min-width: 100%; }
.dt th, .dt td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--hair); }
.dt th { font-size: 12px; font-weight: 700; background: var(--fill); }
.dt td { font-size: 15px; }
.dt .first { text-align: left; }
.dt td.mk {
  color: var(--ng); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--ng);
  background: repeating-linear-gradient(135deg, rgba(217, 48, 37, .28) 0 1px, rgba(217, 48, 37, .06) 1px 6px);
}
.barchart, .scorechart { width: 100%; max-width: 560px; height: auto; display: block; }
.barchart text, .scorechart text { font-family: var(--sans); }
.barchart .ax, .scorechart .ax { font-size: 10px; fill: var(--muted); }
.barchart .cat { font-size: 11px; fill: var(--ink); }
.barchart .val { font-size: 10px; font-weight: 600; fill: var(--ink); }
.barchart .val.mk { font-weight: 800; fill: var(--ng); }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }

/* 解き方 */
.numbered { list-style: none; padding: 0; }
.numbered li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.6; }
.numbered li + li { margin-top: 8px; }
.numbered .n { flex: none; width: 20px; height: 20px; margin-top: 2px; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.bullets { list-style: none; padding: 0; }
.bullets li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.6; }
.bullets li + li { margin-top: 6px; }
.bullets li i { flex: none; width: 5px; height: 5px; margin-top: 10px; }
.calc { white-space: pre-wrap; font-size: 15px; line-height: 1.6; }

/* ○× */
.markview { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.markview svg { animation: pop .25s cubic-bezier(.3, 1.4, .5, 1); }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px; }
.empty .btn { width: 240px; }

/* 結果 */
.result .box.strong { padding: 20px; }
.score-huge { font-size: 96px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stats { width: 100%; padding-top: 8px; }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.stat b { font-size: 20px; font-weight: 700; }
.stat span { font-size: 11px; color: var(--muted); }
.vsep { width: 1px; height: 32px; background: var(--hair); }
.sbar .track { flex: 1; height: 14px; background: var(--fill); }
.sbar .track i { display: block; height: 100%; }
.listrow { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.answer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.answer-grid .cell { min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--hair); line-height: 1.1; }
#exam.finished .scroll .inner { padding-bottom: calc(20px + var(--safe-b)); }

/* シート */
.sheet-layer { position: fixed; inset: 0; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .28); }
.backdrop.fade { animation: fade .2s ease-out; }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 760px; background: #fff;
  border-top: var(--border) solid var(--ink); display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh;
  padding-bottom: var(--safe-b);
}
.sheet.large { height: 92vh; height: 92dvh; }
.sheet.appear { animation: sheetUp .24s ease-out; }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 20px; min-height: 52px; flex: none; }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pad-word { padding: 12px 8px 20px 20px; }
.wordrow { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hair); font-size: 15px; text-align: left; }
.wordrow .ic { align-self: center; flex: none; }
.vrow { gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--hair); }
.card-face { min-height: 320px; justify-content: center; gap: 16px; padding: 24px 20px; }
.card-word { font-size: 40px; font-weight: 700; line-height: 1.2; word-break: break-word; }
.cards-done { min-height: 60vh; gap: 4px; }
.totals .stat b { font-size: 20px; }

/* 設定のスイッチ */
.toggle { cursor: pointer; min-height: 44px; position: relative; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .sw { width: 50px; height: 30px; border: var(--border) solid var(--ink); position: relative; flex: none; background: #fff; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; background: var(--ink); transition: transform .15s, background .15s; }
.toggle input:checked + .sw { background: var(--ink); }
.toggle input:checked + .sw::after { transform: translateX(20px); background: #fff; }
.toggle input:focus-visible + .sw { outline: 2px solid var(--ink); outline-offset: 2px; }

/* メモ */
.memo {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 760px; height: 50vh; height: 50dvh;
  z-index: 46; background: #fff; border-top: var(--border) solid var(--ink); display: flex; flex-direction: column;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); padding-bottom: var(--safe-b);
}
.memo.full { height: 92vh; height: 92dvh; }
.memo.appear { animation: sheetUp .22s ease-out; }
.memo-head { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 16px; min-height: 48px; border-bottom: var(--border) solid var(--ink); flex: none; }
.memo-pad {
  flex: 1 1 auto; min-height: 0; position: relative;
  background-image: linear-gradient(var(--fill) 1px, transparent 1px), linear-gradient(90deg, var(--fill) 1px, transparent 1px);
  background-size: 24px 24px;
}
.memo-pad canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }

/* ダイアログ */
.dialog-layer { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.dialog-layer .backdrop { animation: fade .15s ease-out; }
.dialog { position: relative; width: 100%; max-width: 480px; background: #fff; border-top: var(--border) solid var(--ink); padding: 16px 16px calc(16px + var(--safe-b)); animation: sheetUp .2s ease-out; }
@media (min-width: 600px) { .dialog-layer { align-items: center; } .dialog { border: var(--border) solid var(--ink); } }
.dlg-title { font-size: 13px; color: var(--muted); text-align: center; font-weight: 600; padding: 4px 0 12px; }
.dlg-btn { display: block; width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; text-align: center; border: var(--border) solid var(--ink); background: #fff; }
.dlg-btn + .dlg-btn { margin-top: 8px; }
.dlg-btn.destructive { color: var(--ng); border-color: var(--ng); }
.dlg-btn.cancel { background: var(--ink); color: #fff; }
.dlg-btn:active { opacity: .55; }

/* トースト・広告 */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; padding: 10px 16px; max-width: 90vw; }
/* 広告：内容の下に余白をあけて置く（ボタンの押し間違いを防ぐ） */
.ad-box { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--hair); min-height: 100px; }
#ad-screen { margin-top: 24px; padding-bottom: calc(24px + var(--safe-b)); }
.ad-label { font-size: 10px; color: var(--muted); letter-spacing: 1px; margin-bottom: 6px; }

/* アニメーション */
@keyframes slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheetUp { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dialog { animation-name: dlgUp; }
@keyframes dlgUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 大きな画面 */
@media (min-width: 900px) {
  .passage.ja { font-size: 18px; }
  .passage.en, .statement.en { font-size: 19px; }
}
