/* 성경 퀴즈 — 모바일 우선 (최대 480px) 스타일 */

* {
    box-sizing: border-box;
}

/* HTML hidden 속성 강제 — .modal-overlay 등 display:flex 룰이 hidden 을 override 하는 문제 차단 */
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    background: #f4f6fb;
    color: #1a2032;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.quiz-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 14px 96px;
}

/* ===== 헤더 ===== */
.quiz-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 14px;
}

.header-left {
    display: flex;
    align-items: center;
    justify-self: start;
}

.header-right {
    display: flex;
    gap: 8px;
    justify-self: end;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 8px;
    color: #4a5572;
    text-decoration: none;
    font-size: 14px;
    border-radius: 6px;
}

.back-link:hover {
    background: rgba(74, 85, 114, 0.08);
}

.quiz-page-title {
    margin: 0;
    font-size: 18px;
    text-align: center;
    color: #1a2032;
}

.header-btn {
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #d0d6e3;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #2c3754;
    transition: background-color 120ms, border-color 120ms;
}

.header-btn:hover {
    background: #f0f3f9;
}

.header-btn.danger {
    color: #b53b3b;
    border-color: #e5b5b5;
}

.header-btn.danger:hover {
    background: #fbecec;
}

/* ===== 패널 공용 ===== */
.quiz-panel {
    background: #fff;
    border-radius: 14px;
    padding: 20px 18px;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
    margin-bottom: 16px;
}

.panel-title {
    margin: 0 0 6px;
    font-size: 17px;
    color: #1a2032;
}

.panel-desc {
    margin: 0 0 16px;
    color: #586278;
    font-size: 14px;
}

/* ===== 생성 폼 ===== */
.quiz-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #3b4566;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d6e3;
    border-radius: 9px;
    font-size: 15px;
    font-family: inherit;
    background: #fafbfd;
    color: #1a2032;
    min-height: 44px;
    transition: border-color 120ms, background-color 120ms;
}

.form-textarea {
    resize: vertical;
    min-height: 200px;
    line-height: 1.7;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #4a6cf7;
    background: #fff;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.primary-btn {
    flex: 1;
    min-height: 48px;
    padding: 0 16px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, transform 80ms;
}

.primary-btn:hover {
    background: #3a5be0;
}

.primary-btn:active {
    transform: translateY(1px);
}

.primary-btn:disabled {
    background: #b6c0d9;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    min-height: 44px;
    padding: 0 18px;
    background: #fff;
    color: #2c3754;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms;
}

.secondary-btn:hover {
    background: #f0f3f9;
    border-color: #b6c0d9;
}

.form-hint {
    margin: 0;
    font-size: 12px;
    color: #7a839c;
}

/* ===== 풀이 뷰 ===== */
.playing-toolbar {
    display: flex;
    margin-bottom: 14px;
}

.playing-toolbar .secondary-btn {
    padding: 0 14px;
    font-size: 13px;
}

.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #4a5572;
}

.progress-text {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.progress-text #quizSetTitle {
    color: #2c3754;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60vw;
}

.progress-divider {
    color: #b6c0d9;
}

.score-text {
    flex-shrink: 0;
    color: #4a6cf7;
    font-weight: 600;
}

.progress-bar {
    height: 6px;
    background: #e3e8f2;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 18px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6cf7, #6a8aff);
    width: 0%;
    transition: width 220ms ease;
}

.questions-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.question-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px 16px;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
}

.question-meta {
    display: flex;
    justify-content: flex-end;
    font-size: 12px;
    color: #7a839c;
    margin-bottom: 6px;
}

.question-content {
    font-size: 16px;
    line-height: 1.75;
    color: #1a2032;
    margin: 0 0 16px;
}

.options-label {
    font-size: 12px;
    color: #7a839c;
    margin-bottom: 8px;
}

/* ===== 답 입력 — 책/장/절 셀렉트 ===== */
.answer-selects {
    display: grid;
    /* 책·장 2개 셀렉트 (절 셀렉트 제거됨). 책 이름이 길어 2fr, 장은 1fr */
    grid-template-columns: 2fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.answer-select {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #d0d6e3;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #2c3754;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #7a839c 50%),
                      linear-gradient(135deg, #7a839c 50%, transparent 50%);
    background-position: calc(100% - 14px) calc(50% - 2px),
                         calc(100% - 9px) calc(50% - 2px);
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
}

.answer-select:focus {
    outline: none;
    border-color: #4a6cf7;
}

.answer-select:disabled {
    background-color: #f0f3f9;
    color: #8a92a8;
    cursor: not-allowed;
}

.answer-actions {
    display: flex;
    gap: 8px;
}

.answer-submit-btn {
    flex: 1;
    min-height: 44px;
    padding: 0 16px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, transform 80ms;
}

.answer-submit-btn:hover:not(:disabled) {
    background: #3a5be0;
}

.answer-submit-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.answer-submit-btn:disabled {
    background: #b6c0d9;
    cursor: not-allowed;
}

.answer-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #f4f6fb;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-badge {
    display: inline-block;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.result-badge.full {
    background: #e3f5e8;
    color: #1f6b2a;
    border: 1px solid #8fcf99;
}

.result-badge.partial {
    background: #fff5d6;
    color: #6b4a00;
    border: 1px solid #ffd76b;
}

.result-badge.zero {
    background: #fdecec;
    color: #8a2828;
    border: 1px solid #e5b5b5;
}

.result-answer {
    font-size: 14px;
    color: #2c3754;
}

.dont-know-row {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.dont-know-btn {
    border: none;
    background: none;
    color: #4a6cf7;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
}

.dont-know-btn:hover {
    text-decoration: underline;
}

.dont-know-btn:disabled {
    color: #b6c0d9;
    cursor: default;
    text-decoration: none;
}

.playing-footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ===== 기록 등록 ===== */
.attempt-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 22px;
}

.attempt-register-btn {
    width: 100%;
}

.attempt-hint {
    margin: 0;
    text-align: center;
    font-size: 12px;
    color: #7a839c;
}

/* ===== 기록판 (leaderboard) ===== */
.leaderboard-panel {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid #e3e8f2;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
}

.leaderboard-title {
    margin: 0;
    font-size: 15px;
    color: #1a2032;
}

.leaderboard-refresh {
    min-height: 44px;
    padding: 0 12px;
    font-size: 13px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-empty {
    margin: 8px 0 0;
    text-align: center;
    color: #7a839c;
    font-size: 13px;
}

.leaderboard-card {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fafbfd;
    border: 1px solid #e3e8f2;
    border-radius: 10px;
}

.leaderboard-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e3e8f2;
    color: #4a5572;
    font-weight: 700;
    font-size: 13px;
}

.leaderboard-card.top-1 .leaderboard-rank {
    background: #ffd76b;
    color: #6b4a00;
}

.leaderboard-card.top-2 .leaderboard-rank {
    background: #d6dde8;
    color: #2c3754;
}

.leaderboard-card.top-3 .leaderboard-rank {
    background: #f1c39b;
    color: #6b3a14;
}

.leaderboard-info {
    min-width: 0;
}

.leaderboard-nickname {
    font-weight: 600;
    color: #1a2032;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-meta {
    font-size: 12px;
    color: #7a839c;
}

.leaderboard-score {
    font-weight: 700;
    color: #4a6cf7;
    font-size: 15px;
    white-space: nowrap;
}

/* ===== 기존 퀴즈 세트 목록 ===== */
.existing-sets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.existing-set-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    background: #fafbfd;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: #1a2032;
    transition: background-color 120ms, border-color 120ms, transform 80ms;
}

.existing-set-card:hover {
    background: #f0f4ff;
    border-color: #b9c5e8;
}

.existing-set-card:active {
    transform: translateY(1px);
}

.existing-set-card:focus-visible {
    outline: 2px solid #4a6cf7;
    outline-offset: 2px;
}

.existing-set-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a2032;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.existing-set-meta {
    font-size: 12px;
    color: #7a839c;
}

/* ===== 안내 상태 ===== */
.state-panel {
    text-align: center;
}

.state-message {
    margin: 12px 0;
    color: #586278;
}

/* ===== 토스트 ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9000;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.toast {
    pointer-events: auto;
    background: #1a2032;
    color: #fff;
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: toast-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
    max-width: 90vw;
    text-align: center;
}

.toast.success {
    background: #2f7a3f;
}

.toast.danger {
    background: #b53b3b;
}

.toast.warn {
    background: #b8731f;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 모달 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 60, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9500;
    animation: overlay-in 140ms ease both;
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 20px 18px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    animation: modal-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-title {
    margin: 0 0 12px;
    font-size: 17px;
    color: #1a2032;
}

.modal-body {
    color: #3b4566;
    font-size: 14px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-body label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #3b4566;
}

.modal-body input,
.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d6e3;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    min-height: 40px;
}

.modal-body textarea {
    min-height: 160px;
    resize: vertical;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 120ms;
}

.modal-cancel {
    background: #fff;
    color: #2c3754;
    border-color: #d0d6e3;
}

.modal-cancel:hover {
    background: #f0f3f9;
}

.modal-ok {
    background: #4a6cf7;
    color: #fff;
}

.modal-ok:hover {
    background: #3a5be0;
}

.modal-ok.danger {
    background: #d95252;
}

.modal-ok.danger:hover {
    background: #b53b3b;
}

/* ===== 모바일 좁은 화면 ===== */
@media (max-width: 480px) {
    .quiz-layout {
        padding: 12px 10px 96px;
    }

    .quiz-page-title {
        font-size: 16px;
    }

    .quiz-panel {
        padding: 16px 14px;
    }

    .question-content {
        font-size: 15px;
    }

    .answer-selects {
        grid-template-columns: 1fr;
    }

    /* 생성 버튼 영역 — 좁은 화면에선 세로로 쌓아 풀폭 탭 영역 확보 */
    .form-actions {
        flex-direction: column;
    }

    .progress-text #quizSetTitle {
        max-width: 50vw;
    }

    .leaderboard-card {
        grid-template-columns: 32px 1fr auto;
        gap: 10px;
        padding: 10px;
    }

    .leaderboard-nickname {
        font-size: 13px;
    }

    .leaderboard-score {
        font-size: 14px;
    }
}
