/* ==========================================================
   順番タッチ - style.css
   見た目は number-memory / letter-trace(基準実装)に合わせる
   すべてのクラスに .ttouch- プレフィックスを付与(WP 干渉防止)
   ========================================================== */

.ttouch-body {
  margin: 0;
  background: #e9ecef;
}

.ttouch-app [hidden] { display: none !important; }

.ttouch-app,
.ttouch-app *,
.ttouch-app *::before,
.ttouch-app *::after {
  box-sizing: border-box;
}

.ttouch-app {
  /* ---- CSS 変数(基準実装と共通) ---- */
  --ttouch-red: #E03131;
  --ttouch-blue: #1971C2;
  --ttouch-bg: #f4f6fb;
  --ttouch-card: #ffffff;
  --ttouch-text: #212529;
  --ttouch-muted: #5c6670;
  --ttouch-primary: #3b5bdb;
  --ttouch-primary-dark: #2f49b3;
  --ttouch-border: #dee2e6;
  --ttouch-radius: 16px;

  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  min-height: 640px;
  margin: 0 auto;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
  background: var(--ttouch-bg);
  color: var(--ttouch-text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* 詳細度 0 のリセット(個別クラスの margin 等を邪魔しない) */
:where(.ttouch-app) :is(h1, h2, p, dl, dd, ul, ol) { margin: 0; padding: 0; }
:where(.ttouch-app) :is(ul, ol) { list-style: none; }

.ttouch-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- トップバー(戻る／効果音) ---------- */
.ttouch-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: 4px;
}
.ttouch-app a.ttouch-back,
.ttouch-app .ttouch-sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ttouch-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background-color 0.15s ease;
}
.ttouch-app a.ttouch-back { color: var(--ttouch-primary); }
.ttouch-app .ttouch-sound-btn { color: var(--ttouch-muted); }
.ttouch-app a.ttouch-back:hover { background: #edf2ff; color: var(--ttouch-primary-dark); }
.ttouch-app .ttouch-sound-btn:hover { background: #f1f3f5; }
.ttouch-app a.ttouch-back:active,
.ttouch-app .ttouch-sound-btn:active { transform: scale(0.94); }
.ttouch-back svg,
.ttouch-sound-btn svg { display: block; width: 22px; height: 22px; }
.ttouch-app a.ttouch-back:focus-visible,
.ttouch-app .ttouch-sound-btn:focus-visible,
.ttouch-app .ttouch-btn:focus-visible,
.ttouch-app .ttouch-hint-btn:focus-visible,
.ttouch-app .ttouch-circle:focus-visible,
.ttouch-app .ttouch-details summary:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }

/* ---------- 画面共通 ---------- */
.ttouch-screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
}
.ttouch-screen--play { flex: none; gap: 12px; }

.ttouch-card {
  background: var(--ttouch-card);
  border-radius: var(--ttouch-radius);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ---------- ボタン ---------- */
.ttouch-btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.ttouch-btn:active:not(:disabled) { transform: scale(0.97); }

.ttouch-btn--primary { background: var(--ttouch-primary); color: #fff; box-shadow: 0 4px 0 var(--ttouch-primary-dark); }
.ttouch-btn--primary:hover:not(:disabled) { background: #4263eb; }
.ttouch-btn--cta { min-height: 64px; font-size: 1.25rem; }
.ttouch-app a.ttouch-btn--x {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  background: #111; color: #fff; text-decoration: none;
}
.ttouch-app a.ttouch-btn--x:hover { background: #333; color: #fff; }
.ttouch-btn--ghost { background: transparent; color: #495057; border: 1px solid var(--ttouch-border); min-height: 44px; }

/* ---------- ① スタート画面 ---------- */
.ttouch-title-area {
  font-size: clamp(1.4rem, 5.5vw, 1.8rem);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}
.ttouch-title { padding-top: 4px; font-size: 1em; }
.ttouch-title__sub { font-size: 0.7em; color: var(--ttouch-primary); }

.ttouch-rule__lead { text-align: center; font-size: 1.05rem; margin-bottom: 12px; }
.ttouch-rule__figure { display: block; width: 100%; max-width: 240px; height: auto; margin: 0 auto 14px; }
.ttouch-rule__list { font-size: 0.85rem; display: grid; gap: 4px; }
.ttouch-rule__list li { padding-left: 1.1em; position: relative; }
.ttouch-rule__list li::before { content: "●"; position: absolute; left: 0; color: var(--ttouch-primary); font-size: 0.6em; top: 0.5em; }

.ttouch-stats { display: flex; justify-content: space-around; text-align: center; gap: 8px; }
.ttouch-stats__item { flex: 1; }
.ttouch-stats__item dt { font-size: 0.75rem; color: var(--ttouch-muted); }
.ttouch-stats__item dd { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.ttouch-details { padding: 8px 16px; font-size: 0.85rem; color: #495057; }
.ttouch-details summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.ttouch-table { width: 100%; margin: 4px 0 8px; border-collapse: collapse; }
.ttouch-table th, .ttouch-table td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--ttouch-border); }
.ttouch-table td:first-child { font-weight: 800; color: var(--ttouch-primary); }

/* スポンサー枠(スタート画面は余白・枠線・背景を持たない) */
.ttouch-sponsor { text-align: center; }
.ttouch-sponsor--result { margin-top: 48px; } /* 操作ボタンから 35px 以上離す */

/* ---------- ② プレイ画面 ---------- */
.ttouch-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background: var(--ttouch-card);
  border-radius: var(--ttouch-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.ttouch-hud__stage { font-size: 0.9rem; font-weight: 800; }
.ttouch-hud__timer { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ttouch-hud__miss { font-size: 0.9rem; font-weight: 800; text-align: right; }

.ttouch-guide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
}
.ttouch-guide__target { font-size: 1.25rem; font-weight: 800; }

.ttouch-hint-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--ttouch-primary);
  border-radius: 999px;
  background: var(--ttouch-card);
  color: var(--ttouch-primary-dark);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}
.ttouch-hint-btn[aria-pressed="true"] { background: #fff3bf; border-color: #f08c00; color: var(--ttouch-text); }

.ttouch-canvas {
  position: relative;
  width: 100%;
  height: 400px;
  background: var(--ttouch-card);
  border-radius: var(--ttouch-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.ttouch-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(5rem, 28vw, 9rem);
  font-weight: 900;
  line-height: 1;
  color: var(--ttouch-primary);
}

/* 丸: ボタン自体は動かさず、見た目(.ttouch-circle__face)だけ揺らす */
.ttouch-circle {
  position: absolute;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.ttouch-circle:disabled { opacity: 1; cursor: default; }
.ttouch-circle__face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 3px solid var(--ttouch-primary);
  border-radius: 50%;
  background: #ffffff;
  color: var(--ttouch-text);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.ttouch-circle--done .ttouch-circle__face { background: var(--ttouch-primary); color: #ffffff; }
.ttouch-circle--miss .ttouch-circle__face { border-color: #e03131; animation: ttouch-shake 0.3s; }
.ttouch-circle--hint .ttouch-circle__face { box-shadow: 0 0 0 4px #f08c00; animation: ttouch-hint 1.4s ease-in-out infinite; }

@keyframes ttouch-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
}
@keyframes ttouch-hint {
  0%, 100% { box-shadow: 0 0 0 4px #f08c00; }
  50% { box-shadow: 0 0 0 4px rgba(240, 140, 0, 0.35); }
}

/* ---------- ③ 結果画面 ---------- */
.ttouch-result__title { text-align: center; font-size: 1.4rem; font-weight: 800; }
.ttouch-result__main { position: relative; text-align: center; padding-top: 24px; }

.ttouch-new-record {
  display: inline-block; margin-bottom: 8px; padding: 2px 14px;
  background: #c92a2a; color: #fff;
  font-weight: 900; letter-spacing: 0.08em; border-radius: 999px;
  animation: ttouch-blink 0.9s ease-in-out infinite alternate;
}
@keyframes ttouch-blink { from { transform: scale(1); } to { transform: scale(1.08); } }

.ttouch-result__rank {
  width: 96px; height: 96px; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #ffffff;
  font-size: 3.4rem; font-weight: 900; line-height: 1;
  background: #5c6670;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: ttouch-pop 0.5s;
}
@keyframes ttouch-pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
.ttouch-result__comment { font-size: 1rem; font-weight: 700; }
.ttouch-result__score { font-size: 2.6rem; font-weight: 900; line-height: 1.3; font-variant-numeric: tabular-nums; }

.ttouch-actions { display: grid; gap: 12px; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 380px) {
  .ttouch-app { padding-left: 16px; padding-right: 16px; }
}
@media (min-width: 600px) {
  .ttouch-app { margin-top: 16px; margin-bottom: 16px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12); }
}

/* 動きを減らす設定への配慮(揺れと点滅を止める。赤枠・ヒントの枠・数字は表示する) */
@media (prefers-reduced-motion: reduce) {
  .ttouch-app *, .ttouch-app *::before, .ttouch-app *::after {
    animation: none !important;
    transition: none !important;
  }
}
