/* 数字さがし（シュルテ・テーブル）固有の見た目（共通は ../common/base.css）。
   カードの地は --board（ダークでも明るい生成り）なので、カードの中の文字・マスは決まった色 */
[hidden] { display: none !important; }

.board-wrap { position: relative; }
.card {
  background: var(--board); color: #1F2328; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 8px; display: flex; flex-direction: column; align-items: center;
}
.hud { width: 100%; max-width: 560px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; font-size: 15px; color: #5B616B; min-height: 40px; }
.hud #hud-l { text-align: left; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.hud #hud-r { text-align: right; white-space: nowrap; }
.hud .clock { font-size: 24px; font-weight: 700; color: #1F2328; min-width: 4.2em; text-align: center; }
/* つぎに押す記号（マスと同じ見た目の小さな札） */
.next { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 6px;
  background: #FFFFFF; border: 2px solid #2F5D8A; color: #1F2328; font-size: 22px; font-weight: 700; line-height: 1; }
.next.r { color: #B23A3A; box-shadow: inset 0 0 0 3px #E8B4AF; }
.next.r::before { content: ''; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid #B23A3A; margin-right: 4px; }

/* マス: 1辺は「幅」と「画面の高さ」の小さい方（スマホでも1画面に収まる）。文字はマスの大きさに合わせる */
.grid {
  --n: 5; --gap: 6px;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--gap);
  width: min(100%, 500px, calc(100svh - 290px)); min-width: min(100%, 300px); aspect-ratio: 1; margin: 8px auto 0;
  container-type: inline-size;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.grid[data-n="6"], .grid[data-n="7"] { --gap: 4px; }
.tile {
  appearance: none; margin: 0; padding: 0; min-width: 0; min-height: 0; position: relative; cursor: pointer;
  background: #FFFFFF; border: 1.5px solid #CFCBC1; border-radius: 6px; color: #1F2328;
  font: inherit; font-weight: 700; font-size: 24px; font-size: calc(100cqi / var(--n) * .42); line-height: 1; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; box-shadow: 0 1px 0 rgba(31, 35, 40, .08);
}
.grid[data-set="kana"] .tile { font-size: calc(100cqi / var(--n) * .40); }
.tile:focus { outline: none; }
.tile:active { transform: translateY(1px); }
/* 2色: 赤は赤い字＋内側の赤い縁＋小さな三角（色だけで区別しない） */
.tile.r { color: #B23A3A; box-shadow: inset 0 0 0 3px #E8B4AF; }
.tile.r::before { content: ''; position: absolute; left: 5px; top: 5px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid #B23A3A; }
/* 押したマスの印（設定で「印を残す」のとき） */
.tile.done { background: #E3E9EF; color: #8A929C; border-color: #D3DAE2; box-shadow: none; }
.tile.done.r { color: #C99A95; }
.tile.done::after { content: ''; position: absolute; right: 6px; bottom: 6px; width: 10px; height: 6px; border-left: 2.5px solid #2F5D8A; border-bottom: 2.5px solid #2F5D8A; transform: rotate(-45deg); }
.tile.hit { background: #D6E4D9; }
.tile.ng { box-shadow: inset 0 0 0 4px #B23A3A; }
.tile.answer { outline: 4px solid #2F5D8A; outline-offset: 2px; z-index: 2; }
.tile.cursor { outline: 3px dashed #1F2328; outline-offset: 2px; z-index: 1; }
.tile.shake { animation: shake .35s ease-out; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } 100% { transform: none; } }
/* 数字キーで行を選んだとき: その行に点線の枠、マスの隅に列の番号 */
.tile.rowsel { outline: 3px dashed #2F5D8A; outline-offset: 1px; z-index: 1; }
.tile.rowsel[data-col]::after { content: attr(data-col); position: absolute; right: 4px; top: 3px; width: auto; height: auto; border: 0; transform: none;
  font-size: 12px; font-weight: 700; color: #2F5D8A; }
.grid.pop { animation: pop-in .2s ease-out; }
@keyframes pop-in { from { transform: scale(.97); opacity: .5; } to { transform: none; opacity: 1; } }
.grid.veil .tile { color: transparent !important; background: #E6E2D8 !important; box-shadow: none !important; cursor: default; }
.grid.veil .tile::before, .grid.veil .tile::after { display: none; }

.fb { min-height: 1.6em; margin: 6px 0 0; font-size: 17px; font-weight: 700; color: #1F2328; text-align: center; line-height: 1.6; }
.fb.ok { color: #2E7D4F; }
.fb.ng { color: #B23A3A; }

/* 一時停止 */
.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; }
.callout { z-index: 3; }
#play .controls { justify-content: center; margin-top: 8px; }

/* 結果（盤の下に） */
.result-box { position: static; margin: 10px auto 0; max-width: 600px; }
.result-box h2 { margin-top: 0; font-size: 1.3rem; }
.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); line-height: 1.4; display: block; }
.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); text-align: left; }
.result-box .note { color: var(--ink-sub); font-size: 15px; }

/* 記録のグラフ（1本の折れ線。縦＝時間、横＝遊んだ順） */
.chart { margin: 8px 0 4px; }
.chart figcaption { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.chart-plot { position: relative; }
.chart svg { display: block; width: 100%; height: 180px; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .lbl { fill: var(--ink-sub); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .pt.last { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .bestl { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .bestt { fill: var(--ok); font-size: 12px; font-weight: 700; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 2px 8px; font-size: 14px; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }

@media (max-width: 480px) {
  .stage { padding: 8px; }
  .card { padding: 8px 4px 6px; }
  .grid { width: min(100%, calc(100svh - 270px)); }
  .grid[data-n="6"], .grid[data-n="7"] { --gap: 3px; }
  #play .controls { gap: 6px; }
  .controls .btn.icon { padding: 0 8px; }
  .stats b { font-size: 24px; }
  #controls-btn { display: none; } /* 操作のしかたはゲームのすぐ下にあるので、スマホ幅ではボタンを1行に収める */
}
@media (prefers-reduced-motion: reduce) { .tile.shake, .grid.pop { animation: none; } }
/* 上のバーの高さを一定に（No.93。数字は一番長い文が画面の幅（360px・375px 以上・641px 以上）で何行になるか。--tb-rt はふりがなの分。base.css・turnbar.js） */
.turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; --tb-rt: 11px; --tb-st-rt: 11px; }
@media (min-width: 375px) { .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
@media (min-width: 641px) { .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
:root:lang(en) .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; --tb-rt: 0px; --tb-st-rt: 0px; }
@media (min-width: 375px) { :root:lang(en) .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
@media (min-width: 641px) { :root:lang(en) .turnbar { --tb-msg-lines: 1; --tb-st-lines: 1; } }
/* 上のバーの高さ ここまで */
