:root {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #6b6b70;
  --ink-faint: #9b9b9f;
  --line: #e2e0e6;
  --track: #ece9f2;
  --accent: #5b5bd6;
  --accent-dark: #4744b8;
  --accent-soft: rgba(91, 91, 214, 0.12);
  --good: #34c759;
  --good-soft: rgba(52, 199, 89, 0.14);
  --bad: #ff3b30;
  --bad-soft: rgba(255, 59, 48, 0.14);
  --shadow: 0 1px 2px rgba(28, 28, 30, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-card: #2c2c2e;
    --ink: #f2f2f7;
    --ink-soft: #9a9a9e;
    --ink-faint: #7a7a7e;
    --line: #3a3a3c;
    --track: #3a3a3e;
    --accent: #7c7cf0;
    --accent-dark: #9494f5;
    --accent-soft: rgba(124, 124, 240, 0.18);
    --good: #30d158;
    --good-soft: rgba(48, 209, 88, 0.16);
    --bad: #ff453a;
    --bad-soft: rgba(255, 69, 58, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #1c1c1e;
  --bg-card: #2c2c2e;
  --ink: #f2f2f7;
  --ink-soft: #9a9a9e;
  --ink-faint: #7a7a7e;
  --line: #3a3a3c;
  --track: #3a3a3e;
  --accent: #7c7cf0;
  --accent-dark: #9494f5;
  --accent-soft: rgba(124, 124, 240, 0.18);
  --good: #30d158;
  --good-soft: rgba(48, 209, 88, 0.16);
  --bad: #ff453a;
  --bad-soft: rgba(255, 69, 58, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #6b6b70;
  --ink-faint: #9b9b9f;
  --line: #e2e0e6;
  --track: #ece9f2;
  --accent: #5b5bd6;
  --accent-dark: #4744b8;
  --accent-soft: rgba(91, 91, 214, 0.12);
  --good: #34c759;
  --good-soft: rgba(52, 199, 89, 0.14);
  --bad: #ff3b30;
  --bad-soft: rgba(255, 59, 48, 0.14);
  --shadow: 0 1px 2px rgba(28, 28, 30, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  /* iOS: 画面端からの引っぱりでアプリ全体がゴムのように動くのを止める */
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  /* iOS(WKWebView)対策: タップ時の灰色フラッシュ・長押し選択・横向き時の文字拡大を止める */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", "Segoe UI", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.screen {
  max-width: 440px;
  margin: 0 auto;
  /* ノッチ・ホームインジケータを避ける(viewport-fit=coverとセット) */
  padding: calc(32px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right))
           calc(48px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.hidden { display: none !important; }

.screen.screen-enter {
  opacity: 0;
  transform: translateY(10px);
}

@media (prefers-reduced-motion: reduce) {
  .screen { transition: none; }
}

/* ---- Buttons ---- */
button {
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease;
  /* iOS: ダブルタップズームと長押しメニューを抑止し、押した感を素直に返す */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:active { transform: scale(0.96); }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary, .btn-secondary, .btn-text {
  border: none;
  border-radius: 14px;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 20px;
  /* Appleのヒューマンインターフェースガイドラインの最小タップ領域 44pt に合わせる */
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-large { width: 100%; font-size: 16px; padding: 16px 20px; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-text {
  background: none;
  color: var(--accent);
  padding: 8px 4px;
  font-weight: 600;
  font-size: 14px;
}

/* ---- Home ---- */
.brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}
/* 看板は彼女の絵。絵文字だと端末ごとに絵柄が変わるうえ、
   アプリの顔が前髪ゲームの彼女と別人になってしまう(2026-09-01) */
.mascot { width: 40px; height: 60px; }
.mascot .avatar-svg { width: 100%; height: 100%; display: block; }
.brand h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.tagline { color: var(--ink-soft); font-size: 13.5px; margin: 0; }

/* ゲームが4本になった時点で、390×664(iPhoneの実効表示領域)に図鑑まで収まらなくなった。
   ホームは一覧で見渡せることが値打ちなので、余白を詰めて折り返しの内側に戻す。
   5本目を足すときは、ここがまた溢れるはず(3〜5本という上限の実体はこれ) */
.game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 16px;
  text-align: left;
}

.game-icon { font-size: 26px; flex-shrink: 0; }
.game-body { display: flex; flex-direction: column; gap: 3px; }
.game-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.game-desc { font-size: 12.5px; color: var(--ink-soft); }

/* ---- Game screens (shared header) ---- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-label {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---- Result screen (shared by all 3 games) ---- */
#screen-result { justify-content: center; align-items: stretch; }

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-emoji { font-size: 48px; }
.result-title { font-size: 20px; font-weight: 700; margin: 0; }
.result-message { color: var(--ink-soft); margin: 0; font-size: 14px; }
.result-tease { color: var(--accent-dark); margin: 6px 0 0; font-size: 13.5px; font-weight: 600; }

.result-card.pop-in {
  animation: pop-in 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes pop-in {
  0% { opacity: 0; transform: scale(0.85) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.fade-in {
  animation: fade-in 0.35s ease;
}

@keyframes fade-in {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .result-card.pop-in, .fade-in { animation: none; }
}

/* ホーム下部の小さな導線(ストア提出に必要なサポート・プライバシーへの入口) */
.home-footer {
  margin-top: auto;
  padding-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}
.home-footer a { color: var(--ink-soft); text-decoration: none; }

/* ---- このアプリについて ---- */
.about-body { display: flex; flex-direction: column; gap: 18px; }
.about-mark { font-size: 40px; text-align: center; }
.about-title { text-align: center; font-size: 18px; margin: 0; }
.about-version {
  text-align: center;
  margin: -12px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.about-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.about-links a {
  display: block;
  padding: 13px 14px;
  min-height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.about-section h3 { font-size: 14px; margin: 0 0 6px; }
.about-section p { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; line-height: 1.8; }
.about-note { font-size: 12.5px; color: var(--good); font-weight: 600; }
.share-button { margin-top: 12px; }

/* ---- 今日の1問 ---- */
.daily-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
  color: #fff;
  min-height: 44px;
}
.daily-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 2px 8px;
}
.daily-title { font-size: 15.5px; font-weight: 700; }
.daily-desc { font-size: 12px; opacity: 0.85; line-height: 1.6; }

.home-streak {
  margin: -4px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* 音のスイッチ。押せる範囲を広く取るため、ラベル全体をタップ対象にする */
.about-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.about-switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

/* iPhone SE(320×568)のような背の低い端末では、ホームの一覧が図鑑まで届かない
   (実測 bottom 701px / 高さ 568px)。高さが足りないときだけ詰める。
   390×664 の見た目は変えない(2026-08-28のテストで発見) */
@media (max-height: 600px) {
  .game-list { gap: 6px; }
  .game-item { padding: 8px 14px; }
  .game-desc { display: none; }
  /* いちばん場所を取っていたのは見出しまわり(138px)。名乗りは一度読めば足りる */
  .mascot { width: 32px; height: 48px; }
  .brand { gap: 2px; margin-bottom: 2px; }
  .daily-card { padding: 12px 14px; }
  .brand h1 { font-size: 18px; }
  .tagline { display: none; }
}

/* 読み上げにだけ届かせる。目には見えないが、display:none にすると読まれない */
.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;
}

/* 結果画面の紙吹雪。良い結果のときだけ、控えめに落とす
   (2026-08-31、実機の指摘「やったあと、アニメーションとか絵がなくて、寂しい」) */
.result-card { position: relative; overflow: hidden; }

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.3, 0.7, 0.6, 1);
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-12px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(320px) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece { display: none; }
}

/* ゲームの目印。絵文字は端末ごとに絵柄が変わるので、自前のアイコンにそろえた */
.game-icon-svg {
  width: 26px;
  height: 26px;
  display: block;
  color: var(--accent);
}
