/* すべて .otsuri-app 配下にスコープ。配色・角丸・ボタンは脳トレの他ゲーム(もじならべ等)と共通 */
.otsuri-app {
  --ink: #212529; --paper: #f4f6fb; --card: #ffffff; --page: #e9ecef;
  --accent: #3b5bdb; --accent-d: #2f49b3; --accent-l: #edf2ff;
  --ok: #237a35; --ng: #c92a2a; --line: #dee2e6; --muted: #5c6670; --focus: #ffd43b;
  max-width: 720px; margin: 0 auto; padding: 12px 16px 16px; box-sizing: border-box;
  color: var(--ink); background: var(--paper);
  /* ページ全体の背景色(body を直接指定せず、はみ出し影で塗る。スクロール領域は増えない) */
  box-shadow: 0 0 0 100vmax var(--page);
  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.5; text-align: center;
}
.otsuri-app *, .otsuri-app *::before, .otsuri-app *::after { box-sizing: border-box; }
.otsuri-app [hidden] { display: none !important; }
.otsuri-app p, .otsuri-app h1, .otsuri-app h2 { margin: 0; }

/* ---------- 共通部品 ---------- */
.otsuri-app .otsuri-screen { display: flex; flex-direction: column; gap: 6px; }
.otsuri-app .otsuri-card {
  padding: 12px 14px; background: var(--card); border-radius: 16px; box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.otsuri-app button {
  touch-action: manipulation; font: inherit; cursor: pointer;
}
.otsuri-app .otsuri-btn {
  min-width: 48px; min-height: 56px; padding: 8px 18px; font-size: 20px; font-weight: 700;
  color: var(--accent); background: var(--card); border: 3px solid var(--accent); border-radius: 999px;
}
.otsuri-app .otsuri-btn:hover { background: var(--accent-l); }
.otsuri-app .otsuri-btn:focus-visible,
.otsuri-app .otsuri-coin-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.otsuri-app .otsuri-primary { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 0 var(--accent-d); }
.otsuri-app .otsuri-primary:hover { background: #4263eb; }
.otsuri-app .otsuri-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.otsuri-app .otsuri-btn:disabled:hover { background: var(--card); }
.otsuri-app .otsuri-primary:disabled:hover { background: var(--accent); }
.otsuri-app .otsuri-cta { width: 100%; min-height: 64px; font-size: 22px; }
.otsuri-app .otsuri-mini { min-height: 48px; padding: 4px 12px; font-size: 16px; }

.otsuri-app .otsuri-title { font-size: clamp(1.5rem, 6vw, 1.9rem); font-weight: 800; line-height: 1.35; color: var(--ink); }

/* ---------- コイン(額面ラベル付き。色だけに頼らない) ---------- */
.otsuri-app .otsuri-coin-500 { background-color: #fce8b2; border-color: #b8860b; }
.otsuri-app .otsuri-coin-100 { background-color: #dee2e6; border-color: #6c757d; }
.otsuri-app .otsuri-coin-50 { background-color: #f1f3f5; border-color: #6c757d; }
.otsuri-app .otsuri-coin-10 { background-color: #f4c7a1; border-color: #a85a22; }
.otsuri-app .otsuri-coin-5 { background-color: #ffd43b; border-color: #c77700; }
.otsuri-app .otsuri-coin-1 { background-color: #ffffff; border-color: #868e96; }

/* ---------- ① スタート画面 ---------- */
.otsuri-app .otsuri-start { gap: 16px; padding-top: 8px; }
.otsuri-app .otsuri-rule { padding: 16px; }
.otsuri-app .otsuri-demo { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; margin-bottom: 12px; background: var(--paper); border-radius: 12px; }
.otsuri-app .otsuri-demo-coin { display: block; width: 36px; height: 36px; border: 3px solid; border-radius: 50%; }
.otsuri-app .otsuri-demo-coin.otsuri-coin-500 { width: 46px; height: 46px; }
.otsuri-app .otsuri-demo-coin.otsuri-coin-100 { width: 42px; height: 42px; }
.otsuri-app .otsuri-demo-coin.otsuri-coin-1 { width: 30px; height: 30px; }
.otsuri-app .otsuri-rule-text { font-size: 1.05rem; text-align: left; }

/* スタート画面: 成績(ハイスコア・最高ランク・プレイ回数) */
.otsuri-app .otsuri-records { display: flex; justify-content: space-around; gap: 8px; margin: 0; padding: 10px 8px; text-align: center; }
.otsuri-app .otsuri-records-item { margin: 0; min-width: 0; }
.otsuri-app .otsuri-records dt { font-size: 16px; color: var(--muted); }
.otsuri-app .otsuri-records dd { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.3; }
.otsuri-app .otsuri-records-rank { color: var(--accent); }

/* スタート画面: ランク判定基準(折りたたみ。数字記憶・文字なぞりと同じ見た目) */
.otsuri-app .otsuri-details { padding: 8px 16px; font-size: 16px; color: var(--muted); text-align: left; }
.otsuri-app .otsuri-details summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.otsuri-app .otsuri-details summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.otsuri-app .otsuri-details-points { display: grid; gap: 4px; margin: 4px 0 10px; padding: 0; list-style: none; color: var(--ink); }
.otsuri-app .otsuri-details-points li { position: relative; padding-left: 1.1em; }
.otsuri-app .otsuri-details-points li::before { content: "●"; position: absolute; left: 0; top: .45em; font-size: .6em; color: var(--accent); }
.otsuri-app .otsuri-details-points strong { color: var(--accent-d); }
.otsuri-app .otsuri-table { width: 100%; margin: 4px 0 8px; border-collapse: collapse; line-height: 1.4; }
.otsuri-app .otsuri-table th, .otsuri-app .otsuri-table td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.otsuri-app .otsuri-table td:first-child { width: 4em; font-weight: 800; color: var(--accent); }

/* 戻るボタン(スタート画面・結果画面の左上。他の脳トレと同じ丸型) */
.otsuri-app .otsuri-topbar { display: flex; align-items: center; min-height: 48px; }
.otsuri-app a.otsuri-back {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%;
  color: var(--accent); background: var(--card); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); text-decoration: none; touch-action: manipulation;
}
.otsuri-app a.otsuri-back:hover { background: var(--accent-l); color: var(--accent-d); }
.otsuri-app a.otsuri-back:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.otsuri-app .otsuri-back svg { display: block; width: 22px; height: 22px; }

/* ---------- ② プレイ画面 ---------- */
.otsuri-app .otsuri-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 6px;
  font-size: 16px; font-weight: 700; border-bottom: 2px solid var(--line);
}
.otsuri-app .otsuri-elapsed { font-variant-numeric: tabular-nums; }

.otsuri-app .otsuri-register { padding: 6px 14px; }
.otsuri-app .otsuri-register-title { font-size: 16px; font-weight: 700; color: var(--accent-d); }
.otsuri-app .otsuri-amount-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.otsuri-app .otsuri-amount-label { font-size: 18px; font-weight: 700; }
.otsuri-app .otsuri-amount { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }

.otsuri-app .otsuri-tray-block { padding: 8px 12px; }
.otsuri-app .otsuri-tray-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; font-size: 16px; font-weight: 700; }
.otsuri-app .otsuri-tray-title { color: var(--accent-d); }
.otsuri-app .otsuri-tray-total { color: var(--ink); font-size: 18px; }
.otsuri-app .otsuri-tray {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; min-height: 56px; margin: 4px 0 2px; padding: 4px;
  background: var(--paper); border: 2px dashed #adb5bd; border-radius: 12px;
}
.otsuri-app .otsuri-tray-hint { font-size: 16px; color: var(--muted); }

.otsuri-app .otsuri-coin-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--ink);
  font-size: 16px; font-weight: 800; border: 3px solid; border-radius: 50%; box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
}
.otsuri-app .otsuri-coin-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.otsuri-app .otsuri-coin-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.otsuri-app .otsuri-tray .otsuri-coin-btn { flex: 0 0 50px; width: 50px; height: 50px; border-width: 2px; font-size: 16px; letter-spacing: -.03em; }

.otsuri-app .otsuri-notice { min-height: 22px; line-height: 1.4; font-size: 16px; font-weight: 700; color: var(--ng); }
.otsuri-app .otsuri-controls { display: flex; justify-content: space-between; gap: 12px; }
.otsuri-app .otsuri-controls .otsuri-btn { flex: 1 1 0; padding: 8px 10px; }

.otsuri-app .otsuri-coins-title { margin-bottom: 2px; font-size: 16px; font-weight: 700; }
.otsuri-app .otsuri-coin-grid { display: grid; grid-template-columns: repeat(3, 1fr); justify-items: center; align-items: center; gap: 6px; }
.otsuri-app .otsuri-coin-grid .otsuri-coin-btn { width: 60px; height: 60px; font-size: 17px; }
.otsuri-app .otsuri-coin-grid .otsuri-coin-btn[data-value="500"] { width: 70px; height: 70px; font-size: 19px; }
.otsuri-app .otsuri-coin-grid .otsuri-coin-btn[data-value="100"] { width: 66px; height: 66px; font-size: 18px; }
.otsuri-app .otsuri-coin-grid .otsuri-coin-btn[data-value="5"],
.otsuri-app .otsuri-coin-grid .otsuri-coin-btn[data-value="1"] { width: 58px; height: 58px; font-size: 16px; }

/* 判定結果パネル */
.otsuri-app .otsuri-feedback { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 12px; }
.otsuri-app .otsuri-feedback-message { font-size: 21px; font-weight: 800; line-height: 1.35; }
.otsuri-app .otsuri-feedback[data-verdict="bonus"] .otsuri-feedback-message { color: var(--accent-d); }
.otsuri-app .otsuri-feedback[data-verdict="correct"] .otsuri-feedback-message { color: var(--ok); }
.otsuri-app .otsuri-feedback[data-verdict="incorrect"] .otsuri-feedback-message { color: var(--ng); }
.otsuri-app .otsuri-feedback-line { font-size: 17px; line-height: 1.4; }
.otsuri-app .otsuri-feedback-score { margin: 0 0 4px; font-size: 28px; font-weight: 800; color: var(--accent-d); }

/* ---------- ③ 結果画面 ---------- */
.otsuri-app .otsuri-result { gap: 12px; padding-top: 0; }
.otsuri-app .otsuri-result-main { padding-top: 20px; text-align: center; }
.otsuri-app .otsuri-new-record {
  display: inline-block; margin-bottom: 8px; padding: 2px 14px; color: #fff; font-size: 16px; font-weight: 900; letter-spacing: .08em;
  background: var(--ng); border-radius: 999px;
}
.otsuri-app .otsuri-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: 54px; font-weight: 900; line-height: 1; background-color: #495057;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}
.otsuri-app .otsuri-rank-badge[data-rank="S"] { background-color: #b45309; }
.otsuri-app .otsuri-rank-badge[data-rank="A"] { background-color: #c92a2a; }
.otsuri-app .otsuri-rank-badge[data-rank="B"] { background-color: #1971c2; }
.otsuri-app .otsuri-rank-badge[data-rank="C"] { background-color: #237a35; }
.otsuri-app .otsuri-rank-badge[data-rank="D"] { background-color: #495057; }
.otsuri-app .otsuri-result-caption { font-size: 16px; font-weight: 700; color: var(--muted); }
.otsuri-app .otsuri-result-score { font-size: 42px; font-weight: 900; line-height: 1.3; color: var(--ink); font-variant-numeric: tabular-nums; }
.otsuri-app .otsuri-stats { display: flex; justify-content: space-around; gap: 8px; margin: 0; padding: 10px 8px; text-align: center; }
.otsuri-app .otsuri-stats-item { margin: 0; min-width: 0; }
.otsuri-app .otsuri-stats dt { font-size: 16px; color: var(--muted); }
.otsuri-app .otsuri-stats dd { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.3; color: var(--accent); font-variant-numeric: tabular-nums; }
.otsuri-app .otsuri-result-actions { display: grid; gap: 10px; }
.otsuri-app .otsuri-result-actions .otsuri-btn { display: flex; align-items: center; justify-content: center; width: 100%; text-align: center; text-decoration: none; touch-action: manipulation; }
.otsuri-app a.otsuri-x { color: #fff; background: #111; border-color: #111; font-size: 18px; }
.otsuri-app a.otsuri-x:hover { background: #333; border-color: #333; }
.otsuri-app .otsuri-ghost { min-height: 48px; font-size: 18px; color: var(--muted); background: transparent; border: 1px solid var(--line); }
.otsuri-app .otsuri-ghost:hover { background: #f1f3f5; }

/* ---------- レスポンシブ ---------- */
@media (min-width: 600px) {
  .otsuri-app { margin: 16px auto; padding: 20px 24px 24px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12), 0 0 0 100vmax var(--page); }
  .otsuri-app .otsuri-coin-grid { grid-template-columns: repeat(6, 1fr); }
  .otsuri-app .otsuri-tray .otsuri-coin-btn { flex-basis: 56px; width: 56px; height: 56px; border-width: 3px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .otsuri-app { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .otsuri-app *, .otsuri-app *::before, .otsuri-app *::after { animation: none !important; transition: none !important; }
}
