/* ============================================
   단어 히어로 - Word Hero
   Kid-Friendly Modern Design
   ============================================ */

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

:root {
    --primary: #6366F1;
    --primary-light: #A5B4FC;
    --secondary: #EC4899;
    --accent: #F59E0B;
    --accent-light: #FCD34D;
    --success: #10B981;
    --success-light: #6EE7B7;
    --error: #EF4444;
    --bg: #EEEAFF;
    --bg-card: #FFFFFF;
    --text: #1E1B4B;
    --text-dim: #7C7A9C;
    --border: #DDD6FE;
    --shadow-sm: 0 2px 8px rgba(99,102,241,0.08);
    --shadow-md: 0 6px 20px rgba(99,102,241,0.12);
    --shadow-lg: 0 16px 40px rgba(99,102,241,0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-full: 50px;
}

body {
    font-family: 'Gaegu', 'Gowun Dodum', 'IBM Plex Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* ============ 공통 ============ */
.screen {
    position: fixed; inset: 0;
    display: none; justify-content: center; align-items: center;
    z-index: 10;
}
.screen.active { display: flex; }

/* ============ 시작 화면 ============ */
.start-bg {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(168,85,247,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(236,72,153,0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(99,102,241,0.06) 0%, transparent 70%);
    z-index: 0;
}

.start-container {
    text-align: center;
    padding: 1.5rem;
    max-width: 520px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.title-characters {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.title-main-char {
    width: 100px; height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 6px 15px rgba(168,85,247,0.3));
}

.title-side-char {
    width: 55px; height: 55px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.title-side-char.left { transform: scaleX(-1); animation-delay: 0.3s; }
.title-side-char.right { animation-delay: 0.6s; }

.game-title {
    font-size: 3.2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 0;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 8px;
    margin-bottom: 1rem;
    font-weight: 400;
}

.start-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.mode-select, .difficulty-select { margin-bottom: 1rem; }

.mode-select h2, .difficulty-select h2 {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
    letter-spacing: 1px;
}

.mode-buttons, .diff-buttons {
    display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap;
}

.mode-btn {
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    min-width: 110px;
}

.mode-btn:hover {
    border-color: var(--primary-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.mode-btn.active {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15), var(--shadow-md);
}

.mode-char-img {
    width: 45px; height: 45px; object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    transition: transform 0.2s ease;
}
.mode-btn:hover .mode-char-img { transform: scale(1.15) rotate(-5deg); }
.mode-btn.active .mode-char-img { transform: scale(1.1); }
.mode-label { font-size: 0.85rem; font-weight: 600; }

.diff-btn {
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.2rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.diff-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.diff-btn.active {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}

.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-full);
    padding: 0.8rem 2.5rem;
    color: white;
    font-family: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(99,102,241,0.35);
}
.btn-start:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(99,102,241,0.4);
}
.btn-start:active { transform: scale(0.97); }

.start-footer {
    display: flex; gap: 0.7rem; justify-content: center;
}

.secret-hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    opacity: 0.75;
    animation: secretHintPulse 2.5s ease infinite;
}

@keyframes secretHintPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; color: var(--accent); }
}

.btn-secondary {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.2rem;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

/* ============ 게임 방법 / 통계 ============ */
.how-container, .stats-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.how-container h2, .stats-container h2 {
    font-size: 1.4rem; margin-bottom: 1.2rem; color: var(--primary);
}

.how-steps { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }
.how-step {
    display: flex; align-items: center; gap: 0.8rem; text-align: left;
    background: var(--bg); padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
}
.step-icon { font-size: 1.5rem; min-width: 2.5rem; text-align: center; }
.step-char { width: 35px; height: 35px; object-fit: contain; }
.how-step p { font-size: 0.9rem; }

.btn-back {
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.6rem 1.6rem;
    color: var(--text); font-family: inherit; font-size: 0.9rem;
    cursor: pointer; transition: all 0.2s ease;
}
.btn-back:hover { background: white; border-color: var(--primary-light); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--bg); border-radius: var(--radius-sm); padding: 0.8rem;
}
.stat-label { color: var(--text-dim); font-size: 0.75rem; margin-bottom: 0.2rem; }
.stat-value { font-size: 1.5rem; color: var(--primary); font-weight: 700; }

/* ============ 게임 HUD ============ */
.game-hud {
    position: absolute; top: 0; left: 0; right: 0; height: 50px;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 1.2rem;
    background: linear-gradient(180deg, rgba(15,12,50,0.95) 0%, rgba(15,12,50,0.8) 100%);
    backdrop-filter: blur(8px);
    z-index: 20;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 1rem; }

.hud-hearts { display: flex; align-items: center; gap: 0.4rem; }
.hud-hearts-label { font-size: 0.65rem; color: rgba(255,255,255,0.4); letter-spacing: 1px; }
.hearts { display: flex; gap: 0.2rem; font-size: 1.2rem; }
.heart { transition: all 0.3s ease; }
.heart.lost { filter: grayscale(1); opacity: 0.2; transform: scale(0.7); }

.level-badge {
    background: rgba(99,102,241,0.3);
    color: var(--primary-light);
    font-size: 0.85rem; font-weight: 700;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    border: 1px solid rgba(99,102,241,0.3);
}

.combo-display {
    display: flex; align-items: center; gap: 0.3rem;
    opacity: 0; transition: all 0.3s ease; transform: scale(0.5);
}
.combo-display.active { opacity: 1; transform: scale(1); }
.combo-count {
    font-size: 1.6rem; font-weight: 700; color: var(--accent-light);
    text-shadow: 0 0 12px rgba(245,158,11,0.6);
}
.combo-label { font-size: 0.8rem; color: var(--accent-light); opacity: 0.8; }

.score-display { display: flex; flex-direction: column; align-items: flex-end; }
.score-label { font-size: 0.6rem; color: rgba(255,255,255,0.35); letter-spacing: 2px; }
.score-value { font-size: 1.3rem; font-weight: 700; color: var(--accent-light); }

/* ============ 게임 영역 ============ */
.game-area {
    position: absolute; top: 50px; left: 0; right: 0; bottom: 110px;
    overflow: hidden;
    background: url('../images/vincentiu-solomon-ln5drpv_ImI-unsplash.jpg') center center / cover no-repeat;
}

/* 은하수 사진 위에 살짝 어둡게 오버레이 (캐릭터 가독성) */
.game-area::before {
    content: '';
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* 은하수 효과 (사진 사용으로 불필요) */
.game-area .milky-way {
    display: none;
}

/* 히어로 */
.hero {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    z-index: 5;
}
.hero-img {
    width: 45px; height: 45px;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3));
}

/* ============ 몬스터 ============ */
.monster {
    position: absolute;
    display: flex; flex-direction: column; align-items: center;
    transition: top 0.5s ease;
    z-index: 3;
}

.monster-img-wrap {
    width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease, filter 0.3s ease;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
}
.monster-img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }

.monster.targeted .monster-img-wrap {
    transform: scale(1.2);
    filter: drop-shadow(0 0 12px rgba(252,211,77,0.5));
}

.monster-word {
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 0.2rem 0.6rem;
    margin-top: 0.2rem;
    font-family: 'IBM Plex Sans KR', monospace;
    font-size: 1.1rem; font-weight: 600;
    white-space: nowrap; letter-spacing: 2px;
    backdrop-filter: blur(4px);
}
.monster.targeted .monster-word {
    border-color: var(--accent-light);
    box-shadow: 0 0 12px rgba(252,211,77,0.25);
}

.monster-word .char { transition: color 0.1s ease; }
.monster-word .char.typed { color: var(--success-light); }
.monster-word .char.current { color: var(--accent-light); text-decoration: underline; }
.monster-word .char.error { color: #FCA5A5; }
.monster-word .char.pending { color: rgba(255,255,255,0.5); }

/* 보스 */
.monster.boss .monster-img-wrap { width: 85px; height: 85px; }
.monster.boss .monster-word {
    font-size: 1.25rem;
    border-color: var(--error);
    box-shadow: 0 0 16px rgba(239,68,68,0.35);
}

.boss-hp-bar {
    width: 100%; height: 5px;
    background: rgba(255,255,255,0.12);
    border-radius: 3px; margin-top: 0.25rem; overflow: hidden;
}
.boss-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--error), #F97316);
    border-radius: 3px; transition: width 0.3s ease;
}

/* 유니콘 */
.monster.unicorn .monster-img-wrap {
    width: 80px; height: 80px;
    animation: unicornFloat 1.5s ease-in-out infinite, unicornGlow 2s ease infinite;
}
.monster.unicorn .monster-word {
    border-color: #A855F7;
    background: rgba(168,85,247,0.2);
    box-shadow: 0 0 18px rgba(168,85,247,0.35);
}
.monster.unicorn.targeted .monster-word {
    box-shadow: 0 0 22px rgba(168,85,247,0.5), 0 0 40px rgba(252,211,77,0.15);
}
.unicorn-label {
    background: linear-gradient(135deg, #A855F7, var(--accent));
    color: white; font-size: 0.65rem; font-weight: 700;
    padding: 0.12rem 0.5rem; border-radius: 8px; margin-top: 0.15rem;
    animation: unicornLabelPulse 1s ease infinite;
}

/* 시크릿 히든 메세지 몬스터 */
.monster.secret-monster .monster-img-wrap {
    width: 75px; height: 75px;
    animation: secretMonsterFloat 1.8s ease-in-out infinite, secretMonsterGlow 2s ease infinite;
}
.monster.secret-monster .monster-word {
    border-color: var(--secret-color, #FF6B9D);
    background: rgba(255,107,157,0.22);
    box-shadow: 0 0 20px var(--secret-color, #FF6B9D);
    font-size: 1.15rem;
    color: white;
}
.monster.secret-monster.targeted .monster-img-wrap {
    transform: scale(1.25);
}
.monster.secret-monster.targeted .monster-word {
    box-shadow: 0 0 28px var(--secret-color, #FF6B9D), 0 0 45px rgba(252,211,77,0.2);
}
.secret-label {
    background: linear-gradient(135deg, var(--secret-color, #FF6B9D), #F472B6);
    color: white; font-size: 0.68rem; font-weight: 700;
    padding: 0.15rem 0.6rem; border-radius: 10px; margin-top: 0.15rem;
    box-shadow: 0 0 10px var(--secret-color, #FF6B9D);
    animation: secretLabelPulse 1.2s ease infinite;
    letter-spacing: 0.5px;
}

/* SH 스페셜 */
.monster.sh-special .monster-img-wrap {
    width: 85px; height: 85px;
    animation: shFloat 2s ease-in-out infinite, shRainbowGlow 3s linear infinite;
}
.monster.sh-special .monster-word {
    border-color: #F97316;
    background: linear-gradient(135deg, rgba(249,115,22,0.2), rgba(245,158,11,0.1));
    box-shadow: 0 0 22px rgba(249,115,22,0.4), 0 0 40px rgba(245,158,11,0.15);
    font-size: 1.2rem;
}
.monster.sh-special.targeted .monster-img-wrap { transform: scale(1.3); }
.monster.sh-special.targeted .monster-word {
    box-shadow: 0 0 28px rgba(249,115,22,0.6), 0 0 50px rgba(245,158,11,0.25);
}
.sh-label {
    background: linear-gradient(90deg, #F97316, #FBBF24, #34D399, #60A5FA, #A78BFA, #F97316);
    background-size: 200% 100%;
    color: white; font-size: 0.7rem; font-weight: 700;
    padding: 0.15rem 0.6rem; border-radius: 10px; margin-top: 0.15rem;
    animation: shLabelPulse 1.5s ease infinite;
    box-shadow: 0 0 10px rgba(245,158,11,0.3);
}

/* ============ 타이핑 영역 ============ */
.typing-area {
    position: absolute; bottom: 0; left: 0; right: 0; height: 110px;
    background: linear-gradient(180deg, rgba(15,12,50,0.8) 0%, rgba(15,12,50,0.95) 100%);
    backdrop-filter: blur(10px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 0.4rem 1.2rem;
    z-index: 20;
    border-top: 1px solid rgba(99,102,241,0.12);
    gap: 0.35rem;
}

.word-display {
    font-size: 1.5rem; font-weight: 700; letter-spacing: 3px;
    min-height: 1.8rem; color: white;
}

/* 타이핑 + 아이템 같은 행 */
.typing-inner {
    display: flex; flex-direction: row; align-items: center; gap: 0.8rem;
    width: 100%; max-width: 820px;
}

.typing-input {
    flex: 1;
    padding: 0.45rem 1.2rem;
    border: 2px solid rgba(99,102,241,0.35);
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.06);
    color: white;
    font-family: 'IBM Plex Sans KR', monospace;
    font-size: 1.1rem; text-align: center;
    outline: none; transition: all 0.3s ease;
    min-width: 0;
}
.typing-input:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 16px rgba(252,211,77,0.12);
    background: rgba(255,255,255,0.09);
}
.typing-input.error {
    border-color: var(--error);
    box-shadow: 0 0 12px rgba(239,68,68,0.18);
}
.typing-input::placeholder { color: rgba(255,255,255,0.2); font-size: 0.9rem; }

/* 아이템 - 타이핑 옆 가로 배치 */
.power-ups {
    display: flex; flex-direction: row; gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}
.powerup-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 12px;
    padding: 0.35rem 0.5rem;
    color: white; font-family: inherit;
    cursor: pointer; transition: all 0.2s ease;
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    position: relative;
    min-width: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
}
.powerup-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.55);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.powerup-btn.available {
    border-color: var(--accent-light);
    background: rgba(245,158,11,0.25);
    box-shadow: 0 0 14px rgba(245,158,11,0.45), 0 2px 8px rgba(0,0,0,0.3);
    animation: powerupGlow 1.8s ease-in-out infinite;
}

@keyframes powerupGlow {
    0%, 100% { box-shadow: 0 0 14px rgba(245,158,11,0.45), 0 2px 8px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 22px rgba(245,158,11,0.7), 0 2px 8px rgba(0,0,0,0.3); }
}

.pu-img {
    width: 34px; height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.powerup-count {
    position: absolute; top: -6px; right: -6px;
    font-size: 0.72rem; font-weight: 700;
    color: white;
    background: var(--primary);
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid rgba(15,12,50,0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.powerup-btn.available .powerup-count {
    background: var(--accent);
    color: white;
}

.powerup-desc {
    font-size: 0.6rem; color: rgba(255,255,255,0.85);
    font-weight: 600;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ============ 팝업 ============ */
.level-clear-popup {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center;
    z-index: 100;
}
.level-clear-popup.active { display: flex; }

.popup-content {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 2rem; text-align: center;
    border: 2px solid var(--accent); box-shadow: var(--shadow-lg);
    color: var(--text);
}
.popup-content h2 { font-size: 1.6rem; margin-bottom: 0.8rem; color: var(--primary); }
.clear-stats p { font-size: 0.95rem; margin: 0.3rem 0; color: var(--text-dim); }
.clear-stats span { color: var(--text); font-weight: 700; }

.boss-warning {
    position: absolute; inset: 0;
    display: none; justify-content: center; align-items: center;
    background: rgba(239,68,68,0.12);
    z-index: 90; pointer-events: none;
}
.boss-warning.active { display: flex; }
.warning-text {
    font-size: 2.3rem; color: var(--error);
    text-shadow: 0 0 20px rgba(239,68,68,0.6);
    animation: warningPulse 0.5s ease infinite;
}

/* ============ 게임 오버 ============ */
.gameover-container { text-align: center; padding: 1.5rem; max-width: 420px; }
.gameover-title {
    font-size: 2.8rem; color: var(--error);
    text-shadow: 0 2px 10px rgba(239,68,68,0.25);
}
.gameover-char-img {
    width: 80px; height: 80px; object-fit: contain;
    filter: grayscale(0.3) drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.gameover-stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0.6rem; margin: 1rem auto;
}
.go-stat {
    background: var(--bg-card); border-radius: var(--radius-sm);
    padding: 0.7rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.go-label { display: block; font-size: 0.72rem; color: var(--text-dim); margin-bottom: 0.15rem; }
.go-value { display: block; font-size: 1.4rem; color: var(--primary); font-weight: 700; }

.go-newrecord {
    font-size: 1.2rem; color: var(--accent);
    text-shadow: 0 0 10px rgba(245,158,11,0.3);
    margin: 0.7rem 0;
}
.go-unicorn-stat {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(168,85,247,0.06), rgba(99,102,241,0.04));
    border-color: rgba(168,85,247,0.15);
}
.go-unicorn-stat .go-value { color: #A855F7; }
.go-sh-stat {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(249,115,22,0.06), rgba(245,158,11,0.04));
    border-color: rgba(249,115,22,0.15);
}
.go-sh-stat .go-label { color: #F97316; }
.go-sh-stat .go-value { color: #F97316; text-shadow: 0 0 6px rgba(249,115,22,0.25); }
.gameover-buttons { display: flex; gap: 0.7rem; justify-content: center; margin-top: 1rem; }

/* ============ 파티클 ============ */
.particles-container { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.particle { position: absolute; border-radius: 50%; pointer-events: none; }

/* ============ 효과 ============ */
.screen-shake { animation: screenShake 0.3s ease; }
.screen-flash-red { animation: flashRed 0.3s ease; }
::-webkit-scrollbar { display: none; }
