:root {
  --bg:        #fbfaf7;
  --panel:     #ffffff;
  --ink:       #23282e;
  --ink-soft:  #5c6672;
  --line:      #e2ddd4;
  --accent:    #1f6f8b;
  --key:       #ffffff;
  --key-line:  #cfd6dd;
  --key-press: #dceaf0;
  --ok:        #1f7a4d;
  --ok-bg:     #e6f4ec;
  --ng:        #b0362f;
  --ng-bg:     #fbeae8;
  --shadow:    0 1px 2px rgba(20,25,30,.10), 0 3px 10px rgba(20,25,30,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #14161a;
    --panel:     #1c2026;
    --ink:       #e8eaed;
    --ink-soft:  #a3adb8;
    --line:      #333a43;
    --accent:    #6fc3dd;
    --key:       #262c34;
    --key-line:  #3d4650;
    --key-press: #33424c;
    --ok:        #5fd39a;
    --ok-bg:     #16301f;
    --ng:        #f08b82;
    --ng-bg:     #331817;
    --shadow:    0 1px 2px rgba(0,0,0,.40), 0 3px 10px rgba(0,0,0,.28);
  }
}
:root[data-theme="dark"] {
  --bg:        #14161a;
  --panel:     #1c2026;
  --ink:       #e8eaed;
  --ink-soft:  #a3adb8;
  --line:      #333a43;
  --accent:    #6fc3dd;
  --key:       #262c34;
  --key-line:  #3d4650;
  --key-press: #33424c;
  --ok:        #5fd39a;
  --ok-bg:     #16301f;
  --ng:        #f08b82;
  --ng-bg:     #331817;
  --shadow:    0 1px 2px rgba(0,0,0,.40), 0 3px 10px rgba(0,0,0,.28);
}

:root {
  --font-main:
    "UD デジタル教科書体 NK-R", "UD Digi Kyokasho NK-R", "UD Digi Kyokasho NK",
    "UD デジタル教科書体 N-R", "UD Digi Kyokasho N",
    "Klee One", "Yuji Syuku",
    "Hiragino Maru Gothic ProN", "ヒラギノ丸ゴ ProN",
    "BIZ UDPGothic", "Yu Gothic Medium", "Yu Gothic", "Meiryo",
    sans-serif;

  --font-num:
    "UD デジタル教科書体 NK-R", "UD Digi Kyokasho NK-R", "UD Digi Kyokasho NK",
    "BIZ UDPGothic", "Hiragino Maru Gothic ProN", "Yu Gothic Medium", sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 18px; }
@media (min-width: 40rem) { html { font-size: 19px; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-main);
  font-size: 1.25rem;
  line-height: 1.85;
  letter-spacing: .04em;
  -webkit-text-size-adjust: 100%;
}

p, li, .q-text, .unit-name { word-break: keep-all; overflow-wrap: anywhere; }

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

body.q-page {
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex; flex-direction: column;
}

body.q-page #app {
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column;
}
body.q-page .wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex; flex-direction: column;
  padding-bottom: .5rem;
}

body.q-page .q-card { min-height: 0; overflow-y: auto; }

body.q-page .pad { margin-top: auto; width: 100%; flex: 0 0 auto; }

.site-head {
  text-align: center;
  padding: 1.5rem 1rem .5rem;
}

.brand {
  margin: 0 0 .35rem;
  font-size: .95rem;
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.brand a { color: inherit; text-decoration: none; }
.brand a:hover,
.brand a:focus-visible { text-decoration: underline; }

.brand-logo {
  margin: 0 0 .6rem;
  line-height: 0;
}
.brand-logo img {
  width: 100%;
  max-width: 19rem;
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.brand-logo.sub img { max-width: 9rem; }

.brand-logo a { display: inline-block; line-height: 0; }
.brand-logo a:hover,
.brand-logo a:focus-visible { text-decoration: none; }
.brand-logo a:focus-visible img { outline: 3px solid var(--accent); outline-offset: 3px; }
.site-head h1 {
  font-size: 2rem;
  margin: 0 0 .25rem;
  color: var(--accent);
  letter-spacing: .06em;
}
.site-head .lead {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.area-name {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 2rem 0 .75rem;
  font-size: 1.15rem;
  color: var(--ink-soft);
  letter-spacing: .08em;
}
.area-name::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.unit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .75rem;
}

@media (min-width: 34rem) {
  .unit-list { grid-template-columns: 1fr 1fr; }
}

.unit-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 4.5rem;
  padding: .85rem 1rem;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.unit-card:active { background: var(--key-press); }
.unit-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.unit-card .no {
  flex: 0 0 auto;
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--panel);
  font-family: var(--font-num);
  font-size: 1.1rem;
}
.unit-card .unit-name { font-size: 1.2rem; line-height: 1.5; }
.unit-card .unit-sub {
  display: block;
  font-size: .85rem;
  color: var(--ink-soft);
  letter-spacing: .02em;
}

.unit-card.todo {
  opacity: .55;
  border-style: dashed;
  box-shadow: none;
  cursor: default;
}
.unit-card.todo .no { background: var(--line); color: var(--ink-soft); }

.unit-card .unit-now { display: none; }
.unit-card.is-now {
  border-color: var(--accent);
  background: var(--key-press);
}
.unit-card.is-now .unit-now {
  display: block;
  flex: 0 0 auto;
  margin-left: auto;
  padding: .15rem .55rem;
  border-radius: .5rem;
  background: var(--accent);
  color: var(--panel);
  font-size: .85rem;
  white-space: nowrap;
}

.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: clamp(.4rem, 1.5vh, .75rem) 1rem;
  border-bottom: 2px solid var(--line);
  background: var(--panel);
}
.q-head .back {
  display: grid; place-items: center;
  width: 3rem; height: clamp(2.6rem, 6vh, 3rem);
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--key);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.4rem;
}
.q-head .title { font-size: 1.1rem; letter-spacing: .05em; }

.dots { display: flex; gap: .3rem; }
.dots i {
  width: .7rem; height: .7rem;
  border-radius: 50%;
  background: var(--line);
  display: block;
}
.dots i.done { background: var(--ok); }
.dots i.now  { background: var(--accent); transform: scale(1.35); }

.q-card {
  margin: clamp(.5rem, 2vh, 1.25rem) 0;
  padding: clamp(.75rem, 3vh, 2rem) 1rem;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.q-text {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 0 0 clamp(.4rem, 1.5vh, 1rem);
}
.q-expr {
  font-family: var(--font-num);
  font-size: clamp(2rem, min(13vw, 9vh), 4.6rem);
  line-height: 1.25;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .3em;
}

.q-expr .blank {
  min-width: 1.5em;
  min-height: 1.25em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .04em .1em;
  border: .055em solid var(--accent);
  border-radius: .08em;
  color: var(--ink);
}
.q-expr .blank.filled { border-color: var(--ink); }

.dot-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .55rem;
  max-width: 22rem;
  margin: 0 auto 1.25rem;
}
.dot-field b {
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  display: block;
}

.dot-field b:nth-child(5n) { margin-right: 1.1rem; }

.q-card.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.q-card.is-ng { border-color: var(--ng); background: var(--ng-bg); }
.verdict {
  margin: .75rem 0 0;
  min-height: 2rem;
  font-size: 1.3rem;
}
.verdict.ok { color: var(--ok); }
.verdict.ng { color: var(--ng); }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(.35rem, 1.2vh, .6rem);
  max-width: 24rem;
  margin: 0 auto;
}
.pad button {

  min-height: clamp(3rem, 7.5vh, 4rem);
  font-family: var(--font-num);
  font-size: clamp(1.5rem, 4vh, 1.9rem);
  color: var(--ink);
  background: var(--key);
  border: 2px solid var(--key-line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
.pad button:active { background: var(--key-press); transform: translateY(1px); }
.pad button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pad button.wide { grid-column: span 2; }
.pad button.del { font-size: 1.4rem; color: var(--ink-soft); }

.result {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.result .score {
  font-family: var(--font-num);
  font-size: clamp(3rem, 16vw, 5rem);
  color: var(--accent);
  line-height: 1.2;
}
.btn-row { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.25rem; }
.btn {
  min-height: 3.5rem;
  padding: 0 1.5rem;
  display: inline-flex; align-items: center;
  font-family: var(--font-main);
  font-size: 1.15rem;
  color: var(--ink);
  background: var(--key);
  border: 2px solid var(--key-line);
  border-radius: 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.btn:active { transform: translateY(1px); }

.note-adult {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: .85rem;
  line-height: 1.8;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.note-adult code { font-size: .95em; }

.entry { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: .75rem; }
.entry-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 5.5rem;
  padding: 1rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: .9rem;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}
.entry-card:active { background: var(--key-press); transform: translateY(1px); }
.entry-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.entry-no {
  flex: 0 0 auto;
  width: 2.6rem; height: 2.6rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--panel);
  font-family: var(--font-num);
  font-size: 1.3rem;
}
.entry-name { font-size: 1.35rem; line-height: 1.5; }
.entry-sub {
  display: block;
  margin-top: .2rem;
  font-size: .95rem;
  color: var(--ink-soft);
}
.area-note {
  margin: -.5rem 0 1.25rem;
  font-size: .95rem;
  line-height: 1.8;
  color: var(--ink-soft);
}

.mk-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.mk-field { display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.mk-field select {
  font-family: inherit;
  font-size: 1.05rem;
  padding: .6rem .8rem;
  min-height: 3rem;
  border: 2px solid var(--key-line);
  border-radius: .6rem;
  background: var(--key);
  color: var(--ink);
}
.mk-id { font-size: .95rem; color: var(--ink-soft); margin: 0 0 1rem; }
.mk-id code, .id-form code {
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 1.05em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .3rem;
  padding: .1em .4em;
}
.mk-sep { margin: 0 .5rem; opacity: .5; }
.mk-warn {
  background: var(--ng-bg);
  border: 2px solid var(--ng);
  border-radius: .6rem;
  padding: .8rem 1rem;
  font-size: .95rem;
  line-height: 1.7;
  color: var(--ink);
}

.id-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .9rem;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.id-form label { display: block; margin-bottom: .6rem; font-size: 1rem; }
.id-form input {
  font-family: ui-monospace, "Consolas", monospace;
  font-size: 1.3rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 3.5rem;
  padding: .6rem .8rem;
  margin-bottom: .8rem;
  border: 2px solid var(--key-line);
  border-radius: .6rem;
  background: var(--key);
  color: var(--ink);
}
.id-form input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.id-err { color: var(--ng); font-size: .95rem; margin: .8rem 0 0; }

.cam {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .9rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.cam video, .cam img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: #000;
  border-radius: .5rem;
}
.cam-note {
  margin: .8rem 0 0;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--ink-soft);
  text-align: center;
}
.cam-note.is-warn { color: var(--ng); }

.how {
  font-size: 1.05rem;
  line-height: 1.8;
  margin: 0 0 1rem;
  color: var(--ink-soft);
}
.mark-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.mark-item {
  border-radius: .7rem;
  border: 2px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
.mark-item.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.mark-item.is-ng { border-color: var(--ng); background: var(--ng-bg); }

.judge-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  min-height: 4.5rem;
  padding: .5rem .9rem;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.judge-row:active { transform: translateY(1px); }
.judge-row:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.judge-row .qn {
  flex: 0 0 auto;
  width: 2rem;
  font-size: .95rem;
  color: var(--ink-soft);
  text-align: right;
}
.judge-row .qx {
  flex: 1 1 auto;
  font-family: var(--font-num);
  font-size: 1.5rem;
  letter-spacing: .04em;
  min-width: 0;
  overflow-wrap: anywhere;
}
.judge-row .ans {
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-size: 1.8rem;
  font-weight: 700;
  min-width: 2.4em;
  text-align: center;
}
.judge-row .mk {
  flex: 0 0 auto;
  width: 2.6rem;
  font-size: 1.8rem;
  text-align: center;
}
.mark-item.is-ok .mk { color: var(--ok); }
.mark-item.is-ng .mk { color: var(--ng); }

@media print {
  :root {
    --bg: #fff; --panel: #fff; --ink: #000; --ink-soft: #444;
    --line: #999; --accent: #000;
  }

  body.q-page { height: auto; overflow: visible; display: block; }
  body.q-page .wrap { display: block; }
  .q-head, .pad, .btn-row, .note-adult, .verdict { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .print-sheet { display: block !important; }
  .q-card { display: none !important; }
  .print-sheet ol {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem 2rem;
  }
  .print-sheet li {
    font-family: var(--font-num);
    font-size: 1.8rem;
    border-bottom: 1px solid var(--line);
    padding: .4rem 0;
    break-inside: avoid;
  }
  @page { margin: 14mm; }
}
.print-sheet { display: none; }
