body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: #333;
    font-weight: 600;
    box-sizing: border-box;
    background: #f0f2f5;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow-x: hidden;
    width: 100vw;
    max-width: 100vw;
}

html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Phase 4-A: 화면 전환용 래퍼 */
.screen {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    box-sizing: border-box;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

.screen.fade-in {
    opacity: 0;
    transform: translateX(20px);
    animation: fadeInScreen 0.3s ease forwards;
}

@keyframes fadeInScreen {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#category-selection-screen {
    flex-direction: column;
}

/* 카테고리 선택 화면 스타일 */
.category-container {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 95vw;
    max-width: 800px;
    backdrop-filter: blur(12px);
    
    height: 680px;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    margin: 0 auto;
}

.category-container h1 {
    font-size: 2.2em;
    color: #2d3748;
    margin: 0 0 10px;
    text-align: center;
}

.subtitle {
    font-size: 1.1em;
    color: #4a5568;
    margin-bottom: 30px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.category-card {
    background: linear-gradient(135deg, #fdfbfb, #ebedee);
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: #4299e1;
}

.card-icon {
    font-size: 2.5em;
}

.card-text {
    font-size: 1.2em;
    font-weight: 700;
    color: #2d3748;
}

/* --- 게임 레이아웃 3단계 구조 --- */

.game-container {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 95vw;
    max-width: 800px;
    backdrop-filter: blur(12px);
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 680px;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
}

/* Header Area (Fixed) */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 15px 10px 15px;
    border-bottom: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.header-center {
    display: flex;
    justify-content: center;
    flex: 1;
}

.header-right {
    justify-content: flex-end;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-action-btn {
    padding: 8px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.header-action-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    transform: translateY(-1px);
}

.header-action-btn:active {
    transform: translateY(0);
}

.header-action-btn svg {
    fill: #6b7280;
    transition: fill 0.2s ease;
}

.header-action-btn:hover svg {
    fill: #4b5563;
}

.game-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    text-align: center;
}

/* Content Area (Scrollable) */
.game-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 15px;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Footer Area (Fixed) */
.game-footer {
    display: flex;
    flex-direction: column;
    padding: 10px 15px 15px 15px;
    border-top: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
    overflow: hidden;
    box-sizing: border-box;
}

/* --- 헤더 영역 컴포넌트 스타일 --- */
#home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    padding: 8px;
    flex-shrink: 0;
}

#home-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

#home-btn:active {
    transform: translateY(0);
}

#home-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.lives-display {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 36px;
    min-width: 120px;
    padding: 0 8px;
}

.progress-indicator {
    display: flex;
    align-items: center;
    font-size: 0.8em;
    font-weight: 600;
    color: #4a5568;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 45px;
    height: 36px;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.review-mode-indicator {
    display: flex;
    align-items: center;
    font-size: 0.8em;
    font-weight: 500;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    flex-shrink: 0;
    min-height: 28px;
    box-sizing: border-box;
}

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

.next-problem-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6;
    color: white;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    box-sizing: border-box;
}

.next-problem-btn:hover {
    background: #2563eb;
    border-color: #2563eb;
    transform: translateY(-1px);
}

.show-result-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    box-sizing: border-box;
}

.show-result-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.life-bar {
    width: 6px; /* 너비를 줄여서 더 세련되게 */
    height: 20px; /* 높이도 적절하게 조정 */
    background-color: #ef4444; /* 더 부드러운 빨간색 */
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
    opacity: 0.8; /* 약간의 투명도로 부드럽게 */
}

.life-bar.lost {
    opacity: 0.3;
    background-color: #cbd5e0;
}
/* --- 최종 수정 끝 --- */

/* --- 콘텐츠 영역 컴포넌트 스타일 --- */
.source-display {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.3em;
    font-weight: 600;
    color: #4a5568;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 15px;
    flex-shrink: 0;
    min-height: 75px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.problem-area {
    background-color: rgba(227, 242, 253, 0.9); 
    border: 1px solid rgba(187, 222, 251, 0.5);
    padding: 15px;
    border-radius: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start; 
    align-content: flex-start; 
    gap: 6px; 
    flex-grow: 1;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* 스크롤바 스타일링 */
.problem-area::-webkit-scrollbar {
    width: 6px;
}

.problem-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.problem-area::-webkit-scrollbar-thumb {
    background: rgba(66, 153, 225, 0.5);
    border-radius: 3px;
}

.problem-area::-webkit-scrollbar-thumb:hover {
    background: rgba(66, 153, 225, 0.7);
}

/* 언더바 스타일 단어 컨테이너 */
.word-container {
    display: inline-block;
    margin: 4px 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.word-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.word-container.has-active-blank {
    border-color: #4299e1;
    box-shadow: 0 8px 20px rgba(66, 153, 225, 0.2);
}

.word-display {
    font-size: 1.4em;
    font-weight: 500;
    color: #2d3748;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    line-height: 1.2;
    display: flex;
    align-items: baseline;
}

.char-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 0.8em;
    position: relative;
}

.fixed-char {
    color: #2d3748;
    width: 100%;
    text-align: center;
    position: relative;
}

.underbar-blank {
    color: #4299e1;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 3px;
    width: 100%;
    text-align: center;
    min-height: 1.2em;
}

.underbar-blank:hover {
    background: rgba(66, 153, 225, 0.1);
    transform: scale(1.1);
}

.underbar-blank.active {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    animation: pulse 1.5s infinite;
}

.underbar-blank.correct {
    color: #48bb78 !important;
    background: rgba(72, 187, 120, 0.1) !important;
    animation: none !important;
}

.underbar-blank.incorrect {
    color: #f56565;
    background: rgba(245, 101, 101, 0.1);
    animation: shake 0.5s ease-in-out;
}

.underbar-blank.hint-filled {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.1) !important;
}

.hint-number-underbar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #edf2f7;
    color: #718096;
    font-weight: 600;
    border-radius: 4px;
    padding: 0;
    width: 14px;
    height: 14px;
    font-size: 0.6em;
    transition: all 0.3s ease;
    margin-top: 8px;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    letter-spacing: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 기존 박스형 스타일들 제거됨 - 언더바 스타일로 대체 */

/* --- 푸터 영역 컴포넌트 스타일 --- */
.hint-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 40px;
    flex-wrap: wrap;
}

.hint-btn {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: default; /* 클릭 불가능한 레이블 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    box-sizing: border-box;
}

/* 힌트는 레이블이므로 호버 효과 제거 */

.hint-btn.disabled {
    background: rgba(107, 114, 128, 0.05);
    color: #9ca3af;
    border-color: rgba(107, 114, 128, 0.1);
    cursor: not-allowed;
    opacity: 0.6;
}

.hint-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: 500;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 32px;
    height: 28px;
    box-sizing: border-box;
}

.word-blank.hint-filled {
    background: rgba(59, 130, 246, 0.1) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    color: #3b82f6 !important;
}

.keyboard-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 5px;
    background: linear-gradient(135deg, rgba(230, 230, 250, 0.2), rgba(210, 220, 240, 0.3));
    border-radius: 15px;
    box-sizing: border-box;
    border: 2px solid rgba(135, 206, 250, 0.3);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.key {
    background: white;
    color: #4a5568;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    user-select: none;
    transition: all 0.1s ease;
    flex: 1;
    min-width: 0;
    max-width: 40px;
    aspect-ratio: 1 / 1.2;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
    /* 모바일 터치 최적화 */
    min-height: 36px;
    touch-action: manipulation;
}

.keyboard-row:last-child .key {
    flex-grow: 1.2;
}

.key:hover {
    background: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.key:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
}

.key.disabled {
    background: #a0aec0;
    color: #718096;
    cursor: not-allowed;
    transform: none;
    border-color: #a0aec0;
}

.key.disabled:hover {
    background: #a0aec0;
    transform: none;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
}

.blank-nav-btn {
    background: white;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 0;
    max-width: 50px;
    padding: 8px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.blank-nav-btn:hover {
    background: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    padding: 20px;
    box-sizing: border-box;
}

/* 대시보드 모달은 더 높은 z-index */
#dashboard-modal {
    z-index: 1100;
}

/* 리더보드 모달도 더 높은 z-index */
#global-leaderboard-modal {
    z-index: 1100;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 600px;
    width: 100%;
    animation: modalSlideIn 0.3s ease-out;
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #718096;
    transition: all 0.2s ease;
    z-index: 1;
}

.modal-close-btn:hover {
    background: #f7fafc;
    color: #2d3748;
    transform: scale(1.1);
}

.modal-close-btn:active {
    transform: scale(0.95);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    color: #4a5568;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 700;
}

.sentence-display {
    margin-bottom: 25px;
    text-align: left;
}

.original-sentence {
    font-size: 1.2em;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    padding: 18px;
    background: #f7fafc;
    border-radius: 10px;
    border-left: 4px solid #4299e1;
    line-height: 1.6;
}

.modal-word {
    display: inline;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
}

.modal-word.reading-highlight {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    color: #2d3748 !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    transform: scale(1.05);
    z-index: 10;
    animation: modalWordPulse 1s ease-in-out infinite;
}

@keyframes modalWordPulse {
    0%,
    100% {
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    }
    50% {
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.7);
    }
}

.source {
    font-size: 0.9em;
    color: #718096;
    margin-bottom: 12px;
    font-style: italic;
}

.korean-translation {
    font-size: 1em;
    color: #4a5568;
    padding: 12px;
    background: #edf2f7;
    border-radius: 10px;
    line-height: 1.6;
}

.score-display {
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #e6fffa, #b2f5ea);
    border-radius: 10px;
    border-left: 4px solid #38b2ac;
}

.score-text {
    font-size: 1em;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 5px;
}

.perfect-bonus {
    font-size: 0.9em;
    font-weight: 600;
    color: #38a169;
    animation: perfectPulse 1.5s ease-in-out infinite;
}

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

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    min-height: 36px;
    box-sizing: border-box;
}

.modal-btn.primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.modal-btn.primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    transform: translateY(-1px);
}

.modal-btn.secondary {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
    border-color: rgba(107, 114, 128, 0.2);
}

.modal-btn.secondary:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.modal-btn.tertiary {
    background: transparent;
    color: #6b7280;
    border-color: rgba(107, 114, 128, 0.2);
}

.modal-btn.tertiary:hover {
    background: rgba(107, 114, 128, 0.05);
    border-color: rgba(107, 114, 128, 0.25);
    color: #4b5563;
    transform: translateY(-1px);
}

.modal-btn:active {
    transform: translateY(0);
}

/* 공유 섹션 스타일 */
.share-section {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 36px;
    box-sizing: border-box;
}

.share-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.share-btn:active {
    transform: translateY(0);
}

.share-btn svg {
    fill: currentColor;
    flex-shrink: 0;
}

/* 다크모드 토글 버튼과 헤더 스타일 */
.category-header {
    position: relative;
    width: 100%;
    height: 40px;
    margin-bottom: 20px;
    margin-top: -20px;
    flex-shrink: 0;
}

.main-title {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-top: 0;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
}

.dark-mode-toggle:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

#dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
}

#dark-mode-toggle:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

#dark-mode-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.dark-mode-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 다크모드 스타일 */
body.dark-mode {
    background: #1a202c;
    color: #e2e8f0;
}

.dark-mode .category-container,
.dark-mode .game-container {
    background-color: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
}

.dark-mode .category-container h1,
.dark-mode .category-container .subtitle {
    color: #e2e8f0;
}

.dark-mode .category-card {
    background: rgba(74, 85, 104, 0.6);
    border: 2px solid rgba(113, 128, 150, 0.3);
    color: #e2e8f0;
}

.dark-mode .category-card .card-text {
    color: #e2e8f0;
}

.dark-mode .category-card:hover {
    background: rgba(74, 85, 104, 0.8);
    border-color: rgba(113, 128, 150, 0.6);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.dark-mode .problem-area {
    background: rgba(74, 85, 104, 0.3);
    border: 1px solid rgba(113, 128, 150, 0.3);
    color: #e2e8f0;
}

.dark-mode .source-display {
    background: rgba(74, 85, 104, 0.3);
    color: #e2e8f0;
}

.dark-mode .hint-controls {
    color: #e2e8f0;
}

.dark-mode .word-container {
    background: rgba(74, 85, 104, 0.6);
    border-color: rgba(113, 128, 150, 0.3);
}

.dark-mode .word-container:hover {
    background: rgba(74, 85, 104, 0.8);
    border-color: rgba(113, 128, 150, 0.6);
}

.dark-mode .word-container.has-active-blank {
    border-color: #4299e1;
}

.dark-mode .word-display {
    color: #e2e8f0;
}

.dark-mode .fixed-char {
    color: #e2e8f0;
}

.dark-mode .underbar-blank {
    color: #63b3ed;
}

.dark-mode .underbar-blank:hover {
    background: rgba(99, 179, 237, 0.2);
}

.dark-mode .underbar-blank.active {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
}

.dark-mode .underbar-blank.correct {
    color: #68d391 !important;
    background: rgba(104, 211, 145, 0.2) !important;
}

.dark-mode .underbar-blank.incorrect {
    color: #fc8181;
    background: rgba(252, 129, 129, 0.2);
}

.dark-mode .underbar-blank.hint-filled {
    color: #f6e05e !important;
    background: rgba(246, 224, 94, 0.2) !important;
}

.dark-mode .hint-number-underbar {
    background: rgba(113, 128, 150, 0.3);
    color: #a0aec0;
}

.dark-mode .key {
    background: rgba(74, 85, 104, 0.6);
    border: 1px solid rgba(113, 128, 150, 0.3);
    color: #e2e8f0;
}

.dark-mode .key:hover {
    background: rgba(74, 85, 104, 0.8);
    border-color: rgba(113, 128, 150, 0.6);
}

.dark-mode .key.disabled {
    background: rgba(45, 55, 72, 0.5);
    color: #4a5568;
}

.dark-mode .blank-nav-btn {
    background: rgba(74, 85, 104, 0.6);
    border: 1px solid rgba(113, 128, 150, 0.3);
    color: #e2e8f0;
}

.dark-mode .blank-nav-btn:hover {
    background: rgba(74, 85, 104, 0.8);
    border-color: rgba(113, 128, 150, 0.6);
}

.dark-mode .modal-content {
    background: rgba(45, 55, 72, 0.98);
    color: #e2e8f0;
    border: 1px solid rgba(113, 128, 150, 0.3);
}

.dark-mode .modal-content h2 {
    color: #e2e8f0;
}

.dark-mode .modal-btn.primary {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.dark-mode .modal-btn.primary:hover {
    background: #60a5fa;
    border-color: #60a5fa;
}

.dark-mode .modal-btn.secondary {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .modal-btn.secondary:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
}

.dark-mode .modal-btn.tertiary {
    background: transparent;
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .modal-btn.tertiary:hover {
    background: rgba(156, 163, 175, 0.1);
    border-color: rgba(156, 163, 175, 0.3);
    color: #d1d5db;
}

.dark-mode .share-btn {
    background: rgba(156, 163, 175, 0.15);
    border-color: rgba(156, 163, 175, 0.25);
    color: #9ca3af;
}

.dark-mode .share-btn:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
}

.dark-mode #home-btn {
    background: rgba(156, 163, 175, 0.15);
    border-color: rgba(156, 163, 175, 0.25);
    color: #9ca3af;
}

.dark-mode #home-btn:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
}

/* .dark-mode .lives-display 스타일 제거 */

.dark-mode #dark-mode-toggle {
    background: rgba(156, 163, 175, 0.15);
    border-color: rgba(156, 163, 175, 0.25);
    color: #9ca3af;
}

.dark-mode #dark-mode-toggle:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
    transform: translateY(-1px);
}

/* Dark mode button border updates */
.dark-mode .global-leaderboard-btn,
.dark-mode .dashboard-btn,
.dark-mode .login-btn {
    background: rgba(156, 163, 175, 0.15);
    border: 1px solid rgba(156, 163, 175, 0.25);
    color: #9ca3af;
}

/* 다크모드에서 아이콘 색깔 수정 */
.dark-mode .global-leaderboard-btn svg,
.dark-mode .dashboard-btn svg {
    fill: #9ca3af;
}

.dark-mode .global-leaderboard-btn:hover svg,
.dark-mode .dashboard-btn:hover svg {
    fill: #d1d5db;
}

/* 다크모드 토글 버튼 스타일 */
.dark-mode .dark-mode-toggle {
    background: rgba(156, 163, 175, 0.15);
    border-color: rgba(156, 163, 175, 0.25);
    color: #9ca3af;
}

.dark-mode .dark-mode-toggle:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
}

/* 다크모드 토글 버튼의 아이콘 색깔 */
.dark-mode #dark-mode-toggle svg,
.dark-mode .dark-mode-toggle svg {
    fill: #9ca3af;
}

.dark-mode #dark-mode-toggle:hover svg,
.dark-mode .dark-mode-toggle:hover svg {
    fill: #d1d5db;
}

/* 다크모드 힌트 및 버튼 스타일 */
.dark-mode .hint-btn {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .hint-btn.disabled {
    background: rgba(156, 163, 175, 0.05);
    color: #6b7280;
    border-color: rgba(156, 163, 175, 0.1);
}

.dark-mode .hint-counter {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .word-blank.hint-filled {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    color: #60a5fa !important;
}

.dark-mode .review-mode-indicator {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .next-problem-btn {
    background: #3b82f6;
    border-color: #3b82f6;
}

.dark-mode .next-problem-btn:hover {
    background: #60a5fa;
    border-color: #60a5fa;
}

.dark-mode .show-result-btn {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .show-result-btn:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
}




.dark-mode .game-title {
    color: #e2e8f0;
}

.dark-mode .progress-indicator {
    background: rgba(113, 128, 150, 0.2);
    border-color: rgba(113, 128, 150, 0.3);
    color: #e2e8f0;
}

.dark-mode .game-header {
    background: rgba(45, 55, 72, 0.8);
    border-bottom-color: rgba(113, 128, 150, 0.3);
}

.dark-mode .header-action-btn {
    background: rgba(156, 163, 175, 0.15);
    border-color: rgba(156, 163, 175, 0.25);
}

.dark-mode .header-action-btn:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
}

.dark-mode .header-action-btn svg {
    fill: #9ca3af;
}

.dark-mode .header-action-btn:hover svg {
    fill: #d1d5db;
}

.dark-mode .leaderboard-svg-spinner {
    fill: #9ca3af;
}

.dark-mode .life-bar {
    background-color: #f87171; /* 다크모드에서는 조금 더 밝은 빨간색 */
    opacity: 0.9; /* 다크모드에서는 조금 더 진하게 */
}

.dark-mode .life-bar.lost {
    background-color: #4b5563;
    opacity: 0.4;
}

.dark-mode .game-footer {
    background: rgba(45, 55, 72, 0.8);
    border-top-color: rgba(113, 128, 150, 0.3);
}

/* 모바일 가상 키보드 활성화 상태 */
.game-container.mobile-keyboard-active {
    max-height: none !important;
}

.game-container.mobile-keyboard-active .game-content {
    max-height: 200px;
    overflow-y: auto;
}

.game-container.mobile-keyboard-active .problem-area {
    max-height: 150px;
}

@media (max-width: 768px) {
    /* Prevent any horizontal overflow on mobile */
    * {
        box-sizing: border-box;
        max-width: 100vw;
    }
    
    html, body {
        overflow-x: hidden;
        width: 100vw;
        max-width: 100vw;
        padding: 0;
        margin: 0;
    }

    /* 모바일에서 상단 버튼 위치 조정 */
    .category-header {
        margin-top: 0 !important;
        height: 50px !important;
        padding-top: 10px;
    }
    
    .header-buttons {
        top: 10px !important;
        right: 10px !important;
    }
    
    /* 모바일에서 카테고리 화면 높이 조정 */
    .category-container {
        height: 95vh;
        max-height: 700px;
        padding: 15px;
        width: 96vw;
        max-width: 96vw;
        margin: 0 auto;
        box-sizing: border-box;
    }
    
    /* ADDED: Forces a 2-column layout on mobile to prevent scrolling */
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .game-container {
        height: 95vh;
        max-height: 700px;
        width: 96vw;
        max-width: 96vw;
        margin: 0 auto;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .game-header {
        padding: 10px 10px 8px 10px;
    }
    
    .game-title {
        font-size: 1.1em;
    }
    
    .header-left,
    .header-right {
        gap: 8px;
    }
    
    .header-actions {
        gap: 6px;
    }
    
    .header-action-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    #home-btn,
    #dark-mode-toggle {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .lives-display {
        height: 32px;
        min-width: 100px;
        padding: 0 6px;
    }
    
    .life-bar {
        height: 18px; /* 모바일: 조금 더 작게 */
    }
    
    .header-action-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .game-content {
        padding: 10px;
        gap: 10px;
    }
    
    .game-footer {
        padding: 8px 10px 10px 10px;
    }
    
    .source-display {
        min-height: 65px;
        font-size: 1.1em;
    }
    
    .progress-indicator {
        font-size: 0.7em;
        padding: 4px 8px;
        min-width: 35px;
        height: 32px;
    }

    .word-container {
        margin: 3px 6px;
        padding: 6px 8px;
    }

    .word-display {
        font-size: 1.2em;
        font-weight: 500;
        letter-spacing: 0.1em;
    }

    .char-column {
        width: 0.75em;
    }

    .fixed-char {
        font-weight: 500;
    }

    .underbar-blank {
        font-weight: 500;
        /* 터치 타겟 크기 확장 */
        position: relative;
    }
    
    .underbar-blank::before {
        content: '';
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
        /* 최소 44px 터치 타겟 보장 */
    }

    .hint-number-underbar {
        font-size: 0.55em;
        font-weight: 500;
        padding: 0;
        width: 12px;
        height: 12px;
        margin-top: 6px;
        border-radius: 3px;
        margin-left: auto;
        margin-right: auto;
        letter-spacing: 0;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .modal-buttons {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .modal-btn {
        flex: 1;
        min-width: 0;
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .review-mode-indicator {
        font-size: 0.7em;
        padding: 6px 10px;
    }
    
    .next-problem-btn {
        font-size: 0.8em;
        padding: 6px 12px;
    }
    
    .show-result-btn {
        font-size: 0.8em;
        padding: 6px 12px;
    }
    
    .hint-controls {
        gap: 6px;
    }
    
    /* Mobile keyboard area optimization */
    .keyboard-area {
        padding: 8px 3px;
        gap: 4px;
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .keyboard-row {
        width: 100%;
        max-width: 100%;
        gap: 2px;
        box-sizing: border-box;
        justify-content: center;
        flex-wrap: nowrap;
    }
    
    .key {
        font-size: 0.9em;
        max-width: 32px;
        min-height: 32px;
        flex: 1;
        box-sizing: border-box;
        min-width: 28px;
    }
    
    /* Force all content to stay within viewport */
    .game-header,
    .game-content,
    .game-footer {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .problem-area {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    .word-group {
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Phase 2-B: 배지 알림 스타일 */
.badge-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    max-width: 350px;
    min-width: 280px;
}

.badge-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.badge-notification-content {
    display: flex;
    align-items: center;
    padding: 16px;
    color: white;
}

.badge-icon {
    font-size: 48px;
    margin-right: 16px;
    flex-shrink: 0;
}

.badge-info {
    flex: 1;
}

.badge-info h3 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
}

.badge-info h4 {
    margin: 0 0 6px 0;
    font-size: 18px;
    font-weight: 600;
}

.badge-info p {
    margin: 0 0 8px 0;
    font-size: 13px;
    opacity: 0.8;
    line-height: 1.3;
}

.badge-rarity {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-rarity.common {
    background: rgba(107, 114, 128, 0.3);
    color: #D1D5DB;
}

.badge-rarity.uncommon {
    background: rgba(5, 150, 105, 0.3);
    color: #A7F3D0;
}

.badge-rarity.rare {
    background: rgba(37, 99, 235, 0.3);
    color: #BFDBFE;
}

.badge-rarity.epic {
    background: rgba(124, 58, 237, 0.3);
    color: #DDD6FE;
}

.badge-rarity.legendary {
    background: rgba(220, 38, 38, 0.3);
    color: #FECACA;
}

/* 모바일 배지 알림 조정 */
@media (max-width: 768px) {
    .badge-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        min-width: auto;
        transform: translateY(-100px);
    }
    
    .badge-notification.show {
        transform: translateY(0);
    }
    
    .badge-notification-content {
        padding: 12px;
    }
    
    .badge-icon {
        font-size: 36px;
        margin-right: 12px;
    }
    
    .badge-info h4 {
        font-size: 16px;
    }
    
    .badge-info p {
        font-size: 12px;
    }
}

/* Phase 2-B: 대시보드 스타일 */
.dashboard-container {
    width: 96vw;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.dashboard-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dashboard-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dashboard-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.dashboard-btn:active {
    transform: translateY(0);
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
}

.dashboard-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.stat-info h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.dashboard-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #f0f0f0;
}

.dashboard-section h2 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #333;
    font-weight: 600;
}

.badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: center;
    position: relative;
}

.badge-item .badge-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.badge-item .badge-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.badge-item .badge-rarity {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.category-progress-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.category-progress-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
}

.category-progress-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.category-icon {
    font-size: 24px;
}

.category-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.category-stats {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.saved-sentences-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.saved-sentence-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid #667eea;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s ease;
}

.saved-sentence-content {
    flex: 1;
}

.delete-sentence-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    border-radius: 8px !important; /* 원형이 아닌 둥근 사각형 */
    color: #ef4444 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.delete-sentence-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
    transform: scale(1.05) !important;
}

.delete-sentence-btn:active {
    transform: scale(0.95) !important;
}

.saved-sentence-text {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.saved-sentence-translation {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.saved-sentence-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 모바일 대시보드 조정 */
@media (max-width: 768px) {
    .dashboard-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .dashboard-header {
        padding: 16px 20px;
    }

    .dashboard-header h1 {
        font-size: 20px;
    }

    .dashboard-content {
        padding: 20px;
        gap: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        gap: 12px;
    }

    .stat-icon {
        font-size: 24px;
    }

    .stat-value {
        font-size: 24px;
    }

    .dashboard-section {
        padding: 20px;
    }

    .badges-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }

    .badge-item {
        padding: 12px;
    }

    .badge-item .badge-icon {
        font-size: 28px;
    }

    .category-progress-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* ========================================
   Phase 3: 인증 및 글로벌 기능 스타일
   ======================================== */

/* 인증 섹션 */
.auth-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 로그인 버튼 */
.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-icon {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Arial', sans-serif;
}

.login-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(0);
}

/* 인증 섹션 */
.auth-section {
    display: flex;
    align-items: center;
    height: 40px; /* 주변 버튼들과 동일한 높이 */
}

/* 사용자 프로필 */
.user-profile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    height: 40px; /* 주변 버튼들과 동일한 높이 */
    box-sizing: border-box;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

/* Dashboard Modal */
.dashboard-modal-content {
    width: 90vw;
    max-width: 800px;
    max-height: 85vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dashboard-modal-content .dashboard-content {
    padding: 20px;
    gap: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* flexbox 내에서 스크롤 가능하게 함 */
}

.dashboard-modal-content .dashboard-content::-webkit-scrollbar {
    width: 6px;
}

.dashboard-modal-content .dashboard-content::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-modal-content .dashboard-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.dashboard-modal-content .dashboard-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

.dashboard-modal-content .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.dashboard-modal-content .stat-card {
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.section-title,
.dashboard-modal-content .section-title {
    font-size: 18px !important;
    margin: 32px 0 16px 0 !important;
    color: #333 !important;
    text-align: center !important;
    font-weight: 600 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 다크모드 대응 */
body.dark-mode .section-title,
body.dark-mode .dashboard-modal-content .section-title {
    color: #e2e8f0 !important;
}

body.dark-mode .dashboard-modal-content .stat-card {
    background: rgba(45, 55, 72, 0.9);
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .dashboard-modal-content .stat-card h3::after {
    color: #a0aec0;
}

body.dark-mode .dashboard-modal-content .badge-item {
    background: rgba(45, 55, 72, 0.9);
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .dashboard-modal-content .badge-name {
    color: #e2e8f0;
}

body.dark-mode .dashboard-modal-content .category-progress-item {
    background: rgba(45, 55, 72, 0.9);
    border-color: #4a5568;
}

body.dark-mode .dashboard-modal-content .category-name {
    color: #e2e8f0;
}

body.dark-mode .dashboard-modal-content .category-stats {
    color: #a0aec0;
}

body.dark-mode .dashboard-modal-content .progress-bar {
    background: #4a5568;
}

/* 저장된 문장 스타일 - 강제 표시 */
#saved-sentences-container,
.dashboard-modal-content #saved-sentences-container,
.dashboard-modal-content .saved-sentences-container {
    display: block !important;
    flex-direction: column !important;
    gap: 12px !important;
    max-height: none !important; /* 높이 제한 제거 */
    overflow-y: visible !important; /* 컨테이너 자체 스크롤 제거 */
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 50px !important;
    position: relative !important;
    z-index: 1 !important;
}

.saved-sentence-item,
.dashboard-modal-content .saved-sentence-item {
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 12px !important;
    padding: 16px !important;
    border-left: 4px solid #667eea !important;
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-bottom: 12px !important;
    min-height: 80px !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.saved-sentence-content,
.dashboard-modal-content .saved-sentence-content {
    display: block !important;
    width: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.saved-sentence-text,
.dashboard-modal-content .saved-sentence-text {
    font-size: 16px !important;
    font-weight: 500 !important;
    color: #333 !important;
    margin-bottom: 8px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.saved-sentence-translation,
.dashboard-modal-content .saved-sentence-translation {
    font-size: 14px !important;
    color: #666 !important;
    margin-bottom: 8px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.saved-sentence-meta,
.dashboard-modal-content .saved-sentence-meta {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #999 !important;
    font-size: 12px !important;
    margin-top: 8px !important;
}

.saved-sentence-meta .category-info {
    text-align: left !important;
}

.saved-sentence-meta .date-info {
    text-align: right !important;
    color: #666 !important;
}

/* 다크모드 저장된 문장 */
body.dark-mode .dashboard-modal-content .saved-sentence-item {
    background: rgba(45, 55, 72, 0.9);
    border-color: #4a5568;
    border-left-color: #667eea;
}

body.dark-mode .dashboard-modal-content .saved-sentence-text {
    color: #e2e8f0;
}

body.dark-mode .dashboard-modal-content .saved-sentence-translation {
    color: #a0aec0;
}

body.dark-mode .dashboard-modal-content .saved-sentence-meta {
    color: #6b7280 !important;
}

body.dark-mode .saved-sentence-meta .date-info {
    color: #9ca3af !important;
}

/* 빈 상태 스타일 */
.dashboard-modal-content .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.dashboard-modal-content .empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.dashboard-modal-content .empty-state p {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

body.dark-mode .dashboard-modal-content .empty-state {
    color: #a0aec0;
}

body.dark-mode .dashboard-modal-content .empty-state p {
    color: #a0aec0;
}

.dashboard-modal-content .section-title:first-of-type {
    margin-top: 16px;
}

.dashboard-modal-content .category-progress-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.dashboard-modal-content .badges-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.dashboard-modal-content .badge-item {
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.dashboard-modal-content .badge-icon {
    font-size: 24px;
    margin: 0 auto;
}

.dashboard-modal-content .badge-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.dashboard-modal-content .badge-rarity {
    font-size: 10px;
    opacity: 0.7;
}

/* 연승 배지 레벨별 색깔 */
.dashboard-modal-content .streak-badge.common {
    background: rgba(34, 197, 94, 0.9);
    border-color: #16a34a;
}

.dashboard-modal-content .streak-badge.uncommon {
    background: rgba(59, 130, 246, 0.9);
    border-color: #2563eb;
}

.dashboard-modal-content .streak-badge.rare {
    background: rgba(168, 85, 247, 0.9);
    border-color: #7c3aed;
}

.dashboard-modal-content .streak-badge.legendary {
    background: rgba(251, 191, 36, 0.9);
    border-color: #f59e0b;
}

/* 다크모드에서 연승 배지 색깔 */
body.dark-mode .dashboard-modal-content .streak-badge.common {
    background: rgba(34, 197, 94, 0.8);
    border-color: #22c55e;
}

body.dark-mode .dashboard-modal-content .streak-badge.uncommon {
    background: rgba(59, 130, 246, 0.8);
    border-color: #3b82f6;
}

body.dark-mode .dashboard-modal-content .streak-badge.rare {
    background: rgba(168, 85, 247, 0.8);
    border-color: #a855f7;
}

body.dark-mode .dashboard-modal-content .streak-badge.legendary {
    background: rgba(251, 191, 36, 0.8);
    border-color: #fbbf24;
}

/* 글로벌 리더보드 버튼 */
.global-leaderboard-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.2);
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-leaderboard-btn:hover {
    background: rgba(107, 114, 128, 0.15);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    transform: translateY(-1px);
}

.global-leaderboard-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 다크모드 대응 */

.dark-mode .global-leaderboard-btn:hover,
.dark-mode .dashboard-btn:hover,
.dark-mode .login-btn:hover {
    background: rgba(156, 163, 175, 0.25);
    border-color: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
    transform: translateY(-1px);
}

body.dark-mode .user-profile {
    background: rgba(45, 55, 72, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .user-name {
    color: #e2e8f0;
}

body.dark-mode .logout-btn {
    background: rgba(239, 68, 68, 0.2);
}

body.dark-mode .logout-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* 대시보드 다크모드 대응 */
body.dark-mode .dashboard-container {
    background: #1a202c;
}

body.dark-mode .dashboard-section {
    background: #2d3748;
    border-color: #4a5568;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .dashboard-section h2 {
    color: #e2e8f0;
}

body.dark-mode .stat-card {
    background: #374151;
    border-color: #4a5568;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .stat-card h3 {
    color: #a0aec0;
}

body.dark-mode .stat-value {
    color: #e2e8f0;
}

body.dark-mode .badge-item {
    background: #374151;
    border-color: #4a5568;
}

body.dark-mode .badge-item h4 {
    color: #e2e8f0;
}

body.dark-mode .badge-item p {
    color: #a0aec0;
}

body.dark-mode .category-progress-item {
    background: #374151;
    border-color: #4a5568;
}

body.dark-mode .category-progress-item h4 {
    color: #e2e8f0;
}

body.dark-mode .category-progress-item p {
    color: #a0aec0;
}

body.dark-mode .progress-bar {
    background: #4a5568;
}

body.dark-mode .saved-sentence-item {
    background: #374151;
    border-color: #667eea;
    border-left-color: #667eea;
}

body.dark-mode .saved-sentence-text {
    color: #e2e8f0;
}

body.dark-mode .saved-sentence-translation {
    color: #a0aec0;
}

body.dark-mode .saved-sentence-meta {
    color: #6b7280;
}

body.dark-mode .delete-sentence-btn {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}

body.dark-mode .delete-sentence-btn:hover {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: rgba(239, 68, 68, 0.6) !important;
    color: #ef4444 !important;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .auth-section {
        gap: 6px;
    }
    
    .login-btn {
        width: 36px;
        height: 36px;
    }
    
    .auth-section {
        height: 36px; /* 모바일에서 조금 더 작게 */
    }
    
    .user-profile {
        gap: 4px;
        padding: 4px 8px;
        height: 36px; /* 모바일에서 조금 더 작게 */
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
    }
    
    .user-name {
        font-size: 13px;
        max-width: 80px;
    }
    
    .logout-btn {
        width: 20px;
        height: 20px;
    }
    
    .global-leaderboard-btn {
        width: 36px;
        height: 36px;
    }
}

/* ========================================
   Phase 3: 글로벌 리더보드 모달 스타일
   ======================================== */

.leaderboard-modal-content {
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-header h2 {
    margin: 0;
    color: #2d3748;
    font-size: 24px;
}

.close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

/* 필터 섹션 */
.leaderboard-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.filter-select:hover {
    border-color: #6366f1;
}

.filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* 통계 섹션 */
.leaderboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
}

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

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

/* 리더보드 리스트 */
.leaderboard-list {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    background: #f9fafb;
    border-color: #6366f1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaderboard-item.current-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.leaderboard-item.current-user .rank,
.leaderboard-item.current-user .player-name,
.leaderboard-item.current-user .score {
    color: white;
}

.rank {
    width: 40px;
    font-size: 18px;
    font-weight: 700;
    color: #6b7280;
    text-align: center;
}

.rank.top-3 {
    color: #f59e0b;
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 12px;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-details {
    font-size: 12px;
    color: #6b7280;
}

.score {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    text-align: right;
    min-width: 60px;
}

/* 로딩 및 에러 상태 */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.leaderboard-svg-spinner {
    width: 64px;
    height: 64px;
    display: block;
    margin: 0 auto;
    flex-shrink: 0;
    position: relative;
    left: 0;
    fill: #6b7280;
    transition: fill 0.2s ease;
}

.error-message {
    text-align: center;
    padding: 40px;
    color: #ef4444;
}

.retry-btn {
    margin-top: 12px;
    padding: 8px 16px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-btn:hover {
    background: #dc2626;
}

/* 다크모드 대응 */
body.dark-mode .modal-header {
    border-bottom-color: #4a5568;
}

body.dark-mode .modal-header h2 {
    color: #e2e8f0;
}

body.dark-mode .close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.dark-mode .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

body.dark-mode .filter-select {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .filter-select:hover,
body.dark-mode .filter-select:focus {
    border-color: #6366f1;
}

body.dark-mode .leaderboard-stats {
    background: #2d3748;
}

body.dark-mode .stat-label {
    color: #a0aec0;
}

body.dark-mode .stat-value {
    color: #e2e8f0;
}

body.dark-mode .leaderboard-item {
    background: #2d3748;
    border-color: #4a5568;
}

body.dark-mode .leaderboard-item:hover {
    background: #374151;
}

body.dark-mode .player-name {
    color: #e2e8f0;
}

body.dark-mode .player-details {
    color: #a0aec0;
}

body.dark-mode .score {
    color: #e2e8f0;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .leaderboard-modal-content {
        width: 95vw;
        max-height: 85vh;
    }
    
    .leaderboard-filters {
        flex-direction: column;
        gap: 8px;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .leaderboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
    
    .leaderboard-item {
        padding: 10px 12px;
    }
    
    .player-avatar {
        width: 32px;
        height: 32px;
        margin: 0 8px;
    }
    
    .player-name {
        font-size: 14px;
    }
    
    .score {
        font-size: 16px;
    }
}

/* 다크모드에서 메인화면 아이콘 위치 고정 */
.dark-mode .header-buttons {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
}

.dark-mode .category-header {
    margin-top: -20px !important;
    height: 40px !important;
    position: relative !important;
}

/* 모바일 다크모드에서도 동일한 위치 적용 */
@media (max-width: 768px) {
    .dark-mode .header-buttons {
        top: 10px !important;
        right: 10px !important;
    }
    
    .dark-mode .category-header {
        margin-top: 0 !important;
        height: 50px !important;
        padding-top: 10px;
    }
    
    /* Dashboard Modal Mobile */
    .dashboard-modal-content {
        width: 95vw;
        max-height: 85vh;
        border-radius: 20px;
    }
    
    .dashboard-modal-content .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .dashboard-modal-content .stat-card {
        padding: 12px;
        gap: 8px;
    }
    
    .dashboard-modal-content .stat-icon {
        display: none;
    }
    
    /* 모바일에서 스탯카드 텍스트 간소화 */
    .dashboard-modal-content .stat-card:nth-child(1) h3::after {
        content: "완료\A문제";
        white-space: pre;
    }
    
    .dashboard-modal-content .stat-card:nth-child(2) h3::after {
        content: "합계\A점수";
        white-space: pre;
    }
    
    .dashboard-modal-content .stat-card:nth-child(3) h3::after {
        content: "최고\A연승";
        white-space: pre;
    }
    
    .dashboard-modal-content .stat-card:nth-child(4) h3::after {
        content: "완벽\A지수";
        white-space: pre;
    }
    
    .dashboard-modal-content .stat-card h3 {
        font-size: 0;
    }
    
    .dashboard-modal-content .stat-card h3::after {
        font-size: 12px;
        font-weight: 600;
        color: #666;
    }
    
    .dashboard-modal-content .dashboard-content {
        padding: 16px;
        gap: 20px;
        border-radius: 20px;
    }
    
    .dashboard-modal-content .category-progress-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .dashboard-modal-content .badges-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
    
    .dashboard-modal-content .badge-item {
        padding: 12px;
        gap: 8px;
    }
    
    .dashboard-modal-content .badge-icon {
        font-size: 20px;
    }
    
    .dashboard-modal-content .badge-name {
        font-size: 10px;
    }
    
    .dashboard-modal-content .badge-rarity {
        font-size: 8px;
    }
    
    .dashboard-modal-content .section-title {
        font-size: 16px;
        margin: 24px 0 12px 0;
    }
}

/* 에러 모달 스타일 */
.error-modal {
    max-width: 500px;
    width: 100%;
}

.error-modal h2 {
    color: #dc2626;
    margin-bottom: 20px;
    text-align: center;
}

.error-content {
    margin-bottom: 25px;
}

.error-content p {
    margin-bottom: 20px;
    line-height: 1.6;
}

.solution-steps {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.solution-steps h4 {
    color: #1f2937;
    margin: 0 0 10px 0;
    font-size: 14px;
}

.solution-steps ol {
    margin: 0;
    padding-left: 20px;
}

.solution-steps li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.help-text {
    background: #eff6ff;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
    margin-top: 15px;
}

.help-text small {
    color: #1e40af;
}

.alternative {
    background: #f0fdf4;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #22c55e;
    margin-top: 15px;
}

.alternative p {
    margin: 0;
    color: #166534;
}

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

.modal-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.modal-actions .btn.primary {
    background: #3b82f6;
    color: white;
}

.modal-actions .btn.primary:hover {
    background: #2563eb;
}

.modal-actions .btn.secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.modal-actions .btn.secondary:hover {
    background: #e5e7eb;
}

/* 다크모드 에러 모달 */
body.dark-mode .error-modal h2 {
    color: #f87171;
}

body.dark-mode .solution-steps {
    background: #374151;
    color: #e5e7eb;
}

body.dark-mode .solution-steps h4 {
    color: #f3f4f6;
}

body.dark-mode .help-text {
    background: #1e3a8a;
    border-left-color: #60a5fa;
}

body.dark-mode .help-text small {
    color: #93c5fd;
}

body.dark-mode .alternative {
    background: #166534;
    border-left-color: #4ade80;
}

body.dark-mode .alternative p {
    color: #86efac;
}

body.dark-mode .modal-actions .btn.secondary {
    background: #374151;
    color: #e5e7eb;
    border-color: #6b7280;
}

body.dark-mode .modal-actions .btn.secondary:hover {
    background: #4b5563;
}

/* 에러 모달 모바일 대응 */
@media (max-width: 768px) {
    .error-modal {
        margin: 10px;
        max-width: none;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* Phase 4-A: 게임 상태 복원 모달 스타일 */
.restore-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.restore-confirmation-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    animation: scaleIn 0.3s ease-out forwards;
}

.restore-confirmation-content h3 {
    margin: 0 0 16px 0;
    color: #1f2937;
    font-size: 20px;
    font-weight: 600;
}

.restore-confirmation-content p {
    margin: 0 0 24px 0;
    color: #6b7280;
    line-height: 1.6;
    font-size: 14px;
}

.restore-confirmation-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.restore-confirmation-buttons .btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restore-confirmation-buttons .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.restore-confirmation-buttons .btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restore-confirmation-buttons .btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* 다크모드 지원 */
body.dark-mode .restore-confirmation-content {
    background: #1f2937;
    color: #e5e7eb;
}

body.dark-mode .restore-confirmation-content h3 {
    color: #f3f4f6;
}

body.dark-mode .restore-confirmation-content p {
    color: #9ca3af;
}

body.dark-mode .restore-confirmation-buttons .btn-secondary {
    background: #374151;
    color: #e5e7eb;
    border-color: #6b7280;
}

body.dark-mode .restore-confirmation-buttons .btn-secondary:hover {
    background: #4b5563;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .restore-confirmation-content {
        padding: 24px;
        width: 95%;
    }
    
    .restore-confirmation-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .restore-confirmation-buttons button {
        width: 100%;
    }
}

/* 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* 게임 상태 저장 표시 */
.game-state-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.game-state-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.game-state-indicator.error {
    background: rgba(239, 68, 68, 0.9);
}

/* 다크모드에서 게임 상태 표시 */
body.dark-mode .game-state-indicator {
    background: rgba(34, 197, 94, 0.8);
}

body.dark-mode .game-state-indicator.error {
    background: rgba(239, 68, 68, 0.8);
}

/* Phase 4-A: 로딩 상태 스타일 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}


.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: white;
    text-align: center;
}

.loading-text {
    font-size: 16px;
    font-weight: 500;
}

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

/* 버튼 로딩 상태 */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 부드러운 호버 효과 개선 */
.category-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* 키보드 애니메이션 개선 */
.keyboard-key {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.keyboard-key:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.keyboard-key.pressed {
    transform: translateY(1px);
    transition: transform 0.1s ease;
}

/* Phase 4-A: 새로운 모달용 애니메이션 (기존 모달과 충돌 방지) */
.modal.phase4-modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.phase4-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal.phase4-modal .modal-content {
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.phase4-modal.show .modal-content {
    transform: scale(1) translateY(0);
}

/* 기존 모달들의 부드러운 전환 효과 */
#success-modal,
#game-over-modal,
#dashboard-modal,
#leaderboard-modal {
    transition: opacity 0.2s ease;
}

#success-modal[style*="flex"],
#game-over-modal[style*="flex"],
#dashboard-modal[style*="flex"],
#leaderboard-modal[style*="flex"] {
    opacity: 1;
}

#success-modal[style*="none"],
#game-over-modal[style*="none"],
#dashboard-modal[style*="none"],
#leaderboard-modal[style*="none"] {
    opacity: 0;
}
