@import url('https://fonts.googleapis.com/css2?family=Jua&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --primary-color: #0984e3; /* 지적인 파란색 */
    --secondary-color: #00cec9;
    --bg-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --text-color: #fff;
    --btn-hover: #74b9ff;

    /* [프로그래머 테스트 전용] 터미널/코드 테마 토큰 */
    --prog-green: #3ddc84;      /* compile success green */
    --prog-green-dim: #2a9d5c;
    --prog-amber: #ffb454;      /* warning amber */
    --prog-terminal-bg: #0d1117;
    --prog-terminal-border: #30363d;
    --prog-mono-font: 'JetBrains Mono', 'Consolas', monospace;
}

body {
    font-family: 'Jua', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    text-align: center;
    padding: 20px 0;
}

.container {
    position: relative; /* [추가] 내부 요소(언어 버튼)의 위치 기준점 */
    background-color: var(--surface-color);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 600px;
}

.screen { display: flex; flex-direction: column; align-items: center; }
.title { color: var(--secondary-color); font-size: 2.2rem; margin-bottom: 10px; }
.description { font-size: 1.1rem; margin-bottom: 30px; line-height: 1.6; color: #ccc; }

.btn {
    font-family: 'Jua', sans-serif;
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    position: relative;
    text-decoration: none;
    width: 100%; /* 버튼 꽉 차게 */
    margin-bottom: 10px;
}
.btn:hover { background-color: var(--btn-hover); transform: scale(1.02); }
.btn:active { transform: scale(0.97); }
.btn:disabled { background-color: #555; cursor: not-allowed; transform: none; }

/* 퀴즈 화면 */
#quiz-screen { width: 100%; }
.header-status {
    width: 100%;
    display: flex;
    justify-content: flex-end; /* 오른쪽 정렬 유지 */
    margin-bottom: 5px;
    color: #888;

    /* [수정 핵심] 버튼이 들어갈 자리를 확보하기 위해 오른쪽 안쪽 여백 추가 */
    padding-right: 70px;
    box-sizing: border-box; /* 패딩이 너비에 포함되도록 설정 */
    align-items: center; /* 텍스트 수직 중앙 정렬 */
    height: 30px; /* 버튼 높이와 비슷하게 라인 확보 */
}

.progress-container { width: 100%; height: 10px; background-color: #444; border-radius: 5px; margin-bottom: 20px; overflow: hidden; }
#progress-bar { width: 0%; height: 100%; background-color: var(--secondary-color); border-radius: 5px; transition: width 0.3s; }

.category-badge {
    background-color: #6c5ce7;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 10px;
    animation: prog-badge-pop 0.3s ease;
}

#question {
    margin-bottom: 30px;
    font-size: 1.4rem;
    min-height: 3.5rem;
    word-break: keep-all;
    animation: prog-fade-in 0.35s ease;
}

/* 4지 선다 그리드 */
.btn-grid.four-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
}
/* 화면이 넓을 때는 2열로 배치 (선택사항) */
@media (min-width: 480px) {
    .btn-grid.four-options { grid-template-columns: 1fr 1fr; }
}

/* 결과 화면 */
#result-image {
    width: 160px;
    height: 160px;
    margin: 20px 0;
    border-radius: 28px;
    object-fit: cover;
    border: 4px solid var(--secondary-color);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(0, 206, 201, 0.12);
    animation: prog-pop-in 0.5s ease;
}
#result-title { color: var(--secondary-color); font-size: 2rem; margin-bottom: 5px; animation: prog-fade-in 0.4s ease; }
.score-display { font-size: 2.5rem; color: #ff7675; margin-bottom: 15px; font-weight: bold; }
#result-description { font-size: 1.1rem; line-height: 1.5; margin-bottom: 20px; white-space: pre-wrap;}

/* 공유 버튼 */
#share-buttons { display: flex; gap: 10px; margin-bottom: 25px; width: 100%; }
.share-btn { font-size: 0.95rem; padding: 12px; flex: 1; margin-bottom: 0;}
#kakao-btn { background-color: #FEE500; color: #191919; }
#kakao-btn:hover { background-color: #f7d800; }
#copy-btn { background-color: #555; }

/* 하단 링크 버튼들 */
#other-games-container {
    width: 100%;
    margin-top: 30px;
    padding: 20px 10px;
    background-color: #333;
    border-radius: 10px;
}
#other-games-container h3 { color: #fff; margin-bottom: 15px; font-size: 1.1rem; }


/* 토스트 팝업 */
#toast-popup {
    visibility: hidden;
    min-width: 250px;
    background-color: rgba(50, 50, 50, 0.9);
    color: #fff;
    text-align: center;
    border-radius: 10px;
    padding: 16px;
    position: fixed;
    z-index: 10000;
    left: 50%;
    transform: translateX(-50%);
    bottom: 50px;
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s;
}
#toast-popup.show { visibility: visible; opacity: 1; bottom: 80px; }
.ad-container { margin: 20px 0; min-height: 100px; display: flex; justify-content: center; }

/* 타이머 스타일 */
#timer-box {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff7675;
    margin-bottom: 10px;
    transition: color 0.3s;
}
#timer-box.prog-timer-warning {
    animation: prog-timer-pulse 0.6s infinite;
}

/* 정답/오답 피드백 스타일 */
.btn.correct {
    background-color: #00b894 !important; /* 녹색 */
    color: #fff;
    border: 2px solid #00cec9;
    transform: scale(1.02);
    animation: prog-correct-pop 0.4s ease;
}

.btn.wrong {
    background-color: #d63031 !important; /* 빨간색 */
    color: #fff;
    opacity: 0.8;
    animation: prog-shake 0.4s ease;
}

/* 정답 공개 시 정답 버튼 강조 */
.btn.reveal {
    background-color: #00b894 !important;
    box-shadow: 0 0 10px #00b894;
}

/* 언어 변경 버튼 위치 미세 조정 */
.lang-btn {
    position: absolute;
    top: 30px;   /* 컨테이너 padding(30px)과 높이를 맞춤 */
    right: 30px; /* 컨테이너 padding(30px)과 우측 여백을 맞춤 */
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 15px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
    font-family: sans-serif;
    line-height: 1;
}

.lang-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.install-btn {
    background-color: #2d3436; /* 어두운 회색 계열 */
    margin-top: 15px;          /* 시작 버튼과 간격 */
    border: 1px solid #636e72;
}

.install-btn:hover {
    background-color: #636e72;
    transform: scale(1.02);
}

/* =========================================================
   [프로그래머 테스트 전용] 터미널 / 코드 블록 시그니처 스타일
   ========================================================= */

.prog-title { color: var(--prog-green); }

/* 시작 화면 - 터미널 창 */
.prog-terminal {
    width: 100%;
    background-color: var(--prog-terminal-bg);
    border: 1px solid var(--prog-terminal-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 25px;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.prog-terminal-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background-color: #161b22;
    border-bottom: 1px solid var(--prog-terminal-border);
}
.prog-terminal-title {
    margin-left: 6px;
    font-family: var(--prog-mono-font);
    font-size: 0.8rem;
    color: #8b949e;
}
.prog-terminal-body {
    padding: 20px;
}
.prog-terminal-body .title { text-align: center; }
.prog-terminal-body .description {
    font-family: var(--prog-mono-font);
    font-size: 0.95rem;
    color: #c9d1d9;
    text-align: left;
    margin-bottom: 0;
}
.prog-highlight { color: var(--prog-amber); font-weight: 700; }

.prog-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.prog-dot-red { background-color: #ff5f56; }
.prog-dot-yellow { background-color: #ffbd2e; }
.prog-dot-green { background-color: #27c93f; }

.prog-cursor {
    display: inline-block;
    color: var(--prog-green);
    animation: prog-blink 1s step-end infinite;
}

/* 문제 화면 - 코드 블록 */
.prog-code-block {
    width: 100%;
    box-sizing: border-box;
    background-color: var(--prog-terminal-bg);
    border: 1px solid var(--prog-terminal-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    text-align: left;
    animation: prog-fade-in 0.35s ease;
}
.prog-code-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #161b22;
    border-bottom: 1px solid var(--prog-terminal-border);
}
.prog-code-filename {
    margin-left: 6px;
    font-family: var(--prog-mono-font);
    font-size: 0.75rem;
    color: #8b949e;
}
.prog-code-content {
    margin: 0;
    padding: 16px;
    font-family: var(--prog-mono-font);
    font-size: 0.9rem;
    line-height: 1.6;
    color: #79ffe1;
    text-align: left;
    white-space: pre;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 결과 등급 뱃지 강조 (점수에 따라 JS가 색상 클래스를 부여) */
.score-display.prog-score-high { color: var(--prog-green); }
.score-display.prog-score-mid { color: var(--prog-amber); }

/* =========================================================
   다른 사이트 홍보용 - 프로모 카드 그리드
   ========================================================= */
#other-games-container {
    position: relative;
    background: linear-gradient(160deg, #363636, #2a2a2a);
    border: 1px solid #414141;
}

#other-games-container h3 {
    margin-bottom: 18px;
    font-size: 1.15rem;
    background: linear-gradient(90deg, #74b9ff, #00cec9, #6c5ce7, #74b9ff);
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: prog-shine-text 4s linear infinite;
}

.promo-grid-wrap {
    position: relative;
}

.promo-grid {
    display: grid;
    grid-auto-flow: dense;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 480px) {
    .promo-grid { grid-template-columns: repeat(3, 1fr); }
}

.promo-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    aspect-ratio: 1 / 1;
    padding: 14px 8px;
    border-radius: 16px;
    text-decoration: none;
    color: #fff;
    text-align: center;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

/* 유리 광택 하이라이트 - 호버 시 대각선으로 스윽 지나감 */
.promo-card::before {
    content: '';
    position: absolute;
    top: -60%; left: -30%;
    width: 55%; height: 220%;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 60%);
    transform: rotate(20deg) translateX(-160%);
    transition: transform 0.6s ease;
    pointer-events: none;
}
.promo-card:hover::before { transform: rotate(20deg) translateX(160%); }

.promo-card:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45); }
.promo-card:active { transform: scale(0.94); }
.promo-card:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* 첫 카드 = 눈에 띄는 스포트라이트 히어로 타일 (2x2) */
.promo-grid .promo-card:first-child {
    grid-column: span 2;
    grid-row: span 2;
    border-radius: 20px;
    animation: prog-hero-glow 2.4s ease-in-out infinite;
}
.promo-grid .promo-card:first-child .promo-icon { font-size: 3.2rem; }
.promo-grid .promo-card:first-child .promo-text { font-size: 1rem; }

/* HOT / NEW 리본 뱃지로 호기심 유발 */
.promo-grid .promo-card:first-child::after,
.promo-grid .promo-card:nth-child(9)::after {
    position: absolute;
    top: 8px; left: 8px;
    font-family: var(--prog-mono-font);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    z-index: 1;
}
.promo-grid .promo-card:first-child::after { content: 'HOT'; background: #ff4757; color: #fff; }
.promo-grid .promo-card:nth-child(9)::after { content: 'NEW'; background: #00cec9; color: #0d1117; }

.promo-icon {
    font-size: 2.2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
    animation: prog-icon-float 3s ease-in-out infinite;
}
.promo-grid .promo-card:nth-child(2n) .promo-icon { animation-delay: 0.4s; }
.promo-grid .promo-card:nth-child(3n) .promo-icon { animation-delay: 0.8s; }

.promo-text {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
    word-break: keep-all;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

/* 카드마다 컬러를 순환시켜 단조로운 리스트가 아닌 알록달록한 '앱 아이콘 그리드' 느낌으로 */
.promo-grid .promo-card:nth-child(6n+1) { background: linear-gradient(135deg, #6c5ce7, #341f97); }
.promo-grid .promo-card:nth-child(6n+2) { background: linear-gradient(135deg, #00cec9, #0984e3); }
.promo-grid .promo-card:nth-child(6n+3) { background: linear-gradient(135deg, #ff7675, #d63031); }
.promo-grid .promo-card:nth-child(6n+4) { background: linear-gradient(135deg, #0984e3, #341f97); }
.promo-grid .promo-card:nth-child(6n+5) { background: linear-gradient(135deg, #fd79a8, #e84393); }
.promo-grid .promo-card:nth-child(6n+6) {
    background: linear-gradient(135deg, #ffeaa7, #fab1a0);
    color: #2d3436;
}
.promo-grid .promo-card:nth-child(6n+6) .promo-text { text-shadow: none; }
.promo-grid .promo-card:nth-child(6n+6) .promo-icon { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15)); }

/* 더보기 버튼 - 항상 펼쳐서 보여주므로 더 이상 노출하지 않음 */
.promo-expand-btn {
    display: none;
}

/* =========================================================
   애니메이션 키프레임
   ========================================================= */
@keyframes prog-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes prog-pop-in {
    0% { opacity: 0; transform: scale(0.7); }
    70% { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes prog-badge-pop {
    0% { transform: scale(0.85); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes prog-correct-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1.02); }
}

@keyframes prog-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@keyframes prog-timer-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes prog-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes prog-count-up {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

@keyframes prog-shine-text {
    to { background-position: -300% center; }
}

@keyframes prog-hero-glow {
    0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 0 0 0 rgba(255, 255, 255, 0); }
    50% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 255, 255, 0.25); }
}

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

@keyframes prog-border-flow {
    to { background-position: 100% 100%, -300% 0; }
}

/* 모바일 폭 좁을 때 코드 블록 폰트 축소 */
@media (max-width: 380px) {
    .prog-code-content { font-size: 0.8rem; }
    .prog-terminal-body .description { font-size: 0.88rem; }
}

/* 모션 최소화 환경 배려 */
@media (prefers-reduced-motion: reduce) {
    #question, .category-badge, #result-image, #result-title, .prog-code-block,
    .btn.correct, .btn.wrong, #timer-box.prog-timer-warning, .prog-cursor,
    #other-games-container h3, .promo-grid .promo-card:first-child, .promo-icon {
        animation: none !important;
    }
}