/* ==========================================
   万博クイズ 1000問 - スタイルシート
   ========================================== */

/* --- アニメーション定義 --- */
@keyframes correctFlash {
    0% { background-color: #4CAF50; transform: scale(1); }
    50% { background-color: #66BB6A; transform: scale(1.03); }
    100% { background-color: #4CAF50; transform: scale(1); }
}

@keyframes incorrectFlash {
    0% { background-color: #E4002B; transform: scale(1); }
    25% { transform: translateX(-4px); }
    50% { background-color: #FF5252; transform: translateX(4px); }
    75% { transform: translateX(-4px); }
    100% { background-color: #E4002B; transform: scale(1); }
}

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

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.5); }
    70% { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes confetti {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

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

@keyframes bigCross {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

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

/* --- 汎用アニメーションクラス --- */
.animate-slide-in-up {
    animation: slideInUp 0.5s ease-out forwards;
}

.animate-slide-in-down {
    animation: slideInDown 0.4s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-pop-in {
    animation: popIn 0.4s ease-out forwards;
}

/* --- レベルカード --- */
.level-card {
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent);
    transition: opacity 0.3s ease;
}

.level-card:hover::before {
    opacity: 1;
}

.level-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.level-card.locked {
    background: #e0e0e0 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.level-card.locked:hover {
    transform: none;
    box-shadow: none;
}

.level-card.locked::before {
    display: none;
}

.level-card-1 { background: linear-gradient(135deg, #4CAF50, #66BB6A); color: white; }
.level-card-2 { background: linear-gradient(135deg, #2196F3, #42A5F5); color: white; }
.level-card-3 { background: linear-gradient(135deg, #FF9800, #FFB74D); color: white; }
.level-card-4 { background: linear-gradient(135deg, #9C27B0, #BA68C8); color: white; }
.level-card-5 { background: linear-gradient(135deg, #E4002B, #FF5252); color: white; }

/* --- カテゴリカード --- */
.category-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
}

.category-card:hover {
    border-color: #0068B7;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 104, 183, 0.15);
}

.category-card .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* --- クイズ選択肢ボタン --- */
.choice-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 1.25rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.choice-btn:hover:not(:disabled) {
    border-color: #0068B7;
    background: #f0f7ff;
    transform: translateX(4px);
}

.choice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.choice-btn .choice-label {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0068B7;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.875rem;
}

.choice-btn.correct {
    border-color: #4CAF50;
    background: #e8f5e9;
    animation: correctFlash 0.6s ease;
}

.choice-btn.correct .choice-label {
    background: #4CAF50;
}

.choice-btn.incorrect {
    border-color: #E4002B;
    background: #fce4ec;
    animation: incorrectFlash 0.5s ease;
}

.choice-btn.incorrect .choice-label {
    background: #E4002B;
}

/* --- プログレスバー --- */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0068B7, #FFB800);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* --- ランキングテーブル --- */
.ranking-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.ranking-table th {
    background: #0068B7;
    color: white;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.ranking-table th:first-child {
    border-top-left-radius: 8px;
}

.ranking-table th:last-child {
    border-top-right-radius: 8px;
}

.ranking-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    font-size: 0.875rem;
}

.ranking-table tbody tr:hover {
    background: #f0f7ff;
}

.ranking-table tbody tr.my-score {
    background: linear-gradient(90deg, #fff8e1, #fff3cd, #fff8e1);
    font-weight: 600;
    box-shadow: inset 4px 0 0 #FFB800;
    animation: myScoreGlow 2s ease-in-out infinite;
}

@keyframes myScoreGlow {
    0%, 100% { background-color: rgba(255, 243, 205, 0.6); }
    50% { background-color: rgba(255, 243, 205, 1); }
}

.my-nickname {
    font-weight: 800;
    color: #b8860b;
}

.my-badge {
    display: inline-block;
    background: linear-gradient(135deg, #FFB800, #FFC940);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 50px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}

.ranking-table .rank-1 td:first-child { color: #FFB800; font-weight: bold; font-size: 1.1rem; }
.ranking-table .rank-2 td:first-child { color: #9e9e9e; font-weight: bold; }
.ranking-table .rank-3 td:first-child { color: #CD7F32; font-weight: bold; }

/* --- 検定合格証 --- */
.certificate {
    margin-bottom: 1.5rem;
}

.certificate-inner {
    background: linear-gradient(145deg, #fdf6e3, #fff8dc, #fdf6e3);
    border-radius: 16px;
    padding: 6px;
    box-shadow: 0 8px 32px rgba(180, 140, 60, 0.25), inset 0 0 20px rgba(255,215,0,0.1);
}

.certificate-border {
    border: 3px double #c9a84c;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    position: relative;
    background: linear-gradient(180deg, rgba(255,248,220,0.5), rgba(253,246,227,0.8));
}

.certificate-border::before,
.certificate-border::after {
    content: '✦';
    position: absolute;
    color: #c9a84c;
    font-size: 1.2rem;
    opacity: 0.6;
}

.certificate-border::before { top: 8px; left: 12px; }
.certificate-border::after { bottom: 8px; right: 12px; }

/* --- 結果画面（不合格） --- */
.result-failed {
    background: linear-gradient(135deg, #E4002B, #FF5252);
    color: white;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    animation: popIn 0.6s ease-out;
}

/* --- ○×アニメーション --- */
.answer-symbol {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10rem;
    font-weight: bold;
    z-index: 100;
    pointer-events: none;
}

.answer-symbol.correct-symbol {
    color: rgba(76, 175, 80, 0.6);
    animation: bigCircle 0.6s ease-out forwards;
}

.answer-symbol.incorrect-symbol {
    color: rgba(228, 0, 43, 0.6);
    animation: bigCross 0.6s ease-out forwards;
}

/* --- 紙吹雪 --- */
.confetti-piece {
    position: fixed;
    top: -10px;
    z-index: 200;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti 3s ease-in forwards;
}

/* --- 解説エリア --- */
.explanation-area {
    background: #f5f5f5;
    border-left: 4px solid #FFB800;
    border-radius: 0 12px 12px 0;
    padding: 1.25rem;
    margin-top: 1rem;
}

.explanation-box {
    background: white;
    border: 2px solid #FFB800;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.explanation-box p {
    color: #333;
    line-height: 1.6;
    font-size: 0.9rem;
}

/* --- ランキング登録CTA --- */
.ranking-register-cta {
    background: linear-gradient(145deg, #fdf6e3, #fff8dc, #fdf6e3);
    border: 2px solid #c9a84c;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 16px rgba(180, 140, 60, 0.2);
}

.btn-ranking-register {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #c9a84c, #e6c86e);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-ranking-register:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.4);
    background: linear-gradient(135deg, #b89a40, #d4b85e);
}

/* --- タブ --- */
.tab-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e0e0e0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f5f5f5;
    color: #666;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: white;
    border-color: #0068B7;
    color: #0068B7;
}

/* --- フォーム --- */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #0068B7;
    box-shadow: 0 0 0 3px rgba(0, 104, 183, 0.1);
}

.btn-primary {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #E4002B, #ff3355);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(228, 0, 43, 0.3);
}

.btn-secondary {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #0068B7, #2196F3);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 104, 183, 0.3);
}

.btn-gold {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #FFB800, #FFC940);
    color: #333;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 184, 0, 0.3);
}

/* --- タイマー --- */
.timer-display {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: bold;
    color: #0068B7;
}

/* --- クイズ画面コンパクトレイアウト --- */
#quiz-area .choice-btn {
    padding: 0.6rem 1rem;
}

#quiz-area .space-y-3 > * + * {
    margin-top: 0.5rem;
}

/* --- モバイル対応 --- */
@media (max-width: 640px) {
    .choice-btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.5rem;
    }

    .choice-btn .choice-label {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.7rem;
    }

    .choice-btn .choice-text {
        line-height: 1.3;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }

    .answer-symbol {
        font-size: 6rem;
    }

    .level-card {
        padding: 1rem;
    }

    /* クイズ画面をビューポート内に収める */
    #quiz-area {
        font-size: 0.95rem;
    }

    .explanation-box {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .explanation-box p {
        font-size: 0.85rem;
        line-height: 1.5;
    }
}
