/* =========================================
   共通設定・デザイン (260219-title-to-before_game8kore.html ベース)
   ========================================= */
:root {
    --page-title-margin-top: 40px;
    --difficulty-button-gap: 40px;
    --difficulty-button-zoom: 0.85;
    --page-title-max-width: 400px;
}

body, html {
    margin: 0; padding: 0; height: 100%; overflow: hidden;
    font-family: 'sans-serif';
    background-color: #f39c12;
    background-image: url('../assets/images/title-haikei.png');
    background-size: cover; background-position: center;
    color: white;
    transition: background-color 1.5s ease;
}

.screen {
    display: none; width: 100%; height: 100%;
    flex-direction: column; align-items: center;
    position: relative; overflow-y: auto;
    opacity: 0; transition: opacity 1s ease;
}
.screen.active { display: flex; opacity: 1; }

/* ゲーム画面・リザルト画面は全画面オーバーレイ */
#game-screen  { position: fixed; inset: 0; z-index: 40; background: #0f172a; overflow: hidden; }
#result-screen { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.95); overflow-y: auto; }

/* アニメーション */
@keyframes pulse { 0%{transform:scale(1);}50%{transform:scale(1.05);}100%{transform:scale(1);} }
.pulse-header { animation: pulse 3s infinite ease-in-out; }
.fade-exit { opacity: 0 !important; transition: opacity 1.5s ease !important; pointer-events: none; }
@keyframes pop { 0%{transform:scale(1);}50%{transform:scale(1.3);}100%{transform:scale(1);} }
.pop-anim { animation: pop 0.2s ease-out; }
@keyframes shake {
    10%,90%{transform:translate3d(-1px,0,0);}
    20%,80%{transform:translate3d(2px,0,0);}
    30%,50%,70%{transform:translate3d(-4px,0,0);}
    40%,60%{transform:translate3d(4px,0,0);}
}
.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }

/* ロゴ・ボタン共通 */
.title-logo { width: 900px; max-width: 90%; z-index: 10; }
.start-button { cursor: pointer; transition: transform 0.2s, opacity 1.5s ease; z-index: 10; height: 80px; width: auto; object-fit: contain; }
.start-button:hover { transform: scale(1.1); }

/* 難易度選択 */
.difficulty-header { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: var(--page-title-margin-top); width: 100%; z-index: 10; }
.player-indicator-img { height: 100px; width: auto; transition: all 0.5s cubic-bezier(0.175,0.885,0.32,1.275); opacity: 0.3; transform: scale(0.8); }
.player-indicator-img.active { opacity: 1; transform: scale(1.5); }
.difficulty-button-container { flex: 1; display: flex; width: 100%; justify-content: center; align-items: center; gap: var(--difficulty-button-gap); z-index: 5; }
.difficulty-button-wrapper { cursor: pointer; transition: transform 0.2s ease; transform: scale(var(--difficulty-button-zoom)); display: flex; justify-content: center; align-items: center; }
.difficulty-button-wrapper:hover { transform: scale(calc(var(--difficulty-button-zoom) * 1.05)); }
.difficulty-button { height: 60vh; width: auto; object-fit: contain; }

/* サイドスロット */
.side-selection-slot { position: absolute; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 15px; transition: all 0.6s cubic-bezier(0.23,1,0.32,1); opacity: 0; z-index: 20; }
#p1-slot { left: -300px; }
#p1-slot.visible { left: 80px; opacity: 1; }
#p2-slot { right: -300px; }
#p2-slot.visible { right: 80px; opacity: 1; }
.slot-choice-img { height: 40vh; border: 6px solid white; border-radius: 30px; background: rgba(255,255,255,0.3); }

/* 撮影画面 UI */
.video-viewport {
    position: relative; width: 100%; aspect-ratio: 1/1;
    background: rgba(0,0,0,0.5); border-radius: 24px;
    overflow: hidden; border: 8px solid #fff; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
}
video { position: absolute; height: 100% !important; width: 200% !important; max-width: none !important; object-fit: cover; transform: scaleX(-1); top: 0; }
#shared-video      { left: 0; }
#shared-video-copy { left: -100%; }

.smile-meter { height: 10px; background: rgba(255,255,255,0.2); border-radius: 5px; overflow: hidden; margin-top: 5px; }
.smile-level { height: 100%; background: #48bb78; width: 0%; transition: width 0.1s; }
.captured-preview { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; z-index: 20; display: none; background: rgba(0,0,0,0.8); }

.image-button { transition: transform 0.1s, opacity 0.2s; cursor: pointer; background: none; border: none; padding: 0; }
.image-button:hover { transform: scale(1.05); opacity: 0.9; }
.image-button img { max-height: 80px; width: auto; }
.back-btn-small { max-height: 80px !important; }

.instruction-area { height: 300px; display: flex; justify-content: center; align-items: center; margin-top: 20px; }
.instruction-img { max-width: 700px; height: auto; }

/* オーバーレイ指示 */
#big-instruction-screen { position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; justify-content: center; align-items: center; background: rgba(0,0,0,0.3); backdrop-filter: blur(4px); transition: opacity 0.5s ease-out; pointer-events: none; }
.big-instruction-img { max-width: 80%; max-height: 60%; object-fit: contain; animation: pulse 1.5s infinite ease-in-out; filter: drop-shadow(0 0 30px rgba(255,255,255,0.5)); }

/* ゲーム Canvas */
/* ランキング行の装飾 */
.ranking-row {
    display: flex; align-items: center; gap: 20px;
    padding: 15px 25px; background: rgba(255,255,255,0.05);
    border-radius: 15px; border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s;
}
.ranking-row:hover { transform: scale(1.02); background: rgba(255,255,255,0.08); }
.rank-badge {
    width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; font-weight: bold; font-size: 20px; shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #fcd34d, #d97706); color: #78350f; box-shadow: 0 0 15px rgba(245,158,11,0.4); }
.rank-2 { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #374151; }
.rank-3 { background: linear-gradient(135deg, #fbbf24, #b45309); color: #451a03; }
.rank-other { background: #374151; color: #9ca3af; }

/* 楽曲タブ */
.song-tab {
    padding: 10px 20px;
    background: #1f2937;
    border: 2px solid #374151;
    border-radius: 12px;
    color: #9ca3af;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.song-tab:hover {
    background: #374151;
    color: white;
}
.song-tab.active {
    background: #f59e0b;
    border-color: #fef3c7;
    color: white;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

/* カスタムスクロールバー */
.scrollbar-thin::-webkit-scrollbar {
    width: 8px;
}
.scrollbar-thin::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 4px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

/* ランキングモーダルのディゾルブ・スケール演出 */
#ranking-modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(0px);
}
#ranking-modal.active {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(8px);
}
/* モーダル内部のコンテンツを少しズームさせる */
#ranking-modal > div {
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#ranking-modal.active > div {
    transform: scale(1);
}
