/* Quiz4 CSS - 確実動作版（中央寄せ対応）*/
/* 配置場所: assets/quiz4.css */

/* ==========================================
   南の島のおじぃ カラーコンセプト（ネイビー＋ゴールド）
   ========================================== */
.quiz4-root {
    --base: #FFFFFF;
    --base-light: #FAFAFA;
    --base-dark: #F5F5F5;
    --main: #1e3a5f;
    --main-light: #2d5a8f;
    --main-dark: #0f1e3a;
    --accent: #d4af37;
    --accent-light: #f4cf5f;
    --accent-dark: #b8941f;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E8E8E8;
    --shadow: 0 4px 20px rgba(30, 58, 95, 0.10);
    --shadow-hover: 0 8px 30px rgba(30, 58, 95, 0.15);
}

/* 外ラッパー - 確実に中央配置 */
.quiz4-outer {
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    width: 100% !important;
    min-height: auto;
    padding: 20px 12px;
    margin: 0 auto !important;
    position: relative;
    background: transparent !important;
}

/* 画面全体を覆うfixed背景レイヤー（コンテンツの後ろに固定） */
.quiz4-bg-fixed {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: #1e3a5f;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='380' viewBox='0 0 600 380'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='0.55' opacity='0.13'%3E%3Cellipse cx='150' cy='190' rx='140' ry='50' transform='rotate(0   150 190)'/%3E%3Cellipse cx='150' cy='190' rx='140' ry='50' transform='rotate(40  150 190)'/%3E%3Cellipse cx='150' cy='190' rx='140' ry='50' transform='rotate(80  150 190)'/%3E%3Cellipse cx='150' cy='190' rx='140' ry='50' transform='rotate(120 150 190)'/%3E%3Cellipse cx='150' cy='190' rx='140' ry='50' transform='rotate(160 150 190)'/%3E%3Ccircle cx='150' cy='190' r='140'/%3E%3Ccircle cx='150' cy='190' r='100'/%3E%3Ccircle cx='150' cy='190' r='60'/%3E%3Cellipse cx='450' cy='190' rx='140' ry='50' transform='rotate(0   450 190)'/%3E%3Cellipse cx='450' cy='190' rx='140' ry='50' transform='rotate(40  450 190)'/%3E%3Cellipse cx='450' cy='190' rx='140' ry='50' transform='rotate(80  450 190)'/%3E%3Cellipse cx='450' cy='190' rx='140' ry='50' transform='rotate(120 450 190)'/%3E%3Cellipse cx='450' cy='190' rx='140' ry='50' transform='rotate(160 450 190)'/%3E%3Ccircle cx='450' cy='190' r='140'/%3E%3Ccircle cx='450' cy='190' r='100'/%3E%3Ccircle cx='450' cy='190' r='60'/%3E%3Cellipse cx='300' cy='190' rx='160' ry='45' transform='rotate(20  300 190)'/%3E%3Cellipse cx='300' cy='190' rx='160' ry='45' transform='rotate(70  300 190)'/%3E%3Cellipse cx='300' cy='190' rx='160' ry='45' transform='rotate(110 300 190)'/%3E%3Cellipse cx='300' cy='190' rx='160' ry='45' transform='rotate(160 300 190)'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 600px auto;
}

/* ルート要素 */
.quiz4-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.quiz4-root * {
    box-sizing: border-box;
}

/* 読み込み中 */
.quiz4-loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--text-light);
    background: var(--base-light);
    border-radius: 10px;
    border: 2px solid var(--border);
}

/* メインコンテナ */
.quiz4-container {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8F9FA 50%, #F0F2F5 100%);
    border-radius: 20px;
    padding: 12px;
    margin: 0 auto;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* セットアップ画面 */
.quiz4-setup {
    background: var(--base);
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 500px;
    width: 100%;
    border: 2px solid var(--border);
}

.quiz4-setup h1 {
    font-size: 2rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--main) 0%, var(--main-light) 60%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quiz4-setup p {
    margin: 10px 0;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* クイズ画面 */
.quiz4-wrap {
    background: var(--base);
    border-radius: 15px;
    padding: 30px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border: 2px solid var(--border);
    max-height: none;
    overflow: visible;
}

/* ヘッダー */
.quiz4-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: 15px;
    position: static;
}

/* タイトルはヘッダーから除外（フッターに表示） */
.quiz4-qcount {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--main);
    letter-spacing: 0.02em;
}

.quiz4-progress {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 0 18px 0;
}

.quiz4-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.quiz4-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* timebar 削除 */

.quiz4-timer {
    background: linear-gradient(135deg, var(--main-light), var(--main));
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.25);
    border: 2px solid rgba(212, 175, 55, 0.35);
}

.quiz4-timer.warning {
    /* 修正: 背景はネイビーのまま、数字だけ赤にする */
    background: linear-gradient(135deg, var(--main-light), var(--main));
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.6);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* 質問エリア */
.quiz4-question-container {
    margin-bottom: 30px;
}

.quiz4-question {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: var(--text);
    text-align: center;
    line-height: 1.5;
}

/* 画像問題（任意） */
.quiz4-question-media {
    display: flex;
    justify-content: center;
    margin: 0 0 14px;
}

.quiz4-question-image {
    width: min(240px, 70vw);
    height: auto;
    max-height: 220px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

/* 選択肢 */
.quiz4-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

@media (max-height: 760px) {
    .quiz4-wrap { padding: 18px; }
    .quiz4-header { margin-bottom: 10px; padding-bottom: 10px; }
    .quiz4-question-container { margin-bottom: 16px; }
    .quiz4-choices { margin: 12px 0; gap: 12px; }
}

@media (max-height: 640px) {
    .quiz4-outer { padding: 8px; }
    .quiz4-container { padding: 8px; border-radius: 16px; }
    .quiz4-wrap { padding: 14px; }
    .quiz4-header { gap: 10px; margin-bottom: 10px; padding-bottom: 10px; }
    .quiz4-question-container { margin-bottom: 12px; }
}

@media (max-width: 640px) {
    .quiz4-choices { grid-template-columns: 1fr; }
}

.quiz4-choice {
    padding: 20px;
    border: 3px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* 選択肢の色分け */
.quiz4-choice:nth-child(1) {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.quiz4-choice:nth-child(2) {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.quiz4-choice:nth-child(3) {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.quiz4-choice:nth-child(4) {
    background: linear-gradient(135deg, #10b981, #059669);
}

.quiz4-choice:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* 回答状態 */
/* 修正: 正解を緑色の強調表示（枠線・影・テキスト変化）に変更 */
.quiz4-choice.correct {
    background: linear-gradient(135deg, #16a34a, #15803d) !important;
    border: 3px solid #bbf7d0 !important;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35), 0 8px 25px rgba(22, 163, 74, 0.4) !important;
    transform: scale(1.04) !important;
    animation: correctPulse 0.6s ease;
}

.quiz4-choice.incorrect {
    background: linear-gradient(135deg, #7f1d1d, #991b1b) !important;
    animation: incorrectShake 0.6s ease;
}

.quiz4-choice.dimmed {
    opacity: 0.4;
    transform: none;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==========================================
   クリック待ち状態（回答後）
   ========================================== */
.quiz4-wrap.quiz4-waiting-click {
    cursor: pointer;
}

/* ==========================================
   結果スロット（ヘッダー直下）
   ========================================== */

/* クリック促しヒント */
.quiz4-click-hint {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 0 4px;
    animation: hintBlink 1.2s ease-in-out infinite;
}

@keyframes hintBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* 結果パネル本体 */
.quiz4-result-panel {
    width: 100%;
    background: linear-gradient(135deg, var(--main-dark) 0%, var(--main) 100%);
    border: 2px solid rgba(212, 175, 55, 0.45);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 4px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.quiz4-result-panel.quiz4-result-panel-show {
    opacity: 1;
    transform: translateY(0);
}

/* 解説テキスト行（解説あり時のみ表示） */
.quiz4-result-explanation {
    font-size: 1rem;
    line-height: 1.7;
    color: #fff;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    text-align: left;
}

/* タイトル＋次へボタン行 */
.quiz4-result-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
}

.quiz4-result-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.70);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* レスポンシブ：小画面ではタイトルを非表示 */
@media (max-width: 480px) {
    .quiz4-result-title {
        display: none;
    }
    .quiz4-result-action {
        justify-content: center;
    }
}

/* フッター */
.quiz4-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.quiz4-counter {
    color: var(--text-light);
    font-weight: 600;
}

/* ボタン */
.quiz4-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    margin: 5px;
}

.quiz4-btn-primary {
    background: linear-gradient(135deg, var(--main-light) 0%, var(--main) 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(30, 58, 95, 0.28);
    border: 2px solid rgba(212, 175, 55, 0.35);
}

.quiz4-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(30, 58, 95, 0.35);
}

.quiz4-btn-secondary {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    color: var(--main-dark);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.28);
}

.quiz4-btn-secondary:hover {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    transform: translateY(-1px);
}

/* 結果画面 */
.quiz4-results {
    text-align: center;
}

.quiz4-results-header h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--main);
}

.quiz4-score {
    font-size: 3rem;
    font-weight: 800;
    margin: 20px 0;
    background: linear-gradient(135deg, var(--main) 0%, var(--main-light) 60%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quiz4-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.quiz4-stat-card {
    background: linear-gradient(135deg, var(--base) 0%, var(--base-light) 100%);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.quiz4-stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--main);
    margin-bottom: 5px;
}

.quiz4-stat-label {
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
}

/* エラー表示 */
.quiz4-error {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border: 2px solid #fecaca;
    border-radius: 15px;
    padding: 25px;
    color: #991b1b;
    text-align: center;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.1);
}

.quiz4-error h3 {
    margin: 0 0 10px 0;
    color: #dc2626;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .quiz4-outer {
        padding: 12px 8px;
    }
    
    .quiz4-container {
        padding: 15px;
    }
    
    .quiz4-setup, .quiz4-wrap {
        padding: 20px;
    }
    
    .quiz4-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .quiz4-qcount { font-size: 1.1rem; }
    
    .quiz4-question {
        font-size: 1.1rem;
    }
    
    .quiz4-choices {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .quiz4-choice {
        padding: 15px;
        min-height: 60px;
        font-size: 0.9rem;
    }
    
    .quiz4-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .quiz4-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .quiz4-score {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .quiz4-setup h1 {
        font-size: 1.5rem;
    }
    
    .quiz4-choice {
        padding: 12px;
        min-height: 50px;
    }
    
    .quiz4-btn {
        width: 100%;
        margin: 5px 0;
    }
}
