* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #020259 0%, #1a0b6b 50%, #2d1b8a 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: #ffffff;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    min-height: 100dvh;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 홈 버튼 스타일 */
.home-button-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 15px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.home-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.home-icon {
    font-size: 1.2rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

header h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 10px;
    background: linear-gradient(45deg, #ffffff, #a8d8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(168, 216, 255, 0.3);
}

header p,
.subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: #b8c5d6;
    opacity: 0.9;
    word-break: keep-all;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.quiz-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 35px;
    box-shadow:
            0 25px 50px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    position: relative;
    overflow: hidden;
    animation: slideInFromLeft 0.8s ease-out;
    margin: 0 10px;
    min-width: 0;   /* flex 자식이 내부 콘텐츠로 인해 늘어나지 않도록 */
}

/* 퀴즈 내부 컨테이너들이 부모 너비를 넘지 않도록 강제 */
.quiz-container .question-container,
.quiz-container .options,
.quiz-container .result-container,
.quiz-container .explanation,
.quiz-container .explanation-content {
    min-width: 0;
    max-width: 100%;
}

.quiz-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.quiz-container:hover::before {
    left: 100%;
}

.quiz-header {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e, #16a34a);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.6);
    position: relative;
    overflow: hidden;
    animation: pulse 2s infinite;
}

.progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.question-number {
    text-align: center;
    font-size: 1.1rem;
    color: #d1d9e6;
}

.question-container {
    padding: 0;
    margin-bottom: 25px;
    min-width: 0;
    max-width: 100%;
}

.question-container h2 {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 30px;
    color: #ffffff;
    text-align: left;
    line-height: 1.6;
    font-weight: 500;
    padding: 0 5px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.options {
    margin-bottom: 30px;
}

/* 코드 블록 스타일 */
.code-block {
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3a 100%);
    border: 1px solid rgba(168, 216, 255, 0.2);
    border-radius: 12px;
    margin: 20px 0;
    overflow: hidden;           /* 라운드 모서리 유지 */
    box-shadow:
            0 8px 25px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(168, 216, 255, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 100%;
    width: 100%;
    min-width: 0;
}

.code-header {
    background: linear-gradient(90deg, rgba(168, 216, 255, 0.15), rgba(74, 222, 128, 0.15));
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 20px);
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    font-weight: 600;
    color: #a8d8ff;
    border-bottom: 1px solid rgba(168, 216, 255, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
}

.code-header::before {
    content: '◉ ◉ ◉';
    color: rgba(255, 255, 255, 0.3);
    margin-right: 10px;
    font-size: 0.6rem;
}

.code-block pre {
    margin: 0;
    padding: clamp(12px, 3vw, 20px);
    background: transparent;
    overflow-x: auto;            /* 긴 줄은 가로 스크롤로 */
    -webkit-overflow-scrolling: touch;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: clamp(0.65rem, 1.5vw, 0.8rem);
    line-height: 1.5;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.code-block code {
    color: #f8f8f2;
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: inherit;
    white-space: pre;
}

.language-sql {
    color: #e8f4fd;
}

.code-block .sql-keyword {
    color: #ff79c6;
    font-weight: 600;
}

.code-block .sql-string {
    color: #f1fa8c;
}

.code-block .sql-comment {
    color: #6272a4;
    font-style: italic;
}

.code-block .sql-number {
    color: #bd93f9;
}

.inline-code {
    background: rgba(255, 255, 255, 0.1);
    color: #a8d8ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: clamp(0.75rem, 1.8vw, 0.85em);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 공통 스크롤바 스타일 (코드 블록 + 테이블) */
.code-block pre::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    height: 8px;
}

.code-block pre::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.code-block pre::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.code-block pre::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.explanation-summary {
    font-size: 1.5rem;
    font-weight: 600;
    color: #a8d8ff;
    margin: 20px 0 15px 0;
    padding-left: 10px;
    border-left: 4px solid #4ade80;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.explanation-summary:hover {
    color: #7fc8ff;
    transform: translateX(3px);
}

/* 마크다운 헤딩 - 반응형 */
.markdown-h1 {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem);
    font-weight: 700;
    color: #ffffff;
    margin: 25px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(168, 216, 255, 0.3);
}

.markdown-h2 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 600;
    color: #a8d8ff;
    margin: 20px 0 15px 0;
    padding-left: 10px;
    border-left: 4px solid #4ade80;
}

.markdown-h3 {
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    font-weight: 600;
    color: #d1d9e6;
    margin: 18px 0 12px 0;
}

.markdown-paragraph {
    font-size: clamp(0.875rem, 2vw, 1rem);
    line-height: 1.7;
    margin-bottom: 15px;
    color: #e8f4fd;
}

.markdown-bold {
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.markdown-divider {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(168, 216, 255, 0.5), transparent);
    margin: 25px 0;
}

/* ========== 테이블 스타일 ========== */
.table-container {
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;                     /* 추가: 세로 스크롤바는 막기 */
    -webkit-overflow-scrolling: touch;      /* 추가: 부드러운 스크롤 */
    border: 1px solid rgba(168, 216, 255, 0.2);   /* table에서 옮겨오면 깔끔 */
}

.markdown-table {
    width: max-content;
    min-width: 100%;             /* 추가: 좁은 표는 컨테이너 꽉 채움 */
    border-collapse: collapse;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(168, 216, 255, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(168, 216, 255, 0.2);
    border-radius: 12px;
    table-layout: auto;
}

.markdown-table th {
    background: linear-gradient(90deg, rgba(168, 216, 255, 0.2), rgba(74, 222, 128, 0.2));
    color: #ffffff;
    font-weight: 600;
    padding: 15px 20px;
    text-align: left;
    border-bottom: 2px solid rgba(168, 216, 255, 0.3);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
}

.markdown-table td {
    padding: 12px 20px;
    color: #e8f4fd;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    line-height: 1.5;
    white-space: nowrap;
}

.markdown-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.markdown-table tr:last-child td {
    border-bottom: none;
}

.markdown-link {
    color: #FFD700;
    text-decoration: underline;
}

.markdown-link:hover {
    color: #FFFF66;
}

/* ========== 블록쿼트(인용구) 스타일 ========== */
.markdown-blockquote {
    background: linear-gradient(135deg, rgba(168, 216, 255, 0.08), rgba(74, 222, 128, 0.04));
    border-left: 4px solid #4ade80;
    border-radius: 0 12px 12px 0;
    padding: 16px 20px;
    margin: 18px 0;
    color: #d1d9e6;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    line-height: 1.7;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(168, 216, 255, 0.1);
    border-left: 4px solid #4ade80;
}

.markdown-blockquote p {
    margin-bottom: 8px;
    color: #d1d9e6;
}

.markdown-blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-blockquote .markdown-bold {
    color: #ffffff;
}

.markdown-blockquote .markdown-blockquote {
    margin: 12px 0;
    border-left-color: #a8d8ff;
    background: rgba(168, 216, 255, 0.06);
}

/* ========== 리스트 스타일 ========== */
.markdown-list {
    margin: 14px 0;
    padding-left: 1.8em;
    color: #e8f4fd;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    line-height: 1.7;
}

/* 중첩 리스트 */
.markdown-list .markdown-list {
    margin: 6px 0;
    padding-left: 1.6em;
}

.markdown-list-item {
    margin-bottom: 6px;
    padding-left: 0.4em;
}

.markdown-list-item::marker {
    color: #4ade80;
}

ol.markdown-list {
    list-style-type: decimal;
    padding-left: 2em;
}

ol.markdown-list .markdown-list-item::marker {
    color: #a8d8ff;
    font-weight: 600;
}

ol.markdown-list .markdown-list-item {
    padding-left: 0.3em;
}

/* ========== 체크박스(체크리스트) 스타일 ========== */
.markdown-checklist {
    list-style: none;
    padding-left: 8px;
}

.markdown-task-item {
    margin-bottom: 8px;
    padding-left: 0;
}

.markdown-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
    user-select: none;
}

.markdown-checkbox-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.markdown-checkbox {
    display: none;
}

.markdown-checkbox-custom {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid rgba(168, 216, 255, 0.4);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 2px;
    position: relative;
}

.markdown-checkbox-custom::after {
    content: '';
    display: block;
    width: 5px;
    height: 10px;
    border: solid transparent;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s ease;
    margin-top: -2px;
}

.markdown-checkbox:checked + .markdown-checkbox-custom {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border-color: #22c55e;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.markdown-checkbox:checked + .markdown-checkbox-custom::after {
    border-color: #ffffff;
    transform: rotate(45deg) scale(1);
}

.markdown-checkbox-label.checked .markdown-checkbox-text {
    color: rgba(168, 216, 255, 0.5);
    text-decoration: line-through;
    text-decoration-color: rgba(168, 216, 255, 0.3);
}

.markdown-checkbox-text {
    flex: 1;
    color: #e8f4fd;
    line-height: 1.6;
    transition: color 0.2s ease;
}

.markdown-checkbox-text p {
    margin: 0;
    display: inline;
}

/* 이미지 컨테이너 스타일 */
.image-container {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.question-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.question-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.image-placeholder {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin: 15px 0;
    color: #a8d8ff;
    font-style: italic;
    font-size: 0.9rem;
}

/* 선택지 텍스트 - 반응형 */
.option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    padding-right: 40px;
    max-width: 100%;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.option.selected {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
    position: relative;
}

.option.selected::after {
    content: '✓';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #4ade80;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
}

.option.single-choice.selected::after {
    content: '●';
    font-size: 1rem;
}

.option.single-choice::before {
    content: '○';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
    font-size: 1rem;
}

.option.single-choice.selected::before {
    display: none;
}

.option.correct {
    background: rgba(34, 197, 94, 0.3);
    border-color: #22c55e;
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.6);
    animation: correctAnswer 0.6s ease-out;
}

.option.incorrect {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
    animation: incorrectShake 0.6s ease-out;
}

.option.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.option-label {
    font-weight: bold;
    margin-right: 10px;
    background: #020259;
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    min-width: 25px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(2, 2, 89, 0.3);
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    flex-shrink: 0;
}

.option span:last-child {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 공통 버튼 스타일 */
.submit-btn, .next-btn, .restart-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-btn:hover,
.next-btn:hover,
.restart-btn:hover {
    transform: translateY(-2px);
}

.submit-btn {
    background: linear-gradient(45deg, #020259, #1a0b6b);
    color: white;
    box-shadow: 0 8px 20px rgba(2, 2, 89, 0.4);
}

.submit-btn:hover {
    box-shadow: 0 12px 30px rgba(2, 2, 89, 0.6);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.next-btn {
    background: linear-gradient(45deg, #4ade80, #22c55e);
    color: #020259;
    box-shadow: 0 8px 20px rgba(74, 222, 128, 0.4);
}

.next-btn:hover {
    box-shadow: 0 12px 30px rgba(74, 222, 128, 0.6);
}

.restart-btn {
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

.restart-btn:hover {
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.6);
}

.final-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.learn-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(45deg, #3b82f6, #2563eb);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.learn-link-btn:hover {
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.6);
    transform: translateY(-2px);
}

.home-return-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(45deg, #6b7280, #4b5563);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(107, 114, 128, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.home-return-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(107, 114, 128, 0.6);
    background: linear-gradient(45deg, #4b5563, #374151);
}

.home-return-btn::before {
    content: '🏠';
    font-size: 1.3rem;
}

.result-container {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.result-message {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.result-message.correct {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid #22c55e;
    color: #4ade80;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.result-message.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
    color: #fca5a5;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.explanation {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.explanation h3 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #a8d8ff;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.explanation-content {
    font-size: clamp(0.875rem, 2vw, 1rem);
    color: #ffffff;
    line-height: 1.7;
}

.explanation-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 15px 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
}

.explanation-image:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

.final-result {
    text-align: center;
    animation: bounceIn 1s ease;
}

.final-result h2 {
    font-size: 2.2rem;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #4ade80, #22c55e, #16a34a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.score {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    padding: 35px;
    margin-bottom: 30px;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow:
            0 25px 50px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: slideInFromRight 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

.score::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(74, 222, 128, 0.1), transparent);
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.score p {
    font-size: 1.5rem;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.score-percentage {
    font-size: 4rem !important;
    font-weight: bold;
    background: linear-gradient(45deg, #4ade80, #22c55e, #16a34a, #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.5);
    background-size: 300% 300%;
    animation: gradientShift 2s ease infinite, pulse 2s infinite;
    position: relative;
    z-index: 1;
}

.score-stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: fadeIn 0.8s ease-out;
}

.stats-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.histogram {
    margin-bottom: 20px;
    padding: 0;
}

.distribution-chart {
    width: 100%;
    height: auto;
}

.stats-summary {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4ade80;
}

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

@keyframes slideInFromLeft {
    from { opacity: 0; transform: translateX(-100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@keyframes progressAnimation {
    0% { width: 0%; }
}

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

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ========== 반응형 디자인 ========== */
@media (max-width: 768px) {
    .container {
        padding: 15px 18px;
    }

    header h1 {
        font-size: 2rem;
        animation: bounceIn 1s ease;
    }

    header p {
        font-size: 1rem;
        animation: fadeIn 1.2s ease;
    }

    .quiz-container {
        margin: 0;
        padding: 22px 18px;
        border-radius: 20px;
        animation: slideInFromLeft 0.6s ease-out;
    }

    .option {
        padding: 10px 35px 10px 12px;
        font-size: 0.8rem;
        border-radius: 10px;
    }

    .option.selected::after,
    .option.single-choice::before {
        right: 10px;
    }

    .option-label {
        padding: 3px 7px;
        min-width: 20px;
        font-size: 0.7rem;
    }

    .submit-btn, .next-btn, .restart-btn, .home-return-btn {
        font-size: 1.1rem;
        padding: 12px;
        border-radius: 12px;
    }

    .final-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .home-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .score-percentage {
        font-size: 3rem !important;
    }

    .final-result h2 {
        font-size: 1.8rem;
    }

    .score {
        padding: 25px;
        border-radius: 20px;
    }

    /* 블록쿼트 모바일 */
    .markdown-blockquote {
        padding: 12px 14px;
        margin: 14px 0;
        font-size: 0.85rem;
    }

    /* 리스트 모바일 */
    .markdown-list {
        padding-left: 20px;
    }

    /* 체크박스 모바일 */
    .markdown-checkbox-custom {
        width: 18px;
        height: 18px;
        min-width: 18px;
    }

    /* ===== 테이블: 카드형 레이아웃으로 전환 ===== */
    .table-container {
        box-shadow: none;
        background: transparent;
        border-radius: 0;
    }

    .markdown-table {
        background: transparent;
        border: none;
        border-radius: 0;
        backdrop-filter: none;
    }

    .markdown-table,
    .markdown-table thead,
    .markdown-table tbody,
    .markdown-table tr,
    .markdown-table th,
    .markdown-table td {
        display: block;
        width: 100%;
    }

    /* 헤더는 시각적으로 숨기되 접근성은 유지 */
    .markdown-table thead {
        position: absolute;
        left: -9999px;
        top: -9999px;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }

    .markdown-table tr {
        margin-bottom: 14px;
        border: 1px solid rgba(168, 216, 255, 0.25);
        border-radius: 12px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(168, 216, 255, 0.04));
        padding: 6px 12px;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .markdown-table tr:hover {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(168, 216, 255, 0.06));
    }

    .markdown-table td {
        border: none;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
        padding: 10px 4px 10px 38%;
        position: relative;
        text-align: left;
        font-size: 0.82rem;
        line-height: 1.5;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        min-height: 40px;
    }

    .markdown-table td:last-child {
        border-bottom: none;
    }

    /* 각 셀 앞에 헤더 라벨 표시 (data-label 속성 사용) */
    .markdown-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 4px;
        top: 10px;
        width: 33%;
        padding-right: 8px;
        font-weight: 600;
        color: #a8d8ff;
        font-size: 0.78rem;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
        line-height: 1.4;
    }

    /* data-label이 없을 때는 라벨 영역 제거 */
    .markdown-table td:not([data-label])::before,
    .markdown-table td[data-label=""]::before {
        content: "";
        display: none;
    }

    .markdown-table td:not([data-label]),
    .markdown-table td[data-label=""] {
        padding-left: 4px;
    }
}

@media (max-width: 767px) {
    .page-layout {
        padding: 0;
        gap: 0;
    }

    .quiz-container {
        margin: 0;
    }

    .question-container {
        padding: 0;
    }

    .container {
        padding: 15px 18px;
        padding-top: 70px;
    }

    .ad-container .ad-pc { display: none !important; }
    .ad-container .ad-mobile { display: block !important; }
    .ad-container { min-height: 100px; }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.6rem;
    }

    .quiz-container {
        padding: 18px 14px;
        margin: 0;
    }

    .question-container {
        padding: 0;
    }

    .option {
        padding: 8px 30px 8px 10px;
        font-size: 0.78rem;
        margin-bottom: 8px;
    }

    .option-label {
        padding: 2px 6px;
        min-width: 18px;
        font-size: 0.65rem;
    }

    /* 코드 블록: 작은 화면에서 폰트·패딩 축소 */
    .code-block {
        margin: 14px 0;
        border-radius: 10px;
    }

    .code-block pre {
        padding: 10px 12px;
        font-size: 0.68rem;
    }

    .code-header {
        padding: 6px 12px;
        font-size: 0.65rem;
    }

    .inline-code {
        font-size: 0.78em;
        padding: 1px 4px;
    }

    .score-percentage {
        font-size: 2.5rem !important;
    }

    .final-result h2 {
        font-size: 1.5rem;
    }

    .progress-bar {
        height: 6px;
    }

    .explanation {
        padding: 18px 14px;
    }

    /* 테이블 카드: 480px 이하에서는 더 컴팩트하게 */
    .markdown-table td {
        padding: 8px 4px 8px 40%;
        font-size: 0.78rem;
    }

    .markdown-table td::before {
        font-size: 0.72rem;
        width: 35%;
    }
}

/* 성능 최적화를 위한 미디어 쿼리 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #020259 0%, #0a0628 50%, #1a0b3d 100%);
    }

    .quiz-container {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .option {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto;
    min-height: 90px;
    width: 100%;
    text-align: center;
}

.ad-container .kakao_ad_area {
    margin: 0 auto;
}

.ad-container .ad-mobile { display: none !important; }

/* ========== 페이지 레이아웃 (배너 - 본문 - 배너) ========== */
.page-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.page-layout .container {
    flex-shrink: 1;
    min-width: 0;
}

.side-ad {
    width: 160px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 40px;
}

@media (min-width: 1400px) {
    .side-ad {
        display: flex;
    }
}
