/* 型トレ — 落ち着いた和の配色（生成り・藍・墨・朱） */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2a2723;
  --muted: #6f675c;
  --line: #ddd3c2;
  --ai: #1f3a5f;       /* 藍 */
  --ai-soft: #e3e9f1;
  --shu: #b8432f;      /* 朱 */
  --shu-soft: #f7e3de;
  --take: #2f7d57;     /* 若竹 */
  --take-soft: #e0f0e6;
  --kin: #b8892d;
  --key: #fffdf8;
  --key-fn: #ece4d4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --pad-h: 0px;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --math: "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18; --paper: #252320; --ink: #eee8dc; --muted: #a79f92; --line: #3d3933;
    --ai: #8fb0dc; --ai-soft: #26303d; --shu: #e58a76; --shu-soft: #3a2621; --take: #7cc59d; --take-soft: #1f3329;
    --kin: #d9b262; --key: #2d2a26; --key-fn: #37332d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.6; min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
body.with-keypad .app { padding-bottom: calc(var(--keypad-h, 300px) + 24px); }
a { color: var(--ai); }
h1 { font-size: 1.4rem; margin: .3em 0; }
h1 small { font-size: .8rem; font-weight: normal; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.noscript { padding: 1rem; }

/* ---- ヘッダー ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem max(1rem, env(safe-area-inset-left)); background: var(--ai); color: #f7f3ea;
}
@media (prefers-color-scheme: dark) { .topbar { background: #16263b; } }
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: .08em; min-height: 44px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: #f7f3ea; color: var(--ai); font-family: var(--math); font-size: 1.2rem;
}
@media (prefers-color-scheme: dark) { .brand-mark { color: #16263b; } }
.stage-badge { font-size: .85rem; opacity: .9; }

.app { max-width: 560px; margin: 0 auto; padding: 1rem; }

/* ---- ホーム ---- */
.hero { text-align: center; padding: 1.2rem 0 .6rem; }
.hero h1 { font-size: 2rem; letter-spacing: .15em; margin: 0; font-family: var(--math); }
.hero.small { padding: .2rem 0 .4rem; }
.hero.small h1 { font-size: 1.4rem; }
.lead { color: var(--muted); margin: .4rem 0 0; }
.sec-title { font-size: 1rem; margin: 1.4rem 0 .6rem; padding-left: .6rem; border-left: 4px solid var(--shu); }

.stage-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; background: var(--paper); padding: .3rem; border-radius: 22px; border: 1px solid var(--line); }
.stage-tab {
  min-height: 44px; border: 0; border-radius: 18px; background: transparent; color: var(--ink); padding: .25rem .2rem;
  font-size: .85rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem; cursor: pointer; line-height: 1.2;
}
.stage-tab .st-icon { font-size: 1.05rem; }
.stage-sub { font-size: .85rem; color: var(--muted); margin: .5rem .2rem 0; }
.sc-text { display: flex; flex-direction: column; gap: .15rem; }
.sc-desc { font-size: .8rem; color: var(--muted); font-weight: 400; }
.chip.exam { border-color: var(--shu); color: var(--shu); }
.tip.trap { background: transparent; border: 1px dashed var(--shu); }
sup.idx { font-size: .6em; margin-right: -.35em; vertical-align: .9em; }
.stage-tab.on { background: var(--ai); color: #fff; }
@media (prefers-color-scheme: dark) { .stage-tab.on { color: #16263b; } }
.stage-pick { display: grid; gap: .8rem; }
.stage-card {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: .8rem; text-align: left;
  padding: 1rem 1.2rem; min-height: 72px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; font-size: 1.2rem;
}
.sc-icon { font-size: 2rem; }
.sc-name { font-weight: 700; }
.sc-sub { font-size: .85rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .9rem 0; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .4rem; text-align: center; }
.stat-num { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ai); font-family: var(--math); line-height: 1.2; }
.stat-label { font-size: .75rem; color: var(--muted); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.mode {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .6rem; align-items: center;
  padding: .7rem .8rem; min-height: 60px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.mode.mix { grid-column: 1 / -1; background: var(--ai); color: #fff; border-color: var(--ai); }
@media (prefers-color-scheme: dark) { .mode.mix { color: #16263b; } }
.m-icon { grid-row: 1 / 3; font-size: 1.6rem; }
.m-name { font-weight: 700; }
.m-sub { font-size: .78rem; opacity: .8; }

.unit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.unit-card {
  display: flex; flex-direction: column; gap: .15rem; padding: .8rem; min-height: 110px;
  border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); color: var(--ink);
  text-decoration: none; box-shadow: var(--shadow); transition: transform .08s;
}
.unit-card:active { transform: scale(.98); }
.u-meta { margin-top: auto; padding-top: .3rem; font-size: .72rem; color: var(--ai); font-weight: 700; }

/* ---- 高校：科目カード（トラック → 科目 → 単元） ---- */
.subject-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.subject-card {
  display: grid; grid-template-columns: 56px 1fr auto; column-gap: .8rem; align-items: center;
  min-height: 76px; padding: .7rem .9rem; border-radius: var(--radius); background: var(--paper);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .08s;
}
.subject-card:active { transform: scale(.98); }
.sb-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  background: var(--ai); color: #fff; font-size: 1.5rem; font-weight: 700; font-family: var(--math);
}
@media (prefers-color-scheme: dark) { .sb-icon { color: #16263b; } }
.sb-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.sb-name { font-weight: 800; font-size: 1.1rem; }
.sb-desc { font-size: .74rem; color: var(--muted); line-height: 1.4; }
.sb-count { display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: 1.4rem; color: var(--ai); line-height: 1.1; }
.sb-count small { font-size: .68rem; font-weight: 600; color: var(--muted); }
.modes.single { grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 720px) { .subject-grid { grid-template-columns: 1fr 1fr; } }
.u-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--ai-soft); font-size: 1.3rem; font-family: var(--math); font-weight: 700; color: var(--ai);
}
.u-icon.big { width: 56px; height: 56px; font-size: 1.8rem; flex: none; }
.u-name { font-weight: 700; margin-top: .3rem; }
.u-desc { font-size: .75rem; color: var(--muted); line-height: 1.4; }

/* ---- 単元ページ ---- */
.back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-size: .95rem; }
.unit-head { display: flex; gap: .9rem; align-items: center; }
.unit-head h1 { margin: 0; }
.unit-head p { margin: .1rem 0 0; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .8rem 0 0; }
.chip { font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--ai); border-radius: 12px; overflow: hidden; }
.seg-btn { min-height: 48px; border: 0; background: var(--paper); color: var(--ai); font-size: 1rem; font-weight: 700; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--ai); }
.seg-btn.on { background: var(--ai); color: #fff; }
@media (prefers-color-scheme: dark) { .seg-btn.on { color: #16263b; } }

.actions { display: grid; gap: .6rem; margin: 1rem 0; }
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 48px; padding: .6rem 1rem; border-radius: 12px; border: 1px solid var(--ai);
  background: var(--paper); color: var(--ai); font-size: 1rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn small { font-weight: normal; font-size: .75rem; opacity: .85; }
.btn.primary { background: var(--ai); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #16263b; } }
.btn.big { min-height: 60px; font-size: 1.1rem; }
.btn.danger { border-color: var(--shu); color: var(--shu); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }

.best-table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.best-table th, .best-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
.best-table.wide td { text-align: center; }
.best-table thead th { background: var(--ai-soft); font-size: .8rem; }
.table-wrap { overflow-x: auto; }

/* ---- 問題画面 ---- */
.qbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .5rem; }
.qtitle { font-weight: 700; font-size: .9rem; text-align: center; line-height: 1.3; }
.qtitle small { display: block; font-weight: normal; color: var(--muted); font-size: .75rem; }
.qright { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-family: var(--math); font-size: 1.05rem; color: var(--ink); }
.progress { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: .2rem 0 .6rem; }
.progress span { height: 8px; border-radius: 4px; background: var(--line); font-size: 0; }
.progress span.ok { background: var(--take); }
.progress span.ng { background: var(--shu); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.question { margin: .6rem 0; }
.question .prompt { font-size: .95rem; }
.question .math { font-size: 1.5rem; text-align: center; padding: .7rem 0 .3rem; overflow-x: auto; }
.note { font-size: .82rem; color: var(--muted); display: block; margin-top: .3rem; }

.fields { display: grid; gap: .5rem; }
.field {
  display: grid; grid-template-columns: minmax(4.5em, auto) 1fr auto; align-items: center; gap: .6rem;
  padding: .4rem .6rem; min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); cursor: pointer;
}
.field.active { border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.flabel { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.fbox { font-family: var(--math); font-size: 1.5rem; min-height: 1.6em; display: flex; align-items: center; overflow-x: auto; white-space: nowrap; }
.fsuffix { color: var(--muted); }
.caret { display: none; width: 2px; height: 1.2em; background: var(--ai); margin-left: 1px; animation: blink 1s steps(1) infinite; }
.field.active .caret { display: inline-block; }
@keyframes blink { 50% { opacity: 0; } }
.field.shake { animation: shake .3s; border-color: var(--shu); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---- フィードバック ---- */
.feedback { margin-top: .8rem; scroll-margin-top: 64px; }
.feedback.ok { border-color: var(--take); background: linear-gradient(var(--take-soft), var(--paper) 90px); }
.feedback.ng { border-color: var(--shu); background: linear-gradient(var(--shu-soft), var(--paper) 90px); }
.verdict { display: flex; align-items: center; gap: .6rem; font-size: 1.4rem; font-weight: 700; }
.verdict .mark { font-size: 3rem; line-height: 1; font-family: var(--math); }
.feedback.ok .verdict { color: var(--take); }
.feedback.ng .verdict { color: var(--shu); }
.ans-table { width: 100%; border-collapse: collapse; margin: .6rem 0; font-size: .95rem; }
.ans-table th, .ans-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.ans-table thead th { font-size: .75rem; color: var(--muted); font-weight: normal; }
.ans-table td.math { font-family: var(--math); font-size: 1.15rem; }
.ans-table tr.bad td:last-child { color: var(--shu); }
.ans-table tr.good td:last-child { color: var(--take); }
.expl-title { font-size: .95rem; margin: .8rem 0 .3rem; }
.steps { padding-left: 1.4rem; margin: 0 0 1rem; }
.steps li { margin: .35rem 0; line-height: 1.9; }
.steps li:has(.tip) { list-style: none; margin-left: -1.4rem; }
.tip { display: block; background: var(--ai-soft); border-radius: 10px; padding: .5rem .7rem; font-size: .9rem; }

.flash {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 50;
  font-size: 9rem; font-family: var(--math); font-weight: 700; animation: pop .5s ease-out;
}
.flash.ok { color: var(--take); }
.flash.ng { color: var(--shu); }
.flash[hidden] { display: none; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } 30% { transform: scale(1.05); opacity: .95; } to { opacity: 0; } }

/* ---- 結果・履歴・復習 ---- */
.result { text-align: center; }
.big-score { font-size: 1.6rem; font-family: var(--math); }
.big-score span { font-size: 4rem; font-weight: 700; color: var(--ai); }
.best-badge { color: var(--kin); font-weight: 700; margin: 0; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .8rem 0; }
.result-stats div { background: var(--bg); border-radius: 10px; padding: .5rem; }
.result-stats b { display: block; font-size: 1.2rem; }
.wrong-list { display: grid; gap: .5rem; }
.wrong summary { cursor: pointer; display: flex; gap: .6rem; align-items: flex-start; min-height: 44px; }
.w-no { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--shu); color: #fff; font-size: .85rem; }
.w-q { font-size: .9rem; }
.hist-list, .review-list { list-style: none; padding: 0; margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.hist-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: .6rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .88rem; align-items: center; }
.review-list li { display: grid; gap: .1rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .88rem; }
.hist-list li:last-child, .review-list li:last-child { border-bottom: 0; }
.h-date { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.h-score { font-weight: 700; color: var(--ai); }
.h-time { font-variant-numeric: tabular-nums; }
.r-unit { font-size: .78rem; color: var(--muted); }
.r-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; font-size: 1.1rem; padding: 2rem 0; }

/* ---- キーパッド ---- */
.keypad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--key-fn); border-top: 1px solid var(--line);
  padding: .45rem max(.45rem, env(safe-area-inset-left)) calc(.45rem + env(safe-area-inset-bottom));
}
.keypad[hidden] { display: none; }
.keys { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: .35rem; }
.key {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--key); color: var(--ink);
  font-size: 1.35rem; font-family: var(--math); cursor: pointer; touch-action: manipulation; user-select: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
.key:active { transform: translateY(1px); filter: brightness(.94); }
.key.fn { font-family: var(--font); font-size: .9rem; background: var(--key-fn); font-weight: 600; }
.key.sym { color: var(--ai); font-weight: 700; }
.key[data-k="/"] { font-size: 1rem; font-family: var(--font); }
.key.ok { background: var(--shu); color: #fff; border-color: var(--shu); font-family: var(--font); font-size: 1.1rem; font-weight: 700; min-height: 52px; }

/* ---- 数式表示 ---- */
.v { font-family: var(--math); font-style: italic; padding: 0 .04em; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .12em; line-height: 1.15; font-size: .92em; }
.frac > .fn { padding: 0 .2em .05em; border-bottom: .08em solid currentColor; }
.frac > .fd { padding: .05em .2em 0; }
.frac > .fb { display: none; }
.frac.sm { font-size: .75em; }
.sqrt { display: inline-flex; align-items: flex-start; white-space: nowrap; }
.sqrt > .sq { font-family: var(--math); font-size: 1.05em; line-height: 1.1; margin-right: -.05em; }
.sqrt > .rc { border-top: .08em solid currentColor; padding: 0 .12em 0 .08em; margin-top: .14em; line-height: 1.15; }
sup { font-size: .68em; line-height: 0; }
sub { font-size: .68em; line-height: 0; }
.vec { position: relative; display: inline-block; }
.vec::before { content: "→"; position: absolute; top: -.72em; left: 0; right: 0; text-align: center; font-size: .7em; font-style: normal; }
.system { display: inline-flex; flex-direction: column; align-items: flex-start; border-left: 2px solid currentColor; border-radius: 10px 0 0 10px; padding: .1em 0 .1em .6em; gap: .2em; text-align: left; font-size: .9em; }
.sigma, .int { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin-right: .15em; }
.sigma .sg { font-size: 1.6em; line-height: 1; }
.sigma .st, .sigma .sb, .int .it, .int .ib { font-size: .6em; }
.int .is { font-size: 1.7em; line-height: 1; font-family: var(--math); }
.int { flex-direction: column; }

@media (min-width: 700px) {
  .app { padding: 1.5rem; }
  .unit-grid { grid-template-columns: 1fr 1fr 1fr; }
  .key { min-height: 52px; }
}
@media (max-width: 370px) {
  .question .math { font-size: 1.3rem; }
  .unit-card { min-height: 100px; }
}

/* ---- 回答方式の切替 ---- */
.mode-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .6rem; margin: .8rem 0; }
.mode-cap { font-size: .85rem; color: var(--muted); font-weight: 700; }
.mode-row .seg { grid-template-columns: 1fr 1.6fr; }
.mode-row .seg-btn { min-height: 44px; font-size: .95rem; }
.mode-tag { margin-left: .4rem; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--ai-soft); color: var(--ai); }
.mode-tag.choice { background: var(--take-soft); color: var(--take); }
.small { font-size: .8rem; }
.note.mistake { color: var(--shu); font-weight: 600; }

/* ---- 4択ボタン（2×2） ---- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .4rem; }
.choices.one-col { grid-template-columns: 1fr; }
.choice {
  display: flex; align-items: center; gap: .5rem; text-align: left;
  min-height: 84px; padding: .6rem .7rem; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); color: var(--ink);
  cursor: pointer; touch-action: manipulation; box-shadow: 0 2px 0 rgba(0, 0, 0, .1); font-size: 1.25rem;
}
.choices.one-col .choice { min-height: 64px; }
.choice:active:not(:disabled) { transform: translateY(1px); background: var(--ai-soft); }
.c-no { flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--ai-soft); color: var(--ai); font-size: 1rem; font-weight: 700; }
.c-body { flex: 1; min-width: 0; display: grid; gap: .1rem; overflow-x: auto; }
.c-line { display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
.c-label { font-size: .75rem; color: var(--muted); }
.c-val { font-family: var(--math); font-size: 1.3rem; }
.c-val.math { padding: 0; text-align: left; overflow: visible; }
.c-suffix { font-size: .8rem; color: var(--muted); }
.choice:disabled { cursor: default; opacity: 1; color: var(--ink); }
.choice.right { border-color: var(--take); background: var(--take-soft); }
.choice.wrong { border-color: var(--shu); background: var(--shu-soft); }
.choice.right .c-no { background: var(--take); color: #fff; }
.choice.wrong .c-no { background: var(--shu); color: #fff; }
.choice:disabled:not(.right):not(.wrong) { opacity: .55; }

/* ---- ランキング（任意機能） ---- */
.mode.rank { grid-column: 1 / -1; }
.rank-box { margin: 1rem 0; }
.rank-box .actions { margin: .6rem 0 0; }
.rank-ok { color: var(--take); font-weight: 700; margin: 0; }
.rank-ng { color: var(--shu); margin: 0; }
.rank-filters { display: grid; gap: .5rem; margin: .8rem 0; }
.rank-filters .seg { grid-template-columns: repeat(4, 1fr); }
.rank-filters .seg.rank-mode { grid-template-columns: 1fr 1fr; }
.rank-filters .seg-btn { min-height: 44px; font-size: .95rem; }
.rank-sel { display: grid; grid-template-columns: 4.2em 1fr; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); font-weight: 700; }
.rank-sel select, .rank-field input { min-height: 46px; width: 100%; font-size: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); padding: 0 .6rem; font-family: inherit; }
.rank-list { list-style: none; margin: .3rem 0 1rem; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rank-row { display: grid; grid-template-columns: 2.4rem 1fr auto auto; gap: .5rem; align-items: center; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
.rank-row:last-child { border-bottom: 0; }
.rank-row.me { background: var(--take-soft); box-shadow: inset 4px 0 0 var(--take); font-weight: 700; }
.rk-no { text-align: center; font-family: var(--math); font-weight: 700; font-size: 1.05rem; }
.rk-nick { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rk-nick small { color: var(--take); margin-left: .3rem; }
.rk-nick small.rk-sub { display: block; margin: 0; color: var(--muted); font-weight: 400; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.rk-time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 4.4em; }
.rank-err { border-color: var(--shu); }
.rank-form { display: grid; gap: .8rem; }
.rank-field { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 700; }
.rank-warn { background: var(--shu-soft); border-radius: 10px; padding: .5rem .7rem; margin: 0; font-size: .9rem; }
.rank-check { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.rank-check input { width: 22px; height: 22px; }
.rank-msg { color: var(--shu); font-weight: 700; margin: 0; min-height: 1.2em; }

/* 4択：ギブアップ（答えを見る） */
.giveup-wrap { display: flex; justify-content: center; margin-top: .9rem; }
.giveup { background: transparent; border: 1px dashed var(--line, #c9c2b0); color: var(--muted, #6b665a); border-radius: 999px; min-height: 44px; padding: .4rem 1.4rem; font-size: .9rem; cursor: pointer; }
.giveup:active:not(:disabled) { background: var(--ai-soft); }
.giveup:disabled { opacity: .35; cursor: default; }
.giveup-tag { display: inline-block; font-size: .78em; padding: 0 .5em; border-radius: 999px; background: var(--shu-soft); color: var(--shu); }
