/* =========================================
   Base & Variables
   ========================================= */
:root {
    --bg-dark: #0f1115;
    --panel-glass: rgba(255, 255, 255, 0.05);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #8b9bb4;

    --accent-red: #ff4757;
    --accent-green: #2ed573;
    --accent-blue: #3742fa;
    --accent-yellow: #ffa502;
    --accent-gold: #ffd700;
    --primary-multi: #9c88ff; 

    /* ★変更/追加: モード用テーマカラー */
    --accent-daily: #ff9f43; /* オレンジ (Daily / Streak用) */
    --accent-storage: #00e5ff; /* シアン (Storage用) */

    --font-ui: 'Inter', 'Noto Sans JP', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Rush Mode Accent */
    --accent-rush: #ff9f43;
}

* { box-sizing: border-box; }

/* 修正: overscroll-behavior-y を追加してバウンス(赤い部分の露出)を防止 */
html, body { 
    margin: 0; 
    padding: 0; 
    font-family: var(--font-ui); 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    overflow-x: hidden; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column;
    touch-action: manipulation;
    /* overscroll-behavior-y: none; ★追加: これでフッター下の引っ張りを無効化 */
}
/* .bg-orb { position: fixed; border-radius: 50%; filter: blur(80px); z-index: -1; opacity: 0.4; }
.orb-1 { width: 300px; height: 300px; background: #3742fa; top: -50px; left: -50px; }
.orb-2 { width: 400px; height: 400px; background: #ff4757; bottom: -100px; right: -100px; } */
.container { max-width: 600px; margin: 0 auto; padding: 15px; padding-bottom: 30px; flex: 1; width: 100%; }
.screen { display: none !important; }
.screen.active { display: block !important; animation: fadeIn 0.4s ease-out forwards; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Header */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; max-width: 800px; margin: 0 auto; width: 100%; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; cursor: pointer; }
.logo-icon { width: 38px; height: 38px; object-fit: contain; border: none !important; background: transparent !important; box-shadow: none !important; filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); }
.logo-text { font-family: var(--font-ui); font-weight: 900; font-size: 1.5rem; letter-spacing: 2px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); background: linear-gradient(to right, #fff, #ccc); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav-btn { background: var(--panel-glass); border: 1px solid var(--panel-border); color: var(--text-main); padding: 6px 14px; border-radius: 20px; cursor: pointer; font-size: 0.8rem; backdrop-filter: blur(5px); transition: 0.2s; }
.nav-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* Hero Section */
.hero-section { text-align: center; margin: 15px 0 35px; }
.hero-subtitle { color: var(--text-muted); letter-spacing: 2px; font-size: 0.75rem; text-transform: uppercase; margin-bottom: 5px; }
.hero-title { font-size: clamp(2rem, 8vw, 3rem); margin: 0; line-height: 1.1; white-space: nowrap; }
.hero-title span { margin: 0 1px; }
.char-r { background: none !important; -webkit-text-fill-color: var(--accent-red) !important; color: var(--accent-red) !important; text-shadow: 0 0 10px rgba(255, 71, 87, 0.4); }
.char-g { background: none !important; -webkit-text-fill-color: var(--accent-green) !important; color: var(--accent-green) !important; text-shadow: 0 0 10px rgba(46, 213, 115, 0.4); }
.char-b { background: none !important; -webkit-text-fill-color: var(--accent-blue) !important; color: var(--accent-blue) !important; text-shadow: 0 0 10px rgba(55, 66, 250, 0.4); }

/* Daily Color */
.daily-section { 
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)); 
    border: 1px solid rgba(255, 255, 255, 0.2); 
    border-radius: 20px; 
    padding: 25px; 
    margin-bottom: 30px; 
    cursor: pointer; 
    position: relative; 
    overflow: hidden; 
    transition: transform 0.2s, box-shadow 0.2s; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 20px; 
}
.daily-section:hover { transform: translateY(-2px); box-shadow: 0 10px 40px -10px rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.4); }
.daily-section::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(45deg, rgba(255, 0, 0, 0.1), rgba(0, 255, 0, 0.1), rgba(0, 0, 255, 0.1)); z-index: -1; opacity: 0.5; }
.daily-main-container { display: flex; align-items: center; gap: 20px; flex: 1; }
.daily-preview-large { width: 100px; height: 100px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.2); box-shadow: 0 0 30px rgba(0,0,0,0.5); flex-shrink: 0; background-color: #000; transition: background-color 0.5s; }
.daily-content { display: flex; flex-direction: column; justify-content: center; }
.daily-label { font-size: 0.7rem; letter-spacing: 2px; color: var(--accent-daily); font-weight: bold; margin-bottom: 5px; }
.daily-date { font-family: var(--font-mono); color: var(--text-muted); font-size: 0.85rem; margin-bottom: 5px; }
/* 修正: 文字切れ対策でpadding-bottomを追加 */
.daily-title { font-size: 2rem; font-weight: 900; margin: 0; line-height: 1; background: linear-gradient(to right, #fff, #ddd); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; padding-bottom: 5px; }
.daily-desc { font-size: 0.85rem; color: #aaa; margin: 5px 0 0; }
.daily-status { background: #fff; color: #000; padding: 10px 20px; border-radius: 30px; font-weight: bold; font-size: 0.9rem; letter-spacing: 1px; white-space: nowrap; box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2); text-align: center; }
.daily-status.played { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: none; border: 1px solid rgba(255, 255, 255, 0.2); }
/* Versus History Mobile Adjustments */
@media (max-width: 600px) {
    .vh-cell {
        padding: 6px 2px; /* パディングを削減 */
        font-size: 0.65rem; /* フォントサイズ縮小 */
        min-height: 35px;
    }
    .vh-header-name {
        font-size: 0.65rem;
    }
    .vh-score-col {
        gap: 3px; /* ドットとの間隔を詰める */
    }
    .vh-color-dot {
        width: 10px;
        height: 10px; /* ドットも少し小さく */
    }
    /* 4人時はさらに詰める */
    .players-4-history .vh-cell {
        font-size: 0.6rem;
        padding: 4px 1px;
    }
}

/* Cards & Grid */
.menu-grid { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 40px; }
/* 修正: カード内のテキストを常に左揃えにする */
.game-card { 
    background: rgba(20, 22, 28, 0.6); 
    border: 1px solid var(--panel-border); 
    border-radius: 16px; 
    padding: 18px; 
    display: flex; 
    align-items: center; 
    cursor: pointer; 
    transition: transform 0.2s, box-shadow 0.2s; 
    position: relative; 
    overflow: hidden; 
    text-align: left; /* 追加: 強制的に左揃え */
}
.game-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5); background: rgba(30, 32, 40, 0.8); border-color: rgba(255, 255, 255, 0.2); }
.game-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.card-origin::before { background: var(--accent-red); } 
.card-rush::before { background: var(--accent-green); } 
.card-survival::before { background: var(--accent-blue); } 
.card-versus::before { background: var(--primary-multi); }
/* ★追加: Color Storage用カードのアクセントカラー */
.card-storage::before { background: var(--accent-storage); }
.card-icon { font-size: 1.8rem; margin-right: 15px; }
.card-content h3 { margin: 0; font-size: 1.1rem; }
.card-content p { margin: 4px 0 0; font-size: 0.75rem; color: var(--text-muted); }
.record-badge { display: inline-block; background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1); padding: 3px 8px; border-radius: 6px; font-size: 0.7rem; font-family: var(--font-mono); color: #eee; margin-top: 6px; line-height: 1.4; }
.record-badge span { color: var(--accent-yellow); font-weight: bold; }
/* Origin Badge */
.std-badge { position: absolute; top: 0; right: 0; background: linear-gradient(135deg, #ffd700, #ffaa00); color: #000; font-size: 0.65rem; font-weight: 900; padding: 4px 8px; border-bottom-left-radius: 10px; letter-spacing: 1px; box-shadow: -2px 2px 5px rgba(0,0,0,0.3); z-index: 10; }

/* Explanation */
.about-section { border-top: 1px solid var(--panel-border); padding-top: 25px; margin-top: 20px; }
.about-title { font-size: 0.9rem; color: var(--text-muted); font-weight: bold; margin-bottom: 12px; text-align: center; letter-spacing: 1px; }
.about-card { background: var(--panel-glass); border: 1px solid var(--panel-border); border-radius: 12px; padding: 15px; margin-bottom: 12px; position: relative; overflow: hidden; }
.about-card.about-rush { border-left: 4px solid var(--accent-green); } 
.about-card.about-origin { border-left: 4px solid var(--accent-red); } 
.about-card.about-survival { border-left: 4px solid var(--accent-blue); } 
.about-card.about-versus { border-left: 4px solid var(--primary-multi); }
/* ★追加: DailyとStorageの説明文用ボーダーカラー */
.about-card.about-daily { border-left: 4px solid var(--accent-daily); }
.about-card.about-storage { border-left: 4px solid var(--accent-storage); }
.about-card h4 { margin: 0 0 6px 0; font-size: 1rem; color: #fff; }
.about-card p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

/* Footer */
.app-footer {
    text-align: center;
    padding: 12px 0 15px;
    margin-top: 0; /* ★修正: 40px -> 0 に変更 (余計な隙間を削除) */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    width: 100%;
}

/* --- フッターボタン共通スタイル --- */
.footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px; /* 少しだけ大きくして押しやすく */
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.85rem; /* フォントサイズを統一 */
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    cursor: pointer;
    border: 1px solid transparent; /* ボーダーの枠を確保 */
}
.footer-btn:hover {
    transform: translateY(-2px);
}
.footer-btn:active {
    transform: translateY(0);
}

/* BMC Button Style (Yellow) - 既存のデザインを維持 */
.bmc-link {
    background: rgba(255, 221, 0, 0.15);
    border-color: rgba(255, 221, 0, 0.3);
    color: #ffdd00;
}
.bmc-link:hover {
    background: rgba(255, 221, 0, 0.25);
    box-shadow: 0 4px 12px rgba(255, 221, 0, 0.3);
    color: #fff;
}

/* Copyright (Button Style) */
.copyright {
    display: inline-block;
    margin-top: 4px;       /* 上の間隔を大幅に削減 (15px -> 4px) */
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copyright:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-multi); /* ホバー時に紫系（Another Worldへのヒント色）に */
    border-color: var(--primary-multi);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(156, 136, 255, 0.2);
}

.copyright:active {
    transform: translateY(0);
}

/* --- Privacy & Policy Styles (Retina Tech Theme) --- */

/* 1. Privacy Button (Footer) - Neon Cyan Style */
.privacy-link {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #00e5ff; /* 鮮やかなシアン */
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.05);
}
.privacy-link:hover {
    background: rgba(0, 229, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
    color: #fff;
    transform: translateY(-2px);
    border-color: #00e5ff;
}

/* 2. Policy Modal Box - Glass & Tech Interface */
.policy-box {
    max-width: 600px; /* 少し幅を広げる */
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    text-align: left;
    
    /* 背景とエフェクト */
    background: linear-gradient(160deg, rgba(20, 30, 48, 0.95), rgba(36, 59, 85, 0.95));
    border: 1px solid rgba(0, 229, 255, 0.3); /* シアンの境界線 */
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 229, 255, 0.2); /* 奥深い影とネオンの光 */
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

/* Modal Header */
.policy-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.policy-title {
    margin: 0;
    color: #00e5ff;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Modal Content Area */
.policy-content {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
    color: #dbe4eb; /* 完全な白ではなく、読みやすい青白系 */
    font-size: 0.9rem;
    line-height: 1.8;
}

/* Custom Scrollbar for Policy */
.policy-content::-webkit-scrollbar { width: 6px; }
.policy-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.policy-content::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.3); border-radius: 3px; }

/* Typography inside Content */
.policy-content h4 {
    color: #fff;
    font-family: var(--font-mono);
    margin: 25px 0 10px;
    font-size: 1rem;
    border-left: 3px solid #00e5ff; /* 左にシアンのライン */
    padding-left: 10px;
    letter-spacing: 1px;
}
.policy-content h4:first-child { margin-top: 0; }

.policy-content p {
    margin: 0 0 15px;
    color: rgba(255, 255, 255, 0.8);
}

/* Modal Footer (Close Button Area) */
.policy-footer {
    padding: 15px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: right;
}

/* Close Button Styling */
.btn-policy-close {
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.5);
    color: #00e5ff;
    padding: 8px 24px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    letter-spacing: 2px;
}
.btn-policy-close:hover {
    background: rgba(0, 229, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
    color: #fff;
}

/* Game UI */
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.game-title { margin: 0; font-size: 1.3rem; letter-spacing: -1px; padding-left: 12px; border-left: 4px solid transparent; line-height: 1.1; }
.color-origin { border-left-color: var(--accent-red); } 
.color-rush { border-left-color: var(--accent-green); } 
.color-survival { border-left-color: var(--accent-blue); } 
/* ★変更: Dailyをオレンジに */
.color-daily { border-left-color: var(--accent-daily); } 
/* ★変更: Storageをシアンに */
.color-storage { border-left-color: var(--accent-storage); }
.color-versus { border-left-color: var(--primary-multi); }
.digital-timer { font-family: var(--font-mono); font-size: 1.3rem; color: var(--text-main); }
.glass-panel { background: var(--panel-glass); border: 1px solid var(--panel-border); backdrop-filter: blur(12px); border-radius: 16px; padding: 15px; margin-bottom: 15px; }
.color-display-area { display: flex; gap: 12px; margin-bottom: 15px; }
.color-panel { flex: 1; text-align: center; }
.panel-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; }
.color-box { width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; background: #000; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3); transition: background-color 0.1s; position: relative; }
.large-box { aspect-ratio: 16 / 9; height: 140px; margin-bottom: 15px; }
.overlay-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 3rem; opacity: 0.2; font-weight: bold; }

/* Slider */
.slider-container { padding: 20px 15px; }
.slider-row { display: flex; align-items: center; margin-bottom: 20px; height: 25px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row label { width: 35px; text-align: center; font-weight: 900; font-family: var(--font-mono); font-size: 1.2rem; text-shadow: 0 0 15px currentColor; flex-shrink: 0; }
.label-r { color: var(--accent-red); } .label-g { color: var(--accent-green); } .label-b { color: var(--accent-blue); }
.custom-range { appearance: none; -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px; background: #333; outline: none; margin: 0 12px; position: relative; cursor: pointer; }
.range-r { background: linear-gradient(to right, #333, var(--accent-red)); } .range-g { background: linear-gradient(to right, #333, var(--accent-green)); } .range-b { background: linear-gradient(to right, #333, var(--accent-blue)); } .range-mono { background: linear-gradient(to right, #333, #fff); }
.custom-range::-webkit-slider-thumb { 
    appearance: none; 
    -webkit-appearance: none; 
    width: 20px; 
    height: 20px; 
    border-radius: 50%; 
    background: #fff; 
    cursor: pointer; 
    box-shadow: none; 
    border: 3px solid var(--bg-dark); 
    margin-top: -6px; /* これでバーの中央に来るように調整 (-8px -> -6px) */
    transition: transform 0.1s; 
}
.custom-range::-webkit-slider-thumb:active { transform: scale(1.2); }.val-num { width: 35px; text-align: right; font-family: var(--font-mono); font-size: 1rem; color: var(--text-main); font-weight: bold; flex-shrink: 0; }
/* Main Action Button (GUESS / START etc) */
.main-action-btn {
    width: 100%;
    padding: 22px;
    font-size: 1.3rem;
    font-weight: 900;
    color: #fff; /* 文字色を白に */
    /* 変更: オレンジ基調のスタイリッシュなグラデーション */
    background: linear-gradient(135deg, #ffa502, #ff4757); 
    border: none;
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 2px;
    /* 影もオレンジ系に合わせて調整 */
    box-shadow: 0 5px 20px rgba(255, 71, 87, 0.4); 
    transition: transform 0.1s, box-shadow 0.1s;
    margin-top: 20px;
    font-family: var(--font-ui);
    touch-action: manipulation;
}
.main-action-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(255, 71, 87, 0.3);
}
.main-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555;
    color: #888;
}

/* Result Screen */
.result-screen { text-align: center; padding-top: 5px; }
.result-page-title { margin: 0 0 15px; font-size: 1.1rem; letter-spacing: 2px; color: var(--text-muted); }
.result-title-big { margin: 0 0 8px; font-size: 2.2rem; letter-spacing: 1px; }
.score-display { margin-bottom: 15px; }
.score-display h1 { font-size: clamp(3rem, 15vw, 4.5rem); margin: 0; font-family: var(--font-ui); font-weight: 900; letter-spacing: -2px; line-height: 1; background: linear-gradient(to bottom, #fff, #999); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.new-record { color: var(--accent-yellow); font-weight: bold; animation: pulse 1s infinite; margin: 5px 0 0; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
.compare-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 20px 0; }
.mini-box { width: 55px; height: 55px; border-radius: 10px; margin: 0 auto 4px; border: 1px solid rgba(255, 255, 255, 0.2); }
.compare-item span { font-size: 0.75rem; font-family: var(--font-mono); color: var(--text-muted); }
.compare-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; font-weight: bold; }
.stats-row { display: flex; justify-content: center; gap: 15px; margin-bottom: 25px; }
.stat-box { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); padding: 8px 16px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; min-width: 100px; }
/* Stat Box Alignment (Rush Result) */
/* 修正: 以前のレイアウト調整を取り消し、元に戻す */
.stat-label { 
    font-size: 0.65rem; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    margin-bottom: 3px; /* 5px -> 3px に戻す */
    /* min-height, display flex 等を削除 */
}
.stat-value { font-family: var(--font-mono); font-size: 1.2rem; font-weight: bold; color: #fff; }
.stat-value.highlight { color: var(--accent-yellow); text-shadow: 0 0 10px rgba(255, 165, 2, 0.3); }
.modal-buttons { display: grid; gap: 12px; margin-bottom: 25px; padding: 0 15px; }

/* Buttons */
.btn-primary { 
    background: linear-gradient(135deg, #2ed573, #1dd1a1); 
    color: #fff; 
    border: none; 
    padding: 14px; 
    border-radius: 12px; 
    font-weight: bold; 
    cursor: pointer; 
    font-size: 1rem; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px; 
    box-shadow: 0 4px 15px rgba(46, 213, 115, 0.4); 
    transition: transform 0.2s, box-shadow 0.2s; 
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(46, 213, 115, 0.6); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: #555; color: #888; cursor: not-allowed; opacity: 0.7; box-shadow: none; }

/* ★追加: リザルト画面のRETURN用ボタン */
.btn-return {
    background: linear-gradient(135deg, #57606f, #2f3542) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    color: #eee !important;
}
.btn-return:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5) !important;
}

.btn-share {
    background: linear-gradient(135deg, #1DA1F2, #0077b5); /* Blue for Share */
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(29, 161, 242, 0.4);
}
.btn-share:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(29, 161, 242, 0.6); }
.btn-share:active { transform: scale(0.98); }
.share-icon { font-size: 1.2rem; }

.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; text-decoration: underline; }
.btn-delete { background: transparent; border: none; color: #555; cursor: pointer; font-size: 1rem; padding: 0; transition: 0.2s; }
.btn-delete:hover { color: var(--accent-red); transform: scale(1.2); }

/* 追加: リスト内シェアボタン */
.btn-share-icon { 
    background: transparent; 
    border: none; 
    color: var(--primary-multi); /* 紫系 */
    cursor: pointer; 
    font-size: 1rem; 
    padding: 0; 
    transition: 0.2s; 
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-share-icon:hover { 
    color: #fff; 
    text-shadow: 0 0 5px var(--primary-multi);
    transform: scale(1.2); 
}

/* --- History List Adjustments --- */

/* 既存の .history-item を修正: クリック可能にする */
.history-item { 
    display: grid; 
    grid-template-columns: 35px 1fr auto; 
    gap: 8px; 
    align-items: center; 
    padding: 10px 8px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
    background: rgba(255, 255, 255, 0.02); 
    border-radius: 8px; 
    margin-bottom: 4px;
    cursor: pointer; /* 追加: クリック可能に */
    transition: background 0.2s; /* 追加 */
}
/* 追加: ホバー効果 */
.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
/* 追加: Color Storage用のグリッド定義（削除ボタンのみ） */
.storage-item {
    /* Shareボタン(30px)を削除し、削除ボタン(30px)だけ残す */
    grid-template-columns: 35px 1fr 30px;
}
/* Origin History Best Record Colors */
.history-item.best-record { 
    background: linear-gradient(90deg, rgba(255, 71, 87, 0.1), transparent);
    border-left: 3px solid var(--accent-red);
}
.history-item.best-record .history-index { 
    color: var(--accent-red);
    font-weight: bold; 
}
/* 変更: スコアの色指定を削除（または黄色で上書き）して、ハイライト時も数字はオレンジ/白を維持 */
.history-item.best-record .history-score-val {
    color: var(--accent-yellow); /* 赤から黄色に戻す */
    text-shadow: 0 0 5px rgba(255, 165, 2, 0.5);
}
.history-index { font-size: 0.85rem; color: #666; font-family: var(--font-mono); text-align: left; grid-column: 1; }
.history-colors { display: flex; flex-direction: column; gap: 3px; min-width: 0; grid-column: 2; }
.color-row { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; font-family: var(--font-mono); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-box { font-size: 0.6rem; color: #fff; background: rgba(255, 255, 255, 0.1); padding: 1px 4px; border-radius: 3px; min-width: 45px; text-align: center; flex-shrink: 0; }
.chip-xs { width: 9px; height: 9px; border-radius: 2px; border: 1px solid rgba(255, 255, 255, 0.3); display: inline-block; flex-shrink: 0; }
/* 既存の .history-right を修正: 幅を固定して揃える */
.history-right { 
    text-align: right; 
    display: flex; 
    flex-direction: column; 
    align-items: flex-end; 
    justify-content: center; 
    gap: 1px; 
    border-left: 1px solid rgba(255, 255, 255, 0.05); 
    padding-left: 8px; /* 少し広げる */
    grid-column: 3;
    min-width: 85px; /* ★追加: ここで幅を確保して揃える */
}
.history-score-val { font-size: 1rem; font-weight: bold; color: #fff; font-family: var(--font-mono); line-height: 1; }
.history-ao5-badge { font-size: 0.6rem; color: var(--bg-dark); background: var(--text-muted); padding: 1px 4px; border-radius: 3px; font-weight: bold; display: inline-block; white-space: nowrap; margin-top: 2px; }
.history-ao5-badge.highlight { background: var(--accent-yellow); color: #000; box-shadow: 0 0 5px rgba(255, 165, 2, 0.5); }
.history-ao5-badge.placeholder { background: transparent; color: #444; border: 1px solid #333; }

/* Rush History Specific */
/* 既存の .rush-history-item を修正: クリック可能にする */
.rush-history-item {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 1.2fr;
    gap: 5px;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    margin-bottom: 4px;
    text-align: center;
    cursor: pointer; /* 追加 */
    transition: background 0.2s; /* 追加 */
}
.rush-history-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
.rush-history-item.best-record {
    background: linear-gradient(90deg, rgba(46, 213, 115, 0.1), transparent);
    border-left: 3px solid var(--accent-green);
}
.rush-history-item.best-record .history-index {
    color: var(--accent-green);
    font-weight: bold;
}

/* Rush History Text Styles */
.rush-stat-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.rush-stat-label {
    font-size: 0.55rem;
    color: #888;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}
.rush-stat-val {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    line-height: 1;
}
/* 既存の .rush-score-val を修正: デフォルトは白にする */
.rush-score-val {
    color: #fff; /* 変更: オレンジから白へ */
    font-size: 1.2rem;
}

/* 追加: ベストレコードの時だけオレンジにする */
.rush-history-item.best-record .rush-score-val {
    color: var(--accent-rush);
}

/* Rush Mode Styles (Green Theme) */
.rush-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    align-items: end;
}
.rush-item-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.rush-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.rush-label { font-size: 0.7rem; color: #aaa; font-weight: bold; letter-spacing: 1px; line-height: 1; margin-bottom: 2px; }
.rush-val-time { 
    font-family: var(--font-mono); 
    font-size: 2.2rem; 
    font-weight: 900; 
    color: var(--accent-green); 
    line-height: 1; 
    text-shadow: 0 0 15px rgba(46, 213, 115, 0.3);
    min-width: 0;
    font-variant-numeric: tabular-nums;
}
.rush-val-score { font-family: var(--font-mono); font-size: 2.2rem; font-weight: 900; color: #fff; line-height: 1; }

.rush-combo { position: absolute; top: 100px; left: 50%; transform: translateX(-50%) rotate(-5deg); font-family: var(--font-mono); font-weight: 900; font-size: 2rem; color: #fff; text-shadow: 2px 2px 0 var(--bg-dark), 0 0 15px var(--accent-green); animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: none; z-index: 10; white-space: nowrap; }
@keyframes popIn { from { transform: translateX(-50%) scale(0) rotate(-20deg); opacity: 0; } to { transform: translateX(-50%) scale(1) rotate(-5deg); opacity: 1; } }
.time-popup { position: absolute; font-family: var(--font-mono); text-align: center; font-weight: 900; pointer-events: none; text-shadow: 0 0 5px rgba(0,0,0,0.8); animation: floatUp 0.8s ease-out forwards; z-index: 1000; line-height: 1.1; }
.popup-acc { font-size: 1.5rem; color: #fff; }
.popup-time { font-size: 2rem; }
.popup-time.good { color: var(--accent-green); } .popup-time.bad { color: var(--accent-red); } .popup-time.safe { color: #ccc; font-size: 1.5rem; }
@keyframes floatUp { 0% { transform: translateY(0) scale(0.8); opacity: 0; } 20% { transform: translateY(-10px) scale(1.1); opacity: 1; } 100% { transform: translateY(-80px) scale(1); opacity: 0; } }

/* Rush Countdown Animation (Minimal & Stylish) */
.rush-countdown {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    /* 余計な装飾を排除し、フォントの美しさだけで勝負 */
    font-family: var(--font-mono); 
    font-size: 10rem; 
    font-weight: 700;
    color: #fff;
    line-height: 1;
    
    /* 初期状態 */
    opacity: 0;
    z-index: 2000;
    pointer-events: none;
    
    /* 文字間を少し詰めて塊感を出す */
    letter-spacing: -0.05em;
}

/* 数字（3, 2, 1）のアニメーション */
.count-animate {
    /* イージングを調整して「バシッ」と止まる動きに */
    animation: simpleSnap 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* GO! のスタイル */
.rush-countdown.go-state {
    font-size: 12rem; /* さらに大きく */
    color: var(--accent-rush); /* オレンジ単色 */
    letter-spacing: -0.02em;
    animation: goPop 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- Keyframes --- */

/* 奥から手前に「ドンッ」と来て、スッと消える */
@keyframes simpleSnap {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5); /* 小さい状態から */
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1); /* 定位置にスナップ */
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1); /* 一瞬溜める */
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.1); /* 少し拡大しながら消える */
    }
}

/* GO! はさらに勢いよく */
@keyframes goPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2);
    }
    40% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5); /* 大きく広がって消える */
    }
}

/* Challenge Extras */
.challenge-status-bar { display: flex; flex-direction: column; gap: 4px; margin-bottom: 15px; background: rgba(20, 22, 28, 0.8); padding: 12px; border-radius: 14px; border: 1px solid var(--panel-border); position: relative; overflow: hidden; }
.challenge-status-bar::after { content: ''; position: absolute; bottom: 0; left: 0; height: 3px; width: 100%; background: linear-gradient(90deg, var(--accent-blue), transparent); opacity: 0.5; }
.challenge-info-top { display: flex; justify-content: space-between; align-items: flex-end; width: 100%; }
.stage-title { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.stage-number-big { font-size: 1.8rem; font-weight: 900; color: #fff; font-family: var(--font-mono); line-height: 1; }
.goal-display { text-align: right; }
.goal-label { font-size: 0.65rem; color: var(--text-muted); }
.goal-val { font-size: 1.1rem; color: var(--accent-green); font-family: var(--font-mono); font-weight: bold; }
.stage-badge-history { font-family: var(--font-mono); font-weight: bold; color: var(--bg-dark); background: var(--text-muted); padding: 2px 4px; border-radius: 4px; font-size: 0.75rem; display: inline-block; white-space: nowrap; }
/* 末尾に追加: Survival Result Title Helper */
.stage-label-small {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

/* Multiplayer (Versus) Styles */
.multi-name-area { margin-bottom: 25px; }
.input-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 1px; }
.name-input { font-size: 1.1rem; font-family: var(--font-mono); text-align: center; width: 180px; background: transparent; border: none; border-bottom: 2px solid var(--text-muted); color: #fff; padding: 4px; outline: none; transition: 0.3s; }
.name-input:focus { border-bottom-color: var(--primary-multi); }
.setting-area { margin: 12px 0; padding: 8px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }
.goal-select { background: #000; color: #fff; border: 1px solid var(--primary-multi); padding: 4px 8px; border-radius: 5px; font-family: var(--font-mono); font-size: 0.9rem; margin-left: 8px; }
.room-id-input { font-size: 1.8rem; font-family: var(--font-mono); text-align: center; width: 140px; background: transparent; border: none; border-bottom: 2px solid var(--primary-multi); color: #fff; margin: 15px 0; outline: none; }
.room-id-display { font-size: 2.8rem; font-family: var(--font-mono); color: var(--primary-multi); font-weight: 900; margin: 15px 0; letter-spacing: 4px; text-shadow: 0 0 15px rgba(156, 136, 255, 0.5); }
.loading-spinner { border: 4px solid rgba(255, 255, 255, 0.1); border-left-color: var(--primary-multi); border-radius: 50%; width: 36px; height: 36px; animation: spin 1s linear infinite; margin: 15px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.status-text { color: #888; font-size: 0.85rem; animation: blink 2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.opponent-status-bar { background: rgba(156, 136, 255, 0.1); color: var(--primary-multi); padding: 7px; border-radius: 8px; margin-bottom: 12px; font-size: 0.85rem; text-align: center; font-weight: bold; border: 1px solid rgba(156, 136, 255, 0.2); }
.multi-lobby-slots { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 15px; }
.multi-lobby-slot { background: rgba(255,255,255,0.05); padding: 8px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; border: 1px solid rgba(255,255,255,0.1); }
.slot-filled { border-color: var(--primary-multi); background: rgba(156,136,255,0.1); }
.slot-name { font-weight: bold; font-size: 0.85rem; }
.slot-status { font-size: 0.65rem; color: #aaa; }

.result-title-style { margin: 0 0 10px; font-size: 1.8rem; letter-spacing: 1px; font-weight: 700; color: #ccc; }
.winner-declare { font-size: 1.3rem; color: var(--accent-gold); font-weight: 900; animation: pulse 1s infinite; margin-bottom: 8px; }
/* ★修正: リザルトコンテナを常に横一列(nowrap)にする */
.res-grid-container {
    display: flex;
    flex-wrap: nowrap; /* 折り返しなし */
    justify-content: center;
    gap: 8px;
    margin-bottom: 0px;
    width: 100%;
}
/* ★修正: 個々のボックスをフレキシブルにする */
.res-grid-box {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
    
    flex: 1; /* 均等にスペースを埋める */
    max-width: 130px; /* PCなどでは広がりすぎないように */
    min-width: 0; /* コンテンツが大きくても縮小を許可 */
    min-height: 110px;
}
/* ★追加: 自分のボックス用スタイル (YOUバッジの代わり) */
.res-grid-box.is-me {
    background: rgba(156, 136, 255, 0.15); /* 紫系の薄い背景 */
    border: 1px solid rgba(156, 136, 255, 0.4);
    box-shadow: 0 0 15px rgba(156, 136, 255, 0.1);
}

.res-grid-rank {
    font-size: 1.1rem; 
    font-weight: 900;
    font-style: italic; 
    margin-bottom: 5px;
    line-height: 1;
}
.res-grid-score { 
    font-size: 1.3rem; 
    font-family: var(--font-mono); 
    font-weight: bold; 
    margin: 4px 0; 
    /* margin-bottom: 5px; スコアと名前の間隔 */
    color: #fff; 
}
.res-grid-name { 
    font-size: 0.75rem; 
    font-weight: bold; 
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
    max-width: 100%; 
    margin-bottom: 4px; 
}


/* ★追加: WINSバッジ内の文字スタイル */
.win-label { font-size: 0.7rem; color: #aaa; }
.win-val { font-size: 1.2rem; color: #fff; font-weight: bold; }

/* 以前の Grid設定や幅指定を削除/無効化 */
.res-grid-container.players-3 .res-grid-box { width: auto; max-width: 130px; }
.res-grid-container.players-4 { display: flex; gap: 8px; } /* Grid設定を上書き */
.res-grid-container.players-4 .res-grid-box { width: auto; max-width: 130px; }

/* ★追加: モバイル対応 (480px以下) - 強力に縮小して一列に収める */
@media (max-width: 480px) {
    .res-grid-container {
        gap: 4px; /* 間隔を詰める */
    }
    
    .res-grid-box {
        padding: 6px 1px; /* 内側の余白を詰める */
        min-height: auto; /* 高さ制限を解除 */
        border-radius: 8px;
    }

    .res-grid-rank { font-size: 1.0rem; margin-bottom: 2px; }
    .res-grid-score { 
        font-size: 1.0rem; 
        margin-bottom: 2px; 
    } /* スコアを小さく */

    .res-grid-name { 
        font-size: 0.6rem; 
        margin-bottom: 2px; 
    } /* 名前を小さく */
    
    .res-win-badge {
        margin-top: 2px;
        padding: 2px 6px;
    }
    .win-label { font-size: 0.45rem; }
    .win-val { font-size: 1.0rem; }
}

/* Versus Rank Fonts (Simplified) */
/* 修正: 1stなどのサイズオーバーライドを削除し、統一サイズに */
.rank-1st { color: var(--accent-gold); }
.rank-2nd { color: #c0c0c0; }
.rank-3rd { color: #cd7f32; }
.rank-4th { color: #9556af; }
.res-you-badge { font-size: 0.55rem; color: var(--accent-green); letter-spacing: 1px; position: absolute; top: 4px; right: 4px; }
.res-win-badge { margin-top: 4px; background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; border: 1px solid rgba(255,255,255,0.1); }
/* --- Versus Result Layout Update --- */

/* 全体を囲むコンテナ: 横並び(Flex)にする */
.multi-compare-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 20px;
    margin: 20px auto;
    max-width: 95%;
}

/* 左側のTargetエリア */
.multi-compare-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

/* 中央の区切り線 */
.multi-compare-divider {
    width: 1px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
}

/* 右側のPlayersエリア (ラッパー) */
.multi-players-wrapper {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* 画面幅が狭い場合は折り返し */
}

/* 個々のプレイヤー要素 */
.multi-compare-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.5s;
}

.multi-compare-label {
    font-size: 0.7rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #fff;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 色を表示する小さい正方形 */
.mini-box {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    margin-bottom: 5px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* RGB数値テキスト */
.rgb-value-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #8b9bb4;
}

/* モバイル対応: 画面が狭くても横並びを維持し、全体を縮小して収める */
@media (max-width: 480px) {
    .multi-compare-container {
        flex-direction: row; /* 横並びを強制 */
        gap: 8px; /* 間隔を詰める */
        padding: 10px 5px; /* コンテナの余白を詰める */
        justify-content: center; /* 中央寄せ */
    }

    /* 区切り線 */
    .multi-compare-divider {
        width: 1px;
        height: 40px; /* 線を少し短く */
        background: rgba(255, 255, 255, 0.2);
        flex-shrink: 0; /* 線が潰れないように */
        margin: 0 2px;
    }

    /* 左側のTargetエリア */
    .multi-compare-target {
        min-width: auto; /* 固定幅を解除 */
        flex-shrink: 0; /* 潰れすぎないように */
    }

    /* 右側のPlayersエリア */
    .multi-players-wrapper {
        gap: 6px; /* プレイヤー同士の間隔を詰める */
        justify-content: center;
    }

    /* 共通: 色の正方形を小さく */
    .mini-box {
        width: 36px; /* 40px -> 28px */
        height: 36px;
        border-radius: 4px;
        margin-bottom: 3px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }

    /* 共通: ラベル文字を小さく */
    .multi-compare-label {
        font-size: 0.5rem; /* 0.7rem -> 0.55rem-> 0.50rem */
        margin-bottom: 2px;
        max-width: 50px; /* 名前が長すぎる場合は省略 */
    }

    /* 共通: RGB数値を小さく */
    .rgb-value-text {
        font-size: 0.55rem; /* 0.7rem -> 0.55rem */
        letter-spacing: -0.6px; /* 文字間を詰めて収まりよくする */
        white-space: nowrap; /* 改行させない */
    }
}
.flex-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Daily Result Styling (Compact) */
.daily-result-bg { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); border-radius: 20px; padding: 25px 15px; box-shadow: 0 0 50px rgba(0,0,0,0.5); }
.daily-res-header { margin-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px; }
.daily-res-label { display: block; font-size: 0.75rem; letter-spacing: 3px; color: var(--accent-gold); font-weight: bold; margin-bottom: 4px; }
.daily-res-date { font-size: 1.4rem; font-family: var(--font-mono); color: #fff; font-weight: bold; }
.daily-compare-container { display: flex; justify-content: center; gap: 20px; margin: 25px 0; }
.daily-color-block { display: flex; flex-direction: column; align-items: center; }
.daily-big-box { width: 70px; height: 70px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.2); margin-bottom: 8px; box-shadow: 0 8px 16px rgba(0,0,0,0.3); }
.daily-rgb-text { font-family: var(--font-mono); font-size: 0.85rem; color: #aaa; }

/* Custom Modals (Compact) */
.custom-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.85); z-index: 2000; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s; }
.custom-modal-box { background: #1a1d24; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; padding: 20px; width: 85%; max-width: 300px; text-align: center; box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7); }
.custom-modal-box p { color: #fff; font-size: 0.95rem; margin: 0 0 20px; line-height: 1.5; }
.custom-modal-actions { display: flex; justify-content: center; gap: 10px; }

/* Glitch Button */
.glitch-btn { background: #000; color: #fff; border: 1px solid #333; padding: 8px 16px; font-family: var(--font-mono); letter-spacing: 2px; cursor: pointer; transition: 0.2s; }
.glitch-btn:hover { background: #111; border-color: #555; text-shadow: 2px 0 red, -2px 0 blue; }
.glitch-text { text-shadow: 2px 0 red, -2px 0 blue; }
.btn-mono { background: #333; box-shadow: none; border: 1px solid #555; }

/* Logo Color Ranks */
.logo-rank-blue { background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%) !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; text-shadow: 0 0 15px rgba(0, 242, 254, 0.4); }
.logo-rank-red { background: linear-gradient(to right, #ff9a9e 0%, #fecfef 99%, #feada6 100%) !important; background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%) !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; text-shadow: 0 0 15px rgba(245, 87, 108, 0.4); }
.logo-rank-purple { background: linear-gradient(to right, #b24592 0%, #f15f79 100%) !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; text-shadow: 0 0 15px rgba(178, 69, 146, 0.4); }
.logo-rank-cyan { background: linear-gradient(to right, #00c6ff, #0072ff) !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; text-shadow: 0 0 20px rgba(0, 198, 255, 0.5); }
.logo-rank-gold { background: linear-gradient(to right, #f7971e, #ffd200) !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; text-shadow: 0 0 25px rgba(255, 210, 0, 0.6); }
.logo-rank-rainbow { background: linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000) !important; background-size: 400% 100% !important; background-clip: text !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; animation: rainbow-text 3s linear infinite; text-shadow: 0 0 30px rgba(255, 255, 255, 0.4); }
@keyframes rainbow-text { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }



/* ... (既存スタイル) ... */

/* Survival Result Score Block */
/* 修正: ID指定ではなくクラスで汎用的に適用 */
.result-score-block { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 15px; 
    margin: 8px 0; 
    padding: 12px; 
    background: rgba(0, 0, 0, 0.2); 
    border-radius: 12px; 
    border: 1px solid rgba(255, 255, 255, 0.05); 
}
.score-item { display: flex; flex-direction: column; align-items: center; }
.score-item .label { font-size: 0.65rem; color: var(--text-muted); margin-bottom: 3px; letter-spacing: 1px; }
.score-item .val { font-size: 1.3rem; font-family: var(--font-mono); font-weight: bold; color: #fff; }
.score-divider { font-size: 1.3rem; color: var(--text-muted); opacity: 0.3; }

/* 履歴リスト内のゴール表示 */
.history-goal-text { 
    font-size: 0.6rem; 
    color: var(--text-muted); 
    font-family: var(--font-mono); 
    white-space: nowrap; 
    margin-top: 2px; 
}
.stage-badge-history { 
    font-family: var(--font-mono); 
    font-weight: bold; 
    color: var(--bg-dark); 
    background: var(--text-muted); 
    padding: 2px 4px; 
    border-radius: 4px; 
    font-size: 0.75rem; 
    display: inline-block; 
    white-space: nowrap; 
}

/* Rush Mode Styles (Green Theme) */
.rush-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    align-items: end;
    /* 修正: マージンを追加してタイトルの下に配置 */
    margin-top: 5px; 
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(46, 213, 115, 0.2);
}
/* ... (以下変更なし) ... */


/* ... (既存のスタイルはそのまま) ... */

/* Tutorial Styles (Updated) */
.tutorial-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #0f1115; z-index: 9999;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    overflow-y: auto; /* スマホで内容が溢れないように */
}
.tut-content {
    text-align: center; width: 100%; max-width: 600px; padding: 20px;
    animation: fadeIn 0.8s ease-out;
    display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.tut-logo {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    animation: fadeIn 1s ease-out;
}
.tut-logo-img { width: 80px; height: 80px; filter: drop-shadow(0 0 15px rgba(255,255,255,0.3)); }
.tut-logo-text { font-family: var(--font-ui); font-weight: 900; font-size: 2rem; color: #fff; letter-spacing: 2px; }

/* Stylish Subtitle */
.tut-subtitle {
    font-family: var(--font-ui);
    font-weight: 200; /* Thin */
    font-size: 1.2rem;
    color: #8b9bb4;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: fadeIn 2s ease-out;
    margin-top: 10px;
}

.tut-skip {
    position: absolute; top: 20px; right: 20px;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: #aaa; padding: 8px 16px; border-radius: 20px; cursor: pointer;
    font-size: 0.8rem; font-family: var(--font-mono); transition: 0.2s;
    z-index: 10000;
}
.tut-skip:hover { background: rgba(255,255,255,0.2); color: #fff; }

.tut-demo-container { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; }
.tut-target-box, .tut-user-box {
    width: 100px; height: 100px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: relative;
    border: 1px solid rgba(255,255,255,0.1);
}
.tut-label-overlay {
    position: absolute; top: -25px; left: 0; width: 100%; text-align: center;
    color: #8b9bb4; font-size: 0.8rem; font-weight: bold; letter-spacing: 1px;
}
.tut-controls-wrapper { width: 100%; max-width: 400px; margin: 0 auto; }
.tut-guide {
    font-family: var(--font-mono); color: var(--text-muted); font-size: 1.2rem; margin-top: 20px;
    min-height: 1.5em; /* Prevent layout jump */
}

/* Stylish PERFECT */
.tut-perfect {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 5px;
    animation: tracking-in-expand 0.4s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
}
@keyframes tracking-in-expand {
  0% { letter-spacing: -0.5em; opacity: 0; }
  40% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Finale */
.tut-finale {
    font-family: var(--font-ui);
    font-weight: 200;
    font-size: 2rem;
    color: #fff;
    line-height: 1.2;
    animation: fadeIn 1s ease-out;
}
.tut-finale .highlight {
    font-weight: 900;
    font-size: 3rem;
    background: linear-gradient(to right, #fff, #999);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Disabled Slider in Tutorial */
.custom-range:disabled { opacity: 0.3; cursor: not-allowed; }
.custom-range:disabled::-webkit-slider-thumb { background: #555; border-color: #333; }


/* ... (既存のスタイル) ... */

/* Versus History (Added) */
.versus-history-container {
    width: 100%;
    margin-top: 25px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto; /* スマホで横スクロール対応 */
}
.vh-grid {
    display: grid;
    /* grid-template-columns はJSで動的に設定 (例: 50px 1fr 1fr) */
    gap: 4px;
    text-align: center;
    align-items: stretch;
    min-width: 280px; /* 極端に潰れないように */
}
.vh-cell {
    padding: 8px 4px;
    font-size: 0.8rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}
/* Header: Player Names */
.vh-header-name {
    font-weight: bold;
    color: #fff;
    font-size: 0.8rem;
    border-bottom: none;
    align-items: flex-end; /* 下揃え */
    padding-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Header: Win Counts */
.vh-header-wins {
    font-family: var(--font-mono);
    color: var(--accent-gold);
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-top: 0;
    padding-bottom: 8px;
    font-size: 0.75rem;
}
/* Column 1: Round Info */
.vh-round-col {
    font-family: var(--font-mono);
    color: #888;
    font-weight: bold;
    flex-direction: row; 
    gap: 8px;
    background: rgba(255,255,255,0.02); /* 少し背景色 */
}
/* Player Score Cells */
.vh-score-col {
    font-family: var(--font-mono);
    color: #fff;
    flex-direction: row; /* スコアの右に色 */
    gap: 6px;
    position: relative;
}
/* Winner Styling */
.vh-winner-cell {
    background: linear-gradient(to bottom, rgba(255, 221, 0, 0.1), transparent);
    border-radius: 4px;
}
.vh-winner-text {
    color: var(--accent-gold) !important;
    text-shadow: 0 0 8px rgba(255, 165, 2, 0.6);
    font-weight: 900;
}
/* Color Dot */
.vh-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* --- Versus History Grid Lines (Gap Method) --- */
.vh-grid {
    display: grid;
    gap: 1px; 
    background-color: rgba(255, 255, 255, 0.1); /* 線の色 */
    border: 1px solid rgba(255, 255, 255, 0.1); /* 外枠 */
    text-align: center;
    align-items: stretch;
    min-width: 280px;
}
.vh-cell {
    border-bottom: none; 
    background-color: rgba(20, 22, 28, 0.95); /* セルの色（透過少し） */
    padding: 8px 4px;
    font-size: 0.8rem;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}
.vh-winner-cell {
    background-color: rgba(255, 221, 0, 0.08);
}

/* ★修正: ヘッダー(名前・勝利数)と左列(ラウンド)の背景色を統一 */
.vh-header-name, .vh-header-wins, .vh-round-col {
    background-color: rgba(35, 40, 50, 1) !important; /* 少し明るいグレーで統一 */
    color: #fff;
}
.vh-header-name {
    align-items: flex-end; /* 名前は下揃え */
    padding-bottom: 4px;
}
.vh-header-wins {
    padding-top: 0;
    padding-bottom: 8px;
    color: var(--accent-gold);
    border-bottom: 1px solid rgba(255,255,255,0.1); /* 区切り線 */
}

/* --- Daily Color Layout Fix --- */
.daily-section {
    /* ...既存... */
    flex-wrap: wrap; /* 修正: 画面幅が狭い時に折り返す */
}
@media (max-width: 600px) {
    .daily-section {
        flex-direction: column;
        text-align: center;
        padding: 25px 20px;
    }
    .daily-main-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        width: 100%; /* 幅を確保 */
    }
    .daily-content {
        width: 100%;
    }
    .daily-desc {
        /* 長文でも崩れないように */
        word-wrap: break-word;
        line-height: 1.4;
    }
    .daily-status {
        width: 100%;
        margin-top: 15px;
        box-sizing: border-box; /* パディングを含める */
    }
}


/* --- Versus Menu Restructure --- */

/* 名前入力エリア */
.versus-top-section {
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

/* グループコンテナ: カードと入力をまとめる枠 */
.versus-group-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--primary-multi);
    border-radius: 16px;
    margin-bottom: 20px;
    overflow: hidden; /* 角丸のため */
    display: flex;
    flex-direction: column;
}

/* 上部のカードボタン部分 */
.game-card.versus-card-top {
    border: none;
    background: transparent;
    border-radius: 0;
    margin: 0;
    padding: 20px;
    transition: background 0.2s;
    /* クリックできることを強調 */
    position: relative;
}
.game-card.versus-card-top:hover {
    background: rgba(156, 136, 255, 0.1);
    transform: none; /* 個別の動きは無効化 */
    box-shadow: none;
}
.game-card.versus-card-top:active {
    background: rgba(156, 136, 255, 0.2);
}

/* 下部の入力エリア */
.versus-input-area {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px 15px;
    border-top: 1px solid rgba(156, 136, 255, 0.3);
    text-align: center;
}

.versus-mini-label {
    display: block;
    font-size: 0.65rem;
    color: var(--primary-multi);
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

/* ID入力フォーム */
.versus-id-input {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    padding: 8px;
    width: 100%;
    text-align: center;
    outline: none;
    letter-spacing: 4px;
}
.versus-id-input:focus {
    border-color: var(--primary-multi);
    background: rgba(0,0,0,0.5);
}

/* ゴール数調整用 */
.versus-input-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.versus-num-input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    width: 60px;
    text-align: center;
    outline: none;
}
.adjust-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}
.adjust-btn:hover { background: var(--primary-multi); border-color: var(--primary-multi); }


/* --- Daily Streak Features --- */

/* メニュー画面のストリークバッジ */
.streak-badge {
    /* ★変更: カード内での絶対配置に変更 */
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--accent-rush); /* オレンジ色 */
    background: rgba(255, 159, 67, 0.15);
    padding: 4px 10px; /* 少し余白調整 */
    border-radius: 6px;
    border: 1px solid rgba(255, 159, 67, 0.3);
    margin-bottom: 0; /* マージン削除 */
    text-shadow: 0 0 10px rgba(255, 159, 67, 0.4);
    animation: fadeIn 0.5s ease-out;
    backdrop-filter: blur(4px); /* 背景が透けても見やすく */
}

/* モバイル調整 (Dailyカードが縦並びになった時の位置調整) */
@media (max-width: 600px) {
    .streak-badge {
        top: 15px;
        right: 15px;
        font-size: 0.8rem;
    }
}

/* リザルト画面の履歴コンテナ */
.daily-history-container {
    width: 100%;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.daily-history-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: bold;
    text-align: left;
    margin-bottom: 8px;
    padding-left: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 履歴アイテム (レイアウト調整) */
.daily-history-item {
    display: grid; 
    /* 修正: 日付幅を75pxに縮小し、中央(色情報)にスペースを譲る */
    grid-template-columns: 75px 1fr auto;
    gap: 8px; 
    align-items: center; 
    padding: 10px 8px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
    background: rgba(255, 255, 255, 0.02); 
    border-radius: 8px; 
    margin-bottom: 4px;
}

/* 今日のハイライト（変更なし） */
.daily-history-item.today-highlight {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
    border-left: 3px solid var(--accent-gold); /* 2px -> 3px に統一 */
}
.daily-history-item.today-highlight .daily-history-date {
    color: var(--accent-gold);
    font-weight: bold;
}

/* 日付フォント調整 (少し小さくして収まりを良くする) */
.daily-history-date {
    font-family: var(--font-mono);
    font-size: 0.7rem; /* 0.75rem -> 0.7rem */
    color: #888; 
    text-align: left;
    white-space: nowrap; 
    letter-spacing: -0.5px; /* 文字間を少し詰める */
}

/* RGB値が見切れないようにフォントサイズ調整 */
.color-row span:last-child {
    font-size: 0.65rem; /* RGB数値のフォントサイズ調整 */
    letter-spacing: -0.5px;
}


/* --- Daily Section Kira-Kira Effect --- */

/* 光の筋となる層 */
.daily-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%; /* 開始位置（画面左外） */
    width: 80%; /* 光の幅 */
    height: 100%;
    /* 斜めの透明な光のグラデーション */
    background: linear-gradient(
        120deg,
        transparent 20%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 80%
    );
    transform: skewX(-20deg); /* 少し斜めにする */
    /* 6秒周期でアニメーションを無限に繰り返す */
    animation: shine-effect 10s infinite linear;
    pointer-events: none; /* クリックを妨げないように */
}

/* 光が移動するアニメーション */
@keyframes shine-effect {
    0% {
        left: -150%; /* 左外からスタート */
    }
    10% {
        left: 250%; /* 右外へ移動完了 */
    }
    100% {
        left: 250%; /* 残りの時間は待機 */
    }
}