/* N5 Mock · Vol. 2 — a paper exam on a desk: white booklet strips, a vermilion answer sheet, graphite marks. */
:root {
  color-scheme: light;
  --desk: #ebe7df;
  --paper: #ffffff;
  --ink: #1d1c1a;
  --ink-2: #57534b;
  --ink-3: #67625a;          /* ≥4.9:1 on both paper and desk, for the small captions */
  --line: #d9d2c5;
  --sheet: #c2462e;          /* answer-sheet print */
  --sheet-2: #9e3522;
  --sheet-tint: #fcf2ee;
  --sheet-line: #eccabf;
  --graphite: #2a292d;       /* a filled mark */
  --ok: #2c7548;
  --ok-tint: #e5f1e9;
  --bar: 58px;
  --r: 8px;
  --sans: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --mono: "BIZ UDGothic", ui-monospace, "SF Mono", monospace;
  --mincho: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
.boot { text-align: center; padding: 30vh 16px; color: var(--ink-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1.5px solid var(--ink); border-radius: var(--r);
  background: var(--paper); font-weight: 700; font-size: 15px;
  transition: background .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: #f6f3ee; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #3a3834; }
.btn.primary:disabled { background: var(--ink-3); border-color: var(--ink-3); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.quiet { border-color: var(--line); }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); font-size: 14px; }

/* ---------- paper pages (intro, breaks, results) ---------- */
.page { max-width: 680px; margin: 0 auto; padding: 40px 16px 64px; }
.paper {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 36px 36px 32px; box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 10px 30px -18px rgba(60,45,20,.25);
}
@media (max-width: 600px) {
  .page { padding: 16px 12px 48px; }
  .paper { padding: 26px 20px 24px; }
}
.kicker { font-size: 13px; letter-spacing: .06em; color: var(--sheet); font-weight: 700; text-transform: uppercase; }
.title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 8px 0 12px; }
.title .jp { font-family: var(--mincho); font-weight: 800; font-size: clamp(44px, 9vw, 64px); line-height: 1.05; letter-spacing: .04em; }
.title .en { font-size: 18px; color: var(--ink-2); font-weight: 700; }
.lede { font-size: 17px; color: var(--ink-2); margin: 0 0 24px; max-width: 34em; }
h2 { font-size: 15px; margin: 28px 0 10px; }
.paper p { margin: 0 0 12px; }
.small { font-size: 14px; color: var(--ink-2); }

.parts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.parts li { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.parts .no {
  width: 28px; height: 28px; border: 1.5px solid var(--sheet); color: var(--sheet); border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.parts .name b { display: block; font-size: 16px; }
.parts .name span { font-size: 13px; color: var(--ink-3); }
.parts .len { font-family: var(--mono); font-weight: 700; font-size: 15px; text-align: right; }
.parts .len span { display: block; font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--ink-3); }
.parts li.done .no { background: var(--sheet); color: #fff; }
.parts li.now { background: var(--sheet-tint); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }

.rules { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 15px; }
.rules li { margin: 4px 0; }
.rules b { color: var(--ink); }
.note { font-size: 13.5px; color: var(--ink-2); background: #f6f3ee; border-radius: var(--r); padding: 12px 14px; margin: 18px 0 0; }

.field { display: grid; gap: 6px; margin: 24px 0 18px; }
.field label { font-size: 14px; font-weight: 700; }
.field input {
  font: inherit; font-size: 16px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r);
  background: #fff; max-width: 320px;
}
.field input:focus { border-color: var(--ink); outline: none; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.credit { font-size: 12.5px; color: var(--ink-3); text-align: center; margin: 22px auto 0; max-width: 520px; }

.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 16px 0 6px; }
.stat b { display: block; font-family: var(--mono); font-size: 22px; }
.stat span { font-size: 13px; color: var(--ink-3); }

/* audio download meter */
.aload { margin: 18px 0; }
.aload .track { height: 6px; background: #eee9e0; border-radius: 3px; overflow: hidden; }
.aload .track i { display: block; height: 100%; width: 0; background: var(--sheet); transition: width .2s; }
.aload .txt { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* ---------- test screen ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94); -webkit-backdrop-filter: saturate(1.3) blur(10px); backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-in { max-width: 1080px; margin: 0 auto; min-height: var(--bar); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.where { display: flex; align-items: center; gap: 10px; min-width: 0; }
.step { font-family: var(--mono); font-size: 13px; color: var(--sheet); border: 1.5px solid var(--sheet); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.where .jp { font-weight: 700; font-size: 17px; white-space: nowrap; }
.where .en { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.now { font-size: 14px; font-weight: 700; color: var(--sheet); white-space: nowrap; }
.bar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.count {
  min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff;
  font-family: var(--mono); font-size: 14px; color: var(--ink-2);
}
.count b { color: var(--ink); }
.timer {
  font-family: var(--mono); font-weight: 700; font-size: 20px; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 6px; background: var(--desk); min-width: 82px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.timer.low { background: var(--sheet); color: #fff; }
.timer.paused { background: #fff; outline: 1.5px dashed var(--ink-3); color: var(--ink-3); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r); background: #fff;
}
.icon-btn svg { width: 18px; height: 18px; }
.aprog { height: 3px; background: transparent; }
.aprog i { display: block; height: 100%; width: 0; background: var(--sheet); }
@media (max-width: 760px) {
  .where .en { display: none; }
  .bar-in { gap: 8px; padding: 0 10px; }
  .where .jp { font-size: 15px; }
  .timer { font-size: 18px; min-width: 70px; padding: 3px 7px; }
}
@media (max-width: 460px) {
  .step { display: none; }
  .count { padding: 0 7px; }
  .btn.small { padding: 0 9px; }
}
.listen-now { display: none; }
@media (max-width: 760px) {
  .bar .now { display: none; }
  .listen-now { display: block; text-align: center; font-size: 13px; font-weight: 700; color: var(--sheet); padding: 4px 0 6px; border-top: 1px solid var(--line); }
}

.tip { display: none; }
@media (max-width: 600px) and (orientation: portrait) {
  .tip {
    display: flex; gap: 10px; align-items: center; justify-content: space-between;
    margin: 10px 12px 0; padding: 9px 12px; border-radius: var(--r);
    background: var(--paper); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); line-height: 1.4;
  }
  .tip .linkish { white-space: nowrap; font-weight: 700; color: var(--ink); }
}
.layout {
  max-width: 1080px; margin: 0 auto; padding: 22px 16px 120px;
  display: grid; grid-template-columns: minmax(0, 720px) 290px; gap: 30px; justify-content: center; align-items: start;
}
.side { position: sticky; top: calc(var(--bar) + 20px); max-height: calc(100vh - var(--bar) - 40px); overflow: auto; }
@media (max-width: 1079px) {
  .layout { grid-template-columns: minmax(0, 720px); }
  .side { display: none; }
}
.booklet { display: grid; gap: 14px; min-width: 0; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  scroll-margin-top: calc(var(--bar) + 14px);
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.card img { width: 100%; }
.card.playing { border-color: var(--sheet); box-shadow: 0 0 0 2px var(--sheet); }
.card.flash { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--ink); } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (max-width: 600px) {
  .layout { padding: 10px 0 110px; }
  .booklet { gap: 10px; }
  .card { border-radius: 0; border-left: 0; border-right: 0; }
}

/* the answer-sheet strip under each question */
.ans {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--sheet-tint); border-top: 1px dashed var(--sheet-line);
}
.qn {
  min-width: 40px; height: 28px; padding: 0 6px; display: grid; place-items: center;
  border: 1.5px solid var(--sheet); border-radius: 3px; color: var(--sheet); font-weight: 700; font-size: 15px;
  background: #fff;
}
.qn small { font-size: 11px; margin-left: 1px; }
.qn.ban { display: flex; align-items: baseline; gap: 1px; justify-content: center; }
.bubbles { display: flex; gap: 12px; }
.b {
  width: 38px; height: 48px; border-radius: 50%;
  border: 1.5px solid var(--sheet); background: #fff; color: var(--sheet);
  font-weight: 700; font-size: 17px; line-height: 1; padding: 0;
  transition: background .12s, color .12s, transform .08s;
}
.b:hover:not(:disabled) { background: var(--sheet-tint); }
.b:active:not(:disabled) { transform: scale(.94); }
.b[aria-checked="true"] { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.flag {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--r);
  background: none; color: var(--ink-3); font-size: 13px;
}
.flag svg { width: 16px; height: 16px; }
.flag:hover { color: var(--ink-2); border-color: var(--sheet-line); }
.flag[aria-pressed="true"] { color: var(--sheet); border-color: var(--sheet); background: #fff; }
.flag[aria-pressed="true"] svg { fill: currentColor; }
@media (max-width: 420px) {
  .ans { gap: 10px; padding: 8px 12px; }
  .bubbles { gap: 9px; }
  .b { width: 36px; height: 44px; font-size: 16px; }
  .flag span { display: none; }
}
.m4-head { padding: 14px 16px 2px; font-size: 14px; color: var(--ink-3); }

/* review marks */
.b.key { border-color: var(--ok); color: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.b.key[aria-checked="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.b.miss[aria-checked="true"] { background: var(--sheet); border-color: var(--sheet); color: #fff; }
.b:disabled { opacity: 1; }
.verdict { margin-left: auto; font-size: 14px; font-weight: 700; }
.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--sheet); }
.card.right .ans { background: #f3f8f4; border-top-color: #cfe3d6; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px; background: var(--sheet-tint); }
.card.right .tools { background: #f3f8f4; }
.tools .btn { min-height: 34px; font-size: 13px; padding: 0 12px; border-width: 1px; }
.tools .btn.on { background: var(--sheet); border-color: var(--sheet); color: #fff; }
.script { border-top: 1px solid var(--line); background: #fff; }
.only-wrong .card.q.right { display: none; }

/* ---------- answer sheet panel ---------- */
.sheet { background: var(--paper); border: 1.5px solid var(--sheet); border-radius: 8px; padding: 14px 14px 10px; }
.sheet-h { color: var(--sheet); font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.sheet-h span { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.sheet-m + .sheet-m { margin-top: 10px; }
.sheet-mh { font-size: 12px; color: var(--sheet); font-weight: 700; margin-bottom: 5px; }
.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.cell {
  position: relative; aspect-ratio: 1 / 1; padding: 0;
  border: 1px solid var(--sheet-line); border-radius: 5px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.cell span { font-size: 10px; color: var(--sheet); }
.cell b { font-family: var(--mono); font-size: 15px; color: var(--graphite); min-height: 16px; }
.cell.done { background: var(--sheet-tint); border-color: var(--sheet); }
.cell.flagged::after {
  content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 9px 9px 0; border-color: transparent var(--sheet) transparent transparent;
}
.cell.ok { background: var(--ok-tint); border-color: #b9d8c4; }
.cell.ok b { color: var(--ok); }
.cell.no { background: #fff; border-color: var(--sheet); }
.cell.no b { color: var(--sheet); }

/* ---------- dialogs ---------- */
dialog {
  border: 0; padding: 0; border-radius: 14px; max-width: min(440px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45); color: var(--ink);
}
dialog::backdrop { background: rgba(32, 28, 22, .45); }
dialog[open] { overflow: auto; }
dialog.float { /* non-modal: the answers behind stay usable */
  position: fixed; inset: auto auto calc(12px + env(safe-area-inset-bottom)) 50%; transform: translateX(-50%);
  margin: 0; z-index: 50; width: min(560px, calc(100vw - 24px)); max-width: none; border: 1.5px solid var(--sheet); border-radius: 12px;
}
.grace { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; }
.grace div { flex: 1; font-size: 14px; line-height: 1.4; }
.grace div span { display: block; color: var(--ink-2); }
.grace b#gc { font-family: var(--mono); color: var(--sheet); }
dialog.sheet-dlg .sheet-h { padding-right: 84px; }
.dlg { padding: 24px 24px 20px; }
.dlg h3 { margin: 0 0 8px; font-size: 18px; }
.dlg p { margin: 0 0 18px; color: var(--ink-2); font-size: 15px; }
.dlg .actions { justify-content: flex-end; }
dialog.sheet-dlg {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 80vh; border-radius: 16px 16px 0 0;
}
dialog.sheet-dlg .sheet { border: 0; border-radius: 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
dialog.sheet-dlg .grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
.dlg-close { position: absolute; top: 10px; right: 10px; }
.big-count { font-family: var(--mono); font-size: 40px; font-weight: 700; text-align: center; margin: 4px 0 10px; color: var(--sheet); }

/* resume overlay */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(32,28,22,.55); display: grid; place-items: center; padding: 16px; }
.overlay .paper { max-width: 420px; text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- results ---------- */
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.total { font-family: var(--mono); font-weight: 700; line-height: 1; }
.total b { font-size: 76px; letter-spacing: -.02em; }
.total span { font-size: 26px; color: var(--ink-3); margin-left: 6px; }
.verdict-line { font-size: 15px; color: var(--ink-2); margin-top: 8px; }
.stamp {
  width: 124px; height: 124px; border-radius: 50%; border: 4px solid var(--sheet); color: var(--sheet);
  display: grid; place-items: center; transform: rotate(-9deg); flex: none;
  font-family: var(--mincho); font-weight: 800; font-size: 40px; letter-spacing: .06em;
  box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 6px var(--sheet);
  opacity: .92;
}
.stamp.pop { animation: stamp .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes stamp { from { transform: rotate(-9deg) scale(1.6); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: .92; } }
.meter { position: relative; margin: 22px 0 6px; }
.meter .track { height: 12px; background: #eee9e0; border-radius: 6px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--ink); border-radius: 6px 0 0 6px; }
.meter.pass .fill { background: var(--ok); }
.meter .tick { position: absolute; top: -5px; width: 2px; height: 22px; background: var(--sheet); }
.meter .tick span { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--sheet); white-space: nowrap; font-weight: 700; }
.meter + .scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 0; }
.secs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 30px 0 10px; }
.sec-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 18px; }
.sec-card h3 { font-size: 14px; margin: 0; }
.sec-card h3 span { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.sec-card .num { font-family: var(--mono); font-weight: 700; font-size: 30px; margin-top: 6px; }
.sec-card .num span { font-size: 15px; color: var(--ink-3); }
.sec-card .meter { margin: 10px 0 18px; }
.sec-card .meter .track { height: 8px; }
.sec-card .meter .tick { height: 18px; }
.sec-card .meter .tick span { top: 19px; font-size: 11px; }
.sec-card .meter { margin-bottom: 28px; }
@media (max-width: 560px) {
  .secs { grid-template-columns: 1fr; }
  .result-top { flex-wrap: nowrap; align-items: flex-start; }
  .total b { font-size: 58px; }
  .total span { font-size: 20px; }
  .stamp { width: 86px; height: 86px; font-size: 28px; border-width: 3px; margin-top: 4px; }
}

.break-down { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; }
.break-down th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 400; padding: 14px 0 4px; border-bottom: 1px solid var(--line); }
.break-down th b { color: var(--ink); font-size: 14px; margin-right: 6px; }
.break-down td { padding: 7px 0; border-bottom: 1px solid #efebe4; vertical-align: middle; }
.break-down td.n { font-family: var(--mono); font-weight: 700; text-align: right; white-space: nowrap; width: 54px; }
.break-down td.bar { width: 34%; padding-left: 14px; }
.mini { height: 6px; background: #eee9e0; border-radius: 3px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--ink); }
.break-down .en { color: var(--ink-3); font-size: 12.5px; margin-left: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 34px 0 12px; align-items: center; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.toggle { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--sheet); }
.review-wrap { max-width: 720px; margin: 0 auto; }
.review-wrap .booklet { margin-top: 6px; }
.review-head { padding: 0 16px; }
@media (max-width: 600px) { .review-head { padding: 0 12px; } .toggle { margin-left: 0; } }

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