/* てんびん方程式 — 画面は白（印刷を前提にしているため） */

:root {
  --paper:      #FFFFFF;
  --sheet:      #F6F7F8;
  --ink:        #1A1E22;
  --ink-soft:   #5C666E;
  --ink-faint:  #9AA2A9;
  --rule:       #DBDFE3;
  --brass:      #A4762A;
  --brass-face: #CB9C46;
  --brass-edge: #6F4E17;
  --wood:       #7E6249;
  --accent:     #2B4C7E;
  --good:       #1B7A57;
  --wrong:      #B4432E;
  --gold:       #B8860B;
  --shadow:     rgba(26, 30, 34, .14);

  --font-display: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --font-body: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
}

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 24px 18px 52px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

main { display: flex; flex-direction: column; gap: 22px; }

.hidden { display: none !important; }

/* ---------- header ---------- */

header { display: flex; flex-direction: column; gap: 12px; }

.masthead { display: flex; flex-direction: column; gap: 2px; }

.titleline {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}

h1 {
  font-family: var(--font-display);
  font-size: 25px; font-weight: 700;
  letter-spacing: .07em; margin: 0;
}

.tagline { font-size: 13px; color: var(--ink-soft); margin: 0; }

.modebar { display: flex; gap: 8px; }

.modebar button {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 8px 18px; cursor: pointer;
  transition: color .14s, border-color .14s, background .14s;
}
.modebar button:hover { color: var(--ink); border-color: var(--ink-faint); }
.modebar button[aria-pressed="true"] {
  color: var(--paper); background: var(--accent); border-color: var(--accent);
}
.modebar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modelink {
  font-family: var(--font-body); font-size: 13px;
  color: var(--ink-soft); text-decoration: none;
  align-self: center; margin-left: auto;
  border-bottom: 1px solid var(--rule); padding-bottom: 1px;
}
.modelink:hover { color: var(--accent); border-bottom-color: var(--accent); }
.modelink:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- 共有 / ホーム画面に追加 ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 9px; }

.act {
  flex: 1 1 auto; min-width: 190px;
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 12px 18px; cursor: pointer;
  transition: background .14s, border-color .14s;
}
.act:hover { background: var(--sheet); border-color: var(--ink-faint); }
.act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.act.share { background: #E9F4EE; border-color: #B4D8C4; color: #17624A; }
.act.share:hover { background: #DBEDE3; border-color: #96C8AC; }

.act.install { background: #F1F2F3; border-color: #D6DADD; color: var(--ink-soft); }
.act.install:hover { background: #E6E9EB; border-color: #BFC5C9; color: var(--ink); }

.act.copied { color: var(--paper); background: var(--good); border-color: var(--good); }

.actions .share-fallback { flex: 1 1 100%; }

/* ---------- ホーム画面に追加の案内シート ----------
   iOS には追加を起動するAPIがないため、ブラウザごとの手順を図で見せる */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; }

.sheet-bg { position: absolute; inset: 0; background: rgba(16, 20, 24, .5); animation: fade .2s ease-out; }

.sheet {
  position: relative;
  background: var(--paper);
  border-radius: 14px 14px 0 0;
  padding: 20px 20px 22px;
  box-shadow: 0 -6px 26px rgba(16, 20, 24, .28);
  animation: rise .26s cubic-bezier(.2, .8, .3, 1);
  max-width: 660px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 15px;
}
.sheet.top { border-radius: 0 0 14px 14px; box-shadow: 0 6px 26px rgba(16, 20, 24, .28); }
.sheet-wrap.top { justify-content: flex-start; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.sheet-head { display: flex; gap: 13px; align-items: center; }
.sheet-head img { border-radius: 11px; flex: none; }
.sheet-title {
  margin: 0; font-family: var(--font-display);
  font-size: 17px; font-weight: 700; line-height: 1.4;
}
.sheet-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

.sheet-steps {
  margin: 0; padding: 0; list-style: none; counter-reset: st;
  display: flex; flex-direction: column; gap: 11px;
}
.sheet-steps li {
  counter-increment: st;
  display: flex; gap: 11px; align-items: flex-start;
  font-size: 15px; line-height: 1.55;
}
.sheet-steps li::before {
  content: counter(st);
  flex: none; width: 24px; height: 24px; margin-top: 1px;
  display: grid; place-items: center;
  font-family: var(--font-num); font-size: 13px; font-weight: 700;
  color: var(--paper); background: var(--accent); border-radius: 50%;
}
.sheet-steps .ic {
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: -6px; margin: 0 3px;
  width: 30px; height: 30px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--sheet); color: var(--accent);
}
.sheet-steps b { font-weight: 700; }

.sheet-note {
  margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink-soft);
  background: var(--sheet); border-left: 3px solid var(--gold);
  border-radius: 0 3px 3px 0; padding: 10px 13px;
}

.sheet-close {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--paper); background: var(--accent);
  border: 0; border-radius: 4px; padding: 12px; cursor: pointer;
}
.sheet-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.sheet-arrow {
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%);
  color: var(--paper); font-size: 26px; line-height: 1;
  text-shadow: 0 2px 6px rgba(16, 20, 24, .5);
  animation: bob 1.1s ease-in-out infinite;
}
.sheet.top .sheet-arrow { bottom: auto; top: -34px; }
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

.rail { display: flex; gap: 4px; }

.rail button {
  flex: 1; min-width: 0;
  font-family: var(--font-num); font-size: 12px;
  color: var(--ink-faint); background: transparent;
  border: 0; border-top: 3px solid var(--rule);
  padding: 7px 0 0; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.rail button:hover { color: var(--ink); }
.rail button[aria-current="true"] { color: var(--ink); border-top-color: var(--accent); }
.rail button.done { border-top-color: var(--good); color: var(--good); }
.rail button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- タイムアタックのバー ---------- */

.chbar {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 12px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.chbar .prog { font-size: 15px; font-weight: 600; }
.chbar .prog span { color: var(--ink-faint); font-size: 13px; }
.chbar .clock { font-size: 20px; font-weight: 600; letter-spacing: .04em; }

/* ---------- 天びん ---------- */

.stage {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 14px 0;
  overflow: hidden;
}

.scale {
  /* 皿は棒の両端から左右に --pan-w/2 ずつはみ出す。
     棒を「枠の幅 − 皿の幅」より長くすると、両端の皿が枠外に出て切れる。 */
  --pan-w: 138px;
  --weight-size: 20px;
  --critter-size: 30px;

  position: relative; min-height: 250px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}

.beam-zone { position: absolute; top: 28px; left: 0; right: 0; display: flex; justify-content: center; }

.beam {
  position: relative;
  width: min(calc(100% - var(--pan-w) - 8px), 390px);
  height: 8px;
  background: linear-gradient(var(--brass-face), var(--brass));
  border-radius: 4px; transform-origin: 50% 50%;
}
.beam::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  background: var(--brass-edge); border-radius: 50%;
}

.hanger {
  position: absolute; top: 4px;
  width: var(--pan-w); margin-left: calc(var(--pan-w) / -2);
  display: flex; flex-direction: column; align-items: center;
  transform-origin: 50% 0;
}
.hanger.l { left: 0; }
.hanger.r { left: 100%; }

.string { width: 1px; height: 48px; background: var(--ink-faint); }

.pan {
  width: var(--pan-w); min-height: 56px; padding: 6px 7px 9px;
  background: linear-gradient(var(--brass-face), var(--brass));
  border-radius: 3px 3px 32px 32px;
  display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center;
  gap: 3px; box-shadow: 0 3px 9px var(--shadow);
}

.post {
  width: 11px; height: 168px;
  background: linear-gradient(90deg, var(--brass-edge), var(--brass), var(--brass-edge));
  border-radius: 2px;
}
.plinth { width: 152px; height: 13px; background: var(--wood); border-radius: 3px; }

.item { animation: pop .22s ease-out; }

.critter { font-size: var(--critter-size); line-height: 1; filter: drop-shadow(0 1px 1px var(--shadow)); }

/* 分銅は 10 / 5 / 1 kg の3種類。大きさと色で見分けられるようにする */
.weight {
  width: var(--weight-size); height: var(--weight-size); border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #E9ECEE, #7C858C);
  border: 1px solid var(--ink); position: relative;
  display: grid; place-items: center;
  font-family: var(--font-num);
  font-size: calc(var(--weight-size) * .46);
  font-weight: 700; color: var(--ink);
  line-height: 1;
}
.weight::after {
  content: ""; position: absolute; left: 50%; top: -3px;
  width: 9px; height: 4px; margin-left: -4.5px;
  border: 1px solid var(--ink); border-bottom: 0; border-radius: 4px 4px 0 0;
}
.weight.w5 {
  width: calc(var(--weight-size) * 1.24); height: calc(var(--weight-size) * 1.24);
  font-size: calc(var(--weight-size) * .5);
  background: radial-gradient(circle at 34% 30%, #DCE3EA, #62707E);
  color: var(--paper);
}
.weight.w10 {
  width: calc(var(--weight-size) * 1.5); height: calc(var(--weight-size) * 1.5);
  font-size: calc(var(--weight-size) * .52);
  background: radial-gradient(circle at 34% 30%, #C9A45A, #7A5A18);
  color: var(--paper);
}

/* せまい画面では皿とおもりを小さくして、棒の長さを確保する */
@media (max-width: 480px) {
  .scale { --pan-w: 112px; --weight-size: 17px; --critter-size: 25px; }
  .pan { padding: 5px 5px 8px; }
}
@media (max-width: 360px) {
  .scale { --pan-w: 98px; --weight-size: 15px; --critter-size: 22px; }
}

@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@keyframes wob {
  0% { transform: rotate(0deg); } 22% { transform: rotate(-3.4deg); }
  48% { transform: rotate(2.1deg); } 72% { transform: rotate(-1deg); }
  100% { transform: rotate(0deg); }
}
@keyframes wob-c {
  0% { transform: rotate(0deg); } 22% { transform: rotate(3.4deg); }
  48% { transform: rotate(-2.1deg); } 72% { transform: rotate(1deg); }
  100% { transform: rotate(0deg); }
}
.wobbling .beam { animation: wob .85s cubic-bezier(.36,.07,.19,.97); }
.wobbling .hanger { animation: wob-c .85s cubic-bezier(.36,.07,.19,.97); }

/* ---------- 式 ---------- */

.eq {
  font-family: var(--font-display);
  font-size: clamp(23px, 6vw, 31px);
  font-variant-numeric: tabular-nums;
  text-align: center; letter-spacing: .03em;
  padding: 15px 0 3px;
  border-top: 1px solid var(--rule); margin-top: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: .1em;
}
.eq .glyph { font-size: 1.05em; }
.eq .op { color: var(--ink-faint); padding: 0 .14em; }
.eq .times { color: var(--ink-soft); padding: 0 .1em; }
.eq .unit { font-size: .62em; color: var(--ink-soft); margin-left: .1em; }

.quest {
  text-align: center; padding-bottom: 15px; margin: 0;
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
}

/* ---------- 応用モード ---------- */

.adv-stage { display: flex; flex-direction: column; gap: 14px; }

.adv-scale { position: relative; padding: 14px 12px 0; }
.adv-tag {
  position: absolute; top: 9px; left: 11px; z-index: 1;
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--accent);
}

.scale.mini { min-height: 176px; --critter-size: 25px; --weight-size: 16px; }
.scale.mini .beam-zone { top: 20px; }
.scale.mini .string { height: 30px; }
.scale.mini .post { height: 112px; }
.scale.mini .pan { min-height: 44px; }

.eq.mini { font-size: clamp(19px, 5vw, 24px); padding: 11px 0 2px; margin-top: 10px; }

.eq-cap {
  margin: 0; padding: 0 0 13px; text-align: center;
  font-size: 12px; color: var(--ink-faint);
}

.adv-quest {
  margin: 0; text-align: center;
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 12px; background: var(--sheet);
}

.adv-picks { flex-direction: column; width: 100%; }
.adv-pick {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  text-align: left; padding: 14px 18px; width: 100%;
}
.adv-pick .ap-t { font-size: 16px; font-weight: 700; }
.adv-pick .ap-d { font-size: 12px; font-weight: 400; opacity: .85; line-height: 1.5; }

.hint-line {
  margin: 0; font-size: 14px; line-height: 1.7;
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); border-radius: 3px;
  padding: 10px 13px;
}
.hint-line .glyph { font-size: 17px; vertical-align: -2px; }
.hint-line b { font-family: var(--font-num); font-size: 16px; }

/* --- てこ（うでの長さがちがう） --- */

.lever {
  position: relative; min-height: 236px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  --critter-size: 27px; --weight-size: 17px;
}
.lbeam {
  position: absolute; top: 60px; left: 4%; right: 4%; height: 9px;
  background: linear-gradient(var(--brass-face), var(--brass));
  border-radius: 4px;
}
.lbeam::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  background: var(--brass-edge); border-radius: 50%;
}
.ltick {
  position: absolute; top: 100%; width: 1px; height: 5px;
  margin-left: -.5px; background: var(--brass-edge); opacity: .6;
}
.lhang {
  position: absolute; top: 100%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
}
.ldist {
  position: absolute; bottom: 100%; margin-bottom: 12px;
  font-family: var(--font-num); font-size: 10px; color: var(--ink-soft);
  white-space: nowrap;
}
.lline { width: 1px; height: 26px; background: var(--ink-faint); }
.ltray {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start;
  gap: 3px; width: 76px; padding: 5px 4px 7px;
  background: linear-gradient(var(--brass-face), var(--brass));
  border-radius: 2px 2px 18px 18px;
  box-shadow: 0 2px 7px var(--shadow);
}
.lever .post { width: 11px; height: 152px; background: linear-gradient(90deg, var(--brass-edge), var(--brass), var(--brass-edge)); border-radius: 2px; }
.lever .plinth { width: 152px; height: 13px; background: var(--wood); border-radius: 3px; }

@media (max-width: 480px) {
  .lever { --critter-size: 22px; --weight-size: 14px; }
  .ltray { width: 58px; }
}

/* ---------- 答えの入力 ---------- */

.answer { display: flex; flex-direction: column; gap: 12px; }

.readout {
  display: flex; align-items: center; justify-content: center; gap: .3em;
  height: 62px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px;
  font-family: var(--font-num); font-size: 30px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: .06em;
}
.readout.empty { color: var(--ink-faint); }
.readout .u { font-family: var(--font-body); font-size: 17px; color: var(--ink-soft); }
.readout.ng { animation: shake .38s; border-color: var(--wrong); color: var(--wrong); }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); } 70% { transform: translateX(-3px); }
}

.readout.ok {
  border-color: var(--good); color: var(--good); background: #EAF6F0;
  font-family: var(--font-display); font-weight: 700; letter-spacing: .1em;
  animation: pop-ok .3s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop-ok {
  from { transform: scale(.8); opacity: .3; } to { transform: scale(1); opacity: 1; }
}

.win .ok-badge {
  align-self: flex-start;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  letter-spacing: .14em; color: var(--paper); background: var(--good);
  border-radius: 3px; padding: 3px 12px; margin-bottom: -3px;
}

.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }

.key {
  font-family: var(--font-num); font-size: 21px; font-weight: 600;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 14px 0; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.key:hover { background: var(--sheet); border-color: var(--ink-faint); }
.key:active { background: var(--rule); }
.key:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 7px; }

.key.del { font-family: var(--font-body); font-size: 15px; color: var(--ink-soft); }
.key.go {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--paper); background: var(--accent); border-color: var(--accent);
}
.key.go:hover { background: #22406E; }
.key.go[disabled] { background: var(--rule); border-color: var(--rule); color: var(--ink-faint); cursor: default; }

.hintbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.hint-btn {
  font-family: var(--font-body); font-size: 14px;
  color: var(--ink-soft); background: transparent;
  border: 1px solid var(--rule); border-radius: 20px;
  padding: 6px 16px; cursor: pointer;
  transition: color .14s, border-color .14s;
}
.hint-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.hint-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.used { font-size: 12px; color: var(--ink-faint); font-family: var(--font-num); }

/* ---------- ヒント ---------- */

.hints {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--sheet); border: 1px solid var(--rule);
  border-radius: 4px; padding: 14px;
}
.hints .lead { font-size: 13px; color: var(--ink-soft); margin: 0 0 2px; }

.op-btn {
  font-family: var(--font-body); font-size: 15px; text-align: left;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 3px; padding: 11px 14px; cursor: pointer;
  transition: background .14s, transform .14s;
}
.op-btn:hover { background: var(--sheet); transform: translateX(2px); }
.op-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.op-btn b { font-family: var(--font-num); font-size: 16px; }
.op-btn .glyph { font-size: 17px; }

/* ---------- 正解 ---------- */

.win {
  background: var(--paper); border: 2px solid var(--good);
  border-radius: 4px; padding: 16px 16px 18px;
  display: flex; flex-direction: column; gap: 11px;
}
.win h2 {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  margin: 0; color: var(--good); letter-spacing: .04em;
}
.steps {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 14px; color: var(--ink-soft);
}
.steps li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.steps .st-eq { color: var(--ink); font-variant-numeric: tabular-nums; }
.steps .st-op { font-size: 12px; }

.next {
  align-self: flex-start;
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--paper); background: var(--good);
  border: 0; border-radius: 3px; padding: 10px 22px; cursor: pointer;
}
.next:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- タイムアタックの設定 ---------- */

.setup {
  border: 1px solid var(--rule); border-radius: 4px; padding: 22px 18px;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
  text-align: center;
}
.setup h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0; }
.setup p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.picks { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* 2軸（問題数 × レベル）の選択 */
.axes { display: flex; flex-direction: column; gap: 13px; width: 100%; }
.axis { display: flex; flex-direction: column; gap: 6px; }
.axis-label {
  font-size: 11px; letter-spacing: .16em; color: var(--ink-faint); text-align: left;
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 0; min-width: 74px;
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 10px 6px; cursor: pointer; line-height: 1.3;
  transition: color .14s, border-color .14s, background .14s;
}
.seg button small {
  display: block; font-family: var(--font-num);
  font-size: 10px; font-weight: 400; opacity: .8; margin-top: 1px;
}
.seg button:hover { color: var(--ink); border-color: var(--ink-faint); }
.seg button[aria-pressed="true"] {
  color: var(--paper); background: var(--accent); border-color: var(--accent);
}
.seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.start-btn {
  width: 100%;
  font-family: var(--font-display); font-size: 19px; font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink); background: #F2C230;
  border: 1px solid #D2A413; border-radius: 4px;
  padding: 15px; cursor: pointer;
}
.start-btn:hover { background: #E8B41C; }
.start-btn:active { background: #D9A611; }
.start-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.pick {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--paper); background: var(--accent);
  border: 0; border-radius: 4px; padding: 14px 30px; cursor: pointer;
}
.pick.alt { background: var(--paper); color: var(--accent); border: 2px solid var(--accent); }
.pick:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.best {
  font-family: var(--font-num); font-size: 13px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- 結果 ---------- */

.result {
  border: 2px solid var(--gold); border-radius: 4px;
  padding: 20px 18px; display: flex; flex-direction: column; gap: 16px;
}
.result h2 {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  margin: 0; text-align: center; letter-spacing: .06em; color: var(--ink-soft);
}
.score {
  font-family: var(--font-num); font-size: clamp(46px, 13vw, 64px); font-weight: 700;
  font-variant-numeric: tabular-nums; text-align: center; line-height: 1;
  color: var(--gold); letter-spacing: -.01em;
}
.score .pt { font-family: var(--font-display); font-size: .32em; margin-left: .12em; color: var(--ink-soft); }
.newbest {
  text-align: center; font-family: var(--font-display); font-size: 14px;
  font-weight: 700; color: var(--good); margin: -8px 0 0;
}

.facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: 3px;
  overflow: hidden;
}
.fact { background: var(--paper); padding: 10px 6px; text-align: center; }
.fact dt { font-size: 11px; color: var(--ink-faint); letter-spacing: .08em; }
.fact dd {
  margin: 2px 0 0; font-family: var(--font-num); font-size: 19px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.share-btn {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--paper); background: var(--gold);
  border: 0; border-radius: 4px; padding: 13px 20px; cursor: pointer; width: 100%;
}
.share-btn:hover { background: #A0760A; }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.share-btn.copied { background: var(--good); }

.share-fallback {
  width: 100%; font-family: var(--font-body); font-size: 13px;
  border: 1px solid var(--rule); border-radius: 3px; padding: 9px;
  resize: none; color: var(--ink); background: var(--sheet);
}

.again { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.again button {
  font-family: var(--font-body); font-size: 14px;
  color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 3px;
  padding: 9px 18px; cursor: pointer;
}
.again button:hover { color: var(--ink); border-color: var(--ink-faint); }
.again button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule); padding-top: 16px;
  font-size: 13px; line-height: 1.75; color: var(--ink-soft);
  display: flex; flex-direction: column; gap: 6px;
}
footer p { margin: 0; }
footer strong { color: var(--ink); font-weight: 700; }
footer .fine { font-size: 12px; color: var(--ink-faint); }
.flinks { display: flex; gap: 14px; padding-top: 2px; }
.flinks a { color: var(--accent); }

/* 子どもの画面のじゃまにならないよう、フッターより下に置く読み物 */
.about {
  border-top: 1px solid var(--rule); padding-top: 16px;
  display: flex; flex-direction: column; gap: 9px;
  font-size: 13.5px; line-height: 1.85; color: var(--ink-soft);
}
.about h2 {
  margin: 0; font-family: var(--font-display);
  font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: .04em;
}
.about p { margin: 0; }
.about strong { color: var(--ink); font-weight: 700; }
.about i { font-family: var(--font-num); font-style: italic; }
.about a { color: var(--accent); }

@media print { .about { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .rail, .answer, .modebar, .chbar, .flinks, footer .fine { display: none; }
  .wrap { max-width: none; padding: 0; gap: 14px; }
  .stage { border-color: #000; break-inside: avoid; }
  .pan, .beam, .post { box-shadow: none; }
}
