﻿/* --- 1. 基本変数とベース設定 --- */
:root { 
    --gold: #d4af37; 
    --bg-dark: #020617; 
    --white: #ffffff; 
    --warm-glow: rgba(212, 175, 55, 0.4); 
    --baseline-color: #94a3b8; 
    --accent-color: #cbd5e1; 
}

body { 
    background-color: var(--bg-dark); 
    color: var(--gold); 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    margin: 0; 
    padding: 0; 
    overflow: hidden; 
    height: 100dvh; 
    touch-action: none; 
    user-select: none; 
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none; 
}

.ritual-font { font-family: 'Sawarabi Mincho', serif; }
.fade-transition { transition: opacity 1.5s ease-in-out, transform 1.5s ease-in-out; }
.hidden-el { display: none !important; opacity: 0 !important; }

/* 2. プログレスリング設定 */
.progress-ring { transform: rotate(-90deg); }
.progress-ring__circle { 
    transition: stroke-dashoffset 0.1s linear; 
    stroke-linecap: round; 
    filter: drop-shadow(0 0 8px var(--warm-glow)); 
}

/* 【安全強化】ハードウェア加速（STATEの安定維持） */
.muscle-path, .progress-ring__circle { 
    will-change: d, stroke-dashoffset; 
}

/* 3. 筋肉の動き（SVG） */
.muscle-path { transition: d 4s cubic-bezier(0.16, 1, 0.3, 1), fill-opacity 4s ease; fill: var(--gold); fill-opacity: 0.05; stroke: var(--gold); stroke-width: 0.8; }
.rubber-active .muscle-path { transition: d 0.8s cubic-bezier(0.2, 0, 0.2, 1), fill-opacity 0.8s ease; fill-opacity: 0.35; }
.rubber-recovering .muscle-path { transition: d 3.5s cubic-bezier(0.4, 0, 0.2, 1), fill-opacity 3.5s ease; fill-opacity: 0.15; }

/* 4. ライズ（立ち上がり）ボタン */
.rise-button { width: 100px; height: 100px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; background: rgba(255, 255, 255, 0.01); display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(12px); transition: all 2s ease; transform: scale(0.85); opacity: 0.5; }
.rise-button.pulsing { animation: pulse-anim 5s infinite cubic-bezier(0.4, 0, 0.2, 1); }
.rise-button.switch-ui { animation: none; transform: scale(1); opacity: 1; border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 40px rgba(255, 255, 255, 0.25); }

@keyframes pulse-anim { 0%, 100% { transform: scale(0.85); opacity: 0.5; } 50% { transform: scale(1.08); opacity: 0.9; } }

#instruction { transition: opacity 1s ease, letter-spacing 1s ease; }

/* 5. 呼吸ガイド（円） */
.breathing-circle { transition-property: transform; transition-timing-function: ease-in-out; will-change: transform; }
.inhale-max { transform: scale(1.6); }
.exhale-min { transform: scale(0.55); }
.glow { filter: blur(40px); background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 70%); }

/* 6. デバッグログ */
#dev-log { position: fixed; bottom: 0; left: 0; right: 0; max-height: 20vh; overflow-y: auto; background: rgba(0, 0, 0, 0.85); color: #9cff9c; font-family: monospace; font-size: 10px; line-height: 1.2; padding: 8px; z-index: 9999; pointer-events: none; border-top: 1px solid rgba(156, 255, 156, 0.3); }

/* 7. 中断復帰オーバーレイ */
#recover-overlay { 
    position: fixed; inset: 0; background: rgba(2, 6, 23, 0.9); z-index: 9000; 
    display: none; flex-direction: column; align-items: center; justify-content: center; backdrop-filter: blur(8px); 
    /* 【安全強化】操作ミスの防止 */
    padding-bottom: env(safe-area-inset-bottom);
}

.btn-recover-group { 
    display: flex; flex-direction: column; gap: 40px; align-items: center; 
    /* 【安全強化】ホームバーとの衝突回避 */
    margin-bottom: calc(env(safe-area-inset-bottom) + 20px);
}

.btn-circle { width: 80px; height: 80px; border-radius: 50%; border: 1px solid var(--gold); display: flex; align-items: center; justify-content: center; background: rgba(212, 175, 55, 0.05); color: var(--gold); transition: all 0.3s ease; cursor: pointer; }
.btn-circle:active { background: var(--gold); color: black; transform: scale(0.9); }

/* 8. テキスト表示設定 */
.stage-container { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; }
#main-text { font-size: 1.5rem; color: var(--baseline-color); margin-bottom: 20px; text-align: center; z-index: 10; min-height: 2.2em; transition: all 0.3s ease; }
#main-text.is-saigo { font-size: 3.5rem; color: white; font-weight: bold; transform: translateY(-10px); }
.sub-text { font-size: 0.9rem; opacity: 0.7; margin-top: 0.4rem; text-align: center; }

/* 9. アウトロ呼吸円 */
.breath-guide-container { display: flex; flex-direction: column; align-items: center; margin-top: 40px; }
.glow-container { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.outro-circle { width: 100px; height: 100px; border-radius: 50%; border: 2px solid var(--baseline-color); transition: transform 10s ease-in-out; }
.outro-inhale-max { transform: scale(1.1) !important; }
.outro-exhale-min { transform: scale(0.7) !important; }

/* 10. 残心演出（SVG） */
.visual-container { width: 200px; height: 250px; display: flex; justify-content: center; }
.vertical-line { stroke: var(--baseline-color); stroke-width: 1.5; stroke-linecap: round; fill: none; d: path("M50,120 Q50,95 50,85"); }
.shooting-star-path { fill: none; stroke: var(--baseline-color); stroke-width: 1.2; stroke-linecap: round; stroke-dasharray: 200; stroke-dashoffset: 200; opacity: 0; }
.core-circle { fill: var(--baseline-color); fill-opacity: 0; stroke: var(--baseline-color); stroke-width: 1; opacity: 0; }

.zanshin-active .vertical-line { animation: line-shinari 10s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }
.zanshin-active .star-trunk { animation: trunk-flow 10s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }
.zanshin-active .core-circle { animation: core-motion 10s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }
.zanshin-active .star-branch { animation: branch-flow 10s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }

@keyframes line-shinari { 0%, 15% { d: path("M50,120 Q50,95 50,85"); } 60%, 100% { d: path("M50,120 Q49,95 50,85"); } }
@keyframes trunk-flow { 0%, 10% { stroke-dashoffset: 200; opacity: 0; } 20% { opacity: 1; } 30%, 85% { stroke-dashoffset: 0; opacity: 0.8; } 100% { opacity: 0; } }
@keyframes core-motion { 0%, 28% { opacity: 0; fill-opacity: 0; transform: scale(1); } 33% { opacity: 0.8; fill-opacity: 0.8; transform: scale(1); } 45% { opacity: 0.5; fill-opacity: 0; transform: scale(1.02); } 100% { opacity: 0; transform: scale(1.03); } }
@keyframes branch-flow { 0%, 30% { stroke-dashoffset: 200; opacity: 0; } 40% { opacity: 1; } 85% { stroke-dashoffset: 0; opacity: 0.6; transform: translate(6px, -6px); } 100% { stroke-dashoffset: -10; opacity: 0; transform: translate(10px, -10px); } }

/* 11. その他ボタン・ガイド設定 */
.btn-outro { padding: 12px 24px; background: #334155; color: white; border: none; border-radius: 4px; cursor: pointer; }

#guide-modal { 
    position: fixed; 
    inset: 0; 
    background: #050505; 
    z-index: 100; 
    display: none; 
    flex-direction: column; 
    padding: 40px 32px; 
    overflow-y: auto; 

    /* 【安全強化】iOSでのスクロール安定化 */
    touch-action: pan-y; /* 縦方向のスクロールジェスチャーのみを許可 */
    -webkit-overflow-scrolling: touch; /* iOS Safariでの滑らかな慣性スクロールを強制 */
}

.guide-content p { margin-bottom: 1.5rem; line-height: 1.8; }
.guide-content h2 { margin-top: 2.5rem; margin-bottom: 1rem; color: var(--gold); font-size: 1.1rem; border-bottom: 1px solid rgba(212, 175, 55, 0.2); padding-bottom: 0.5rem; }

/* 【安全強化】OS設定への配慮（視覚的安全性） */
@media (prefers-reduced-motion: reduce) {
    .rise-button.pulsing,
    .zanshin-active .vertical-line,
    .zanshin-active .star-trunk,
    .zanshin-active .core-circle,
    .zanshin-active .star-branch,
    .breathing-circle {
        animation: none !important;
        transition: none !important;
    }
}