/* もしもラボ 共通スタイル（全ゲーム共通） */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1d1b18;
  --text-sub: #6b665e;
  --line: #e2ddd3;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --accent-soft: #fde6dd;
  --good: #2e9e6a;
  --good-soft: #def3e8;
  --bad: #d64545;
  --bad-soft: #fbe3e3;
  --info: #2f6fd6;
  --info-soft: #e1ebfb;
  --warn: #c98a12;
  --shadow: 0 2px 10px rgba(30, 25, 15, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Noto Serif JP", "Yu Mincho", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f;
    --surface: #211f19;
    --surface-2: #2b2820;
    --text: #f1ede4;
    --text-sub: #a59f93;
    --line: #38342b;
    --accent: #ff7a50;
    --accent-ink: #1a1208;
    --accent-soft: #3a2419;
    --good: #4cc48b;
    --good-soft: #1b3326;
    --bad: #ef6b6b;
    --bad-soft: #3a1d1d;
    --info: #6b9cf0;
    --info-soft: #1c2840;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    --warn: #e0a53a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f; --surface: #211f19; --surface-2: #2b2820; --text: #f1ede4; --text-sub: #a59f93;
  --line: #38342b; --accent: #ff7a50; --accent-ink: #1a1208; --accent-soft: #3a2419; --good: #4cc48b;
  --good-soft: #1b3326; --bad: #ef6b6b; --bad-soft: #3a1d1d; --info: #6b9cf0; --info-soft: #1c2840;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35); --warn: #e0a53a; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
  overflow-x: clip; /* 揺れ演出などで一瞬はみ出しても横スクロールを出さない（sticky は維持） */
}
img, svg, canvas { max-width: 100%; }
a { color: var(--info); }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ヘッダー */
.ml-header {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.ml-header-inner { max-width: 640px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.ml-brand { font-weight: 800; text-decoration: none; color: var(--text); font-size: 15px; display: flex; align-items: center; gap: 6px; }
.ml-brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.ml-header-spacer { flex: 1; }
.ml-icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; min-width: 36px; height: 36px;
  padding: 0 10px; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 4px;
}
.ml-streak-pill { font-size: 13px; color: var(--text-sub); white-space: nowrap; }

/* レイアウト */
.app { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.screen { animation: ml-fade .35s ease both; }
@keyframes ml-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-tight { padding: 14px 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--text-sub); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.big-num { font-size: clamp(40px, 13vw, 72px); font-weight: 900; line-height: 1.1; letter-spacing: -.02em; }
.kicker { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .08em; }
.title-xl { font-size: clamp(28px, 8vw, 40px); font-weight: 900; line-height: 1.25; }
.lead { font-size: 17px; color: var(--text-sub); }
.serif { font-family: var(--font-serif); }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700;
  text-decoration: none; color: var(--text); transition: transform .08s ease, background .2s; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18px; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }

/* 選択肢 */
.choices { display: grid; gap: 10px; }
.choice {
  width: 100%; text-align: left; padding: 14px 16px; min-height: 56px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; line-height: 1.5;
  transition: border-color .15s, background .15s, transform .08s; touch-action: manipulation;
}
.choice:hover { border-color: var(--accent); }
.choice:active { transform: scale(.98); }
.choice.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.is-correct { border-color: var(--good); background: var(--good-soft); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice small { display: block; font-weight: 400; color: var(--text-sub); }

/* 進捗 */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.meter { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--good); transition: width .5s ease, background .3s; }

/* バッジ・タグ */
.tag { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-sub); font-weight: 700; }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-good { background: var(--good-soft); color: var(--good); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }

/* 出典・注意 */
.source { font-size: 12px; color: var(--text-sub); }
.source a { color: var(--text-sub); }
.note {
  font-size: 13px; color: var(--text-sub); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px;
}
details.ml-details { font-size: 14px; }
details.ml-details summary { cursor: pointer; color: var(--text-sub); }

/* 統計の小カード */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--text-sub); }

/* 結果の共有バー */
.share-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-bar .btn { min-height: 48px; padding: 10px 12px; min-width: 0; font-size: 15px; line-height: 1.3; }
.share-bar > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.btn-x { background: #111; color: #fff; border-color: #111; }
.btn-line { background: #06c755; color: #fff; border-color: #06c755; }

/* デイリー */
.daily-box { display: flex; align-items: center; gap: 12px; }
.daily-num { font-weight: 900; font-size: 20px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }

/* 広告枠 */
.ml-ad { margin: 20px 0; min-height: 100px; border: 1px dashed var(--line); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 12px; }
.ml-ad.is-live { border: 0; min-height: 0; display: block; }
.ml-pr { font-size: 12px; }
.ml-pr .tag { margin-right: 6px; }

/* トースト・モーダル */
.ml-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 200;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  transition: .25s ease; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.ml-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ml-modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 150; display: flex; align-items: flex-end; justify-content: center;
  animation: ml-fadein .2s ease;
}
@keyframes ml-fadein { from { opacity: 0; } to { opacity: 1; } }
.ml-modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: ml-up .25s ease;
}
@media (min-width: 600px) { .ml-modal-back { align-items: center; } .ml-modal { border-radius: 20px; } }
@keyframes ml-up { from { transform: translateY(30px); } to { transform: none; } }
.ml-modal img.share-preview { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }

/* フッター */
.ml-footer { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; color: var(--text-sub); font-size: 13px; }
.ml-more { display: grid; gap: 8px; margin: 12px 0 20px; }
.ml-more a {
  display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
}
.ml-more a .emoji { font-size: 26px; width: 36px; text-align: center; }
.ml-more a b { display: block; font-size: 15px; }
.ml-more a span { font-size: 12px; color: var(--text-sub); }
.ml-footer-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
.ml-footer-links a { color: var(--text-sub); }
.ml-stampcard { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; }
.ml-stamp { width: 34px; height: 34px; border-radius: 50%; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; font-size: 18px; filter: grayscale(1); opacity: .5; }
.ml-stamp.on { border: 2px solid var(--accent); filter: none; opacity: 1; background: var(--accent-soft); }

/* スライダー */
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
label.field { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }

/* アニメ */
@keyframes ml-pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: ml-pop .45s cubic-bezier(.2, .8, .3, 1.2) both; }
@keyframes ml-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
.shake { animation: ml-shake .45s ease both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
