/* すべて #ana-app 配下にスコープ（WordPress既存テーマとの衝突回避） */
:root { color-scheme: light; }
body { margin: 0; background: #e9ecef; }
#ana-app {
  /* 配色は脳トレ他ゲーム（ストループ効果テスト等）と共通 */
  --ink: #212529; --paper: #f4f6fb; --card: #ffffff; --accent: #3b5bdb; --accent-d: #2f49b3; --accent-l: #edf2ff;
  --ok: #2F9E44; --ng: #E03131; --line: #dee2e6; --muted: #868e96; --chip: #fff3c4; --chip-edge: #F59F00;
  max-width: 560px; margin: 0 auto; padding: 16px; box-sizing: border-box;
  color: var(--ink); background: var(--paper); min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 18px; line-height: 1.6; text-align: center;
}
#ana-app *, #ana-app *::before, #ana-app *::after { box-sizing: border-box; }
#ana-app [hidden] { display: none !important; }

/* ---------- ① スタート画面（ストループ効果テスト等と同じ構成） ---------- */
#ana-app .ana-start { display: flex; flex-direction: column; gap: 16px; }
#ana-app .ana-title { margin: 0; padding-top: 4px; font-size: clamp(1.4rem, 5.5vw, 1.8rem); font-weight: 800; line-height: 1.35; }
#ana-app .ana-title-sub { display: block; font-size: .7em; color: var(--accent); }
#ana-app .ana-rule { margin: 0; }
#ana-app .ana-rule-lead { margin: 0 0 12px; font-size: 1.05rem; }
#ana-app .ana-rule-lead strong, #ana-app .ana-demo-note strong { color: var(--accent); }
#ana-app .ana-demo { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; background: var(--paper); border-radius: 12px; }
#ana-app .ana-demo-tiles { display: flex; gap: 6px; }
#ana-app .ana-demo-tiles span {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 44px; font-size: 1.3rem; font-weight: 800;
  background: var(--chip); border: 2px solid var(--chip-edge); border-bottom-width: 4px; border-radius: 10px;
}
#ana-app .ana-demo-arrow { color: var(--muted); }
#ana-app .ana-demo-answer { font-size: 1.6rem; font-weight: 800; color: var(--accent); letter-spacing: .08em; }
#ana-app .ana-demo-note { margin: 8px 0 12px; font-size: .85rem; }
#ana-app .ana-rule-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: .85rem; text-align: left; }
#ana-app .ana-rule-list li { position: relative; padding-left: 1.1em; }
#ana-app .ana-rule-list li::before { content: "●"; position: absolute; left: 0; top: .5em; font-size: .6em; color: var(--accent); }

/* トップバー：戻るボタン（全画面共通・他ゲームと同じ丸型アイコン） */
#ana-app .ana-topbar { display: flex; align-items: center; min-height: 44px; margin-bottom: 4px; }
#ana-app a.ana-back {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; background: var(--card); color: var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  text-decoration: none; transition: transform .08s ease, background-color .15s ease;
}
#ana-app a.ana-back:hover { background: var(--accent-l); color: var(--accent-d); }
#ana-app a.ana-back:active { transform: scale(.94); }
#ana-app .ana-back svg { display: block; width: 22px; height: 22px; }
#ana-app a.ana-back:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }

/* ボタン：最小 48px、間隔 12px 以上 */
#ana-app .ana-btn {
  min-width: 48px; min-height: 56px; padding: 8px 18px; font: inherit; font-size: 20px; font-weight: 700;
  color: var(--accent); background: var(--card); border: 3px solid var(--accent); border-radius: 999px; cursor: pointer;
  text-decoration: none;
}
#ana-app .ana-btn:hover { background: var(--accent-l); }
#ana-app .ana-btn:focus-visible, #ana-app .ana-tile:focus-visible, #ana-app .ana-slot:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }
#ana-app .ana-primary { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 0 var(--accent-d); font-size: 26px; padding: 12px 40px; }
#ana-app .ana-primary:hover { background: #4263eb; }
#ana-app .ana-cta { width: 100%; min-height: 64px; padding: 12px 20px; font-size: 1.25rem; }
#ana-app .ana-quiet { border-color: var(--line); color: var(--muted); }
#ana-app .ana-mini { min-height: 48px; font-size: 16px; padding: 4px 12px; }

#ana-app .ana-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 20px; font-weight: 700; border-bottom: 2px solid var(--line); padding-bottom: 12px; }
#ana-app #ana-timer { font-variant-numeric: tabular-nums; }
#ana-app .ana-hint { margin: 20px 0 8px; font-size: 20px; }
#ana-app .ana-hint strong { color: var(--accent-d); }

#ana-app .ana-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 16px 0; }
#ana-app .ana-slot, #ana-app .ana-tile {
  width: 64px; height: 72px; padding: 0; font: inherit; font-size: 32px; font-weight: 700; color: var(--ink); cursor: pointer;
}
#ana-app .ana-slot { background: var(--card); border: 3px dashed #adb5bd; border-radius: 12px; }
#ana-app .ana-slot.ana-filled { background: #fff; border: 3px solid var(--accent); }
#ana-app .ana-tile { background: var(--chip); border: 2px solid var(--chip-edge); border-bottom-width: 6px; border-radius: 14px; }
#ana-app .ana-tile:active { transform: translateY(3px); border-bottom-width: 3px; }
#ana-app .ana-tile.ana-used { visibility: hidden; }  /* 元の位置は空けたまま（レイアウト固定） */

#ana-app .ana-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; }
#ana-app #ana-banner { min-height: 64px; margin-top: 8px; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
#ana-app #ana-banner.ana-ok { color: var(--ok); }
#ana-app #ana-banner.ana-info { color: var(--accent-d); }

/* 操作ロック中（判定・演出・遷移中） */
#ana-app #ana-game.ana-locked .ana-row, #ana-app #ana-game.ana-locked .ana-actions { pointer-events: none; }
#ana-app #ana-game.ana-locked .ana-actions .ana-btn { opacity: .5; }

#ana-app #ana-slots.ana-shake .ana-slot { border-color: var(--ng); background: #fdeceb; animation: ana-shake .5s; }
@keyframes ana-shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

#ana-app .ana-result-title { font-size: 28px; font-weight: 800; margin: 8px 0 16px; }
#ana-app .ana-card { background: var(--card); border-radius: 16px; padding: 16px; margin: 0 0 16px; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
#ana-app .ana-card > p { margin: 0; }
#ana-app .ana-score { font-size: 56px; font-weight: 700; margin: 8px 0; color: var(--accent); }
#ana-app .ana-score small { font-size: 22px; color: var(--ink); }
#ana-app .ana-card > .ana-rank { font-size: 24px; font-weight: 700; margin-top: 12px; }
#ana-app .ana-history { list-style: none; padding: 4px 16px; text-align: left; }
#ana-app .ana-history li { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--line); }
#ana-app .ana-history li:last-child { border-bottom: 0; }
#ana-app .ana-history .ana-r-ok { color: var(--ok); font-weight: 700; }
#ana-app .ana-history .ana-r-ng { color: var(--ng); font-weight: 700; }

/* リザルトのボタン群（他ゲームと同じ：挑戦 → Xシェア → スタートへ） */
#ana-app .ana-result-actions { display: grid; gap: 12px; }
#ana-app .ana-result-actions .ana-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
#ana-app .ana-result-actions .ana-primary { min-height: 64px; font-size: 22px; padding: 12px 20px; }
#ana-app a.ana-x { font-size: 18px; color: #fff; background: #111; border-color: #111; }
#ana-app a.ana-x:hover { color: #fff; background: #333; border-color: #333; }
#ana-app .ana-ghost { min-height: 48px; font-size: 18px; color: var(--muted); background: transparent; border: 1px solid var(--line); }
#ana-app .ana-ghost:hover { background: #f1f3f5; }

/* ---------- スタート画面：ランク判定基準（折りたたみ。他の脳トレと同じ見た目） ---------- */
#ana-app .ana-details { margin: 0; padding: 8px 16px; font-size: 14px; color: #5c6670; text-align: left; }
#ana-app .ana-details summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
#ana-app .ana-details summary:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }
#ana-app .ana-table { width: 100%; margin: 4px 0 8px; border-collapse: collapse; font-size: 14px; line-height: 1.4; }
#ana-app .ana-table th, #ana-app .ana-table td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line); }
#ana-app .ana-table thead th { font-weight: 700; color: #5c6670; }
#ana-app .ana-table tbody th { width: 3em; font-size: 18px; font-weight: 800; text-align: center; }
#ana-app .ana-table tbody tr:last-child th, #ana-app .ana-table tbody tr:last-child td { border-bottom: 0; }
#ana-app .ana-table td:nth-child(2) { white-space: nowrap; font-weight: 700; }
#ana-app .ana-rank-s { color: #c92a2a; }
#ana-app .ana-rank-a { color: #c2410c; }
#ana-app .ana-rank-b { color: #237a35; }
#ana-app .ana-rank-c { color: var(--accent); }
#ana-app .ana-rank-d { color: #495057; }

/* ---------- 結果画面：メインカード（NEW RECORD・ランクバッジ） ---------- */
#ana-app .ana-result-main { padding-top: 24px; }
#ana-app .ana-new-record {
  display: inline-block; margin: 0 0 8px; padding: 2px 14px; color: #fff; font-weight: 900; letter-spacing: .08em;
  background: linear-gradient(90deg, #e03131, #e67700); border-radius: 999px;
}
#ana-app .ana-new-record[hidden] { display: none; }
#ana-app .ana-rank-badge {
  display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; margin: 0 auto 8px;
  border-radius: 50%; color: #fff; font-size: 3.4rem; font-weight: 900; line-height: 1; background: #868e96;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}
#ana-app .ana-rank-badge[data-rank="S"] { background: linear-gradient(135deg, #fcc419, #f76707); }
#ana-app .ana-rank-badge[data-rank="A"] { background: #e03131; }
#ana-app .ana-rank-badge[data-rank="B"] { background: #1971c2; }
#ana-app .ana-rank-badge[data-rank="C"] { background: #2f9e44; }
#ana-app .ana-rank-badge[data-rank="D"] { background: #868e96; }

@media (min-width: 600px) {
  #ana-app { min-height: 640px; margin-top: 16px; margin-bottom: 16px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); }
}
@media (max-width: 420px) {
  #ana-app { padding: 12px; font-size: 17px; }
  #ana-app .ana-slot, #ana-app .ana-tile { width: 56px; height: 64px; font-size: 28px; }
  #ana-app .ana-row { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #ana-app *, #ana-app *::before, #ana-app *::after { animation: none !important; transition: none !important; }
}
