/* =========================================
   1. 基本レイアウト
   ========================================= */
body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100dvh; 
    margin: 0; 
    background-color: #121212; 
    color: #f0f0f0; 
    user-select: none; 
    overflow: hidden;
    touch-action: none;
}

#game-container {
    background-color: #1e1e1e; 
    padding: 15px; 
    border-radius: 15px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7); 
    text-align: center; 
    width: 95%; 
    max-width: 400px; 
    box-sizing: border-box;
    transform: translateY(-10px); 
    position: relative;
}

/* =========================================
   2. ヘッダー・情報パネル
   ========================================= */
#title { font-size: 1.2rem; margin: 10px 0; line-height: 1.4; color: #fff; }
#audio-status { font-size: 0.7rem; font-weight: bold; color: #ffb300; margin-bottom: 8px; letter-spacing: 0.1em; }
.loading-pulse { animation: pulse-text 1.5s infinite; }
@keyframes pulse-text { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

#info-panel { 
    display: flex; justify-content: space-around; padding: 8px 0; 
    margin-bottom: 10px; border-bottom: 2px solid #333; font-weight: bold; font-size: 0.9rem;
}
#timer, #score, #highscore { color: #4dd0e1; }

/* =========================================
   3. ゲームプレイエリア
   ========================================= */
#drag-area-wrapper {
    width: 280px; height: 280px; margin: 15px auto; border-radius: 50%;
    background-image: url('drag_area_bg.jpg'); background-size: cover; background-position: center;
    position: relative; overflow: hidden; box-shadow: inset 0 0 20px rgba(0,0,0,0.8); border: 2px solid #333;
}
#drag-area { 
    width: 100%; height: 100%; background-color: transparent; border: 5px dashed #ffb300; 
    border-radius: 50%; display: flex; flex-direction: column; justify-content: center; 
    align-items: center; touch-action: none; box-sizing: border-box; position: relative; z-index: 5;
}
.wrong-direction { box-shadow: inset 0 0 80px rgba(255, 0, 0, 0.9) !important; border-color: #ff0000 !important; background-color: rgba(255, 0, 0, 0.1) !important; }

#direction-guide { position: absolute; width: 85%; height: 85%; border: 4px solid rgba(255, 255, 255, 0.05); border-radius: 50%; border-top: 4px solid rgba(255, 179, 0, 0.4); animation: guide-rotate 2s linear infinite; pointer-events: none; }
@keyframes guide-rotate { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }

#indicator { position: absolute; width: 45px !important; height: 45px !important; transform: translate(-50%, -50%); z-index: 20; pointer-events: none; }

#instruction-1, #instruction-2 {
    font-weight: bold;
    text-shadow: 2px 2px 2px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    pointer-events: none;
}
#instruction-1 { font-size: 1rem; color: #fff; margin: 0; }
#instruction-2 { font-size: 0.75rem; margin: 5px 0 0 0; color: #ffb300; }

#audio-notice { font-size: 0.7rem; color: #aaa; margin: 15px 0 5px 0; line-height: 1.4; white-space: pre-line; }

/* =========================================
   4. ボタン
   ========================================= */
#start-button, #retry-button { 
    padding: 16px; font-size: 1.1rem; background-color: #4CAF50; color: white; border: none; 
    border-radius: 10px; cursor: pointer; width: 100%; margin-top: 15px; font-weight: bold; 
    box-sizing: border-box; box-shadow: 0 4px 0 #2e6b31; display: block;
}
#start-button:active, #retry-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #2e6b31; }

.secondary-button { 
    background-color: #444; width: auto; min-width: 120px; font-size: 0.85rem; padding: 10px 20px; 
    margin-top: 25px !important; margin-bottom: 10px; border-radius: 8px; opacity: 0.8; color: white; border: none;
}

#sub-button-container { display: flex; justify-content: center; gap: 10px; }

/* =========================================
   5. オーバーレイ
   ========================================= */
#countdown-overlay, #result-overlay, #main-ranking-modal {
    position: fixed; 
    top: 50%; 
    left: 50%; 
    width: 100vw; 
    height: 100dvh; 
    background: rgba(0, 0, 0, 0.9); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 9999; 
    transform: translate(-50%, -50%) !important;
}

#countdown-text { 
    color: #ffeb3b; font-weight: 900; font-size: 15vw; 
    text-shadow: 0 0 30px rgba(255, 235, 59, 0.5); 
    text-align: center; width: 100%; margin: 0;
}

#result-content, #main-ranking-content { 
    background: #282828; padding: 25px; border-radius: 15px; text-align: center; 
    border: 2px solid #ffb300; width: 90%; max-width: 380px; 
    max-height: 90vh; overflow-y: auto; box-sizing: border-box; 
}
#main-ranking-content { border-color: #4dd0e1; }

/* =========================================
   6. リザルト・ランキング詳細
   ========================================= */
#final-score { font-size: 2.2rem; font-weight: bold; color: #4dd0e1; margin: 5px 0; }
#new-highscore { color: #ffeb3b; font-weight: bold; font-size: 0.9rem; margin-bottom: 15px; min-height: 1.2em; }

#promo-container { background: linear-gradient(145deg, #1a1a1a, #333); padding: 15px; border-radius: 12px; border: 2px solid #4dd0e1; margin-bottom: 15px; }
#promo-message { font-size: 0.9rem; font-weight: bold; color: #fff; margin-bottom: 12px; line-height: 1.5; white-space: pre-line; }

.ticket-button { display: block; background: linear-gradient(to right, #ff0055, #ff4d00); color: white; text-decoration: none; padding: 18px 5px; border-radius: 50px; font-size: 1.1rem; font-weight: 900; margin: 5px 0; animation: pulse-ticket 2s infinite; }
@keyframes pulse-ticket { 0%, 100% { transform: scale(1); } 70% { transform: scale(1.05); } }

#ranking-catchphrase { 
    color: #ffb300; 
    /* 見切れ防止：clampで自動調整 */
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); 
    font-weight: bold; margin-bottom: 12px; animation: flash 2s infinite;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; display: block;
}
@keyframes flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

#name-input-area { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 15px; }
#player-name { width: 90%; padding: 12px; border-radius: 8px; border: 1px solid #444; background: #111; color: white; font-size: 1rem; text-align: center; box-sizing: border-box; }
#submit-score-button { width: 90%; padding: 12px; background: #4dd0e1; color: #000; font-weight: bold; border-radius: 8px; border: none; cursor: pointer; }

#ranking-list, #main-ranking-list { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; text-align: left; }
#ranking-list li, #main-ranking-list li { padding: 6px 0; border-bottom: 1px solid #333; display: flex; justify-content: space-between; color: #ccc; }

#close-ranking-button { 
    background-color: #444; color: white; border: none; padding: 10px 20px; 
    border-radius: 8px; cursor: pointer; margin-top: 15px; width: 100%;
}

/* =========================================
   7. 演出・その他
   ========================================= */
.hidden { display: none !important; }
.god-mode-bg { animation: god-flash 0.5s infinite; }
@keyframes god-flash { 0%, 100% { background-color: #282828; } 50% { background-color: #442200; border-color: #ffeb3b; } }
.confetti { position: fixed; width: 10px; height: 10px; z-index: 4000; pointer-events: none; }

@media screen and (min-width: 600px) {
    #countdown-text { font-size: 120px; }
}

@media screen and (max-height: 600px) {
    #drag-area-wrapper { width: 230px; height: 230px; }
    #title { font-size: 1rem; margin: 5px 0; }
}

/* 追加: 全世界累計カウンターのスタイル */
#global-counter-container {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #4dd0e1;
    border-radius: 8px;
    padding: 8px;
    margin: 5px auto 15px auto;
    width: fit-content;
    min-width: 180px;
    box-shadow: 0 0 10px rgba(77, 208, 225, 0.2);
}
.global-label {
    font-size: 0.6rem;
    color: #4dd0e1;
    letter-spacing: 1px;
    margin-bottom: 2px;
    font-weight: bold;
}
#global-total-spin {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: #ffeb3b;
    text-shadow: 0 0 8px rgba(255, 235, 59, 0.6);
}

/* 既存のコードはそのまま維持 */


/* モーダル内のリスト表示をスクロール可能にする */
#main-ranking-list, #ranking-list {
    max-height: 350px; /* 画面の高さに合わせて調整 */
    overflow-y: auto;
    padding: 10px;
    margin: 10px 0;
    list-style: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* スクロールバーのデザイン */
#main-ranking-list::-webkit-scrollbar {
    width: 6px;
}
#main-ranking-list::-webkit-scrollbar-thumb {
    background: #4dd0e1;
    border-radius: 10px;
}

/* モーダルのコンテンツ幅を調整 */
#main-ranking-content {
    max-width: 90%;
    width: 400px;
}