/* 素因数分解・素数ゲーム固有の見た目（共通は ../common/base.css）。盤（カード）の地は --board（ダークでも明るい）なので、中の文字は決まった色 */
[hidden] { display: none !important; }

.board-wrap { position: relative; container-type: inline-size; }

/* ---------- カード ---------- */
.card {
  background: var(--board); color: #1F2328; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 12px; min-height: 300px; display: flex; flex-direction: column; align-items: center;
}
.hud { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; font-size: 15px; color: #5B616B; }
.hud #hud-l { text-align: left; font-weight: 700; color: #1F2328; }
.hud #hud-r { text-align: right; }
.hud .clock { font-size: 20px; font-weight: 700; color: #1F2328; }
.hud .clock.low { color: #9A6415; }
.meter { width: 100%; height: 8px; margin-top: 4px; border-radius: 999px; background: #E6E2D8; overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: #2F5D8A; border-radius: 999px; transform-origin: left center; }
.meter.low i { background: #9A6415; }
.view { width: 100%; display: flex; flex-direction: column; align-items: center; }
.view.pop { animation: pop-in .2s ease-out; }
@keyframes pop-in { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }

/* ① 因数の木・はしご算 */
#tree { display: block; margin: 6px auto 0; width: min(100%, calc(var(--w, 300) * 1.2px)); height: auto; max-height: min(50vh, 470px); }
.eq { margin: 6px 0 0; font-size: 20px; font-weight: 700; line-height: 1.5; text-align: center; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.eq .cur { display: inline-block; padding: 0 6px; border: 2px solid #2F5D8A; border-radius: 6px; color: #2F5D8A; background: #E3ECF5; }
.eq.done { color: #2E7D4F; }
.eq sup, .answers sup, .missed sup, .fb sup { font-size: .65em; vertical-align: super; line-height: 0; position: static; }

/* ② 素数あて */
.jn { margin: 26px 0 10px; font-size: clamp(64px, 20cqw, 110px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: #1F2328; }
.jn.ok { color: #2E7D4F; }
.jn.ng { color: #B23A3A; }
.jn.wait { color: #C9C4B8; }
.jn.shake, .key.shake, .cell.shake { animation: shake .35s ease-out; }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } 100% { transform: none; } }

/* ③ ふるいの表 */
.grid { width: 100%; max-width: 560px; margin: 8px auto 0; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.cell {
  position: relative; appearance: none; aspect-ratio: 1; padding: 0; font: inherit; font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: clamp(13px, 3.4cqw, 20px); color: #1F2328; background: #FFFFFF; border: 1.5px solid #C9C4B8; border-radius: 5px; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; display: flex; align-items: center; justify-content: center;
}
.cell .v { position: relative; z-index: 1; }
.cell small { position: absolute; right: 2px; bottom: 0; font-size: max(9px, .5em); font-weight: 700; color: var(--by, #5B616B); line-height: 1.2; }
.cell.x { background: #ECEAE4; color: #8A8E96; font-weight: 400; border-color: #D9D6CE; cursor: default; }
.cell.x::after { content: ''; position: absolute; left: 14%; right: 14%; top: 50%; height: 2.5px; background: var(--by, #5B616B); transform: rotate(-45deg); border-radius: 2px; }
.cell.o::before { content: ''; position: absolute; inset: 8%; border: 2.5px solid #2E7D4F; border-radius: 50%; }
.cell.o { color: #2E7D4F; cursor: default; }
.cell.cur::before { border-color: #2F5D8A; border-width: 3.5px; }
.cell.cur { color: #2F5D8A; }
.cell:focus-visible { outline: 3px solid #9A6415; outline-offset: 1px; z-index: 2; }
.grid.locked .cell { cursor: default; }

/* 知らせ・考え方 */
.fb { min-height: 1.6em; margin: 8px 0 0; font-size: 17px; font-weight: 700; color: #1F2328; text-align: center; line-height: 1.6; }
.fb.ng { color: #B23A3A; }
.fb.ok { color: #2E7D4F; }
.fb.hint { color: #2F5D8A; }
.fb .sub { display: block; font-weight: 400; color: #1F2328; font-size: 16px; }
.explain { width: 100%; max-width: 560px; margin: 6px auto 0; padding: 10px 14px 12px; border: 2px solid #B23A3A; border-radius: var(--radius); background: #FFFFFF; text-align: center; }
.explain-t { margin: 0; font-size: 18px; font-weight: 700; color: #B23A3A; }
.explain-b { margin: 4px 0 10px; font-size: 16px; line-height: 1.7; color: #1F2328; }
.explain-b .sub { display: block; color: #5B616B; font-size: 14px; margin-top: 2px; }

/* 一時停止 */
.pause-box { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(251, 250, 246, .96); border-radius: var(--radius); color: #1F2328; z-index: 4; text-align: center; padding: 16px; }
.pause-box p { margin: 0; font-size: 18px; font-weight: 700; }

/* ---------- ボタン ---------- */
.pad { max-width: 560px; margin: 10px auto 0; }
.primes { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.key {
  appearance: none; font: inherit; font-size: 24px; font-weight: 700; min-height: 52px; padding: 0 4px; font-variant-numeric: tabular-nums;
  border-radius: var(--radius); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.key.wide { font-size: 19px; background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.key.wide.sub { background: var(--surface); border-color: var(--line-strong); color: var(--accent); }
.key.big { min-height: 64px; font-size: 22px; }
.key.yes { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.key:active:not(:disabled) { transform: translateY(1px); }
.key:disabled { opacity: .4; cursor: not-allowed; }
.key:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.buf { margin: 6px 0 0; text-align: center; color: var(--ink-sub); font-size: 15px; }
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }
@media (max-width: 560px) {
  .primes { grid-template-columns: repeat(5, 1fr); }
  .key { min-height: 48px; font-size: 22px; }
  .card { padding: 8px 8px 10px; }
  .grid { gap: 2px; }
}

/* ---------- 結果 ---------- */
.result-box { position: static; margin: 0 auto; max-width: 600px; }
.result-box h2 { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.stats div { border: 2px solid var(--line); border-radius: var(--radius); padding: 8px 4px; background: var(--surface); text-align: center; }
.stats b { display: block; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats span { font-size: 14px; color: var(--ink-sub); }
.stats .main b { color: var(--ok); }
.result-box .best { display: inline-block; font-size: 14px; color: var(--ok); border: 1.5px solid var(--ok); border-radius: 999px; padding: 0 8px; font-weight: 700; }
.result-box .best-line { margin: 0 0 6px; }
.result-box .small { margin: 6px 0 2px; font-size: 15px; color: var(--ink-sub); }
.answers, .missed { list-style: none; padding: 0; margin: 4px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.answers li, .missed li { display: block; margin: 0; border: 2px solid var(--line); border-radius: 6px; padding: 2px 10px; font-variant-numeric: tabular-nums; font-weight: 700; }
.missed li { border-color: var(--ng); }
.plist { margin: 0 0 10px; font-weight: 700; font-variant-numeric: tabular-nums; word-spacing: .25em; }
.result-box .note { color: var(--ink-sub); font-size: 15px; }
/* 上のバーの高さを一定に（No.93。数字は一番長い文が画面の幅（360px・375px 以上・641px 以上）で何行になるか。--tb-rt はふりがなの分。base.css・turnbar.js） */
.turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; --tb-rt: 11px; --tb-st-rt: 11px; }
@media (min-width: 375px) { .turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; } }
@media (min-width: 641px) { .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
:root:lang(en) .turnbar { --tb-msg-lines: 2; --tb-st-lines: 2; --tb-rt: 0px; --tb-st-rt: 0px; }
@media (min-width: 375px) { :root:lang(en) .turnbar { --tb-msg-lines: 2; --tb-st-lines: 2; } }
@media (min-width: 641px) { :root:lang(en) .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
/* 上のバーの高さ ここまで */
