:root {
    --bg: #faf6ee;
    --bg-deep: #f3ecd9;
    --ink: #1a1814;
    --ink-soft: #5a544a;
    /* --ink-faint: 旧 #8a8478 だと #faf6ee 上で約 3.35:1 で WCAG AA 未達。
       #6e685c に深めて約 4.7:1 に引き上げ、 本文中の補助テキスト/ラベルでも
       AA を満たすようにする。 */
    --ink-faint: #6e685c;
    --paper: #ede5d0;
    --accent: #b88848;
    --accent-soft: #d9b475;
    --accent-bright: #c89858;
    --silhouette: #2a2622;
    --shadow: rgba(20, 18, 14, 0.06);
    --highlight: rgba(184, 136, 72, 0.10);
    /* === フォント変数(言語別に :lang() で上書き) === */
    --font-body: 'Shippori Mincho', serif;
    --font-ui: 'Zen Kaku Gothic New', sans-serif;
    --font-num: 'Cormorant Garamond', serif;
    /* CSS::after用の通貨ラベル(en/zh/fr/koは Step 3 で追加) */
    --label-currency-suffix: ' 閃き';
  }
  /* 英語・フランス語: 西洋セリフ + Inter UI */
  :lang(en), :lang(fr) {
    --font-body: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-num: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  }
  :lang(en) { --label-currency-suffix: ' insights'; }
  :lang(fr) { --label-currency-suffix: ' lueur'; }
  /* 中国語(簡体): Noto Serif/Sans SC */
  :lang(zh) {
    --font-body: 'Noto Serif SC', serif;
    --font-ui: 'Noto Sans SC', sans-serif;
    --font-num: 'Cormorant Garamond', 'Noto Serif SC', serif;
    --label-currency-suffix: ' 灵感';
  }
  /* 韓国語: Noto Serif/Sans KR */
  :lang(ko) {
    --font-body: 'Noto Serif KR', serif;
    --font-ui: 'Noto Sans KR', sans-serif;
    --font-num: 'Cormorant Garamond', 'Noto Serif KR', serif;
    --label-currency-suffix: ' 영감';
  }
  /* en/fr のセリフフォントは線が細く見えるため、全体を約 9% 拡大 */
  html[lang="en"], html[lang="fr"] { font-size: 109%; }
  /* 細かいテキストはさらに一段拡大して可読性を上げる */
  :lang(en) .item-desc, :lang(fr) .item-desc,
  :lang(en) .atom-desc, :lang(fr) .atom-desc { font-size: 0.94rem; line-height: 1.7; }
  :lang(en) .opening-line, :lang(fr) .opening-line { font-size: 1.18rem; line-height: 1.85; }
  :lang(en) .pt-text, :lang(fr) .pt-text { font-size: 1.1rem; }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { height: 100%; overflow: hidden; }

  body {
    font-family: var(--font-body);
    background: var(--bg);
    background-image:
      radial-gradient(ellipse at 20% 10%, rgba(184, 136, 72, 0.04), transparent 50%),
      radial-gradient(ellipse at 80% 90%, rgba(184, 136, 72, 0.05), transparent 50%);
    color: var(--ink);
    position: relative;
    /* タップ連打時にダブルタップズーム/タップハイライト/テキスト選択が起きないよう抑制
       (ピンチズームはアクセシビリティのため残す) */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  body::before {
    content: '';
    position: fixed; inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
    opacity: 0.35;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 1;
  }

  .container {
    position: relative; z-index: 2;
    height: 100vh;        /* fallback */
    height: 100dvh;       /* iOS Safari の URL バー出入りに追従 */
    display: grid;
    grid-template-columns: 1fr 360px;
    grid-template-rows: auto 1fr 130px;
    grid-template-areas:
      "header  panel"
      "stage   panel"
      "log     panel";
    gap: 24px;
    padding: 32px 40px;
  }

  .header { grid-area: header; }
  .stage { grid-area: stage; }
  .panel { grid-area: panel; }
  .log { grid-area: log; }
  .tab-nav { display: none; }

  /* === BGM/SFX 音量設定 UI === */
  /* 画面右上に控えめな♪ボタン。クリックで音量パネルが下にスライド。
     音は物語の静謐さを邪魔しないよう、デフォルト OFF / 控えめな音量。 */
  .audio-toggle {
    position: fixed; top: 16px; right: 20px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-faint);
    border: 1px solid var(--ink-faint);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    z-index: 50;
    opacity: 0.55;
    transition: opacity 0.3s, color 0.3s, border-color 0.3s, background 0.3s;
    font-family: var(--font-ui);
    padding: 0;
  }
  .audio-toggle:hover { opacity: 0.95; color: var(--ink); border-color: var(--ink); }
  .audio-toggle.active { color: var(--accent); border-color: var(--accent); opacity: 0.9; }
  .audio-panel {
    position: fixed; top: 56px; right: 20px;
    background: rgba(28, 22, 18, 0.94);
    border: 1px solid var(--ink-faint);
    padding: 14px 18px;
    z-index: 49;
    min-width: 180px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--ink-soft);
    letter-spacing: 0.15em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }
  .audio-panel[hidden] { display: none; }
  .audio-panel-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    margin: 6px 0;
  }
  .audio-panel-row label { color: var(--ink-soft); }
  .audio-panel input[type="checkbox"] { accent-color: var(--accent); }
  .audio-panel input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
  }

  .phase-label {
    font-family: var(--font-ui);
    font-size: 0.7rem; letter-spacing: 0.45em;
    color: var(--ink-faint); margin-bottom: 18px;
    text-transform: uppercase;
  }
  .phase-label::before { content: '— '; color: var(--accent); }

  .currency-block { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
  .currency-label {
    font-family: var(--font-body);
    font-size: 0.95rem; color: var(--ink-soft);
    letter-spacing: 0.3em;
  }
  .currency-value {
    font-family: var(--font-num);
    font-size: 4.4rem; font-weight: 300;
    letter-spacing: -0.03em; line-height: 0.9;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
  }
  .currency-rate {
    font-family: var(--font-num);
    font-size: 1.05rem; color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    padding-left: 16px;
    border-left: 1px solid rgba(90, 84, 74, 0.2);
  }
  .elapsed-block {
    margin-top: 18px; display: flex;
    align-items: baseline; gap: 12px;
  }
  .elapsed-label {
    font-family: var(--font-ui);
    font-size: 0.65rem; letter-spacing: 0.4em;
    color: var(--ink-faint);
  }
  .elapsed-value {
    font-family: var(--font-body);
    font-size: 0.92rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
  }

  .phase-progress {
    margin-top: 22px; max-width: 460px;
    opacity: 0; transform: translateY(-4px);
    transition: opacity 1.6s ease, transform 1.6s ease;
    pointer-events: none;
  }
  .phase-progress.revealed { opacity: 1; transform: translateY(0); }
  .phase-progress-row {
    display: flex; justify-content: space-between; align-items: baseline;
    font-family: var(--font-ui);
    font-size: 0.65rem; color: var(--ink-faint);
    letter-spacing: 0.3em; margin-bottom: 6px;
  }
  .phase-progress-bar {
    height: 1px;
    background: rgba(90, 84, 74, 0.18);
    position: relative; overflow: hidden;
  }
  .phase-progress-fill {
    position: absolute; left: 0; top: 0; height: 100%;
    background: linear-gradient(to right, var(--accent-soft), var(--accent));
    width: 0; transition: width 0.4s ease;
  }

  /* ============ STAGE ============ */
  .stage {
    display: flex; flex-direction: column;
    min-height: 0;
  }
  .stage-canvas {
    flex: 1; position: relative;
    display: flex; align-items: center; justify-content: center;
    min-height: 0;
  }
  .stage-canvas svg { width: 100%; height: 100%; }
  .stage-action {
    /* 2026-05-25: モバイル overlap 対策の defensive 追加 — walk-button を含む
       コンテナを必ずインタラクティブ層に置く */
    position: relative; z-index: 3;
    padding: 14px 0 4px;
    display: flex; justify-content: center;
  }

  .silhouette-inner {
    transform-origin: center bottom;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.4, 1);
  }
  .silhouette-inner circle, .silhouette-inner rect { fill: var(--silhouette); }
  .silhouette-inner.stepping {
    transform: scale(0.93) translateY(-2px);
    transition: transform 0.08s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .silhouette-companion {
    opacity: 0;
    transition: opacity 3s ease;
  }
  .silhouette-companion.visible { opacity: 0.45; animation: companionBreathe 5.2s ease-in-out infinite; }
  .silhouette-companion.faint.visible { opacity: 0.28; animation: companionBreatheFaint 6.4s ease-in-out infinite; }
  .silhouette-companion circle, .silhouette-companion rect {
    fill: var(--silhouette);
  }
  /* 個体ごとに違う周期で「生きている」呼吸感を出す。
     visible のみに適用。Phase 3 仲間 (data-show=1/30/50/100) に個性を与える。 */
  .silhouette-companion[data-show="1"].visible   { animation-duration: 4.8s; animation-delay: -0.5s; }
  .silhouette-companion[data-show="30"].visible  { animation-duration: 6.2s; animation-delay: -1.5s; }
  .silhouette-companion[data-show="50"].visible  { animation-duration: 5.6s; animation-delay: -2.2s; }
  .silhouette-companion[data-show="100"].visible { animation-duration: 7.4s; animation-delay: -2.8s; }
  @keyframes companionBreathe {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 0.55; }
  }
  @keyframes companionBreatheFaint {
    0%, 100% { opacity: 0.24; }
    50%      { opacity: 0.34; }
  }

  /* ============ FLOATING NARRATION above the silhouette ============ */
  /* シルエットの頭は概ね 40% 付近にあるので、上部 30% 以内に収める */
  .floating-narration {
    position: absolute;
    top: calc(5% + var(--stack, 0) * 36px);
    left: 50%;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    letter-spacing: 0.05em;
    text-align: center;
    max-width: 94%;
    pointer-events: none;
    z-index: 8;
    line-height: 1.7;
    text-shadow:
      0 0 18px var(--bg),
      0 0 10px var(--bg),
      0 0 5px var(--bg),
      0 0 2px var(--bg);
    /* GPU レイヤーに乗せて transform/opacity を滑らかに(filter: blur は重いので不使用) */
    will-change: transform, opacity;
    transform: translate3d(-50%, 14px, 0);
    animation: narrationFloat 3500ms ease-out forwards;
  }
  .floating-narration.event {
    color: var(--accent);
    font-style: italic;
    font-size: 1.05rem;
    animation: narrationFloatEvent 4500ms ease-out forwards;
  }
  /* filter: blur を廃止して transform/opacity のみに(カクカク防止)。translate3d でレイヤー化。 */
  @keyframes narrationFloat {
    0%   { opacity: 0;    transform: translate3d(-50%, 14px, 0); }
    35%  { opacity: 0.95; transform: translate3d(-50%, 0,    0); }
    65%  { opacity: 0.9;  transform: translate3d(-50%, -8px, 0); }
    100% { opacity: 0;    transform: translate3d(-50%, -26px,0); }
  }
  @keyframes narrationFloatEvent {
    0%   { opacity: 0;    transform: translate3d(-50%, 18px,  0) scale(0.97); }
    32%  { opacity: 1;    transform: translate3d(-50%, 0,     0) scale(1);    }
    68%  { opacity: 0.95; transform: translate3d(-50%, -10px, 0) scale(1);    }
    100% { opacity: 0;    transform: translate3d(-50%, -34px, 0) scale(1);    }
  }

  .walk-button {
    /* 2026-05-25: モバイル(Android Chrome)で歩くボタンがログ枠と重なって
       上端しかタップできない、 と報告があったため defensive に position+z-index を付与。
       他要素より明示的に上に置き、 タップ判定が常にボタン全体に届くようにする。 */
    position: relative; z-index: 3;
    padding: 12px 40px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    letter-spacing: 0.4em; text-indent: 0.4em;
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid rgba(90, 84, 74, 0.4);
    cursor: pointer; user-select: none;
    transition: color 0.2s, border-color 0.2s, letter-spacing 0.2s, transform 0.1s;
  }
  .walk-button:hover {
    color: var(--ink);
    border-color: var(--ink);
    letter-spacing: 0.5em;
  }
  .walk-button:active { transform: scale(0.97); }

  /* 営み MAX 達成時の動詞変化アニメーション(洗練版: 控えめな scale + クロスフェード + 静かな波紋) */
  .walk-button.walk-morphing {
    animation: walkMorph 2000ms cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
  }
  @keyframes walkMorph {
    0%   { opacity: 1;    transform: scale(1);    color: var(--ink-soft); border-color: rgba(90,84,74,0.4); letter-spacing: 0.3em;  box-shadow: 0 0 0 rgba(184,136,72,0); }
    35%  { opacity: 0.45; transform: scale(1.08); color: var(--accent);   border-color: var(--accent);     letter-spacing: 0.42em; box-shadow: 0 0 16px rgba(184,136,72,0.4); }
    50%  { opacity: 0;    transform: scale(1.12); color: var(--accent);   border-color: var(--accent);     letter-spacing: 0.48em; box-shadow: 0 0 22px rgba(184,136,72,0.55); }
    60%  { opacity: 0;    transform: scale(1.12); color: var(--accent);   border-color: var(--accent);     letter-spacing: 0.48em; box-shadow: 0 0 22px rgba(184,136,72,0.55); }
    80%  { opacity: 0.9;  transform: scale(1.04); color: var(--accent);   border-color: var(--accent);     letter-spacing: 0.38em; box-shadow: 0 0 18px rgba(184,136,72,0.45); }
    100% { opacity: 1;    transform: scale(1);    color: var(--ink);      border-color: var(--accent);    letter-spacing: 0.3em;  box-shadow: 0 0 12px rgba(184,136,72,0.3); }
  }
  .walk-button.walk-morphed {
    color: var(--ink);
    border-color: var(--accent);
    animation: walkMorphedGlow 2200ms ease-in-out 1;
  }
  @keyframes walkMorphedGlow {
    0%   { box-shadow: 0 0 12px rgba(184,136,72,0.3); }
    100% { box-shadow: 0 0 0 rgba(184,136,72,0); }
  }
  /* 歩くボタン中央から静かに広がる波紋(MAX 演出のアクセント) */
  .walk-button-ripple {
    position: absolute;
    width: 60px; height: 60px;
    margin-left: -30px; margin-top: -30px;
    border: 1px solid rgba(184, 136, 72, 0.5);
    border-radius: 50%;
    pointer-events: none;
    animation: walkButtonRipple 1200ms cubic-bezier(0.2, 0.0, 0.0, 1) forwards;
  }
  @keyframes walkButtonRipple {
    0%   { transform: scale(0.5); opacity: 0.55; }
    100% { transform: scale(3.5); opacity: 0; }
  }

  /* ============ PANEL ============ */
  .panel {
    display: flex; flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS Safari タッチスクロール */
    overscroll-behavior-y: contain;    /* 外部ページへのスクロール連鎖を防ぐ */
    /* 2026-05-25: padding-top で固定ボタン(lang/reset)との重なりを回避 */
    padding-top: 16px;
    /* 2026-05-25: スクロールバーを 8px に拡大(掴みやすさ改善) */
    padding-right: 8px;
    scrollbar-width: thin; /* Firefox */
  }
  .panel::-webkit-scrollbar { width: 8px; }
  .panel::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 4px; }

  .section-title {
    font-family: var(--font-ui);
    font-size: 0.65rem; letter-spacing: 0.5em;
    color: var(--ink-faint); text-transform: uppercase;
    margin-top: 18px; margin-bottom: 10px;
    padding-left: 2px;
    display: flex; align-items: center; gap: 12px;
  }
  .section-title:first-child { margin-top: 0; }
  .section-title::after {
    content: ''; flex: 1; height: 1px;
    background: linear-gradient(to right, var(--ink-faint), transparent);
    opacity: 0.4;
  }
  .section-sub {
    color: var(--ink-faint); font-size: 0.55rem;
    letter-spacing: 0.2em; opacity: 0.6;
  }

  .item-card {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 1px solid rgba(90, 84, 74, 0.12);
    border-left: 2px solid transparent;
    padding: 14px 14px 14px 10px;
    cursor: pointer; text-align: left;
    transition: all 0.2s ease;
    font-family: var(--font-body);
    color: var(--ink); width: 100%; display: block;
    position: relative;
  }
  .item-card:hover:not(:disabled) {
    background: var(--paper);
    border-left-color: var(--accent);
  }
  .item-card:disabled { cursor: not-allowed; }
  .item-card:disabled:not(.maxed):not(.purchased) { opacity: 0.32; }
  .item-card.purchased { opacity: 0.5; cursor: default; }
  .item-card.maxed { opacity: 0.7; cursor: default; }
  .item-card.maxed:hover { background: transparent; border-left-color: transparent; }

  /* MAX 達成セレモニー(2.5 秒間グロー → 1.5 秒フェードアウト)。
     営みカード(.item-card)と Phase 7 ボタン製作カード(.bm-card)の両方で使う。 */
  .item-card.maxed-celebration,
  .bm-card.maxed-celebration {
    opacity: 1;
    background: rgba(184, 136, 72, 0.06);
    border-color: var(--accent);
    border-left-color: var(--accent);
    animation: maxedGlow 2000ms ease-in-out infinite alternate;
    pointer-events: none;
  }
  @keyframes maxedGlow {
    from { box-shadow: 0 0 0 rgba(184,136,72,0); }
    to   { box-shadow: 0 0 18px rgba(184,136,72,0.45); }
  }
  .item-card.maxed-fading,
  .bm-card.maxed-fading {
    opacity: 0.7;
    animation: maxedFade 1500ms ease-out forwards;
    pointer-events: none;
  }
  @keyframes maxedFade {
    from { opacity: 0.7; transform: translateY(0); }
    to   { opacity: 0;   transform: translateY(-8px); }
  }

  .item-card.next-goal {
    background: var(--highlight);
    border-left-color: var(--accent);
  }

  .item-row-1 { display: flex; justify-content: space-between; align-items: baseline; }
  .item-name { font-size: 1.05rem; font-weight: 500; letter-spacing: 0.05em; }
  .item-count {
    font-family: var(--font-num);
    font-size: 1.3rem; color: var(--accent);
    font-variant-numeric: tabular-nums;
  }
  .item-count-cap {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--ink-faint);
    letter-spacing: 0.05em;
    margin-left: 2px;
  }
  .tier-badge {
    display: inline-block;
    margin-left: 6px;
    font-family: var(--font-num);
    font-size: 0.75rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
  }
  .item-desc {
    font-size: 0.78rem; color: var(--ink-faint);
    margin-top: 4px; letter-spacing: 0.02em;
  }
  .item-row-2 {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
  }
  .item-prod {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink-soft);
    letter-spacing: 0.02em;
  }
  .item-prod.has-value { color: var(--accent); }
  .item-prod-add {
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 6px;
  }
  .item-cost {
    font-family: var(--font-num);
    font-size: 1.05rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .item-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .item-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px; letter-spacing: 0.05em;
  }
  .item-card:disabled .item-cost { color: var(--ink-faint); }
  .item-card.purchased .item-row-2 { display: none; }
  .item-cost-max {
    font-family: var(--font-ui);
    font-size: 0.75rem; color: var(--accent);
    letter-spacing: 0.4em; font-weight: 500;
  }

  .purchased-mark {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--accent);
  }
  .panel-empty {
    font-family: var(--font-body);
    font-size: 0.82rem; color: var(--ink-faint);
    padding: 8px 4px; letter-spacing: 0.05em; line-height: 1.7;
  }
  /* レガシー(覚醒/営みの記憶)を引き継いでいる時のメッセージ
     → 通常の empty より少し強調して「引き継いだ実感」 を持たせる */
  .panel-empty.legacy-applied {
    color: rgba(184, 136, 72, 0.85);
    font-style: italic;
    letter-spacing: 0.12em;
  }

  /* ============ LOG ============ */
  .log {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS Safari タッチスクロール */
    overscroll-behavior-y: contain;
    padding-top: 12px;
    border-top: 1px solid rgba(90, 84, 74, 0.18);
    position: relative;
  }
  .log::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 36px; height: 1px;
    background: var(--accent);
  }
  .log-entry {
    font-family: var(--font-body);
    font-size: 0.95rem; color: var(--ink-faint);
    margin-bottom: 8px; letter-spacing: 0.05em;
    line-height: 1.7;
  }
  .log-entry.fresh { animation: fadeIn 1.8s ease-out; }
  .log-entry:last-child { color: var(--ink); font-size: 1.05rem; }
  .log-entry.event { color: var(--accent); font-style: italic; }
  .log-entry.event:last-child { color: var(--accent-bright); }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); filter: blur(2px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
  }

  /* ============ PHASE TRANSITION ============ */
  .phase-transition {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    z-index: 100;
    animation: phaseAppear 2.5s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
  }
  .phase-transition::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(184, 136, 72, 0.18), transparent 60%);
    /* 装飾用の radial gradient は absolute なので static の子要素(pt-button 等)
       の上に重なり、 透明部分でも click を奪う。 これが「続ける」 ボタン押下
       不可の原因だったため pointer-events: none で click を通す。 */
    pointer-events: none;
  }
  @keyframes phaseAppear { from { opacity: 0; } to { opacity: 1; } }
  .pt-numeral {
    font-family: var(--font-num);
    font-size: 7rem; font-weight: 300;
    color: var(--ink); line-height: 1;
    margin-bottom: 24px; letter-spacing: -0.02em;
  }
  .pt-title {
    font-family: var(--font-body);
    font-size: 1.6rem; color: var(--ink);
    letter-spacing: 0.4em; margin-bottom: 36px;
    text-align: center;
  }
  .pt-text {
    font-family: var(--font-body);
    font-size: 1rem; color: var(--ink-soft);
    max-width: 500px; text-align: center;
    line-height: 2; letter-spacing: 0.08em;
  }
  .pt-button {
    margin-top: 56px; padding: 14px 48px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: transparent; color: var(--ink);
    border: 1px solid var(--ink);
    cursor: pointer;
    letter-spacing: 0.4em; text-indent: 0.4em;
    transition: all 0.3s;
  }
  .pt-button:hover { background: var(--ink); color: var(--bg); }
  .pt-note {
    margin-top: 24px;
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.3em;
    text-align: center;
  }
  /* 過渡シーンの各ステージは、子要素が差し替わる際にフェードイン */
  .phase-transition .pt-text,
  .phase-transition .pt-numeral,
  .phase-transition .pt-title,
  .phase-transition .pt-button,
  .phase-transition .pt-shimmer {
    animation: ptStageIn 1400ms ease-out;
  }
  @keyframes ptStageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .phase-transition.fading-out {
    animation: ptFadeOut 1500ms ease-in forwards;
    pointer-events: none;
  }
  @keyframes ptFadeOut {
    to { opacity: 0; }
  }
  /* タップで進む段階の場合、画面全体がポインタ可能 */
  .phase-transition { cursor: pointer; }
  .phase-transition .pt-button { cursor: pointer; }

  /* 「ちいさな揺らぎ」: クリックで次へ進む発光粒 */
  .pt-shimmer {
    margin-top: 48px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, var(--accent-bright), var(--accent-soft) 40%, transparent 75%);
    box-shadow:
      0 0 28px rgba(184, 136, 72, 0.55),
      0 0 56px rgba(184, 136, 72, 0.30);
    cursor: pointer;
    animation: shimmerPulse 2200ms ease-in-out infinite, ptStageIn 1600ms ease-out;
    z-index: 2;
  }
  @keyframes shimmerPulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50%      { transform: scale(1.15); opacity: 1; }
  }

  /* === Phase 1: 物質セクション === */
  .phase1-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  @keyframes phase1Reveal {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .matter-sub-title {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }

  /* 原子カード */
  .atom-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
  }
  .atom-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .atom-card:disabled, .atom-card.insufficient { opacity: 0.45; cursor: default; }
  .atom-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .atom-symbol {
    width: 30px; height: 30px;
    border: 1px solid var(--ink-faint);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-num);
    font-size: 0.95rem; font-weight: 500;
    color: var(--ink);
    flex-shrink: 0;
  }
  .atom-name {
    font-size: 1rem; color: var(--ink);
    letter-spacing: 0.04em; flex: 1;
  }
  .atom-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .atom-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .atom-row-2 {
    margin-top: 8px;
    display: flex; justify-content: flex-end;
  }
  .atom-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .atom-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .atom-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .atom-card:disabled .atom-cost,
  .atom-card.insufficient .atom-cost { color: var(--ink-faint); }

  /* === Phase 1: 分子(P1-3)/ 塊(P1-4)/ 種(P1-5)===
   *  共通レイアウトは atom-card と同じ縦並び。 種はクライマックス感を出すため
   *  金色アクセントの枠と背景グラデを付ける。 */
  .matter-sub-title-mol  { margin-top: 26px; }
  .matter-sub-title-mass { margin-top: 26px; }
  .matter-sub-title-seed { margin-top: 26px; }
  .molecule-card, .mass-card, .seed-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
  }
  .molecule-card:hover:not(:disabled):not(.insufficient),
  .mass-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .molecule-card:disabled, .molecule-card.insufficient,
  .mass-card:disabled, .mass-card.insufficient,
  .seed-card:disabled, .seed-card.insufficient { opacity: 0.45; cursor: default; }
  .molecule-card.locked, .mass-card.locked, .seed-card.locked {
    cursor: default; opacity: 0.55; background: transparent;
  }
  .mol-row-1, .mass-row-1, .seed-row-1 {
    display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px;
  }
  .mol-formula {
    font-family: var(--font-num);
    font-size: 1.25rem; color: var(--ink);
    letter-spacing: 0.02em; min-width: 56px;
  }
  .mol-name, .mass-name { font-size: 1rem; color: var(--ink); letter-spacing: 0.04em; flex: 1; }
  .mol-count, .mass-count, .seed-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .mol-desc, .mass-desc, .seed-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px; letter-spacing: 0.03em;
  }
  .mol-row-2, .mass-row-2, .seed-row-2 {
    margin-top: 8px;
    display: flex; justify-content: space-between; align-items: baseline;
  }
  .mol-cost, .mass-cost, .seed-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .mol-cost::before, .mass-cost::before, .seed-cost::before {
    content: '⤳ ';
    color: var(--ink-faint);
    font-size: 0.85rem;
  }
  .mol-cost::after, .mass-cost::after, .seed-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px; letter-spacing: 0.05em;
  }
  .molecule-card:disabled .mol-cost,
  .molecule-card.insufficient .mol-cost,
  .mass-card:disabled .mass-cost,
  .mass-card.insufficient .mass-cost,
  .seed-card:disabled .seed-cost,
  .seed-card.insufficient .seed-cost { color: var(--ink-faint); }
  .mol-cost-max, .mass-cost-max, .seed-cost-max {
    font-family: var(--font-ui);
    font-size: 0.78rem; color: var(--accent);
    letter-spacing: 0.32em; text-indent: 0.32em;
  }
  .card-gate {
    font-family: var(--font-num);
    font-size: 0.78rem; color: var(--ink-faint);
    letter-spacing: 0.04em;
  }
  .card-gate::before { content: '🔒 '; margin-right: 2px; filter: grayscale(0.6); font-size: 0.78rem; }
  /* 種カードはクライマックスなので、 金色アクセントを少し強める */
  .seed-card {
    background: linear-gradient(180deg, var(--paper), rgba(184, 136, 72, 0.06));
    border: 1px solid rgba(184, 136, 72, 0.4);
    padding: 14px 16px;
  }
  .seed-card:hover:not(:disabled):not(.insufficient) { border-color: var(--accent); }
  .seed-name { font-size: 1.15rem; color: var(--accent); letter-spacing: 0.06em; flex: 1; }
  .seed-cost { color: var(--accent); font-size: 1rem; }

  /* === Phase 2: 環境構築:ステージ背景レイヤ === */
  /* env-* グループは購入個数(state.environment[id])に応じて opacity/visibility をJSで切替 */
  .env-layer { transition: opacity 1800ms ease; }
  .env-layer.hidden { opacity: 0; pointer-events: none; }
  /* 空のグラデーション(背景帯) */
  #env-sky-tint { transition: opacity 2400ms ease; }
  /* 雲のドリフト */
  .env-cloud { animation: cloudDrift 60s linear infinite; }
  .env-cloud.cloud-2 { animation-duration: 90s; animation-delay: -20s; }
  .env-cloud.cloud-3 { animation-duration: 120s; animation-delay: -50s; }
  @keyframes cloudDrift {
    from { transform: translateX(-120px); }
    to   { transform: translateX(720px); }
  }
  /* 星のまたたき */
  .env-star { animation: starTwinkle 3.2s ease-in-out infinite; }
  .env-star:nth-child(2n)   { animation-delay: -0.6s; animation-duration: 4.1s; }
  .env-star:nth-child(3n)   { animation-delay: -1.4s; animation-duration: 2.7s; }
  .env-star:nth-child(5n+1) { animation-delay: -2.2s; animation-duration: 3.8s; }
  @keyframes starTwinkle {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 0.85; }
  }
  /* 太陽のグロー呼吸 */
  #env-sun-disc { animation: sunGlow 8s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
  @keyframes sunGlow {
    0%, 100% { opacity: 0.82; }
    50%      { opacity: 1; }
  }
  /* 海面の波打ち */
  .env-wave { animation: waveShift 6.5s ease-in-out infinite; }
  @keyframes waveShift {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-14px); }
  }

  /* === Phase 2: 環境構築セクション(右パネル) === */
  .phase2-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .environment-cat-block { margin-bottom: 14px; }
  .environment-cat-label {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }
  .environment-cat-cards { display: flex; flex-direction: column; }
  .environment-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
    color: var(--ink);
  }
  .environment-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .environment-card:disabled, .environment-card.insufficient { opacity: 0.45; cursor: default; }
  .environment-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .environment-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(90, 84, 74, 0.18);
  }
  .environment-name {
    font-size: 1rem; color: var(--ink);
    letter-spacing: 0.04em; flex: 1;
  }
  .environment-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .environment-count-cap {
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.05em;
    margin-left: 2px;
  }
  .environment-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .environment-row-2 {
    margin-top: 8px;
    display: flex; justify-content: flex-end;
  }
  .environment-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .environment-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .environment-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .environment-card:disabled .environment-cost,
  .environment-card.insufficient .environment-cost { color: var(--ink-faint); }
  /* カテゴリ別アクセント:左ボーダー */
  .environment-cat-earth { border-left: 2px solid #8a6a3a; }
  .environment-cat-sky   { border-left: 2px solid #7d9ab2; }
  .environment-cat-light { border-left: 2px solid #c89858; }
  .environment-cat-sea   { border-left: 2px solid #5a8a99; }
  /* 「生命」最終象徴 */
  .environment-card.environment-cat-life { border-left: 2px solid #7aa07a; }
  .environment-card.environment-final {
    background: rgba(122, 160, 122, 0.08);
    border-color: #7aa07a;
    animation: lifeBeacon 2400ms ease-in-out infinite alternate;
  }
  @keyframes lifeBeacon {
    from { box-shadow: 0 0 0 rgba(122, 160, 122, 0); }
    to   { box-shadow: 0 0 16px rgba(122, 160, 122, 0.35); }
  }
  .environment-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
  }
  .environment-card.locked .environment-name,
  .environment-card.locked .environment-desc { color: var(--ink-faint); }
  .environment-card.locked .environment-cost { color: var(--ink-faint); font-style: italic; }
  .environment-card.locked .environment-cost::before,
  .environment-card.locked .environment-cost::after { content: none; }
  /* === /Phase 2 === */

  /* 「人」誕生時の特別 fade-in 演出 (4s に延長、儀式的に溜めを作る)
     inline transform: scale(...) と干渉しないよう、opacity と filter のみアニメ */
  .silhouette-companion.first-appear {
    animation: companionFirstAppear 4000ms ease-out forwards;
  }
  .silhouette-companion.first-appear.visible { opacity: 0.6; }
  @keyframes companionFirstAppear {
    0%   { opacity: 0;    filter: blur(5px) brightness(1.5); }
    30%  { opacity: 0.18; filter: blur(3px) brightness(1.3); }
    60%  { opacity: 0.4;  filter: blur(1.2px) brightness(1.15); }
    85%  { opacity: 0.55; filter: blur(0.3px) brightness(1.05); }
    100% { opacity: 0.6;  filter: blur(0) brightness(1); }
  }
  /* 「人」誕生の儀式: 8s かけてステージ全体を僅かに暗く沈める(完全暗転は避ける) */
  .stage-canvas.human-birth-dimming {
    animation: humanBirthDim 8000ms ease-in-out forwards;
  }
  @keyframes humanBirthDim {
    0%   { filter: brightness(1);    }
    25%  { filter: brightness(0.82); }
    65%  { filter: brightness(0.72); }
    100% { filter: brightness(0.88); }
  }

  /* === Phase 3: 生命 === */
  .phase3-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .life-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
  }
  .life-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .life-card:disabled, .life-card.insufficient { opacity: 0.45; cursor: default; }
  .life-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .life-glyph {
    width: 30px; height: 30px;
    border: 1px solid var(--ink-faint);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-body);
    font-size: 1rem; font-weight: 500;
    color: var(--ink);
    flex-shrink: 0;
  }
  .life-name {
    font-size: 1rem; color: var(--ink);
    letter-spacing: 0.04em; flex: 1;
  }
  .life-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .life-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .life-row-2 {
    margin-top: 8px;
    display: flex; justify-content: flex-end;
  }
  .life-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .life-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .life-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .life-card:disabled .life-cost,
  .life-card.insufficient .life-cost { color: var(--ink-faint); }
  .life-sub-title {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }
  .life-sub-title-human {
    margin-top: 24px;
    color: var(--accent);
  }
  /* 「人」ロックプレビューカード */
  .life-card-human-locked {
    border-style: dashed;
    border-color: rgba(184, 136, 72, 0.32);
    background: transparent;
  }
  .life-card-human-locked .life-glyph {
    color: var(--ink-faint);
    border-color: var(--ink-faint);
  }
  .life-card-human-locked .life-name { color: var(--ink-faint); }
  .life-desc-locked {
    font-style: italic;
    color: var(--accent);
    opacity: 0.7;
  }
  /* 解放済み「人」カードは色味で強調 */
  .life-card-human {
    border-color: var(--accent-soft);
  }
  .life-card-human .life-glyph {
    color: var(--accent);
    border-color: var(--accent);
  }
  /* === Phase 3 生命ビジュアルレイヤ (life-layer-*) === */
  .life-layer { transition: opacity 2400ms ease; pointer-events: none; }
  .life-layer.hidden { opacity: 0; }
  /* 微生物: 緩いランダム揺らぎ */
  .life-microbe { animation: microDrift 9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
  .life-microbe:nth-child(2n)   { animation-duration: 11s; animation-delay: -2s; }
  .life-microbe:nth-child(3n)   { animation-duration: 13s; animation-delay: -5s; }
  .life-microbe:nth-child(4n+1) { animation-duration: 8s;  animation-delay: -7s; }
  @keyframes microDrift {
    0%, 100% { transform: translate(0, 0); opacity: 0.55; }
    25%      { transform: translate(2.5px, -2px); opacity: 0.85; }
    50%      { transform: translate(-2px, 2.5px); opacity: 0.7; }
    75%      { transform: translate(1.5px, 1px); opacity: 0.9; }
  }
  /* 草: 風で揺れる */
  .life-grass-blade { animation: grassSway 4.5s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
  .life-grass-blade:nth-child(2n)   { animation-duration: 5.2s; animation-delay: -1.3s; }
  .life-grass-blade:nth-child(3n+1) { animation-duration: 3.9s; animation-delay: -2.4s; }
  @keyframes grassSway {
    0%, 100% { transform: rotate(-3deg); }
    50%      { transform: rotate(3deg); }
  }
  /* 動物: 横切る */
  .life-animal-mover { animation: animalCross 18s linear infinite; }
  .life-animal-mover:nth-child(2) { animation-duration: 24s; animation-delay: -6s; }
  .life-animal-mover:nth-child(3) { animation-duration: 14s; animation-delay: -10s; animation-direction: reverse; }
  .life-animal-mover:nth-child(4) { animation-duration: 21s; animation-delay: -3s; }
  @keyframes animalCross {
    from { transform: translateX(-30px); }
    to   { transform: translateX(640px); }
  }
  /* 生態系: 専用ビジュアルは無し。輪っかは廃止 (cap 到達時の粒子吸収演出に統合) */

  /* === Phase 3 生命フィギュア (魚/樹/獣の大型シルエット) === */
  /* cap 達成で 1 体出現、群れ取得で 3 体、進化取得で形状変化 */
  .life-fig {
    opacity: 0;
    transition: opacity 1500ms ease;
    pointer-events: none;
  }
  .life-fig.visible { opacity: 1; }
  /* appearing アニメは内側 .life-fig-anim に当てる (外側 g の SVG transform を上書きしないため)。
     visible/opacity は外側 .life-fig 側で扱う。 */
  .life-fig.appearing .life-fig-anim {
    transform-box: fill-box;
    transform-origin: center;
    animation: lifeFigAppearInner 1500ms ease-out both;
  }
  @keyframes lifeFigAppearInner {
    0%   { transform: translateY(6px) scale(0.85); }
    100% { transform: translateY(0) scale(1); }
  }
  /* 魚: 海中で左右にゆったり泳ぐ */
  /* NOTE: outer .life-fig-* keeps SVG translate(x,y) attribute for positioning;
     CSS animations are applied to the inner .life-fig-anim wrapper so the two
     transforms compose instead of overwriting each other. */
  .life-fig-fish .life-fig-anim {
    transform-box: fill-box;
    transform-origin: center;
    animation: fishSwim 8s ease-in-out infinite;
  }
  .life-fig-fish.fish-2 .life-fig-anim { animation-duration: 9.5s; animation-delay: -2.2s; }
  .life-fig-fish.fish-3 .life-fig-anim { animation-duration: 7.2s; animation-delay: -4.5s; animation-direction: reverse; }
  @keyframes fishSwim {
    0%, 100% { transform: translate(-30px, 0); }
    25%      { transform: translate(-10px, -3px); }
    50%      { transform: translate( 30px, 0); }
    75%      { transform: translate( 10px,  3px); }
  }
  /* 樹: ゆっくり左右に揺れる */
  .life-fig-tree .life-fig-anim {
    transform-box: fill-box;
    transform-origin: bottom center;
    animation: treeSway 9s ease-in-out infinite;
  }
  .life-fig-tree.tree-2 .life-fig-anim { animation-duration: 10.5s; animation-delay: -3.2s; }
  .life-fig-tree.tree-3 .life-fig-anim { animation-duration: 8.2s;  animation-delay: -5.8s; }
  @keyframes treeSway {
    0%, 100% { transform: rotate(-2deg); }
    50%      { transform: rotate(2deg); }
  }
  /* 獣: 地面を四足で行ったり来たり */
  .life-fig-beast .life-fig-anim {
    transform-box: fill-box;
    transform-origin: bottom center;
    animation: beastWalk 11s ease-in-out infinite;
  }
  .life-fig-beast.beast-2 .life-fig-anim { animation-duration: 13s;  animation-delay: -3.8s; }
  .life-fig-beast.beast-3 .life-fig-anim { animation-duration: 9.5s; animation-delay: -6.5s; animation-direction: reverse; }
  @keyframes beastWalk {
    0%, 100% { transform: translateX(-8px) translateY(0); }
    25%      { transform: translateX(-3px) translateY(-1px); }
    50%      { transform: translateX( 8px) translateY(0); }
    75%      { transform: translateX( 3px) translateY(-1px); }
  }
  /* 進化前/後の切替 (display 切替方式) */
  .life-fig-form-base    { display: inline; }
  .life-fig-form-evolved { display: none; }
  .life-fig.evolved .life-fig-form-base    { display: none; }
  .life-fig.evolved .life-fig-form-evolved { display: inline; }
  /* 視認性向上: 全 figure に薄い輪郭線を追加してシルエットを際立たせる */
  .life-fig path,
  .life-fig rect,
  .life-fig circle,
  .life-fig ellipse,
  .life-fig line {
    stroke: rgba(40, 30, 20, 0.35);
    stroke-width: 0.6;
  }
  /* === /Phase 3 生命フィギュア === */
  /* === /Phase 3 === */


  /* === Phase 4: 知性 === */
  .phase4-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .intellect-sub-title {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }
  .intellect-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
  }
  .intellect-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .intellect-card:disabled, .intellect-card.insufficient { opacity: 0.45; cursor: default; }
  .intellect-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .intellect-name {
    font-size: 1rem; color: var(--ink);
    letter-spacing: 0.04em; flex: 1;
  }
  .intellect-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .intellect-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .intellect-row-2 {
    margin-top: 8px;
    display: flex; justify-content: flex-end;
  }
  .intellect-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .intellect-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .intellect-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .intellect-card:disabled .intellect-cost,
  .intellect-card.insufficient .intellect-cost { color: var(--ink-faint); }
  /* ============ Phase 4: 知性レイヤ ============ */
  /* z-order: env/life より下、rings/silhouette より下。SVG 構造の早い位置に配置 */
  .intellect-layer { transition: opacity 2200ms ease; pointer-events: none; }
  .intellect-layer.hidden { opacity: 0; }

  /* --- A: 浮遊文字グリフ(多文化文字、BMP 範囲) --- */
  /* 楔形/ヒエログリフ/ルーン/ブラーフミーは多くの OS でフォント未対応 → □ になる
     ため、ハングル/アラビア/ラテン/ギリシャ/漢字に置換(全て BMP 範囲)。 */
  .intellect-glyph {
    font-family: 'Shippori Mincho', 'Noto Serif SC', 'Noto Sans', sans-serif;
    font-weight: 500;
    fill: var(--ink);
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 1800ms ease, fill 1800ms ease;
    animation: glyphFloat 9s ease-in-out infinite;
  }
  .intellect-glyph.visible { opacity: var(--glyph-opacity, 0.12); }
  /* 各文字体系で適切な fallback フォント */
  .intellect-glyph.glyph-han    { font-family: 'Shippori Mincho', 'Noto Serif SC', 'Noto Serif JP', serif; }
  .intellect-glyph.glyph-hangul { font-family: 'Noto Sans KR', 'Hiragino Sans', 'AppleGothic', sans-serif; }
  .intellect-glyph.glyph-arabic { font-family: 'Noto Sans Arabic', 'Geeza Pro', 'Arial', sans-serif; }
  .intellect-glyph.glyph-latin  { font-family: 'EB Garamond', 'Cormorant Garamond', 'Noto Serif', serif; font-weight: 600; }
  .intellect-glyph.glyph-greek  { font-family: 'EB Garamond', 'Cormorant Garamond', 'Noto Serif', serif; font-weight: 600; }
  @keyframes glyphFloat {
    0%   { transform: translateY(0) translateX(0); }
    25%  { transform: translateY(-6px) translateX(2px); }
    50%  { transform: translateY(-3px) translateX(-1px); }
    75%  { transform: translateY(-8px) translateX(3px); }
    100% { transform: translateY(0) translateX(0); }
  }
  /* 言語(language)取得時:グリフが自分の位置の周りで小さな円運動を描く。
     真の公転だと SVG 座標変換が複雑になるので、各文字位置を中心にした
     小さな弧運動で「言葉が踊る」感を出す。
     glyphFloat と排他(orbiting クラスでアニメ置換)。 */
  .intellect-glyph.orbiting {
    animation: glyphOrbitDrift var(--orbit-dur, 12s) ease-in-out infinite;
  }
  @keyframes glyphOrbitDrift {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(var(--orbit-r, 6px), calc(var(--orbit-r, 6px) * -0.6)); }
    50%  { transform: translate(0, calc(var(--orbit-r, 6px) * -1.2)); }
    75%  { transform: translate(calc(var(--orbit-r, 6px) * -1), calc(var(--orbit-r, 6px) * -0.6)); }
    100% { transform: translate(0, 0); }
  }
  /* kotobaCeremony フェードアウト: ゲーム画面全体を 1 秒で背景色に覆う。
     Phase 5 オープニング起動の直前に被せる。 */
  .kotoba-fade-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    opacity: 0;
    animation: kotobaFadeOut 1000ms ease-in forwards;
    pointer-events: none;
    z-index: 50;
  }
  @keyframes kotobaFadeOut {
    0%   { opacity: 0; }
    100% { opacity: 1; }
  }

  /* kotobaCeremony 全体オーバーレイ:背景を微かに暗く */
  .kotoba-ceremony-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 12, 8, 0.18);
    opacity: 0;
    animation: kotobaOverlayIn 1500ms ease forwards;
    pointer-events: none;
    z-index: 4;
  }
  @keyframes kotobaOverlayIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
  }

  /* Phase C: 多言語フレーズの嵐 ― ビューポート全体にランダム配置(被らないように) */
  .kotoba-multilang-text {
    position: absolute;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    color: var(--accent);
    animation: kotobaMultiFade 2700ms ease-in-out forwards;
    z-index: 5;
    --kotoba-peak: 0.7;
  }
  @keyframes kotobaMultiFade {
    0%   { opacity: 0; transform: translateY(6px); }
    18%  { opacity: var(--kotoba-peak); transform: translateY(0); }
    78%  { opacity: var(--kotoba-peak); }
    100% { opacity: 0; transform: translateY(-4px); }
  }
  /* Phase 5 オープニング上に被さる多言語嵐 ― 黒背景上で見やすい色味に */
  .kotoba-finale-phase .kotoba-multilang-text {
    color: var(--accent);
  }
  /* Phase D: 最終決めセリフ ― 中央に大きく */
  .kotoba-finale-text {
    position: fixed;
    left: 50%; top: 45%;
    transform: translate(-50%, -50%);
    /* スマホで「はじめに、 言葉があった。」 等が画面からはみ出していた問題対応
       (2026-05-20):viewport 連動の clamp + 折り返し可に変更。 */
    font-size: clamp(1.6rem, 7vw, 3.4rem);
    line-height: 1.4;
    letter-spacing: 0.1em;
    color: var(--accent);
    opacity: 0;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
    pointer-events: none;
    z-index: 110;
    text-shadow: 0 0 24px rgba(184, 136, 72, 0.5);
    animation: kotobaFinaleIn 3000ms ease forwards;
    width: 92vw;
    max-width: 720px;
    text-align: center;
  }
  @keyframes kotobaFinaleIn {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.92); filter: blur(6px); }
    35%  { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.04); filter: blur(2px); }
  }

  /* --- D: 道具シンボル(tool 取得時に上下にバウンス)
         <g> ラッパーで包み、CSS animation がラッパーに当たる構造。
         translateY が小さいので transform-origin の指定は不要。
         fill は子要素に継承される。 */
  .tool-symbol {
    fill: var(--silhouette);
    opacity: 0;
    transition: opacity 1600ms ease;
  }
  .tool-symbol > * { fill: inherit; }
  .tool-symbol.visible { opacity: 0.38; animation: toolBounce 1.6s ease-in-out infinite; }
  /* tool 取得カテゴリ強度に応じてアニメ振幅が大きくなる */
  #intellect-tools[data-tool-tier="2"] .tool-symbol.visible { animation: toolBounce 1.2s ease-in-out infinite; }
  #intellect-tools[data-tool-tier="3"] .tool-symbol.visible { animation: toolBounce 0.9s ease-in-out infinite; }
  /* 個体ごとに位相差を作って群れに見せる */
  .tool-symbol[data-tool-show="1"].visible { animation-delay: 0s; }
  .tool-symbol[data-tool-show="2"].visible { animation-delay: -0.2s; }
  .tool-symbol[data-tool-show="3"].visible { animation-delay: -0.4s; }
  .tool-symbol[data-tool-show="4"].visible { animation-delay: -0.6s; }
  .tool-symbol[data-tool-show="5"].visible { animation-delay: -0.8s; }
  .tool-symbol[data-tool-show="6"].visible { animation-delay: -1.0s; }
  .tool-symbol[data-tool-show="7"].visible { animation-delay: -1.2s; }
  @keyframes toolBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-1.5px); }
  }

  /* --- F: 共同体接続線(community 取得時に仲間 silhouette 間を結ぶ) --- */
  .community-link {
    stroke: var(--accent);
    stroke-width: 0.6;
    stroke-dasharray: 4 3;
    fill: none;
    opacity: 0;
    transition: opacity 1800ms ease;
    pointer-events: none;
  }
  .community-link.visible {
    opacity: var(--link-opacity, 0.18);
    animation: communityLinkFlow 6s linear infinite;
  }
  @keyframes communityLinkFlow {
    0%   { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -28; }
  }

  /* === /Phase 4 === */
  .silhouette-child {
    opacity: 0;
    transition: opacity 2.4s ease;
  }
  .silhouette-child.visible { opacity: 0.42; animation: childBreathe 3.6s ease-in-out infinite; }
  .silhouette-child circle, .silhouette-child rect { fill: var(--silhouette); }
  .silhouette-child[data-show-family="2"].visible { animation-duration: 3.2s; animation-delay: -0.8s; }
  .silhouette-child[data-show-family="3"].visible { animation-duration: 4.1s; animation-delay: -1.6s; }
  .silhouette-child').forEach(el => el.classList.remove('visible'));
    // 表示中の浮遊ナレーションも撤去
    activeFloats.forEach(f => f.div.remove());
    activeFloats.length = 0;
    // キューも空にする(時間差で出てこないように)
    if (floatQueueTimer) { clearTimeout(floatQueueTimer); floatQueueTimer = null; }
  .silhouette-child').forEach(el => {
      const showAt = parseInt(el.getAttribute('data-show-family') || '99', 10);
      if (phase4 && familyCount >= showAt) el.classList.add('visible');
      else el.classList.remove('visible');
    }
  .kotoba-fade-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    opacity: 0;
    animation: kotobaFadeOut 1000ms ease-in forwards;
    pointer-events: none;
    z-index: 50;
  }
  @keyframes kotobaFadeOut {
    0%   { opacity: 0; }
    100% { opacity: 1; }
  }
  .kotoba-multilang-text {
    position: absolute;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    color: var(--accent);
    animation: kotobaMultiFade 2700ms ease-in-out forwards;
    z-index: 5;
    --kotoba-peak: 0.7;
  }
  @keyframes kotobaMultiFade {
    0%   { opacity: 0; transform: translateY(6px); }
    18%  { opacity: var(--kotoba-peak); transform: translateY(0); }
    78%  { opacity: var(--kotoba-peak); }
    100% { opacity: 0; transform: translateY(-4px); }
  }
  .kotoba-finale-phase .kotoba-multilang-text {
    color: var(--accent);
  }
  .kotoba-finale-text {
    position: fixed;
    left: 50%; top: 45%;
    transform: translate(-50%, -50%);
    /* スマホで「はじめに、 言葉があった。」 等が画面からはみ出していた問題対応
       (2026-05-20):viewport 連動の clamp + 折り返し可に変更。 */
    font-size: clamp(1.6rem, 7vw, 3.4rem);
    line-height: 1.4;
    letter-spacing: 0.1em;
    color: var(--accent);
    opacity: 0;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
    pointer-events: none;
    z-index: 110;
    text-shadow: 0 0 24px rgba(184, 136, 72, 0.5);
    animation: kotobaFinaleIn 3000ms ease forwards;
    width: 92vw;
    max-width: 720px;
    text-align: center;
  }
  @keyframes kotobaFinaleIn {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.92); filter: blur(6px); }
    35%  { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.04); filter: blur(2px); }
  }

  /* === Phase 5: 文明 === */
  .phase5-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .civ-cat-label {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }
  .civ-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
    color: var(--ink);
  }
  .civ-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .civ-card:disabled, .civ-card.insufficient { opacity: 0.45; cursor: default; }
  .civ-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .civ-name {
    font-size: 1rem; color: var(--ink);
    letter-spacing: 0.04em; flex: 1;
  }
  .civ-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .civ-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .civ-row-2 { margin-top: 8px; display: flex; justify-content: flex-end; }
  .civ-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .civ-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .civ-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .civ-card:disabled .civ-cost,
  .civ-card.insufficient .civ-cost { color: var(--ink-faint); }
  .civ-cat-settlement  { border-left: 2px solid #8a6a3a; }
  .civ-cat-state       { border-left: 2px solid #7d6a52; }
  .civ-cat-institution { border-left: 2px solid #6a7d8a; }
  .civ-cat-technology  { border-left: 2px solid #5e7d6e; }
  .civ-card.civ-card-myth { border-left: 2px solid #c89858; }
  .civ-card-myth-locked {
    border-style: dashed;
    border-color: rgba(184, 136, 72, 0.32);
    background: transparent;
  }
  .civ-card-myth-locked .civ-name { color: var(--ink-faint); }
  .civ-desc-locked {
    font-style: italic;
    color: var(--accent);
    opacity: 0.7;
  }
  /* Phase 5 SVG レイヤ — 街並み/火/煙/群衆/刻文 共通レイヤ
     2026-05-19: canonical 統合時に欠落していた CSS を復元。
     これが無いと #civ-distant の山並み polygon が default fill=black で
     塗られ、画面下部に黒い塊として描画されるバグになる。 */
  .civ-layer { transition: opacity 1800ms ease; pointer-events: none; }
  .civ-layer.hidden { opacity: 0; }

  /* 遠景: 山並み / 城壁シルエット — 街並みより奥側、薄く配置 */
  #civ-distant path,
  #civ-distant polygon,
  #civ-distant polyline {
    stroke: none;
  }
  #civ-distant .mtn-far { fill: #8a8275; opacity: 0.35; }
  #civ-distant .mtn-mid { fill: #5e5749; opacity: 0.5; }

  /* 街並みシルエット: 黒に近い土色、地平線に立つ。 */
  #civ-skyline path,
  #civ-skyline rect,
  #civ-skyline polygon,
  #civ-skyline circle {
    fill: #1f1c19;
    stroke: none;
  }
  /* 窓の灯り(温色) — 文明の生活感 */
  #civ-skyline .bld-window { fill: #d9b574; opacity: 0.72; }
  /* 城門/入口(暗い穴) */
  #civ-skyline .bld-door { fill: rgba(0, 0, 0, 0.55); }
  /* 樹木の樹冠 — シルエットに少し透けを入れる */
  #civ-skyline .tree-crown { fill: #2a2620; opacity: 0.92; }
  /* アーチの抜き(地平線色で背景と一体化) */
  #civ-skyline .arch-hole { fill: var(--paper, #f3ede0); }

  /* 群衆: 主人公シルエットと同色、 半透明で密集表現 */
  #civ-crowd .crowd-figure { fill: var(--silhouette); opacity: 0.35; }

  /* 火: 黄色のチラチラ点 */
  .civ-fire {
    fill: #f3c155; opacity: 0.85;
    animation: fireFlicker 380ms ease-in-out infinite alternate;
    filter: drop-shadow(0 0 3px rgba(243, 193, 85, 0.7));
  }
  @keyframes fireFlicker {
    0%   { opacity: 0.5; transform: scale(0.9); }
    100% { opacity: 1;   transform: scale(1.08); }
  }
  /* 煙: 上に上がりつつ薄れる */
  .civ-smoke {
    fill: rgba(120, 120, 120, 0.55);
    animation: smokeRise 3200ms ease-out infinite;
    transform-origin: center;
  }
  @keyframes smokeRise {
    0%   { transform: translateY(0)   scale(0.7); opacity: 0;   }
    20%  { opacity: 0.5; }
    100% { transform: translateY(-40px) scale(1.6); opacity: 0; }
  }

  /* 刻文(甲骨文字風): 薄い茶色で地面に静的に並ぶ */
  #civ-glyphs text {
    fill: rgba(90, 70, 40, 0.4);
    font-family: serif;
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.05em;
  }
  /* === /Phase 5 === */

  /* === Phase 6 神化レイヤ ===
     2026-05-19: canonical (agent-a0f757c4e0184b57f) から移植 */
  #halo-ring {
    transform-origin: 295px 168px;
    transform-box: view-box;
    animation: haloSpin 45s linear infinite;
    opacity: 0;
    transition: opacity 1800ms ease, r 1800ms ease, stroke-opacity 1800ms ease;
    pointer-events: none;
  }
  @keyframes haloSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  #halo-ring.halo-explode {
    animation: haloSpin 45s linear infinite, haloExplode 1500ms ease-out forwards;
  }
  @keyframes haloExplode {
    0%   { r: 90; stroke-opacity: 0.7; stroke-width: 1.6; }
    40%  { stroke-opacity: 0.95; stroke-width: 2.2; }
    100% { r: 300; stroke-opacity: 0; stroke-width: 0.4; }
  }
  .deif-temple-layer { transition: opacity 1800ms ease; }
  .deif-temple-layer.hidden { opacity: 0; pointer-events: none; }
  #deif-temple-stage rect,
  #deif-temple-stage polygon { fill: #2a2622; stroke: none; }
  #deif-temple-stage .deif-flame {
    fill: #f3c155; opacity: 0.85;
    animation: deifFlameFlicker 420ms ease-in-out infinite alternate;
    filter: drop-shadow(0 0 2px rgba(243, 193, 85, 0.6));
  }
  @keyframes deifFlameFlicker {
    0%   { opacity: 0.55; transform: scale(0.92); }
    100% { opacity: 1;    transform: scale(1.08); }
  }
  #deif-temple-stage .deif-rays {
    fill: rgba(243, 218, 155, 0.18);
    animation: deifRaysBreathe 3600ms ease-in-out infinite;
  }
  @keyframes deifRaysBreathe {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
  }
  #deif-temple-stage .deif-star {
    fill: rgba(255, 240, 200, 0.9);
    animation: deifStarTwinkle 2800ms ease-in-out infinite alternate;
  }
  @keyframes deifStarTwinkle {
    0%   { opacity: 0.5; }
    100% { opacity: 1;   }
  }
  #deif-temple-stage .deif-cloud { fill: rgba(243, 218, 155, 0.18); }
  #deif-temple-stage .deif-cloud-thick { fill: rgba(243, 218, 155, 0.28); }
  /* === /Phase 6 === */


  /* === Phase 6: 神化 === */
  .phase6-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .deif-cat-label {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 14px 0 8px;
  }
  .deif-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
    color: var(--ink);
  }
  .deif-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .deif-card:disabled, .deif-card.insufficient { opacity: 0.45; cursor: default; }
  .deif-row-1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
  .deif-name { font-size: 1rem; color: var(--ink); letter-spacing: 0.04em; flex: 1; }
  .deif-count {
    font-family: var(--font-num);
    font-size: 1.1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 32px; text-align: right;
  }
  .deif-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .deif-row-2 { margin-top: 8px; display: flex; justify-content: flex-end; }
  .deif-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .deif-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .deif-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .deif-cost-locked {
    font-style: italic;
    color: var(--ink-faint);
    font-size: 0.85rem;
  }
  .deif-card.deif-card-locked {
    border-style: dashed;
    border-color: rgba(184, 136, 72, 0.32);
    background: transparent;
    opacity: 0.6;
  }
  .deif-cat-faith    { border-left: 2px solid #c89858; }
  .deif-cat-temple   { border-left: 2px solid #8a6a3a; }
  .deif-cat-divinity { border-left: 2px solid #b18055; }
  .deif-cat-release  { border-left: 2px solid #7d6a8a; }
  /* === /Phase 6 === */

  /* === Phase 7: ボタン製作 + Endings === */
  .phase7-section {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px dashed rgba(90, 84, 74, 0.18);
    animation: phase1Reveal 1800ms ease-out;
  }
  .bm-category-title {
    font-family: var(--font-ui);
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 18px 0 8px;
  }
  .bm-card {
    display: flex; flex-direction: column;
    width: 100%; text-align: left;
    margin-bottom: 8px; padding: 12px 14px;
    background: var(--paper);
    border: 1px solid rgba(90, 84, 74, 0.12);
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    font-family: var(--font-body);
  }
  .bm-card:hover:not(:disabled):not(.insufficient) {
    background: var(--bg-deep);
    border-color: var(--accent-soft);
  }
  .bm-card:disabled, .bm-card.insufficient { opacity: 0.45; cursor: default; }
  .bm-card.purchased { border-color: var(--accent-soft); }
  .bm-row-1 {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
  }
  .bm-name { font-size: 1rem; color: var(--ink); letter-spacing: 0.04em; flex: 1; }
  .bm-count {
    font-family: var(--font-num);
    font-size: 1rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    min-width: 24px; text-align: right;
  }
  .bm-desc {
    font-size: 0.82rem; color: var(--ink-soft);
    line-height: 1.6; margin-top: 4px;
    letter-spacing: 0.03em;
  }
  .bm-row-2 { margin-top: 8px; display: flex; justify-content: flex-end; }
  .bm-cost {
    font-family: var(--font-num);
    font-size: 0.95rem; color: var(--ink);
    letter-spacing: 0.02em;
  }
  .bm-cost::before { content: '⤳ '; color: var(--ink-faint); font-size: 0.85rem; }
  .bm-cost::after {
    content: var(--label-currency-suffix);
    font-family: var(--font-body);
    font-size: 0.7rem; color: var(--ink-faint);
    margin-left: 3px;
  }
  .bm-card:disabled .bm-cost,
  .bm-card.insufficient .bm-cost { color: var(--ink-faint); }

  /* 受け渡し: Ending 選択 */
  .bm-handoff-title {
    font-family: var(--font-ui);
    font-size: 0.78rem; color: var(--ink);
    letter-spacing: 0.4em; text-indent: 0.4em;
    margin: 26px 0 12px;
    text-align: center;
  }
  .ending-choice {
    display: block; width: 100%;
    margin: 10px 0; padding: 18px 16px;
    background: var(--paper);
    border: 1px solid var(--ink-faint);
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--ink);
    text-align: center;
    letter-spacing: 0.16em;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
  }
  .ending-choice:hover { background: var(--ink); color: var(--bg); }
  .ending-choice .e-numeral {
    font-family: var(--font-num);
    font-size: 0.85rem; color: var(--ink-faint);
    letter-spacing: 0.3em; display: block;
    margin-bottom: 6px;
  }
  .ending-choice .e-name {
    font-size: 1.05rem;
    letter-spacing: 0.36em; text-indent: 0.36em;
    display: block;
  }
  /* 各選択肢の説明文 — 静かに 1 行 */
  .ending-choice .e-desc {
    display: block;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--ink-faint);
    letter-spacing: 0.12em;
    font-style: italic;
  }
  .ending-choice:hover .e-numeral,
  .ending-choice:hover .e-desc { color: var(--bg); }

  /* 神聖(Ending 4)直行ボタン: handoff を経由せず、Phase 7 開始直後に出る特別ルート。
     金色のアクセントで「ふつうの渡し方ではない」 ことを示す。 */
  .holy-choice-wrap {
    margin: 18px 0 28px;
    padding: 14px 0;
    border-top: 1px solid rgba(196, 169, 106, 0.35);
    border-bottom: 1px solid rgba(196, 169, 106, 0.35);
  }
  .holy-choice-title {
    text-align: center;
    font-size: 0.78rem;
    color: rgba(196, 169, 106, 0.85);
    letter-spacing: 0.4em;
    font-style: italic;
    margin-bottom: 12px;
  }
  .ending-choice.holy-choice {
    border-left: 2px solid #c4a96a;
    background: rgba(196, 169, 106, 0.05);
    animation: holyChoiceGlow 3200ms ease-in-out infinite alternate;
  }
  @keyframes holyChoiceGlow {
    from { box-shadow: 0 0 0 rgba(196, 169, 106, 0); }
    to   { box-shadow: 0 0 16px rgba(196, 169, 106, 0.4); }
  }
  .ending-choice.holy-choice:hover {
    background: #c4a96a;
    color: #1a1612;
  }
  .ending-choice.holy-choice:hover .e-numeral,
  .ending-choice.holy-choice:hover .e-desc { color: #1a1612; }

  /* === ゲームクリア画面(Ending 4 神聖の末尾)===
     ending-overlay より z-index 高く、画面を完全に静的な「終」 で覆う。
     リスタートもシェアも出さない ─ ここで物語は完全に閉じる。
     装飾: 夜空の星 + 上下の細い金色の枠 + 中央に三日月のシンボル。
     深い夜の余韻と「物語の終わり」 にふさわしい荘厳さを演出する。 */
  .game-complete {
    position: fixed; inset: 0;
    /* 漆黒に近い夜空 + 中央にうっすら金の光をにじませる */
    background:
      radial-gradient(ellipse at center, rgba(196, 169, 106, 0.06) 0%, rgba(8, 6, 4, 0.96) 55%, rgba(4, 3, 2, 0.99) 100%);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    z-index: 300;
    opacity: 0;
    transition: opacity 3500ms ease;
    pointer-events: auto;
    overflow: hidden;
  }
  .game-complete.visible { opacity: 1; }
  /* 星: 画面全体にちらばる小さな点。ゆっくり瞬く(opacity をふわっと往復)。 */
  .game-complete .gc-stars {
    position: absolute; inset: 0;
    pointer-events: none;
  }
  .game-complete .gc-star {
    position: absolute;
    background: rgba(243, 218, 155, 0.85);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(243, 218, 155, 0.65);
    opacity: 0;
    animation: gcStarTwinkle 5200ms ease-in-out infinite;
  }
  @keyframes gcStarTwinkle {
    0%, 100% { opacity: 0.15; }
    50%      { opacity: 0.95; }
  }
  /* 上下の細い金色の枠 — 古い書物の縁取りのような印象 */
  .game-complete .gc-frame-top,
  .game-complete .gc-frame-bottom {
    position: absolute;
    left: 50%; transform: translateX(-50%);
    width: min(78%, 640px);
    height: 1px;
    background: linear-gradient(
      to right,
      rgba(243, 218, 155, 0) 0%,
      rgba(243, 218, 155, 0.5) 30%,
      rgba(243, 218, 155, 0.7) 50%,
      rgba(243, 218, 155, 0.5) 70%,
      rgba(243, 218, 155, 0) 100%
    );
    box-shadow: 0 0 12px rgba(243, 218, 155, 0.25);
  }
  .game-complete .gc-frame-top    { top: 12%; }
  .game-complete .gc-frame-bottom { bottom: 12%; }
  /* 中央の本文: 月のシンボル → タイトル → 短い区切り → サブ */
  .game-complete .gc-inner {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    z-index: 2;
    padding: 0 24px;
    max-width: 720px;
  }
  /* 三日月シンボル: ゆっくりフェードイン + ほのかなグロー */
  .game-complete .gc-symbol {
    width: 80px; height: 80px;
    margin-bottom: 36px;
    opacity: 0;
    filter: drop-shadow(0 0 14px rgba(243, 218, 155, 0.35));
    animation: gcSymbolIn 4200ms ease 1200ms forwards;
  }
  @keyframes gcSymbolIn {
    from { opacity: 0; transform: translateY(8px) scale(0.92); }
    to   { opacity: 0.92; transform: translateY(0) scale(1); }
  }
  .game-complete .gc-symbol svg { width: 100%; height: 100%; display: block; }
  .game-complete .gc-title {
    font-family: var(--font-body);
    font-size: clamp(1.5rem, 3.6vw, 2.1rem);
    /* 「よい夜を。」 は短い余韻を活かしたいので letter-spacing は控えめ */
    letter-spacing: 0.15em;
    /* 2026-05-20: 中央の金色光と被って読みづらいので白寄りに + 黒の影でコントラスト確保 */
    color: #fffaf0;
    text-align: center;
    text-shadow:
      0 0 4px rgba(0, 0, 0, 0.85),
      0 0 18px rgba(0, 0, 0, 0.65),
      0 0 32px rgba(243, 218, 155, 0.35);
    opacity: 0;
    animation: gcFadeIn 3600ms ease 2200ms forwards;
  }
  /* 区切り: 細い金色の縦線とドット */
  .game-complete .gc-divider {
    margin: 28px 0 24px;
    width: 1px; height: 36px;
    background: linear-gradient(to bottom,
      rgba(243, 218, 155, 0) 0%,
      rgba(243, 218, 155, 0.55) 50%,
      rgba(243, 218, 155, 0) 100%);
    position: relative;
    opacity: 0;
    animation: gcFadeIn 3600ms ease 3000ms forwards;
  }
  .game-complete .gc-divider::before,
  .game-complete .gc-divider::after {
    content: '';
    position: absolute;
    left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px;
    border-radius: 50%;
    background: rgba(243, 218, 155, 0.7);
    box-shadow: 0 0 6px rgba(243, 218, 155, 0.5);
  }
  .game-complete .gc-divider::before { top: -2px; }
  .game-complete .gc-divider::after  { bottom: -2px; }
  .game-complete .gc-sub {
    font-size: 0.9rem;
    /* 2026-05-20: 金色光と被って読みづらかったので白寄り + 黒影でコントラスト確保 */
    color: rgba(252, 240, 210, 0.92);
    letter-spacing: 0.32em;
    text-align: center;
    line-height: 1.9;
    text-shadow:
      0 0 4px rgba(0, 0, 0, 0.85),
      0 0 14px rgba(0, 0, 0, 0.55);
    opacity: 0;
    animation: gcFadeIn 4200ms ease 3800ms forwards;
  }
  /* Ending 4 のクレジット文 ─ サブの下にさらに小さく、 ゆっくり遅れて出現 */
  .game-complete .gc-credit {
    margin-top: 32px;
    font-size: 0.78rem;
    /* 同上:読みやすさ優先で白寄り + 黒影 */
    color: rgba(245, 230, 195, 0.78);
    letter-spacing: 0.4em;
    font-style: italic;
    text-align: center;
    text-shadow:
      0 0 4px rgba(0, 0, 0, 0.8),
      0 0 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    animation: gcFadeIn 4200ms ease 5400ms forwards;
  }
  @keyframes gcFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* === 開発者クレジット(ゲームクリア画面の末尾)=== */
  /* ending.4.credit の下にゆっくり追って出現する。 Thank you / X / 作者名 / 著作 */
  .game-complete .gc-author-block {
    margin-top: 36px;
    display: flex; flex-direction: column; align-items: center;
    gap: 6px;
    opacity: 0;
    animation: gcFadeIn 4200ms ease 7200ms forwards;
    color: rgba(243, 218, 155, 0.7);
    font-family: var(--font-body);
    text-align: center;
  }
  .game-complete .gc-author-thanks {
    font-size: 0.95rem;
    letter-spacing: 0.18em;
    color: rgba(255, 250, 240, 0.88);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
    margin-bottom: 6px;
  }
  .game-complete .gc-author-x {
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    display: inline-flex; align-items: baseline; gap: 0.6em;
  }
  .game-complete .gc-author-x-label {
    color: rgba(243, 218, 155, 0.55);
  }
  .game-complete .gc-author-x-handle {
    color: rgba(243, 218, 155, 0.92);
    text-decoration: none;
    border-bottom: 1px solid rgba(243, 218, 155, 0.4);
    padding-bottom: 1px;
    transition: color 0.3s, border-color 0.3s;
  }
  .game-complete .gc-author-x-handle:hover {
    color: #fffaf0;
    border-color: rgba(243, 218, 155, 0.85);
  }
  .game-complete .gc-author-name {
    margin-top: 8px;
    font-size: 0.78rem;
    letter-spacing: 0.24em;
    color: rgba(243, 218, 155, 0.65);
  }
  .game-complete .gc-author-rights {
    font-size: 0.68rem;
    letter-spacing: 0.3em;
    color: rgba(243, 218, 155, 0.4);
    margin-top: 4px;
  }

  /* === Ending 演出 overlay === */
  .ending-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: flex-start; flex-direction: column;
    z-index: 200;
    /* 2026-05-20: 中央寄せ(justify-content: center)だと、 要素が追加されるたび
       既存要素が上下に押し動かされて「カクついて見える」 (ユーザ指摘)。
       上から積む(flex-start)+ 大きな上余白で位置を固定し、 静かな出現に。 */
    padding: 14vh 20px 60px;
    opacity: 0;
    transition: opacity 2000ms ease, background 3000ms ease, color 3000ms ease;
    /* タイトル/クレジット/レガシー shop/restart/share が縦に積み上がると viewport を
       超えることがあるので、 はみ出し時にスクロールできるようにする(画面が小さいと
       シェアボタンが見切れて「出てこない」 ように見える問題への対策)。 */
    overflow-y: auto;
    overflow-x: hidden;
  }
  .ending-overlay.show { opacity: 1; }
  .ending-overlay.dark   { background: #0d0b08; color: #e6dfd2; }
  .ending-overlay.bright { background: #fbf8f0; color: #1a1612; }
  .ending-overlay .e-line {
    font-family: var(--font-body);
    font-size: 1.15rem;
    color: inherit;
    line-height: 2.2;
    letter-spacing: 0.16em;
    text-align: center;
    max-width: 540px;
    opacity: 0;
    transition: opacity 1600ms ease;
    /* 2026-05-20: flex の流れに置くと clearLines → addLine で
       「新旧 line が縦に並んで上に詰まる」 動きが見える(ユーザ指摘)。
       絶対位置で画面上部寄りに固定して、 同じ場所でクロスフェードする。 */
    position: absolute;
    left: 50%;
    top: 30vh;
    transform: translateX(-50%);
    width: 90%;
    pointer-events: none;
    will-change: opacity;
  }
  .ending-overlay .e-line.visible { opacity: 1; }
  .ending-overlay .e-title {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: inherit;
    letter-spacing: 0.5em;
    text-indent: 0.5em;
    margin-top: 28px;
    opacity: 0;
    transition: opacity 1600ms ease;
  }
  .ending-overlay .e-title.visible { opacity: 1; }
  .ending-overlay .e-credit {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: inherit;
    letter-spacing: 0.18em;
    margin-top: 24px;
    opacity: 0;
    transition: opacity 2000ms ease;
  }
  .ending-overlay .e-credit.visible { opacity: 1; }
  .ending-restart {
    margin-top: 60px; padding: 12px 36px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: transparent; color: inherit;
    border: 1px solid currentColor;
    cursor: pointer;
    letter-spacing: 0.36em; text-indent: 0.36em;
    opacity: 0;
    transition: opacity 1600ms ease, background 0.3s, color 0.3s;
  }
  .ending-restart.visible { opacity: 1; }
  .ending-overlay.dark .ending-restart:hover   { background: #e6dfd2; color: #0d0b08; }
  .ending-overlay.bright .ending-restart:hover { background: #1a1612; color: #fbf8f0; }
  .ending-overlay .ending-restart:hover { background: var(--ink); color: var(--bg); }
  /* 2 段階タップ確認: 1 回目クリック後の「もう一度タップして確認」状態 */
  .ending-restart.confirm-stage {
    border-color: #b88848;
    color: #b88848;
    animation: confirm-pulse 0.8s ease-in-out infinite alternate;
  }
  @keyframes confirm-pulse {
    from { opacity: 0.75; }
    to   { opacity: 1; }
  }

  /* シェア導線(SNS 拡散)— 物語の「渡す」 動作をプレイヤーが SNS で次の誰かに渡す二重化。
     継承(Ending 1)の末尾に「見出し +(X / LINE / コピー / その他)」 を縦並びで表示。 */
  .ending-share-wrap {
    margin-top: 22px;
    display: flex; flex-direction: column; align-items: center;
    width: min(80%, 540px);
    opacity: 0;
    transition: opacity 1800ms ease;
  }
  .ending-share-wrap.visible { opacity: 1; }
  .ending-share-title {
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--ink-faint);
    letter-spacing: 0.3em;
    margin-bottom: 12px;
    text-align: center;
  }
  .ending-share-group {
    display: flex; flex-direction: column; gap: 8px;
    width: 100%;
    align-items: stretch;
  }
  .ending-share {
    padding: 10px 24px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    background: transparent; color: inherit;
    border: 1px dashed currentColor;
    cursor: pointer;
    letter-spacing: 0.24em; text-indent: 0.24em;
    opacity: 0.75;
    transition: opacity 0.3s, background 0.3s, color 0.3s, border-style 0.3s;
    text-align: center;
  }
  .ending-share:hover:not(:disabled) { opacity: 1; border-style: solid; }
  .ending-share:disabled { cursor: default; opacity: 0.5; }
  .ending-overlay.dark .ending-share:hover:not(:disabled)   { background: #e6dfd2; color: #0d0b08; }
  .ending-overlay.bright .ending-share:hover:not(:disabled) { background: #1a1612; color: #fbf8f0; }
  .ending-overlay .ending-share:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
  /* === 永続レガシー(100 万円 + 引き継ぎ 3 種)の Ending 内 UI === */
  /* 「100 万円を、手にした。」 → 引き継ぎ 3 種から購入、 という流れを credit と
     restart の間に挿入。トーンは静かな金色アクセント、 控えめな枠線。 */
  .ending-overlay .legacy-gain {
    margin-top: 32px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    letter-spacing: 0.36em;
    color: rgba(243, 218, 155, 0.88);
    text-shadow: 0 0 14px rgba(243, 218, 155, 0.2);
    text-align: center;
    opacity: 0;
    transition: opacity 2200ms ease;
  }
  .ending-overlay .legacy-gain.visible { opacity: 1; }
  .ending-overlay .legacy-shop {
    margin-top: 22px;
    width: min(80%, 540px);
    display: flex; flex-direction: column;
    gap: 10px;
    opacity: 0;
    transition: opacity 2200ms ease;
    align-items: stretch;
  }
  .ending-overlay .legacy-shop.visible { opacity: 1; }
  .ending-overlay .legacy-shop-title {
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-soft);
    letter-spacing: 0.32em;
    margin-bottom: 4px;
  }
  .ending-overlay .legacy-shop-sub {
    text-align: center;
    font-size: 0.74rem;
    color: var(--ink-faint);
    letter-spacing: 0.24em;
    font-style: italic;
    margin-bottom: 10px;
  }
  .ending-overlay .legacy-have {
    text-align: center;
    font-size: 0.72rem;
    color: rgba(243, 218, 155, 0.7);
    letter-spacing: 0.24em;
    margin-bottom: 14px;
  }
  .ending-overlay .legacy-buy {
    background: transparent;
    color: inherit;
    border: 1px solid rgba(196, 169, 106, 0.45);
    padding: 12px 18px;
    font-family: var(--font-body);
    font-size: 0.86rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.3s, color 0.3s, border-color 0.3s, opacity 0.3s;
    letter-spacing: 0.1em;
    display: flex; flex-direction: column; gap: 4px;
  }
  .ending-overlay .legacy-buy:hover:not(:disabled) {
    background: rgba(196, 169, 106, 0.92);
    color: #1a1612;
    border-color: rgba(196, 169, 106, 1);
  }
  .ending-overlay .legacy-buy:disabled { cursor: default; opacity: 0.4; }
  /* 旧クラス互換(現状は purchased-pending / purchased-locked が主) */
  .ending-overlay .legacy-buy.purchased {
    border-style: dashed;
    opacity: 0.55;
  }
  /* 今周で選択中: 金色背景でアクティブ状態を強調(= ホバー時と同じ見た目) */
  .ending-overlay .legacy-buy.purchased-pending {
    background: rgba(196, 169, 106, 0.92);
    color: #1a1612;
    border-color: rgba(196, 169, 106, 1);
    border-style: solid;
    opacity: 1;
  }
  .ending-overlay .legacy-buy.purchased-pending .lb-cost,
  .ending-overlay .legacy-buy.purchased-pending .lb-desc { color: #1a1612; }
  /* 過去周で確定済み: グレーアウトして再取得不可であることを明示 */
  .ending-overlay .legacy-buy.purchased-locked {
    background: rgba(80, 76, 70, 0.15);
    color: rgba(230, 223, 210, 0.45);
    border-color: rgba(120, 115, 100, 0.35);
    border-style: dashed;
    opacity: 0.45;
    cursor: not-allowed;
  }
  .ending-overlay .legacy-buy.purchased-locked .lb-cost,
  .ending-overlay .legacy-buy.purchased-locked .lb-desc {
    color: rgba(180, 173, 160, 0.55);
  }
  .ending-overlay .legacy-buy .lb-row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px;
  }
  .ending-overlay .legacy-buy .lb-name {
    font-size: 0.92rem;
    letter-spacing: 0.18em;
  }
  .ending-overlay .legacy-buy .lb-cost {
    font-size: 0.7rem;
    color: rgba(243, 218, 155, 0.75);
    letter-spacing: 0.12em;
    white-space: nowrap;
  }
  .ending-overlay .legacy-buy.purchased .lb-cost { color: var(--ink-faint); }
  .ending-overlay .legacy-buy .lb-desc {
    font-size: 0.72rem;
    color: var(--ink-faint);
    letter-spacing: 0.08em;
    font-style: italic;
  }
  .ending-overlay .legacy-buy:hover:not(:disabled) .lb-cost,
  .ending-overlay .legacy-buy:hover:not(:disabled) .lb-desc { color: #1a1612; }

  /* Ending 2: 粉砕粒子 */
  .e-shatter {
    /* 2026-05-20: ending-overlay は flex-start で上から積むため、 e-shatter を
       flex の流れに置くと、 line 削除 → ボタン出現で「上にせり上がる」 動きが
       目立つ。 absolute で画面中央に固定して、 配置の動きを止める。 */
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 220px; height: 220px;
    pointer-events: none;
  }
  .e-shatter .frag {
    position: absolute;
    width: 6px; height: 6px;
    background: currentColor;
    border-radius: 50%;
    left: 50%; top: 50%;
    opacity: 0;
    animation: shatterOut 2400ms ease-out forwards;
  }
  @keyframes shatterOut {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.6); }
  }
  /* 中心の青いボタン(粉砕前) */
  .e-button-core {
    position: absolute; left: 50%; top: 50%;
    width: 56px; height: 56px;
    margin-left: -28px; margin-top: -28px;
    background: radial-gradient(circle at 35% 30%, #7aa6c4, #2d4d6e 70%);
    border-radius: 50%;
    box-shadow: 0 0 22px rgba(122, 166, 196, 0.6);
    animation: coreShatter 2400ms ease-in forwards;
  }
  @keyframes coreShatter {
    0%   { opacity: 1; transform: scale(1); }
    60%  { opacity: 1; transform: scale(1.18); }
    70%  { opacity: 0.8; transform: scale(0.9); filter: blur(2px); }
    100% { opacity: 0; transform: scale(0.4); filter: blur(6px); }
  }

  /* Ending 3: 円環(メビウス風) */
  .e-mobius {
    width: 240px; height: 240px;
    margin: 16px 0;
    animation: mobiusSpin 14s linear infinite;
  }
  @keyframes mobiusSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  .e-mobius circle, .e-mobius path {
    fill: none; stroke: currentColor;
    stroke-width: 1.2;
    opacity: 0.85;
  }

  /* Ending 3: タイムループ演出(時計逆回転 → 画面が円形に閉じる) */
  .e-time-clock {
    /* 2026-05-25: fixed に変更。スクロール可能 overlay 内で top:50% がズレる問題を修正 */
    position: fixed;
    left: 50%; top: 50%;
    width: 200px; height: 200px;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    transition: opacity 2400ms ease, transform 2400ms ease;
  }
  .e-time-clock.visible { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  .e-time-clock.fading-out { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  .e-time-clock circle, .e-time-clock line, .e-time-clock path {
    fill: none; stroke: currentColor;
    stroke-width: 0.8;
    stroke-linecap: round;
  }
  /* 反時計回り 12 秒で 1 周(短針) */
  .e-time-clock .hand-hour {
    transform-origin: 100px 100px;
    animation: clockReverseHour 12s linear infinite;
  }
  /* 反時計回り 4 秒で 1 周(長針) */
  .e-time-clock .hand-min {
    transform-origin: 100px 100px;
    animation: clockReverseMin 4s linear infinite;
  }
  @keyframes clockReverseHour {
    from { transform: rotate(0deg);  }
    to   { transform: rotate(-360deg); }
  }
  @keyframes clockReverseMin {
    from { transform: rotate(0deg);  }
    to   { transform: rotate(-360deg); }
  }
  /* 画面が円形に閉じる: 黒い円が中央から外へ広がる(時間が閉じる象徴) */
  .e-circle-close {
    /* 2026-05-25: fixed に変更。absolute + scale(60) でスクロールバーが発生する問題を修正。
       ending-overlay は overflow-y:auto のため absolute+top:50% がスクロール高の50%に
       ズレてしまい、scale(60)=2400px が overflow を引き起こしていた。 */
    position: fixed;
    left: 50%; top: 50%;
    width: 40px; height: 40px;
    margin-left: -20px; margin-top: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(8,6,4,0.0) 30%, rgba(8,6,4,0.96) 70%);
    box-shadow: 0 0 0 9999px transparent;
    opacity: 0;
    animation: circleClose 4000ms ease-in forwards;
    pointer-events: none;
  }
  @keyframes circleClose {
    0%   { opacity: 0; transform: scale(0.4); box-shadow: 0 0 0 0 rgba(8,6,4,0.0); }
    20%  { opacity: 1; }
    100% { opacity: 1; transform: scale(60); box-shadow: 0 0 0 9999px rgba(8,6,4,0.96); }
  }

  /* Ending 2: 破壊後の沈黙の波紋(中央から外へ広がる薄い円) */
  .e-silence-ring {
    position: absolute;
    left: 50%; top: 50%;
    width: 20px; height: 20px;
    margin-left: -10px; margin-top: -10px;
    border-radius: 50%;
    border: 1px solid currentColor;
    opacity: 0;
    animation: silenceRing 3600ms ease-out forwards;
    pointer-events: none;
  }
  @keyframes silenceRing {
    0%   { opacity: 0; transform: scale(0.5); }
    25%  { opacity: 0.55; }
    100% { opacity: 0; transform: scale(28); }
  }

  /* ============ Phase 7: ボタン本体の SVG 化 ============ */
  /* ステージ中央に「5億年ボタン」が段階的に組み立てられる */
  #the-button {
    opacity: 0;
    transition: opacity 1.8s ease, transform 1.2s cubic-bezier(0.2,0.8,0.4,1);
    transform-origin: 295px 250px;
  }
  #the-button.visible { opacity: 1; }
  /* 概念: 白い四角の枠だけ(opacity 0.3) */
  #the-button .tb-frame {
    stroke: var(--ink);
    fill: none;
    stroke-width: 0.7;
    opacity: 0;
    transition: opacity 1.4s ease, stroke-width 1.4s ease;
  }
  #the-button.stage-concept .tb-frame,
  #the-button.stage-prototype .tb-frame,
  #the-button.stage-activation .tb-frame,
  #the-button.stage-naming .tb-frame,
  #the-button.stage-complete .tb-frame {
    opacity: 0.32;
  }
  #the-button.stage-naming .tb-frame,
  #the-button.stage-complete .tb-frame { opacity: 0.5; stroke-width: 0.9; }
  /* 試作: 内側に円が現れる */
  /* 五億年ボタン本体の「青」: 深夜の青(物語上「青いボタン」 と複数箇所で言及) */
  #the-button .tb-circle {
    fill: none;
    stroke: var(--ink-soft);
    stroke-width: 0.9;
    opacity: 0;
    transition: opacity 1.4s ease, stroke-width 1.4s ease, fill 2s ease;
  }
  #the-button.stage-prototype .tb-circle { opacity: 0.55; stroke: #5a7d9c; }
  #the-button.stage-activation .tb-circle,
  #the-button.stage-naming .tb-circle,
  #the-button.stage-complete .tb-circle {
    opacity: 0.95;
    stroke: #3a5a7c;
    stroke-width: 1.1;
    fill: rgba(58, 90, 124, 0.18);
  }
  /* 起動: 円が光る — 青のグロー */
  #the-button .tb-glow {
    fill: rgba(90, 125, 160, 0.55);
    opacity: 0;
    filter: blur(8px);
    transition: opacity 2.2s ease;
  }
  #the-button.stage-activation .tb-glow,
  #the-button.stage-naming .tb-glow,
  #the-button.stage-complete .tb-glow {
    opacity: 0.7;
    animation: theButtonGlow 4.8s ease-in-out infinite alternate;
  }
  @keyframes theButtonGlow {
    from { opacity: 0.45; filter: blur(7px); }
    to   { opacity: 0.85; filter: blur(11px); }
  }
  /* 命名: ボタン上に「5億年」の文字 */
  #the-button .tb-label {
    font-family: var(--font-body);
    font-size: 5.2px;
    fill: var(--ink);
    text-anchor: middle;
    letter-spacing: 0.2em;
    opacity: 0;
    transition: opacity 1.6s ease;
  }
  #the-button.stage-naming .tb-label,
  #the-button.stage-complete .tb-label { opacity: 0.85; }
  /* 完成: 影 */
  #the-button .tb-shadow {
    fill: rgba(20,18,14,0.18);
    opacity: 0;
    transition: opacity 1.6s ease;
  }
  #the-button.stage-complete .tb-shadow { opacity: 1; }

  /* 受け渡しシーン: 主人公の手前にボタンが移動 */
  #the-button.placed {
    transform: translate(0, 38px) scale(0.6);
  }
  /* 渡された後: 青年側に */
  #the-button.handed {
    transform: translate(110px, 38px) scale(0.6);
  }

  /* ============ Phase 7: 工房シーン(浮遊する小さなシンボル) ============ */
  #workshop-items {
    opacity: 0;
    transition: opacity 1.8s ease;
  }
  #workshop-items.visible { opacity: 1; }
  #workshop-items .ws-item {
    opacity: 0;
    transition: opacity 1.6s ease;
    transform-origin: center;
    transform-box: fill-box;
  }
  #workshop-items .ws-item.shown { opacity: 0.55; }
  #workshop-items .ws-tool {
    animation: workshopFloat 7.5s ease-in-out infinite alternate;
  }
  #workshop-items .ws-blueprint {
    animation: workshopFloat 9s ease-in-out infinite alternate;
    animation-delay: 1.5s;
  }
  #workshop-items .ws-part {
    animation: workshopFloat 8.2s ease-in-out infinite alternate;
    animation-delay: 0.6s;
  }
  @keyframes workshopFloat {
    from { transform: translateY(-2px) rotate(-2deg); }
    to   { transform: translateY(3px) rotate(2deg); }
  }
  #workshop-items .ws-item path,
  #workshop-items .ws-item rect,
  #workshop-items .ws-item circle,
  #workshop-items .ws-item line {
    stroke: var(--ink-soft);
    fill: none;
    stroke-width: 0.6;
  }
  #workshop-items .ws-blueprint rect { fill: rgba(90,84,74,0.05); }
  #workshop-items .ws-part circle { fill: rgba(184,136,72,0.08); }

  /* ============ Phase 7: 青年シルエットの出現 ============ */
  #youth-figure {
    opacity: 0;
    /* 右端からスライドインする */
    transform: translate(620px, 0);
    transition: transform 2s cubic-bezier(0.2,0.8,0.4,1), opacity 1.4s ease;
  }
  #youth-figure.appearing {
    opacity: 1;
    transform: translate(380px, 0);
  }
  #youth-figure.placed {
    transform: translate(360px, 0);
  }
  #youth-figure circle, #youth-figure rect {
    fill: var(--silhouette);
  }
  #youth-figure .youth-inner {
    transform: scale(0.72); /* 主人公(0.85)より若々しい */
    transform-origin: center bottom;
  }
  #youth-figure.walking .youth-inner {
    animation: youthWalk 0.7s ease-in-out infinite alternate;
  }
  @keyframes youthWalk {
    from { transform: scale(0.72) translateY(0); }
    to   { transform: scale(0.72) translateY(-1.5px); }
  }

  /* 主人公がフェードアウト(handoff 後) */
  #silhouette.faded-out {
    transition: opacity 2s ease;
    opacity: 0;
  }

  /* Ending overlay 全体フェードアウト: 神聖の最後にゲームクリア画面へ遷移する際、
     overlay の中身が下に残らないよう全体を消す。3 秒かけてゆっくり。 */
  .ending-overlay.fading-out {
    opacity: 0 !important;
    transition: opacity 3000ms ease;
    pointer-events: none;
  }

  /* ============ Phase 7: Ending 1 専用 — 白フラッシュ + 余韻 ============ */
  /* 白フラッシュは e-flash(GPU レイヤー化済み)に任せ、ending-overlay 自体の
     background は dark のまま動かさない(背景 transition は大画面で CPU 重い)。
     これで白 → dark への戻りもカクつかずに滑らかになる。 */
  .e-flash {
    position: absolute; inset: 0;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    /* will-change で GPU レイヤー化、background transition の代わりに opacity だけで遷移 */
    will-change: opacity;
    transform: translateZ(0);
    /* 8 秒で white peak → 余韻 → フェードアウトしてテキストが見える状態に戻る */
    animation: endingFlash 8000ms ease-out forwards;
    z-index: 0; /* テキスト群より下に */
  }
  @keyframes endingFlash {
    0%   { opacity: 0; }
    8%   { opacity: 1; }
    62%  { opacity: 1; }
    100% { opacity: 0; }
  }

  /* ============ Phase 7: Ending 3 — 時間停止演出 ============ */
  .ending-overlay.frozen-time .e-freeze-stage {
    /* 2026-05-20: ending-overlay は flex-start なので、 line 削除 → freeze-stage 出現で
       上にせり上がる動きが目立つ(ユーザ指摘)。 absolute で画面中央に固定して動かない。 */
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 360px; height: 240px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2000ms ease;
  }
  .ending-overlay.frozen-time .e-freeze-stage.visible    { opacity: 1; }
  .ending-overlay.frozen-time .e-freeze-stage.fading-out { opacity: 0; }
  .ending-overlay.frozen-time .e-freeze-stage::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 60%, rgba(255,255,255,0.04), transparent 70%);
  }
  .e-freeze-figure {
    position: absolute;
    top: 30px;
    width: 22px; height: 130px;
  }
  .e-freeze-figure.elder { left: 130px; }
  .e-freeze-figure.youth { left: 220px; transform: scale(0.85); transform-origin: bottom center; }
  .e-freeze-figure .head {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: currentColor;
    margin: 0 auto;
    opacity: 0.8;
  }
  .e-freeze-figure .body {
    width: 14px; height: 116px;
    border-radius: 4px;
    background: currentColor;
    margin: 2px auto 0;
    opacity: 0.8;
  }
  .e-freeze-particle {
    position: absolute;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    /* 完全に静止(時間停止) */
  }

  /* ============ Phase 7: Ending 4 — メタ(第四の壁) ============ */
  .ending-overlay.meta {
    background: #f5f1e6;
    color: #1a1612;
    align-items: stretch;
    justify-content: flex-start;
    padding: 80px 60px;
    overflow: auto;
  }
  .ending-overlay.meta .e-meta-page {
    max-width: 620px;
    margin: 0 auto;
    font-family: var(--font-body);
    line-height: 2.4;
    letter-spacing: 0.08em;
    color: #1a1612;
  }
  .ending-overlay.meta .e-meta-line {
    font-size: 1.18rem;
    margin-bottom: 1.8em;
    opacity: 0;
    transition: opacity 2s ease;
  }
  .ending-overlay.meta .e-meta-line.visible { opacity: 1; }
  .ending-overlay.meta .e-meta-divider {
    margin: 1em auto;
    width: 30%;
    border-top: 1px solid rgba(26,22,18,0.3);
    opacity: 0;
    transition: opacity 2s ease;
  }
  .ending-overlay.meta .e-meta-divider.visible { opacity: 1; }
  .ending-overlay.meta .e-meta-stage-note {
    font-style: italic;
    font-size: 0.92rem;
    color: rgba(26,22,18,0.55);
    text-align: center;
    margin-bottom: 1.6em;
    opacity: 0;
    transition: opacity 2s ease;
  }
  .ending-overlay.meta .e-meta-stage-note.visible { opacity: 1; }
  .ending-overlay.meta .e-title,
  .ending-overlay.meta .e-credit {
    text-align: center;
  }
  .ending-overlay.meta .ending-restart {
    align-self: center;
  }

  /* 画面右上のボタン群は audio-toggle(♪) → reset → lang の順で右から左に
     並べる。 audio-toggle は最も右(right:20px, 幅 32px)、 reset はその左、
     lang はさらに左。 サイズは reset/lang ともパディング込みで概ね 56px 幅。 */
  .lang-button {
    position: fixed; top: 16px; right: 140px;
    padding: 6px 14px;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    background: var(--bg);
    border: 1px solid var(--ink-faint);
    color: var(--ink-faint);
    cursor: pointer;
    letter-spacing: 0.3em; text-indent: 0.3em;
    transition: color 0.2s, border-color 0.2s;
    z-index: 50;
  }
  .lang-button:hover { color: var(--ink); border-color: var(--ink); }
  .lang-menu {
    position: fixed; top: 50px; right: 140px;
    background: var(--bg);
    border: 1px solid var(--ink-faint);
    box-shadow: 0 4px 14px rgba(20,18,14,0.08);
    padding: 6px 0;
    min-width: 140px;
    z-index: 51;
  }
  .lang-menu[hidden] { display: none; }
  .lang-menu button {
    display: block; width: 100%;
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    background: transparent;
    border: none;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    letter-spacing: 0.04em;
  }
  .lang-menu button:hover { background: var(--paper); }
  .lang-menu button.active { color: var(--accent); }
  .lang-menu button.active::before { content: '✓ '; color: var(--accent); }

  .reset-button {
    /* audio-toggle(♪、 right:20px・幅32px) の左に並ぶ。 lang-button の右、
       audio-toggle の左 という配置で、 3 つのコントロールが横一列に。 */
    position: fixed; top: 16px; right: 68px;
    padding: 6px 14px;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    background: var(--bg);
    border: 1px solid var(--ink-faint);
    color: var(--ink-faint);
    cursor: pointer;
    opacity: 0.4; z-index: 20;
    letter-spacing: 0.3em;
    transition: opacity 0.2s;
  }
  .reset-button:hover { opacity: 1; }

  /* ============ MOBILE ============ */
  @media (max-width: 800px) {
    .container {
      grid-template-columns: 1fr;
      grid-template-rows: auto 1fr auto;
      grid-template-areas:
        "header"
        "main"
        "tabs";
      padding: 16px 18px 0;
      gap: 12px;
    }

    .stage, .panel, .log {
      grid-area: main;
      display: none;
      min-height: 0;
      height: 100%;
    }
    .stage.tab-active { display: flex; }
    .panel.tab-active {
      display: flex;
      overflow-y: scroll; /* iOS は auto より scroll が確実にタッチスクロールする */
    }
    .log.tab-active {
      display: block;
      overflow-y: scroll;
      padding-top: 8px;
      border-top: none;
    }
    .log.tab-active::before { display: none; }

    .tab-nav {
      grid-area: tabs;
      display: flex;
      background: var(--bg);
      border-top: 1px solid rgba(90, 84, 74, 0.2);
      position: relative;
      z-index: 5;
      /* iPhone のホームバー(ジェスチャ領域)を避ける */
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .tab-button {
      flex: 1;
      background: transparent;
      border: none;
      padding: 16px 0 18px;
      font-family: var(--font-body);
      font-size: 0.95rem;
      letter-spacing: 0.3em; text-indent: 0.3em;
      color: var(--ink-faint);
      cursor: pointer;
      position: relative;
      transition: color 0.2s;
      user-select: none;
    }
    .tab-button.active { color: var(--ink); }
    .tab-button.active::before {
      content: '';
      position: absolute; top: 0; left: 30%; right: 30%;
      height: 1.5px; background: var(--accent);
    }
    .tab-button.has-unread::after {
      content: '';
      position: absolute;
      top: 14px; right: calc(50% - 32px);
      width: 5px; height: 5px;
      background: var(--accent); border-radius: 50%;
      animation: pulse 2s ease-in-out infinite;
    }
    @keyframes pulse {
      0%, 100% { opacity: 0.6; }
      50% { opacity: 1; }
    }

    .currency-value { font-size: 2.8rem; }
    .panel { padding-right: 0; }
    .phase-progress { max-width: 100%; }

    /* モバイル: audio-toggle は右端 (right:14px・幅32px) のままなので、
       reset と lang はその左に順に並べる。 */
    .audio-toggle  { top: 14px; right: 14px; }
    .audio-panel   { top: 54px; right: 14px; }
    .reset-button  { top: 14px; right: 60px; }
    .lang-button   { top: 14px; right: 128px; }
    .lang-menu     { top: 46px; right: 128px; }
    /* Phase ラベルがヘッダ右上のボタン群(audio + reset + lang 計 ~210px)に
       重ならないよう、 右側に余白を確保する。 */
    .phase-label { padding-right: 220px; }

    .floating-narration {
      font-size: 0.88rem;
      max-width: 98%;
      top: calc(5% + var(--stack, 0) * 30px);
      letter-spacing: 0.03em;
    }
    .floating-narration.event { font-size: 0.95rem; }
  }

  /* ============ OPENING SCENE(初回時の言語選択を兼ねる)============ */
  .opening {
    position: fixed; inset: 0;
    z-index: 1000;
    background: var(--bg);
    background-image:
      radial-gradient(ellipse at 50% 38%, rgba(184,136,72,0.10), transparent 60%),
      radial-gradient(ellipse at 50% 80%, rgba(184,136,72,0.05), transparent 50%);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px;
    overflow: hidden;
    /* opacity 1 を固定し、 OP が透明で背後の Phase 0 が透けて見えるのを防ぐ。
       挨拶ボタンや silhouette の演出は個別の animation で実現 */
    opacity: 1;
  }
  .opening[hidden] { display: none; }
  @keyframes openingBgIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  .opening.fading-out {
    animation: openingFadeOut 1500ms ease-in forwards;
    pointer-events: none;
  }
  @keyframes openingFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
  }
  /* 紙質ノイズは body から透けて見えるので追加不要 */

  /* 前任者のシルエット(本編より少し奥) */
  .opening-silhouette {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 90%; height: 90%;
    max-width: 560px;
    pointer-events: none;
    opacity: 0;
    animation: openingSilIn 2400ms 400ms ease-out forwards;
  }
  @keyframes openingSilIn {
    to { opacity: 0.42; }
  }
  .opening-silhouette circle, .opening-silhouette rect {
    fill: var(--silhouette);
  }

  /* 挨拶ボタン群 */
  .opening-greetings {
    position: relative; z-index: 2;
    display: flex; flex-direction: column;
    gap: 18px;
    align-items: center;
  }
  .greeting {
    background: transparent; border: none;
    color: var(--ink);
    cursor: pointer;
    padding: 10px 28px;
    letter-spacing: 0.06em;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.6s ease, color 0.5s ease, transform 0.6s ease;
    text-shadow:
      0 0 24px var(--bg),
      0 0 14px var(--bg),
      0 0 6px var(--bg);
    animation: greetingIn 1200ms ease-out forwards;
  }
  @keyframes greetingIn {
    to { opacity: 0.88; transform: translateY(0); }
  }
  /* 各挨拶に固有のフォントとタイミングを与える(アニメーションでフェードイン) */
  .greeting[data-lang="ja"] { animation-delay: 1100ms; font-size: 1.6rem; font-family: 'Shippori Mincho', serif; }
  .greeting[data-lang="en"] { animation-delay: 1500ms; font-size: 1.7rem; font-family: 'EB Garamond', 'Cormorant Garamond', Georgia, serif; font-style: italic; }
  .greeting[data-lang="zh"] { animation-delay: 1900ms; font-size: 1.6rem; font-family: 'Noto Serif SC', serif; }
  .greeting[data-lang="fr"] { animation-delay: 2300ms; font-size: 1.55rem; font-family: 'EB Garamond', 'Cormorant Garamond', Georgia, serif; font-style: italic; }
  .greeting[data-lang="ko"] { animation-delay: 2700ms; font-size: 1.5rem; font-family: 'Noto Serif KR', serif; }
  .greeting:hover, .greeting:focus-visible {
    color: var(--accent);
    outline: none;
    transform: translateY(-1px);
  }
  /* 選択後の状態 */
  .opening.selected .greeting {
    opacity: 0;
    pointer-events: none;
  }
  .opening.selected .greeting.selected {
    opacity: 1;
    color: var(--accent);
    transition: transform 1500ms ease-out, color 800ms ease-out, opacity 800ms ease-out;
  }

  /* 歓迎メッセージ(言語選択後の旧実装、現在は未使用) */
  .opening-message {
    position: relative; z-index: 2;
    margin-top: 36px;
    max-width: 580px;
    font-family: var(--font-body);
    font-size: 1.05rem; color: var(--ink-soft);
    letter-spacing: 0.05em;
    line-height: 1.9;
    text-align: center;
    opacity: 0;
    transition: opacity 1500ms ease-in;
    white-space: pre-line;
  }
  .opening-message.visible { opacity: 1; }

  /* 対話シーケンスの各行(浮かんでは消える)
     シルエットの頭は viewport 35% 付近、
     その少し上に配置して「シルエットが喋っている」感を保つ。
     1〜3行の長さでも頭と被らない */
  .opening-line {
    position: absolute;
    left: 50%; top: 22%;
    transform: translate(-50%, 0);
    z-index: 3;
    font-family: var(--font-body);
    font-size: 1.05rem; color: var(--ink);
    letter-spacing: 0.05em;
    line-height: 1.95;
    text-align: center;
    max-width: 620px;
    width: calc(100% - 64px);
    pointer-events: none;
    text-shadow:
      0 0 22px var(--bg),
      0 0 12px var(--bg),
      0 0 6px var(--bg);
    animation: openingLineCycle 5800ms ease-in-out forwards;
  }
  @keyframes openingLineCycle {
    0%   { opacity: 0; transform: translate(-50%, 12px); filter: blur(3px); }
    16%  { opacity: 0.95; transform: translate(-50%, 0); filter: blur(0); }
    72%  { opacity: 0.95; transform: translate(-50%, 0); filter: blur(0); }
    100% { opacity: 0; transform: translate(-50%, -14px); filter: blur(2px); }
  }
  .opening-line em {
    font-style: normal;
    color: var(--accent);
    letter-spacing: 0.15em;
    padding: 0 2px;
    font-weight: 500;
  }

  /* 「押す」 ボタン: 5億年ボタンを模した円形(本体と同じ「青」 で統一)
     主人公シルエットと縦に重ならないよう画面下部に配置 */
  .opening-press-button {
    position: absolute;
    left: 50%; top: 85%;
    transform: translate(-50%, -50%) scale(0.85);
    z-index: 4;
    width: 132px; height: 132px;
    border-radius: 50%;
    /* 紙色背景で視認性確保(以前は rgba(...,0.10) でほぼ透明だったため
       「ボタンが見えなくて押せない」 と感じる UX バグがあった) */
    background: var(--paper);
    border: 1px solid #3a5a7c;
    box-shadow:
      0 4px 18px rgba(20, 18, 14, 0.10),
      0 0 32px rgba(90, 125, 160, 0.35),
      inset 0 -4px 10px rgba(0, 0, 0, 0.05),
      inset 0 4px 10px rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 1.05rem; color: #3a5a7c;
    letter-spacing: 0.3em; text-indent: 0.3em;
    opacity: 0;
    animation: openingPressIn 2000ms 200ms ease-out forwards;
    transition: background 0.3s ease, color 0.3s ease, transform 0.4s ease, box-shadow 0.4s ease;
  }
  @keyframes openingPressIn {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
    60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
  .opening-press-button:hover:not(:disabled) {
    background: rgba(90, 125, 160, 0.22);
    box-shadow:
      0 4px 22px rgba(20, 18, 14, 0.15),
      0 0 44px rgba(90, 125, 160, 0.55),
      inset 0 -4px 10px rgba(0, 0, 0, 0.05),
      inset 0 4px 10px rgba(255, 255, 255, 0.4);
  }
  .opening-press-button.pressed {
    background: #3a5a7c;
    color: var(--bg);
    transform: translate(-50%, -50%) scale(0.92);
    box-shadow: 0 0 60px rgba(90, 125, 160, 0.7);
  }
  .opening-press-button.faded {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
    transition: opacity 1200ms ease-out, transform 1200ms ease-out;
  }
  @media (max-width: 800px) {
    .opening-line { font-size: 0.96rem; line-height: 1.85; }
    .opening-press-button {
      width: 110px; height: 110px;
      font-size: 0.95rem;
    }
  }

  @media (max-width: 800px) {
    .greeting[data-lang="ja"] { font-size: 1.45rem; }
    .greeting[data-lang="en"] { font-size: 1.55rem; }
    .greeting[data-lang="zh"] { font-size: 1.45rem; }
    .greeting[data-lang="fr"] { font-size: 1.4rem; }
    .greeting[data-lang="ko"] { font-size: 1.35rem; }
    .opening-greetings { gap: 14px; }
    .opening-message { font-size: 0.95rem; margin-top: 28px; }
  }

  /* ============================================================
   * a11y: focus-visible とモーション削減対応
   * ─ キーボード操作で全インタラクティブ要素にアクセスでき、
   *   reduce-motion 設定のユーザにはアニメーションを最小化する。
   * ============================================================ */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
  }
  /* dark / bright 反転背景上では accent が見えづらいので明色 outline に */
  .ending-overlay.dark *:focus-visible,
  .game-complete *:focus-visible {
    outline-color: rgba(243, 218, 155, 0.95);
  }
  /* 既存の box-shadow / animation がある要素では outline-offset を広めに */
  .walk-button:focus-visible,
  .greeting:focus-visible,
  .pt-button:focus-visible {
    outline-offset: 4px;
  }

  @media (prefers-reduced-motion: reduce) {
    /* 無限ループや長尺のアニメ・トランジションを 1 回 / 短時間に。
       状態変化を完全に消すと UI が壊れるので、 短い transition は残す。 */
    *, *::before, *::after {
      animation-iteration-count: 1 !important;
      animation-duration: 0.001ms !important;
    }
    /* 無限点滅・回転・パーティクル系を完全停止 */
    .e-mobius, .e-time-clock .hand-hour, .e-time-clock .hand-min,
    .gc-star, .holy-choice, .gc-symbol, .e-meta-divider,
    .companion, #the-button .tb-glow, .workshop-stage .ws-item,
    .pt-shimmer, .e-flash, .e-shatter .frag, .e-button-core,
    .silhouette, .freeze-particle, .narration-float,
    .floating-narration, .floating-narration.event,
    .env-cloud, .env-star, #env-sun-disc, .env-wave,
    .environment-card.environment-final,
    .life-microbe, .life-grass-blade, .life-animal-mover,
    .life-fig-fish .life-fig-anim, .life-fig-tree .life-fig-anim, .life-fig-beast .life-fig-anim,
    .silhouette-companion.first-appear, .stage-canvas.human-birth-dimming {
      animation: none !important;
    }
    /* 透明から透明への装飾的フェードは無効化、 ただし.visible 等の状態
       切替は CSS transition なので「ぱっと出る」 程度には残す */
    .ending-overlay, .game-complete, .phase-transition {
      transition-duration: 60ms !important;
    }
  }

  /* === ストレージブロック警告バナー =================================
     itch.io 埋め込み iframe で localStorage が遮断されたときに表示。
     ゲーム本体の和の余白(クリーム/墨/ゴールド) に揃え、 控えめに上端に固定。 */
  .storage-blocked-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(680px, calc(100vw - 24px));
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(250, 246, 238, 0.97);
    color: #1a1814;
    border: 1px solid rgba(184, 136, 72, 0.65);
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(26, 24, 20, 0.12);
    font-family: var(--font-body, 'Shippori Mincho'), serif;
    font-size: 0.84rem;
    line-height: 1.5;
  }
  .storage-blocked-banner .sbb-msg { flex: 1; }
  .storage-blocked-banner .sbb-close {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid rgba(26, 24, 20, 0.35);
    color: #1a1814;
    font-family: inherit;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
  }
  .storage-blocked-banner .sbb-close:hover {
    background: rgba(184, 136, 72, 0.12);
    border-color: rgba(184, 136, 72, 0.6);
  }
