/* 개발자 타자연습 - 메인 스타일시트 */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-orange: #d29922;
    --accent-purple: #a371f7;
    --accent-cyan: #39c5cf;
    --code-bg: #0d1117;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 배경 그라데이션 효과 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(163, 113, 247, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* 코드 폰트 */
.code-font {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* 컨테이너 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 헤더 */
.header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* 언어 토글 */
.lang-toggle {
    display: flex;
    gap: 4px;
    margin-left: 16px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.lang-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    color: var(--text-secondary);
}

.lang-btn.active {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* 메인 컨텐츠 */
.main {
    padding: 48px 0;
}

/* 타이틀 섹션 */
.title-section {
    text-align: center;
    margin-bottom: 48px;
}

.title {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* 선택 카드 그리드 */
.selection-section {
    margin-bottom: 48px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

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

.tech-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

/* 선택 카드 */
.selection-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.selection-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.02));
    pointer-events: none;
}

.selection-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.selection-card.selected {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
}

.selection-card.selected::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: var(--accent-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.card-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 시작 버튼 */
.start-section {
    text-align: center;
    margin-top: 48px;
}

.start-btn {
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(88, 166, 255, 0.4);
}

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

/* 타이핑 영역 */
.typing-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.typing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.typing-info {
    display: flex;
    gap: 24px;
}

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

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.info-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-blue);
}

.info-value.success {
    color: var(--accent-green);
}

.info-value.error {
    color: var(--accent-red);
}

/* 코드 표시 영역 */
.code-display {
    padding: 24px;
    background: var(--code-bg);
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.code-display .char {
    transition: background 0.1s, color 0.1s;
}

.code-display .char.current {
    background: var(--accent-blue);
    color: #fff;
    border-radius: 2px;
}

.code-display .char.correct {
    color: var(--accent-green);
}

.code-display .char.incorrect {
    color: var(--accent-red);
    background: rgba(248, 81, 73, 0.2);
    text-decoration: underline wavy var(--accent-red);
}

.code-display .char.pending {
    color: var(--text-muted);
}

/* 입력 영역 */
.input-area {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.typing-input {
    width: 100%;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.typing-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(88, 166, 255, 0.1);
}

/* 단문 모드 - 현재 줄 강조 */
.current-line {
    background: var(--bg-tertiary);
    padding: 20px 24px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    text-align: center;
    margin-bottom: 16px;
}

/* 게임 모드 */
.game-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.game-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

.hp-bar {
    width: 200px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-orange), var(--accent-green));
    transition: width 0.3s;
    border-radius: 10px;
}

.game-score {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-blue);
}

.game-area {
    position: relative;
    width: 100%;
    height: 100%;
    padding-top: 60px;
}

.falling-word {
    position: absolute;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-hover));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: var(--text-primary);
    transition: transform 0.1s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.falling-word.matched {
    animation: wordMatch 0.3s ease-out forwards;
}

@keyframes wordMatch {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.game-input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
}

.game-input {
    width: 100%;
    padding: 16px 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    text-align: center;
}

.game-input:focus {
    border-color: var(--accent-blue);
}

/* 게임 오버 오버레이 */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.game-over-title {
    font-size: 48px;
    font-weight: 800;
    color: var(--accent-red);
    margin-bottom: 16px;
}

.game-over-score {
    font-size: 24px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.restart-btn {
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

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

/* 결과 모달 */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.result-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: var(--transition);
}

.result-modal.show .result-content {
    transform: scale(1);
}

.result-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-sm);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-blue);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* 반응형 */
@media (max-width: 768px) {
    .mode-grid {
        grid-template-columns: 1fr;
    }

    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .title {
        font-size: 32px;
    }

    .typing-info {
        gap: 12px;
    }

    .code-display {
        font-size: 14px;
    }
}

/* 스크롤바 스타일 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 숨김 클래스 */
.hidden {
    display: none !important;
}

/* 로딩 애니메이션 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 프로그레스 바 */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    transition: width 0.3s;
}

/* 뒤로가기 버튼 */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.back-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* 언어별 콘텐츠 표시/숨김 */
html[lang="ko"] .lang-en,
html[lang="en"] .lang-ko {
    display: none !important;
}

html[lang="ko"] .lang-ko,
html[lang="en"] .lang-en {
    display: block;
}

/* 인라인 요소용 */
html[lang="ko"] span.lang-en,
html[lang="en"] span.lang-ko {
    display: none !important;
}

html[lang="ko"] span.lang-ko,
html[lang="en"] span.lang-en {
    display: inline;
}