/* 개발자 퀴즈 - VS Code/터미널 테마 */
:root {
    --primary: #27ae60;
    --primary-dark: #1e8449;
    --primary-light: #2ecc71;
    --bg-dark: #1e1e1e;
    --bg-terminal: #0d1117;
    --bg-card: #252526;
    --text-primary: #d4d4d4;
    --text-secondary: #808080;
    --accent-blue: #569cd6;
    --accent-orange: #ce9178;
    --accent-yellow: #dcdcaa;
    --accent-purple: #c586c0;
    --accent-green: #6a9955;
    --border-color: #3c3c3c;
}

/* Light Mode Override */
[data-theme="light"] {
    --primary: #27ae60;
    --primary-dark: #1e8449;
    --primary-light: #2ecc71;
    --bg-dark: #f5f5fa;
    --bg-terminal: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a70;
    --accent-blue: #569cd6;
    --accent-orange: #ce9178;
    --accent-yellow: #dcdcaa;
    --accent-purple: #c586c0;
    --accent-green: #6a9955;
    --border-color: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* 터치 최적화 */
button, a, input, [role="button"], [role="link"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

input[type="text"], textarea {
    -webkit-user-select: text;
    user-select: text;
}

body {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* App Loader */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.loader-emoji {
    font-size: 48px;
    animation: loader-bounce 1s ease-in-out infinite;
}
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}
.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 500;
}
@keyframes loader-spin {
    to { transform: rotate(360deg); }
}
@keyframes loader-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.app-container {
    max-width: 520px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
}

/* 광고 배너 */
.ad-banner {
    height: 50px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 10px;
}

[data-theme="light"] .ad-banner {
    border: 1px dashed rgba(0, 0, 0, 0.1);
}

.ad-banner::before {
    content: '/* 광고 영역 */';
}

.bottom-ad {
    margin-top: 10px;
    margin-bottom: 0;
}

/* 터미널 헤더 */
.terminal-header {
    background: #323233;
    padding: 10px 15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

[data-theme="light"] .terminal-header {
    background: #f0f0f0;
    border-bottom: 1px solid var(--border-color);
}

.window-controls {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }

.terminal-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
    text-align: center;
}

/* 터미널 바디 */
.terminal-body {
    background: var(--bg-terminal);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 20px;
    min-height: 500px;
}

[data-theme="light"] .terminal-body {
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 시작 화면 */
.ascii-art {
    color: var(--primary);
    font-size: 0.7rem;
    white-space: pre;
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.2;
}

.terminal-prompt {
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.prompt-user {
    color: var(--primary);
}

.prompt-path {
    color: var(--accent-blue);
}

.typing-text {
    color: var(--text-secondary);
}

/* 카테고리 그리드 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.category-btn {
    padding: 14px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 80px;
    touch-action: manipulation;
    position: relative;
}

[data-theme="light"] .category-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .category-btn:hover {
    background: rgba(39, 174, 96, 0.08);
}

.category-btn:hover {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.1);
}

.category-btn.selected {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.2);
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.3);
}

.cat-icon {
    font-size: 1.5rem;
}

.cat-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* 난이도 선택 */
.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    justify-content: center;
}

.prompt-text {
    color: var(--accent-purple);
    font-size: 0.85rem;
}

.diff-btn {
    padding: 10px 16px;
    min-height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    border-color: var(--primary);
}

.diff-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 시작 버튼 */
@keyframes startBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(39, 174, 96, 0); }
}

.start-btn {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--primary);
    border-radius: 6px;
    background: transparent;
    color: var(--primary);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: startBtnPulse 2s ease-in-out infinite;
    animation-delay: 0s;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

.start-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(39, 174, 96, 0.1), transparent);
    animation: shimmerBtn 2s infinite;
}

@keyframes shimmerBtn {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.start-btn:hover {
    background: var(--primary);
    color: white;
    animation: none;
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.4);
}

.start-btn:active {
    transform: scale(0.98);
}

.cursor {
    animation: blink 1s infinite;
    animation-delay: 0s;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 퀴즈 화면 */
.quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.question-num {
    color: var(--accent-blue);
}

.score-display {
    color: var(--primary);
}

@keyframes progressGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(39, 174, 96, 0.3), inset 0 0 8px rgba(39, 174, 96, 0.1); }
    50% { box-shadow: 0 0 16px rgba(39, 174, 96, 0.7), inset 0 0 12px rgba(39, 174, 96, 0.2); }
}

.progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.6);
    animation: progressGlow 2s ease-in-out infinite;
}

.question-block {
    margin-bottom: 15px;
}

.code-comment {
    color: var(--accent-green);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.question-text {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    overflow-x: auto;
}

[data-theme="light"] .code-block {
    background: #f8f8f8;
    border: 1px solid var(--border-color);
}

.code-block:empty {
    display: none;
}

.code-block code {
    color: var(--accent-orange);
}

.code-keyword {
    color: var(--accent-purple);
}

.code-string {
    color: var(--accent-orange);
}

.code-function {
    color: var(--accent-yellow);
}

/* 옵션 */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    padding: 16px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
    position: relative;
}

[data-theme="light"] .option-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .option-btn:hover:not(:disabled) {
    background: rgba(39, 174, 96, 0.08);
}

.option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.1);
}

.option-btn.correct {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.3);
    color: var(--primary);
}

.option-btn.wrong {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

.option-btn:disabled {
    cursor: default;
}

/* 결과 화면 */
.result-ascii {
    color: var(--primary);
    font-size: 0.6rem;
    white-space: pre;
    text-align: center;
    margin-bottom: 20px;
}

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

.result-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

[data-theme="light"] .result-stats {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    animation: statPulse 2s ease-in-out infinite;
    animation-delay: 0s;
}

.result-message {
    text-align: center;
    padding: 15px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

[data-theme="light"] .result-message {
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 프리미엄 버튼 */
.premium-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

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

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

.premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(243, 156, 18, 0.4);
}

.ad-tag {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

/* 프리미엄 결과 */
.premium-result {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), rgba(231, 76, 60, 0.1));
    border: 2px solid #f39c12;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    color: white;
    padding: 6px 15px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 15px;
}

#premium-content {
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* 결과 액션 */
.result-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.retry:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn.share:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.hidden {
    display: none !important;
}

/* 전면 광고 */
.interstitial-ad {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.ad-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
}

.ad-placeholder {
    width: 280px;
    height: 200px;
    background: var(--bg-terminal);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px auto;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

#close-ad {
    padding: 10px 25px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: transparent;
    color: var(--primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

#close-ad:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

#close-ad:disabled {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* 반응형 */
@media (max-width: 400px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .cat-icon {
        font-size: 1.3rem;
    }

    .ascii-art {
        font-size: 0.55rem;
    }
}

/* Daily Challenge Button */
.daily-btn {
    margin-top: 10px;
    background: linear-gradient(135deg, rgba(86, 156, 214, 0.15), rgba(39, 174, 96, 0.15));
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    min-height: 48px;
    touch-action: manipulation;
}

.daily-btn:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.daily-btn:active {
    transform: scale(0.98);
}

.daily-icon { font-size: 1.3rem; }

.daily-streak {
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

.daily-streak:empty { display: none; }

/* Stats Dashboard */
.stats-dashboard {
    margin-top: 16px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

[data-theme="light"] .stats-dashboard {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stats-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mini-stat {
    text-align: center;
}

.mini-stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.mini-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Social Share Buttons */
.share-section {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}
.share-btn {
    min-height: 44px;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.share-btn:focus-visible {
    outline: 3px solid var(--primary, #27ae60);
    outline-offset: 2px;
}
.share-twitter {
    background: #000;
    color: #fff;
}
.share-url {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.15);
}
[data-theme="light"] .share-url {
    background: rgba(0,0,0,0.05);
    color: #333;
    border-color: rgba(0,0,0,0.1);
}
.share-btn:hover {
    transform: translateY(-1px);
}

/* Recommendations Section */
.recommendations-section { margin: 24px 0 0; padding: 0 16px; }
.rec-title { font-size: 15px; font-weight: 700; color: rgba(255,255,255,0.5); margin-bottom: 12px; text-align: center; letter-spacing: 0.5px; }
.rec-grid { display: flex; flex-direction: column; gap: 10px; }
.rec-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; text-decoration: none; color: #fff; transition: all 0.2s ease; }
.rec-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.rec-icon { font-size: 28px; flex-shrink: 0; }
.rec-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rec-name { font-size: 14px; font-weight: 600; }
.rec-desc { font-size: 12px; color: rgba(255,255,255,0.5); }

/* Game Footer */
.game-footer {
  text-align: center;
  padding: 20px 0;
  margin-top: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  font-size: 13px;
  padding: 12px 0;
  transition: color 0.2s;
}

.back-link:hover {
  color: rgba(255,255,255,0.7);
}

/* Light mode: rec-section & back-link overrides */
[data-theme="light"] .rec-card { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .rec-card:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .rec-title { color: rgba(26,26,46,0.5); }
[data-theme="light"] .rec-name { color: #1a1a2e; }
[data-theme="light"] .rec-desc { color: #555; }
[data-theme="light"] .back-link { color: rgba(26,26,46,0.4); }
[data-theme="light"] .back-link:hover { color: rgba(26,26,46,0.7); }

/* === Accessibility Improvements === */
button:focus-visible,a:focus-visible,input:focus-visible,[role="button"]:focus-visible{outline:3px solid #27ae60;outline-offset:2px;}
button,a[href],input[type="button"],input[type="submit"],[role="button"]{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;}
.skip-link{position:absolute;top:-40px;left:0;background:#27ae60;color:white;padding:8px;text-decoration:none;z-index:100;}
.skip-link:focus{top:0;}
[role="dialog"]{z-index:1000;}
@media (prefers-reduced-motion: reduce){*{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important;}}
/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark, var(--bg-primary, var(--background, #0f0f23)));
}

::-webkit-scrollbar-thumb {
    background: #27ae60;
    border-radius: 5px;
    border: 2px solid var(--bg-dark, var(--bg-primary, var(--background, #0f0f23)));
}

::-webkit-scrollbar-thumb:hover {
    background: #52be7f;
    opacity: 0.8;
}

/* Selection Color */
::selection {
    background: #27ae60;
    color: white;
}

::-moz-selection {
    background: #27ae60;
    color: white;
}

@media (prefers-contrast: more){button{border:2px solid #27ae60;}}
.rec-card:focus-visible{outline:3px solid #27ae60;outline-offset:4px;}

/* Glassmorphism Enhancement */
.header, .modal, .overlay, [role="dialog"], .menu {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Card/Panel Glassmorphism */
.card, .panel, .sidebar, [class*="card"] {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
