/* 記憶力トレーニング 固有の見た目（共通は ../common/base.css）。盤の地は明るいまま（ダークでも --board は明るい）なので、盤の中の色は直接書く */
[hidden] { display: none !important; }

.board-wrap { container-type: inline-size; }
.field-box {
  position: relative; background: var(--board); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: clamp(280px, 70cqw, 440px); transition: border-color var(--dur);
}
.field-box.showing { border-color: #2F5D8A; }
.field-box.good { border-color: #2E7D4F; }

/* ---------- マス ---------- */
.grid {
  --n: 3; --gap: 10px;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--gap);
  width: min(100%, 420px); aspect-ratio: 1;
}
.grid[data-size="5"] { --gap: 8px; }
.grid[data-size="6"] { --gap: 6px; }
.tile {
  position: relative; appearance: none; font: inherit; padding: 0; margin: 0; min-width: 0; min-height: 44px;
  border-radius: 8px; border: 2px solid #B9B3A6; background: #FFFFFF; color: #1F2328; cursor: pointer;
  touch-action: manipulation; transition: background-color 80ms, border-color 80ms, transform 80ms;
}
.tile:disabled { cursor: default; }
.tile .kn { position: absolute; left: 6px; top: 3px; font-size: 14px; font-weight: 700; color: #8A8F97; line-height: 1.3; pointer-events: none; }
.tile .lab { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(18px, 7cqw, 34px); font-weight: 700; color: #2F5D8A; pointer-events: none; font-variant-numeric: tabular-nums; }
/* 光る: 黄色の地＋白い丸（色だけに頼らない） */
.tile.lit { background: #D9A21B; border-color: #9A6415; }
.tile.lit::after { content: ''; position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: #FFFFFF; }
.tile.lit .kn { color: #5A3A08; }
/* 押した: 藍の地で一瞬 */
.tile.tap { background: #2F5D8A; border-color: #2F5D8A; transform: translateY(1px); }
.tile.tap .kn { color: #FFFFFF; }
/* 位置: 見つけた */
.tile.found { background: #DCE7F2; border-color: #2F5D8A; }
.tile.found::after { content: ''; position: absolute; left: 50%; top: 46%; width: 30%; height: 16%; border: solid #2F5D8A; border-width: 0 0 4px 4px; transform: translate(-50%, -50%) rotate(-45deg); }
/* まちがい: 赤い地＋× */
.tile.wrong { background: #FBE9E7; border-color: #B23A3A; }
.tile.wrong::before, .tile.wrong::after { content: ''; position: absolute; left: 50%; top: 50%; width: 46%; height: 5px; background: #B23A3A; border-radius: 3px; transform: translate(-50%, -50%) rotate(45deg); }
.tile.wrong::after { transform: translate(-50%, -50%) rotate(-45deg); aspect-ratio: auto; }
/* 押しそびれ: 点線＋「ここ」 */
.tile.missed { background: #FFF6DC; border: 3px dashed #9A6415; }
.tile.missed .lab::before { content: 'ここ'; font-size: clamp(14px, 4cqw, 20px); color: #7A4E0E; }
:root:lang(en) .tile.missed .lab::before { content: 'here'; } /* 英語のページ */
/* 順番の答え: 番号 */
.tile.answer { background: #EEF3F8; border-color: #2F5D8A; }
.tile.answer.wrong .lab { color: #B23A3A; }
.tile.answer .kn, .tile.wrong .kn, .tile.missed .kn, .tile.found .kn { color: #5B616B; }
/* キーボードの枠 */
.tile.cur { outline: 4px solid #9A6415; outline-offset: 2px; }
.tile:focus-visible { outline: 4px solid #9A6415; outline-offset: 2px; }
.grid[data-size="5"] .tile .kn, .grid[data-size="6"] .tile .kn { display: none; }

/* ---------- 数字 ---------- */
.numbox { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.numshow {
  --len: 5; width: 100%; min-height: clamp(90px, 22cqw, 150px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0 .06em; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: #1F2328;
  font-size: clamp(30px, calc(125cqw / max(var(--len), 5)), 110px);
}
.numshow.one { font-size: clamp(80px, 30cqw, 150px); flex-direction: column; }
.numshow b { min-width: .62em; text-align: center; }
.numshow b.blank { visibility: hidden; }
.numshow .br { flex-basis: 100%; height: 0; }
.numshow .prog { display: flex; gap: 5px; margin-top: 8px; }
.numshow .prog i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #C9C4B8; background: #FFFFFF; }
.numshow .prog i.done { background: #8A8F97; border-color: #8A8F97; }
.numshow .prog i.now { background: #2F5D8A; border-color: #2F5D8A; }
.numshow.ask { font-size: clamp(22px, 6cqw, 32px); color: #2F5D8A; }
.numshow.ok { font-size: clamp(36px, 10cqw, 56px); color: #2E7D4F; }
.numshow.cmp b.same { color: #2E7D4F; }
.numshow.cmp b.diff { color: #B23A3A; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.answer-row { display: flex; align-items: center; justify-content: center; gap: 12px; max-width: 100%; }
.answer-label { font-size: 19px; font-weight: 700; color: #5B616B; flex: none; }
.ans {
  --len: 4; display: inline-flex; align-items: center; justify-content: center; min-width: 4.4em; max-width: 100%; height: 1.5em; padding: 0 .3em;
  font-size: clamp(22px, calc(110cqw / max(var(--len), 8)), 36px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em;
  border: 3px solid #C9C4B8; border-radius: 10px; background: #FFFFFF; color: #2F5D8A; overflow: hidden; white-space: nowrap;
}
.ans.on { border-color: #2F5D8A; }
.ans.caret::after { content: ''; width: 3px; height: .8em; background: #2F5D8A; animation: blink 1s steps(1) infinite; margin-left: 2px; }
.ans.ok { background: #E6F3EA; border-color: #2E7D4F; color: #2E7D4F; }
.ans.ng { background: #FBE9E7; border-color: #B23A3A; color: #B23A3A; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 盤の中の大きな文字（レベル） ---------- */
.word {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: clamp(44px, 14cqw, 80px); font-weight: 700; color: #2F5D8A;
}
.word.level { background: rgba(251, 250, 246, .88); border-radius: var(--radius); }

/* ---------- 手番のバー ---------- */
.tag { display: inline-block; white-space: nowrap; font-size: 15px; font-weight: 700; padding: 0 8px; border-radius: 999px; border: 1.5px solid currentColor; margin-left: 6px; vertical-align: middle; color: var(--accent); }
.status .lives { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink-sub); white-space: nowrap; }
.lives .dots { display: inline-flex; gap: 3px; }
.lives .dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink-sub); }
.lives .dots i.on { background: var(--accent); border-color: var(--accent); }

/* ---------- まちがえたとき ---------- */
.fb { margin: 10px auto 0; max-width: 600px; width: 100%; border-radius: var(--radius); padding: 10px 12px; text-align: center; background: var(--surface); border: 2px solid var(--ng); color: var(--ink); }
.fb p { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.fb .controls { margin-top: 8px; }

/* ---------- 数字ボタン ---------- */
.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 480px; margin: 12px auto 0; }
.pad .key {
  appearance: none; font: inherit; font-size: 28px; font-weight: 700; min-height: 54px; padding: 0; 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;
}
.pad .key.erase { grid-column: span 2; font-size: 19px; color: var(--accent); }
.pad .key.enter { grid-column: span 3; font-size: 21px; background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.pad .key:active:not(:disabled) { transform: translateY(1px); }
.pad .key:disabled { opacity: .4; cursor: not-allowed; }
.pad .key:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.linkbtn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- 結果 ---------- */
.result-box { position: static; margin: 10px auto 0; max-width: 600px; }
.result-box .big { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.result-box .best { display: inline-block; margin-left: 8px; font-size: 15px; color: var(--ok); border: 1.5px solid var(--ok); border-radius: 999px; padding: 0 8px; vertical-align: middle; }
.hist-head { margin: 4px 0 4px; font-weight: 700; text-align: left; }
.result-box ol.bars { list-style: none; padding: 0; margin: 0 0 10px; display: grid; width: 100%; gap: 4px; text-align: left; }
.bars li { display: grid; grid-template-columns: 6.8em 1fr 4.6em; align-items: center; gap: 8px; font-size: 15px; font-variant-numeric: tabular-nums; }
.bars li.now { font-weight: 700; }
.bars .when { color: var(--ink-sub); white-space: nowrap; }
.bars li.now .when { color: var(--ink); }
.bars .bar { height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--ink-sub); }
.bars li.now .bar i { background: var(--accent); }
.bars .val { white-space: nowrap; }
.bars .star { color: var(--warn); margin-left: 3px; font-size: 14px; }
.daily-table { margin: 0 auto 10px; border-collapse: collapse; }
.daily-table th, .daily-table td { padding: 2px 12px; border-bottom: 1px solid var(--line); font-size: 17px; }
.daily-table th { text-align: left; font-weight: 400; }
.daily-table td { text-align: right; font-weight: 700; }
.callout { z-index: 5; }

@media (max-width: 420px) {
  .stage { padding: 8px; }
  .field-box { padding: 10px; min-height: 250px; }
  .grid { --gap: 8px; }
  .grid[data-size="5"], .grid[data-size="6"] { --gap: 5px; }
  .pad .key { min-height: 48px; font-size: 26px; }
  .pad { gap: 5px; margin-top: 8px; }
  .controls .btn.icon { padding: 0 9px; }
  :root:lang(en) #play .controls .btn.icon { padding: 0 7px; font-size: 14px; } /* 英語はボタンの文字が長いので1行に収める */
  .status .lives { font-size: 14px; }
  .bars li { grid-template-columns: 6.2em 1fr 4.2em; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ans.caret::after { animation: none; }
  .tile { transition: none; }
}
/* 上のバーの高さを一定に（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: 3; --tb-st-lines: 2; --tb-rt: 0px; --tb-st-rt: 0px; }
@media (min-width: 375px) { :root:lang(en) .turnbar { --tb-msg-lines: 3; --tb-st-lines: 2; } }
@media (min-width: 641px) { :root:lang(en) .turnbar { --tb-msg-lines: 2; --tb-st-lines: 1; } }
/* 上のバーの高さ ここまで */
