/* ===================================
   瞑想アプリ専用スタイル
   =================================== */

/* リセット & 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden; /* 全画面アプリなのでスクロールを無効 */
}

.app-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
    background: #000;
    color: white;
    overflow: hidden;
    user-select: none; /* テキスト選択を無効化 */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* ===================================
   アプリコンテナ
   =================================== */
.app-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===================================
   背景エフェクト
   =================================== */
.background-layer {
    position: absolute;
    inset: 0;
    z-index: -1;
}


.gradient-overlay {
    position: absolute;
    inset: 0;
    background: url('https://shin-yu.net/meisou/webapp/images/BG_blue.jpg') center center / cover no-repeat;
    opacity: 1;
}

/* 星パーティクル */
.star-particles {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    mix-blend-mode: screen; /* スクリーン合成 */
    opacity: 0.9;
}

.star-particles-1 {
    background-image: url('https://shin-yu.net/meisou/webapp/images/Star_01.png');
    animation: starWiggle1 25s ease-in-out infinite;
}

.star-particles-2 {
    background-image: url('https://shin-yu.net/meisou/webapp/images/Star_02.png');
    animation: starWiggle2 30s ease-in-out infinite;
}

/* Star_01用のWiggleアニメーション */
@keyframes starWiggle1 {
    0%, 100% { 
        transform: translate(0, 0) rotate(0deg) scale(1.05);
    }
    20% { 
        transform: translate(3px, -2px) rotate(0.8deg) scale(1.05);
    }
    40% { 
        transform: translate(-2px, 4px) rotate(-0.5deg) scale(1.05);
    }
    60% { 
        transform: translate(4px, 2px) rotate(0.3deg) scale(1.05);
    }
    80% { 
        transform: translate(-1px, -3px) rotate(-0.2deg) scale(1.05);
    }
}

/* Star_02用のWiggleアニメーション */
@keyframes starWiggle2 {
    0%, 100% { 
        transform: translate(0, 0) rotate(0deg) scale(1.05);
    }
    25% { 
        transform: translate(-3px, 1px) rotate(-0.6deg) scale(1.05);
    }
    50% { 
        transform: translate(2px, -4px) rotate(0.4deg) scale(1.05);
    }
    75% { 
        transform: translate(-1px, 3px) rotate(-0.7deg) scale(1.05);
    }
}


/* ===================================
   フローティングボタン
   =================================== */
.floating-buttons {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.floating-button {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.floating-button:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* 説明ボタンのスタイル */
.info-button {
    width: auto;
    padding: 0 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===================================
   メインエリア
   =================================== */
.app-main {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* ===================================
   スクリーン共通
   =================================== */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.screen.active {
    display: flex;
}

.screen-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

/* ===================================
   呼吸エリア
   =================================== */
.breathing-area {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================
   カウントダウンオーバーレイ
   =================================== */
.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.countdown-overlay.active {
    opacity: 1;
}

.countdown-number {
    font-size: 4rem;
    font-weight: bold;
    color: white;
    text-shadow: none;
    opacity: 0;
}

.countdown-number.count-animation {
    animation: countPulse 1s ease-out;
}

.countdown-number.start-text {
    font-size: 2.5rem;
}

@keyframes countPulse {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0.8;
        transform: scale(1);
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .countdown-number {
        font-size: 3rem;
    }
    
    .countdown-number.start-text {
        font-size: 2rem;
    }
}

/* ===================================
   開始画面
   =================================== */
.start-screen {
    animation: fadeIn 0.6s ease-out;
}

.start-header {
    width: 100%;
    max-width: 500px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.start-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.start-footer {
    width: 100%;
    max-width: 400px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-area {
    text-align: center;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #ffd700;
}

.screen-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}



.start-actions {
    width: 100%;
    max-width: 400px;
}

.start-button {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1.5rem 2rem;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.start-button:active {
    transform: translateY(-1px);
}

.button-icon {
    font-size: 1.5rem;
}

.start-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.info-icon {
    font-size: 1.5rem;
}

.info-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

.start-note {
    font-size: 0.9rem;
    opacity: 0.7;
    color: #fbbf24;
}

/* ===================================
   瞑想中画面
   =================================== */
.start-screen .screen-content,
.meditation-screen .screen-content {
    gap: 2rem;
    padding: 1rem;
}


.meditation-header {
    width: 100%;
    max-width: 500px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-info {
    text-align: center;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.timer-display {
    margin-bottom: 1rem;
}

.timer-main {
    font-size: 3.5rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
    text-shadow: none;
    margin-bottom: 0.5rem;
}

.timer-label {
    opacity: 0.7;
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 1s ease-out;
    border-radius: 2px;
}

.meditation-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.breathing-circle {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4) inset, 0 0 15px rgba(255, 255, 255, 0.4);
    --breath-duration: 4s;
}


.circle-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
}

.breathing-text {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: none;
}

.breathing-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
}

/* 呼吸アニメーション（大きい状態から始まってループ） */
.breathing-circle.breathing-active {
    animation: breathingLoop calc(var(--breath-duration) * 2) ease-in-out infinite;
}

.start-screen .breathing-circle,
.breathing-circle.breathing-preview {
    animation: breathingLoop 20s ease-in-out infinite;
    --breath-duration: 10s;
}

/* 一時停止時はアニメーションも停止 */
.breathing-circle.breathing-paused {
    animation-play-state: paused;
}

/* 呼吸ループアニメーション：連続的な拡大・縮小 */
@keyframes breathingLoop {
    0% { 
        /* 吐き始め（大きい状態から開始） */
        transform: translate(-50%, -50%) scale(1.2);
    }
    50% { 
        /* 吐き終わり・吸い始め（小さい） */
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% { 
        /* 吸い終わり（大きい） */
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.breathing-instruction {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1rem;
    opacity: 0.8;
    text-align: center;
    white-space: nowrap;
}

.meditation-footer {
    width: 100%;
    max-width: 400px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-btn.paused {
    background: rgba(255, 193, 7, 0.2);
    border-color: rgba(255, 193, 7, 0.3);
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* ===================================
   完了画面
   =================================== */
.complete-screen .screen-content {
    gap: 2rem;
    animation: slideUp 0.8s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.complete-header {
    text-align: center;
}


.complete-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #ffd700;
}

.complete-message {
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

.complete-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 350px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    border: none;
    padding: 1rem 2rem;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-action {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.primary-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}

.next-session {
    background: rgba(16, 185, 129, 0.1);
    padding: 1.5rem;
    border-radius: 15px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    width: 100%;
    max-width: 350px;
}

.next-text {
    color: #10b981;
    font-weight: 600;
    margin-bottom: 1rem;
}

.tips-list {
    list-style: none;
    padding: 0;
    text-align: left;
}

.tips-list li {
    padding: 0.3rem 0;
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.tips-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: bold;
}

/* ===================================
   サイドパネル共通
   =================================== */
.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 200;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.help-panel.active {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.panel-content {
    padding: 1.5rem;
}


/* ===================================
   ヘルプパネル
   =================================== */
.help-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-section:last-child {
    border-bottom: none;
}

.help-section h4 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.help-section ol,
.help-section ul {
    padding-left: 1.5rem;
}

.help-section li {
    margin-bottom: 0.8rem;
    line-height: 1.6;
    font-size: 0.95rem;
    opacity: 0.9;
}

.faq-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.faq-item:last-child {
    margin-bottom: 0;
}


/* ===================================
   オーバーレイ
   =================================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   レスポンシブデザイン
   =================================== */
@media (max-width: 768px) {
    .screen-content {
        padding: 1rem;
    }
    
    .screen-title {
        font-size: 1.8rem;
    }
    
    .breathing-circle {
        width: 200px;
        height: 200px;
    }
    
    .timer-main {
        font-size: 2.8rem;
    }
    
    
    .help-panel {
        width: 100vw;
        right: -100vw;
    }
    
    .start-info {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0.5rem 1rem;
    }
    
    .app-title {
        font-size: 1rem;
    }
    
    .header-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .breathing-circle {
        width: 180px;
        height: 180px;
    }
    
    .breathing-text {
        font-size: 1.2rem;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .control-btn {
        width: 100%;
    }
}

/* ===================================
   横向き対応
   =================================== */
@media (orientation: landscape) and (max-height: 600px) {
    .screen-content {
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .meditation-screen .screen-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.5rem 1rem;
    }
    
    .meditation-header,
    .meditation-footer {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
    }
    
    .meditation-body {
        flex: 1;
        margin: 0 1rem;
    }
    
    .breathing-circle {
        width: 180px;
        height: 180px;
    }
    
    .timer-main {
        font-size: 2rem;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .complete-stats {
        grid-template-columns: repeat(3, 1fr);
        max-width: 300px;
    }
}

/* ===================================
   アニメーション & エフェクト
   =================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* フォーカス可能要素のアクセシビリティ */
button:focus-visible,
input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ダークモードでの微調整（デフォルトでダークなのでほぼ変更なし） */
@media (prefers-color-scheme: light) {
    /* ライトモード時の調整（必要に応じて） */
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    .breathing-circle {
        border: 2px solid white;
    }
    
    .control-btn {
        border-width: 2px;
    }
    
    .panel-header {
        border-bottom-width: 2px;
    }
}