/**
 * style.css
 * Rainy Spako 게임 스타일
 * 모던 다크 테마 + 비 테마 디자인
 */

/* ========================================= */
/* CSS 변수 */
/* ========================================= */
:root {
    /* 메인 컬러 - 밝고 발랄한 파스텔 테마 */
    --color-bg-dark: #e8f4fd;
    --color-bg-medium: #f5f0ff;
    --color-bg-light: #fff0f7;
    --color-bg-elevated: #ffffff;
    --color-surface: #ffffff;

    /* 텍스트 (밝은 배경에 어두운 글씨) */
    --color-text-primary: #1a1040;
    --color-text-secondary: #4a3870;
    --color-text-muted: #9b8ab0;

    /* 포인트 컬러 (코랄 핑크 - 활기찬) */
    --color-accent: #e91e8c;
    --color-accent-light: #ff5cb8;
    --color-accent-dark: #c2006e;
    --color-accent-glow: rgba(233, 30, 140, 0.25);

    /* 상태 컬러 */
    --color-success: #00b894;
    --color-warning: #ff9800;
    --color-danger: #f44336;
    --color-info: #2196f3;

    /* 그라데이션 */
    --gradient-accent: linear-gradient(135deg, #e91e8c, #ff5722);
    --gradient-gold: linear-gradient(135deg, #ffc107, #ff9800);
    --gradient-danger: linear-gradient(135deg, #f44336, #ff5722);
    --gradient-bg: #ffffff;

    /* 폰트 */
    --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;

    /* 간격 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* 반응형 캔버스 크기 */
    --canvas-width: min(1000px, 100vw);
    --canvas-height: min(700px, 85vh);

    /* 그림자 */
    --shadow-sm: 0 1px 2px rgba(100, 60, 140, 0.15);
    --shadow-md: 0 4px 12px rgba(100, 60, 140, 0.18);
    --shadow-lg: 0 8px 24px rgba(100, 60, 140, 0.22);
    --shadow-glow: 0 0 20px var(--color-accent-glow);

    /* 라운딩 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* ========================================= */
/* 리셋 및 기본 스타일 */
/* ========================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--gradient-bg);
    background-attachment: fixed;
    color: var(--color-text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================= */
/* 유틸리티 클래스 */
/* ========================================= */
.hidden {
    display: none !important;
}

/* 스크롤바 숨기기 */
html, body, * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

/* ========================================= */
/* 화면 컨테이너 */
/* ========================================= */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--gradient-bg);
}

/* ========================================= */
/* 로딩 화면 */
/* ========================================= */
#loading-screen {
    background: #ffffff;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0;
    position: relative;
    max-width: 400px;
    padding: 0 32px;
}

.loading-icon-box {
    width: 128px;
    height: 128px;
    background: #f2f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    margin-bottom: 48px;
}

.loading-title {
    font-size: 30px;
    font-weight: 900;
    color: #0053db;
    letter-spacing: -0.05em;
    position: relative;
    background: none;
    -webkit-text-fill-color: initial;
    text-wrap: balance;
}

.loading-title::after {
    display: none;
}

.loading-subtitle {
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #5a6061;
    margin-top: 8px;
    opacity: 0.6;
}

.loading-bar-section {
    width: 100%;
    margin-top: 48px;
}

.loading-bar-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 12px;
}

.loading-text {
    font-size: 14px;
    color: #5a6061;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.loading-pct {
    font-size: 12px;
    color: #0053db;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background-color: #e2e2e2;
    overflow: hidden;
    position: relative;
}

.loading-progress {
    width: 0%;
    height: 100%;
    background: #0053db;
    animation: loading-slide 2.5s ease-in-out infinite;
    box-shadow: none;
}

@keyframes loading-slide {
    0% {
        width: 0%;
        margin-left: 0%;
    }
    50% {
        width: 65%;
        margin-left: 15%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

.loading-quote {
    font-size: 12px;
    color: #5a6061;
    font-style: italic;
    opacity: 0.7;
    margin-top: 32px;
    text-align: center;
    line-height: 1.6;
    text-wrap: pretty;
}

/* ========================================= */
/* 맵 화면 */
/* ========================================= */
.screen-header {
    width: 100%;
    max-width: var(--canvas-width);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
}

.header-buttons {
    display: flex;
    gap: var(--spacing-sm);
}

/* ========================================= */
/* 캔버스 컨테이너 */
/* ========================================= */
.canvas-container {
    width: var(--canvas-width);
    height: var(--canvas-height);
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-canvas-container {
    width: min(1120px, 100vw);
    height: calc(100vh - 78px);
}

canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
}

/* 클릭 가능 요소에만 포인터 커서 */
button,
select,
[role="button"],
a {
    cursor: pointer;
}

/* ========================================= */
/* 게임 본문 (패널 + 캔버스) */
/* ========================================= */
.game-body {
    display: flex;
    flex: 1;
    width: 100%;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    overflow: hidden;
    position: relative;
}

.game-body > .canvas-container {
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: var(--canvas-width);
}

/* ========================================= */
/* 단어 참조 패널 */
/* ========================================= */
.word-panel {
    width: 180px;
    min-width: 140px;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(240, 230, 255, 0.85));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(180, 140, 220, 0.25);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    margin: var(--spacing-xs);
    box-shadow: var(--shadow-sm);
}

.word-panel-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    text-align: center;
    padding-bottom: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.word-panel-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.word-pair {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
    border-bottom: 1px solid rgba(180, 140, 220, 0.08);
}

.word-pair:hover {
    background-color: rgba(233, 30, 140, 0.07);
}

.word-es {
    font-size: 12px;
    color: var(--color-text-primary);
    font-weight: 700;
}

.word-arrow {
    font-size: 10px;
    color: var(--color-text-muted);
    margin: 0 4px;
    flex-shrink: 0;
    opacity: 0.6;
}

.word-ko {
    font-size: 12px;
    color: var(--color-accent-light);
    text-align: right;
}

/* ========================================= */
/* 게임 화면 헤더 */
/* ========================================= */
.game-header {
    position: relative;
    width: 100%;
    max-width: var(--canvas-width);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f2f4f4;
}

.game-header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.game-logo {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.05em;
    color: #0053db;
}

.game-nav {
    display: flex;
    gap: 20px;
}

.game-nav-link {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: 700;
    color: #757c7d;
    cursor: pointer;
    padding: 6px 0;
    letter-spacing: -0.02em;
    transition: color 0.2s;
    border-bottom: 2px solid transparent;
}

.game-nav-link:hover {
    color: #0053db;
}

.game-nav-active {
    color: #0053db;
    font-weight: 700;
    border-bottom-color: #0053db;
}

.game-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    min-height: 54px;
    z-index: 1;
}

.game-header-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 180px;
    pointer-events: none;
}

.game-header-badge-label {
    font-size: 15px;
    font-weight: 700;
    color: #0053db;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.game-header-badge-value {
    font-size: 44px;
    font-weight: 900;
    line-height: 0.95;
    color: #0053db;
    font-variant-numeric: tabular-nums;
}

.game-header-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.game-header-icon:hover {
    background: #f2f4f4;
}

.game-header-icon-sym {
    font-size: 22px;
    color: #5a6061;
}

/* Legacy stat classes (kept for JS compatibility) */
.game-stat { display: none; }
.stat-label { display: none; }
.stat-value { display: none; }

.lives-hearts {
    font-size: 22px;
    color: var(--color-danger);
    letter-spacing: 3px;
    filter: none;
}

/* ========================================= */
/* 진행도 라벨 + 바 */
/* ========================================= */
.progress-label {
    display: block;
    width: 100%;
    max-width: var(--canvas-width);
    margin: 0 auto;
    font-size: 11px;
    color: #aaa;
    text-align: right;
    padding: 4px 6px 1px;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.progress-container {
    width: 100%;
    max-width: var(--canvas-width);
    height: 4px;
    background-color: #ebeeef;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #0053db;
    transition: width 0.5s ease-out;
    box-shadow: none;
}

/* ========================================= */
/* 콤보 표시 */
/* ========================================= */
.combo-display {
    position: relative;
    top: auto;
    right: auto;
    font-size: 14px;
    font-weight: 900;
    color: #0053db;
    text-shadow: none;
    animation: combo-pulse 0.3s ease-out;
    z-index: 10;
    letter-spacing: -0.03em;
    pointer-events: none;
    background: #dbe1ff;
    border-radius: 4px;
    padding: 4px 10px;
    backdrop-filter: none;
    text-transform: uppercase;
}

@keyframes combo-pulse {
    0% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================= */
/* 입력 필드 */
/* ========================================= */
.input-container {
    flex: 0.6;
    min-height: 0;
    width: 100%;
    max-width: var(--canvas-width);
    padding: 8px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
}

.game-input {
    width: 100%;
    padding: 24px 32px;
    font-size: 20px;
    font-family: var(--font-family);
    color: #2d3435;
    background-color: #f2f4f4;
    border: none;
    border-radius: 0;
    outline: none;
    text-align: center;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    letter-spacing: -0.01em;
    box-shadow: none;
    font-weight: 500;
}

.game-input:focus {
    background-color: #f2f4f4;
    box-shadow: none;
}

.game-input::placeholder {
    color: #adb3b4;
    font-size: 16px;
    font-weight: 400;
}

/* ========================================= */
/* 특수문자 입력 바 */
/* ========================================= */
.special-chars-bar {
    flex: 0.4;
    min-height: 0;
    width: 100%;
    max-width: var(--canvas-width);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 24px;
    background: #ffffff;
    border-top: none;
    flex-wrap: wrap;
    overflow-x: auto;
}

.special-chars-label {
    display: none;
}

.special-char-btn {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-family: var(--font-family);
    font-weight: 700;
    color: #2d3435;
    background: #f2f4f4;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.special-char-btn:hover {
    background: #0053db;
    color: #ffffff;
    transform: none;
    box-shadow: none;
}

.special-char-btn:active {
    transform: scale(0.96);
}

.special-chars-shortcut {
    font-size: 16px;
    color: #5a6061;
    font-weight: 700;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========================================= */
/* 결과 화면 */
/* ========================================= */
.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--spacing-xl);
    padding: var(--spacing-2xl);
    position: relative;
}

.result-title {
    font-size: 40px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 1px;
    text-wrap: balance;
}

.result-title.cleared {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: result-glow 2s ease-in-out infinite alternate;
}

@keyframes result-glow {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.3); }
}

.result-title.failed {
    color: var(--color-danger);
    opacity: 0.9;
}

.result-stars {
    display: flex;
    gap: var(--spacing-lg);
    font-size: 52px;
}

.star {
    color: var(--color-text-muted);
    transition: all 0.4s ease;
    filter: drop-shadow(0 0 0 transparent);
}

.star.filled {
    color: var(--color-warning);
    animation: star-pop 0.6s ease-out;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

@keyframes star-pop {
    0% {
        transform: scale(0) rotate(-30deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.3) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.result-stats {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
    justify-content: center;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 110px;
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(180, 140, 220, 0.25);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.result-stat-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.result-stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.result-buttons {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
    margin-top: var(--spacing-sm);
}

/* ========================================= */
/* 버튼 스타일 */
/* ========================================= */
.btn {
    padding: 14px var(--spacing-xl);
    font-size: 15px;
    font-family: var(--font-family);
    font-weight: 700;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-accent);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0) scale(0.96);
}

.btn-secondary {
    background-color: #f5f0ff;
    color: var(--color-text-primary);
    border: 1px solid rgba(180, 140, 220, 0.3);
}

.btn-secondary:hover {
    background-color: #ede5ff;
    border-color: rgba(233, 30, 140, 0.3);
}

.btn-large {
    padding: var(--spacing-lg) var(--spacing-xl);
    font-size: 17px;
    width: 100%;
    border-radius: var(--radius-lg);
}

.icon-btn {
    padding: 8px 16px;
    min-width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #2d3435;
    background-color: #ffffff;
    border: 1px solid #dde4e5;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.icon-btn:hover {
    background-color: #f2f4f4;
    color: #0053db;
    border-color: #adb3b4;
}

/* ========================================= */
/* 모달 */
/* ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: modal-fade-in 0.2s ease-out;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 400px;
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-lg);
    background: linear-gradient(180deg, #ffffff, #fdf4ff);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(233, 30, 140, 0.15);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    z-index: 101;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(233, 30, 140, 0.1);
    animation: modal-slide-up 0.3s ease-out;
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--color-text-muted);
    background: rgba(180, 140, 220, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--color-accent);
    background: rgba(233, 30, 140, 0.1);
}

.modal-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.3px;
}

.review-badge {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background: var(--gradient-danger);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.best-score {
    font-size: 15px;
    color: var(--color-text-secondary);
}

.jump-info {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: calc(var(--spacing-sm) * -0.5);
}

.jump-info.warning {
    color: var(--color-danger);
    font-weight: 700;
}

.mode-select-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.stats-mode-container {
    margin-top: calc(var(--spacing-sm) * -0.5);
}

.mode-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.mode-select {
    width: 100%;
    padding: 12px var(--spacing-md);
    font-size: 15px;
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background-color: #ffffff;
    border: 1px solid #dde4e5;
    border-radius: var(--radius-md);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235a6061' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.mode-select:focus {
    border-color: #0053db;
    box-shadow: 0 0 0 3px rgba(0, 83, 219, 0.12);
}

.mode-select option {
    background-color: #ffffff;
    color: var(--color-text-primary);
}

/* ========================================= */
/* 통계 모달 */
/* ========================================= */
/* Stats Dashboard - 클린 디자인 */
.modal-content.stats-dashboard {
    max-width: 672px;
    width: min(94vw, 672px);
    max-height: 92vh;
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    border: none;
    background: #ffffff;
    gap: 0;
    border-radius: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

.stats-scroll-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid #ebeeef;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    flex-shrink: 0;
}

.stats-brand { display: flex; align-items: center; gap: 12px; }
.stats-brand-icon {
    display: none;
}
.stats-kicker {
    display: none;
}
.stats-header .modal-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.05em;
    text-transform: uppercase;
    color: #2d3435;
    line-height: 1;
}
.stats-header-actions { display: flex; gap: 8px; align-items: center; }
.stats-icon-btn {
    width: 40px; height: 40px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #5a6061;
    cursor: pointer;
    font-weight: 400;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.2s ease;
}
.stats-icon-btn:hover {
    background: transparent;
    color: #0053db;
    border-color: transparent;
}

.stats-name-input {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-family);
    border: none;
    border-bottom: 2px solid #0053db;
    outline: none;
    background: transparent;
    color: #2d3435;
    padding: 2px 0;
    width: 160px;
}

.stats-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 32px 32px 24px;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
    border-bottom: none;
}
.stats-hero-title {
    font-size: 30px;
    font-weight: 700;
    color: #2d3435;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-wrap: balance;
}
.stats-hero-subtitle {
    color: #5a6061;
    font-size: 14px;
    margin-top: 4px;
    max-width: 380px;
    line-height: 1.5;
    text-wrap: pretty;
}

/* Stats 섹션 공통 타이틀 */
.stats-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #5a6061;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

/* 모드 선택 (stats 내) */
.stats-mode-container {
    padding: 16px 32px;
    margin-top: 0;
}

/* Stage Progress 바 */
.dashboard-progress {
    padding: 16px 32px 32px;
    border-top: 1px solid #ebeeef;
    width: 100%;
    box-sizing: border-box;
    border-bottom: none;
    cursor: pointer;
}
.dashboard-progress.expanded {
    background: #fafbff;
}
.stats-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.stats-progress-chip {
    background: transparent;
    color: #5a6061;
    padding: 0;
    border-radius: 0;
    font-size: 12px;
    font-weight: 700;
}
.stats-progress-track {
    height: 6px;
    background: #f2f4f4;
    border-radius: 3px;
    overflow: hidden;
}
.stats-progress-fill {
    background: #0053db;
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease-out;
}
.stats-progress-label {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #757c7d;
    text-transform: uppercase;
    letter-spacing: .8px;
}
.stats-unlocked-words {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #ebeeef;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}
.stats-word-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #d8e2ff;
    border-radius: 12px;
    font-size: 13px;
    color: #2d3435;
}
.stats-word-chip strong {
    color: #0053db;
    font-weight: 700;
}
.stats-word-chip em {
    font-style: normal;
    color: #5a6061;
}
.stats-unlocked-empty {
    font-size: 14px;
    color: #5a6061;
}

/* ========================================= */
/* 단어장 섹션 */
/* ========================================= */
.wordbook-section {
    padding: 20px 32px 4px;
    border-top: 1px solid #ebeeef;
}
.wordbook-count {
    font-size: 12px;
    font-weight: normal;
    color: #aaa;
    margin-left: 6px;
}
.wordbook-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-bottom: 4px;
}
.wordbook-empty {
    font-size: 13px;
    color: #aaa;
    margin: 4px 0;
}
.wordbook-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 20px;
    font-size: 12px;
    line-height: 1.4;
}
.wordbook-chip strong {
    font-weight: 700;
    font-size: 12px;
}
.wordbook-chip em {
    font-style: normal;
    font-size: 11px;
    opacity: 0.75;
}
.wordbook-chip-ok {
    background: #f0fff4;
    border: 1px solid #86efac;
    color: #166534;
}
.wordbook-chip-ok strong {
    color: #15803d;
}
.wordbook-chip-weak {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #7c2d12;
}
.wordbook-chip-weak strong {
    color: #c2410c;
}
.wordbook-badge-weak {
    font-size: 10px;
    font-weight: 700;
    color: #dc2626;
    opacity: 0.85;
}

/* 숫자 통계 그리드 - 벤토 스타일 */
.stats-grid {
    display: grid;
}
.dashboard-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    padding: 0 32px 32px;
    width: 100%;
    box-sizing: border-box;
    border-bottom: none;
    background: transparent;
}

.stats-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f2f4f4;
    border: none;
    border-radius: 0;
    padding: 16px;
    align-items: flex-start;
    transition: none;
}
.stats-item:hover {
    box-shadow: none;
}
.stats-item-value {
    font-size: 24px;
    font-weight: 700;
    color: #2d3435;
    background: none;
    -webkit-text-fill-color: initial;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stats-item-label {
    font-size: 10px;
    color: #5a6061;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 900;
    order: -1;
}
.stats-item-accent {
    background: #f2f4f4;
    border-color: transparent;
}
.stats-item-accent .stats-item-label { color: #5a6061; }
.stats-item-accent .stats-item-value { color: #2d3435; }

/* 하단 푸터 그리드 */
.stats-footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    padding: 0 32px 32px;
    width: 100%;
    box-sizing: border-box;
}

.stats-week-bars {
    height: 128px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0;
    padding: 8px 0;
    margin-top: 0;
    border-bottom: 1px solid #f2f4f4;
}
.stats-week-bars .bar {
    flex: 1;
    margin: 0 4px;
    border-radius: 0;
    background: #0053db;
    min-height: 5%;
    transition: opacity 0.2s ease;
}
.stats-week-bars .bar.active {
    background: #0053db;
}
.stats-week-labels {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #5a6061;
    font-weight: 700;
    letter-spacing: 0;
    text-align: center;
}
.stats-week-labels span {
    flex: 1;
    text-align: center;
}

/* 퍼포먼스 카드 - 그린/레드 스타일 */
.stats-mini-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stats-mini-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stats-mini-card span {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.stats-mini-card strong {
    font-size: 20px;
    font-weight: 700;
}

/* Correct 카드 */
.stats-mini-correct {
    background: #ecfdf5;
    border-left: 4px solid #10b981;
}
.stats-mini-correct span { color: #065f46; }
.stats-mini-correct strong { color: #064e3b; }

/* Wrong 카드 */
.stats-mini-wrong {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
}
.stats-mini-wrong span { color: #991b1b; }
.stats-mini-wrong strong { color: #7f1d1d; }

/* Stats 모달 푸터 */
.stats-modal-footer {
    padding: 24px 32px;
    border-top: 1px solid #f2f4f4;
    display: flex;
    justify-content: flex-end;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}
.stats-close-btn {
    padding: 12px 32px;
    background: #0053db;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.stats-close-btn:hover {
    background: #0048c1;
}
.stats-close-btn:active {
    transform: scale(0.96);
}

/* ========================================= */
/* 반응형 */
/* ========================================= */
@media (max-width: 1100px) {
    .word-panel {
        width: 140px;
        min-width: 100px;
    }
    .word-es, .word-ko {
        font-size: 11px;
    }
}

/* 태블릿: stats 3열 */
@media (max-width: 860px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 0 24px 24px;
    }
    .stats-header,
    .stats-modal-footer {
        padding-left: 24px;
        padding-right: 24px;
    }
    .stats-hero,
    .dashboard-progress,
    .stats-footer-grid,
    .stats-mode-container {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 600px) {
    .game-header {
        padding: 10px 12px;
    }

    .game-logo {
        font-size: 18px;
    }

    .game-header-badge {
        min-width: auto;
    }

    .game-header-badge-label {
        font-size: 11px;
        letter-spacing: 0.04em;
    }

    .game-header-badge-value {
        font-size: 28px;
    }

    .game-header-right {
        gap: 4px;
    }

    .game-settings-panel {
        padding: 10px 12px;
        gap: 8px;
    }

    .game-settings-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .match-mode-btns {
        width: 100%;
        justify-content: flex-start;
    }

    .match-tool-btn {
        padding: 9px 12px;
        font-size: 13px;
    }

    .word-panel {
        display: none;
    }

    .loading-title {
        font-size: 36px;
    }

    .app-title {
        font-size: 20px;
    }

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

    .lives-hearts {
        font-size: 20px;
    }

    .result-title {
        font-size: 30px;
    }

    .result-stars {
        font-size: 40px;
    }

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

    .result-stat {
        min-width: 90px;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .result-stats {
        gap: var(--spacing-sm);
    }

    .result-buttons {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .modal-content {
        padding: var(--spacing-lg);
    }
    .modal-content.stats-dashboard {
        padding: 0;
    }

    /* Stats 모달 모바일 */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 16px 20px;
        gap: 1px;
    }

    .stats-footer-grid {
        grid-template-columns: 1fr;
        padding: 0 16px 20px;
        gap: 24px;
    }

    .stats-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px 16px 16px;
        gap: 8px;
    }

    .stats-hero-title {
        font-size: 24px;
    }

    .stats-header {
        padding: 16px;
    }

    .stats-modal-footer {
        padding: 16px;
    }

    .dashboard-progress,
    .stats-mode-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .stats-item-value {
        font-size: 20px;
    }

    .stats-item {
        padding: 12px;
    }
}

/* ========================================= */
/* 접근성 */
/* ========================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 포커스 표시 */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}


.network-banner {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.92);
    color: #fff;
    font-size: 0.85rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================= */
/* 로그인 / 프로필 화면 */
/* ========================================= */
.login-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: var(--spacing-xl);
    max-width: 420px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 24px;
    box-shadow: none;
}

.login-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.login-subtitle {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.login-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid rgba(160, 140, 200, 0.35);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    color: var(--color-text-primary);
    font-size: 1.05rem;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.login-input::placeholder {
    color: var(--color-text-muted);
}

.login-back-btn {
    font-size: 0.9rem;
}

/* 인증 탭 */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: rgba(160, 140, 200, 0.12);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 4px;
    width: 100%;
    max-width: 320px;
}

.auth-tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
    background: var(--color-surface);
    color: var(--color-accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* 인증 에러 메시지 */
.auth-info {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    text-align: center;
    text-wrap: pretty;
}

.auth-error {
    font-size: 0.85rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin: 0;
}


.consent-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.consent-row input {
    margin-top: 2px;
}

.legal-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.link-btn {
    border: none;
    background: transparent;
    color: var(--color-accent);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.legal-modal-content {
    max-width: 560px;
}

.legal-modal-body {
    max-height: min(60vh, 520px);
    overflow-y: auto;
    padding: 0 24px 24px;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

.legal-modal-body ul {
    padding-left: 20px;
}

/* 구분선 */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(160, 140, 200, 0.3);
}

/* Google 로그인 버튼 */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #ffffff;
    color: #3c4043;
    border: 1.5px solid rgba(160, 140, 200, 0.4);
    font-weight: 600;
}

.btn-google:hover {
    background: #f8f8f8;
    border-color: rgba(160, 140, 200, 0.7);
}

/* ========================================= */
/* 적응형 속도 배지 */
/* ========================================= */
.slow-mode-badge {
    text-align: center;
    padding: 3px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #b45309;
    background: rgba(251, 191, 36, 0.18);
    border-bottom: 1px solid rgba(251, 191, 36, 0.4);
}

.slow-mode-badge.hidden {
    display: none;
}

/* ========================================= */
/* 스테이지 카드 모드 */
/* ========================================= */
.card-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 20px 24px 28px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    align-self: center;
}

.card-progress {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.06em;
}

.card-word {
    width: 100%;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--color-surface);
    border: 2.5px solid rgba(160, 100, 200, 0.22);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(100, 60, 140, 0.14);
    font-size: clamp(28px, 6vw, 46px);
    font-weight: 700;
    color: var(--color-text-primary);
    padding: 32px 36px;
    line-height: 1.3;
}

.card-hint {
    font-size: 20px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    min-height: 52px;
    display: flex;
    align-items: center;
}

.card-hint-correct {
    color: var(--color-success);
    background: rgba(0, 184, 148, 0.1);
}

.card-hint-wrong {
    color: var(--color-danger);
    background: rgba(244, 67, 54, 0.08);
}

/* 게임 화면 세로 중앙 정렬 */
#game-screen {
    justify-content: flex-start;
}

/* ========================================= */
/* 짝 잇기 게임 */
/* ========================================= */
.match-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: var(--canvas-width);
    overflow: visible;
    padding: 0;
}

.match-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 8px;
    gap: 8px;
    flex-shrink: 0;
}

.match-tool-btn {
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid #dde4e5;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    color: #5a6061;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.match-tool-btn:active {
    transform: scale(0.96);
}

.match-tool-btn.match-mode-active {
    background: #0053db;
    color: #fff;
    border-color: #0053db;
}

.match-mode-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.game-settings-panel {
    width: 100%;
    max-width: var(--canvas-width);
    margin: 0 auto;
    padding: 12px 24px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #e0e3e3;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    box-sizing: border-box;
    transform-origin: top center;
    animation: settings-unfold 0.25s ease-out forwards;
}

.game-settings-panel.hidden {
    display: none;
}

@keyframes settings-unfold {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0); }
    100% { opacity: 1; transform: translateX(-50%) scaleY(1); }
}

.game-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.game-settings-label {
    font-size: 14px;
    color: #5a6061;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* =========================================
 * 카드 그리드 (타이핑 게임)
 * ========================================= */
/* 타이핑 게임 뷰: 헤더/진행바 아래 남은 공간 전체 차지 */
#typing-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: var(--canvas-width);
}

/* 카드 그리드: 4열 × 4행, 4/5 비율로 매치 게임과 카드 크기 통일 */
.card-grid {
    flex: 1;
    height: min(72vh, 620px);
    min-height: min(72vh, 620px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
    padding: 8px;
}

/* 개별 카드: 셀을 꽉 채움 */
.cg {
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px 4px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
    box-shadow: none;
    overflow: hidden;
    transition: background 0.15s, border-color 0.15s, opacity 0.2s;
    user-select: none;
}

/* 활성 카드 */
.cg-active {
    background: #e3f2fd;
    color: #0d47a1;
    border: 2.5px solid #64b5f6;
    box-shadow: none;
    font-size: 16px;
}

/* 예정 카드 */
.cg-upcoming {
    background: #ffffff;
    color: #4c5354;
    border: 2px solid #dde4e5;
    opacity: 1;
}

/* 새 단어 카드 (예정 카드 중 학습 중인 신규 단어) */
.cg-upcoming.cg-new {
    background: #e8f5e9;
    color: #1b5e20;
    border: 2px solid #a5d6a7;
    opacity: 0.85;
}

/* 정답 처리 */
.cg-ok {
    background: #e8f5e9;
    color: #2e7d32;
    border: 2px solid #66bb6a;
    opacity: 0.85;
}

/* 오답 처리 */
.cg-wrong {
    background: #ffebee;
    color: #c62828;
    border: 2px solid #ef9a9a;
}

/* 빈 칸 (카드 수가 16장 미만일 때) */
.cg-empty {
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

.cg-word {
    display: block;
}

.cg-hint {
    display: block;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.6;
    margin-top: 2px;
    line-height: 1.2;
}

.match-grid {
    flex: 1;
    height: min(72vh, 620px);
    min-height: min(72vh, 620px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 6px;
    width: 100%;
    padding: 8px;
    max-height: min(72vh, 620px);
    overflow: visible;
}

/* 카드 기본 */
.mc {
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: clamp(17px, 2.15vh, 21px);
    font-weight: 700;
    padding: 10px 6px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
    line-height: 1.35;
    word-break: break-word;
    box-shadow: none;
    overflow: hidden;
}

.mc:active {
    transform: scale(0.95);
}

/* 소스 언어 카드 (파랑) */
.mc-src {
    background: #e3f2fd;
    color: #0d47a1;
    border: 2px solid #bbdefb;
}

/* 새 단어 카드 (매치 게임, src만) */
.mc-src.mc-new {
    background: #e8f5e9;
    color: #1b5e20;
    border: 2px solid #a5d6a7;
}

/* 타겟 언어 카드 (흰색) */
.mc-tgt {
    background: #ffffff;
    color: #333;
    border: 2px solid #dde4e5;
}

/* 선택됨 */
.mc-selected {
    transform: scale(1.03) translateY(-1px);
    box-shadow: 0 0 0 2.5px #0053db;
}

/* 선택 시 같은 진영 카드는 살짝 흐리게 (반대 진영 선택지 강조) */
#match-grid:has(.mc-src.mc-selected) .mc-src:not(.mc-selected):not(.mc-matched),
#match-grid:has(.mc-tgt.mc-selected) .mc-tgt:not(.mc-selected):not(.mc-matched) {
    opacity: 0.45;
}

/* 매칭됨 → 투명하게 */
.mc-matched {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
}

/* 오답 플래시 */
.mc-wrong {
    animation: mc-shake 0.5s ease;
    background: #ffebee !important;
    border-color: #ef4444 !important;
    color: #c62828 !important;
}

/* 리필 페이드인 */
.mc-refill-in {
    animation: mc-fade-in 0.4s ease-out;
}

@keyframes mc-fade-in {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

/* 카드 스태거 등장 애니메이션 */
@keyframes card-stagger-in {
    0% { opacity: 0; transform: translateY(8px) scale(0.92); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.mc-stagger-in {
    animation: card-stagger-in 0.3s ease-out both;
}

.cg-stagger-in {
    animation: card-stagger-in 0.3s ease-out both;
}

@keyframes mc-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* ========================================= */
/* 게임 헤더 인라인 모드 선택 */
/* ========================================= */
.mode-select-inline {
    appearance: none;
    background: #ffffff;
    border: 1px solid #dde4e5;
    border-radius: 0;
    color: #2d3435;
    font-size: 15px;
    font-weight: 600;
    padding: 0 14px;
    height: 42px;
    box-sizing: border-box;
    cursor: pointer;
    outline: none;
}

.mode-select-inline:focus {
    border-color: #0053db;
    box-shadow: none;
}

/* ========================================= */
/* 스테이지 그리드 */
/* ========================================= */
.stage-grid-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 32px;
}

.sg-world {
    margin-bottom: 24px;
}

.sg-world-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--wc, #9b8ab0) 12%, transparent);
}

.sg-world-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--wc, #9b8ab0);
    flex-shrink: 0;
}

.sg-world-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--color-text-primary);
}

.sg-world-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-left: auto;
}

.sg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

.sg-card {
    position: relative;
    background: #fff;
    border: 2px solid #e8e0f5;
    border-radius: 12px;
    padding: 8px 6px 6px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border-top: 3px solid var(--wc, #9b8ab0);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sg-card:hover:not(.sg-locked) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.sg-card.sg-locked {
    cursor: default;
    opacity: 0.55;
    filter: grayscale(0.5);
}

.sg-card.sg-done {
    background: color-mix(in srgb, var(--wc, #9b8ab0) 8%, #fff);
}

.sg-card.sg-boss {
    border-style: dashed;
}

.sg-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sg-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--wc, #9b8ab0);
}

.sg-badge {
    font-size: 9px;
    font-weight: 800;
    background: var(--wc, #9b8ab0);
    color: #fff;
    border-radius: 4px;
    padding: 1px 4px;
}

.sg-cat {
    font-size: 10px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sg-stars {
    font-size: 12px;
    letter-spacing: 1px;
    color: #ddd;
    margin-top: auto;
}

.sg-stars .on {
    color: #f59e0b;
}

.sg-lock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 10px;
}


.legal-links-inline {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    font-size: 0.82rem;
}

.legal-links-inline a {
    color: var(--color-accent);
    text-decoration: underline;
}

.stats-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.stats-legal-link {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-decoration: underline;
}

.policy-page {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f6f8ff 0%, #eef2ff 100%);
    color: var(--color-text-primary);
    font-family: var(--font-family);
}

.policy-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 20px 56px;
    line-height: 1.7;
}

.policy-wrap h1 {
    margin: 0 0 8px;
    text-wrap: balance;
}

.policy-wrap h2 {
    margin-top: 24px;
    margin-bottom: 8px;
}

.policy-meta {
    color: var(--color-text-muted);
    margin-bottom: 20px;
}
