@charset "UTF-8";

/* ---------- CSS Variables & Palette ---------- */
:root {
    /* Pastel Theme Colors */
    --bg-gradient-1: #fff1f2; /* Soft pink-cream */
    --bg-gradient-2: #e0fbfc; /* Soft cyan */
    --text-main: #4a4a4a; /* Soft dark charcoal */
    --text-muted: #8b8b8b;
    
    /* UI Element Colors */
    --board-bg: rgba(255, 255, 255, 0.25);
    --timer-bg: #ffe4e1;
    --timer-text: #ff6b81;
    --progress-track: #f0f0f0;
    --progress-fill: #7bed9f; /* Bright pastel green */
    
    /* Keyboard Colors */
    --key-top: #ffffff;
    --key-side: #e2e8f0;
    --key-text-kr: #576574;
    --key-text-en: #c8d6e5;
    
    /* State Colors */
    --key-active-border: #70a1ff;
    --key-active-shadow: rgba(112, 161, 255, 0.4);
    --key-correct-bg: #c7ecee;
    --key-wrong-bg: #ffcccc;
    
    /* Shadows */
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 20px 40px rgba(0, 0, 0, 0.08);
}

/* ---------- Reset & Global Settings ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Jua', sans-serif;
    min-height: 100vh;
    color: var(--text-main);
    background-color: var(--bg-gradient-1); /* Fallback */
    user-select: none; /* Prevent text selection for kids */
    -webkit-user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* ---------- 10가지 만화 배경 슬라이더 ---------- */
#bg-slider {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 3s ease-in-out;
}

.bg-layer.active {
    opacity: 1;
}

#app-container {
    width: 100%;
    max-width: 1000px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
    z-index: 10;
}

/* ---------- 배경 동물 캐릭터 ---------- */
#animal-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.animal {
    position: absolute;
    width: 50px;
    height: 50px;
    background-repeat: no-repeat;
    animation: play-sprite 0.6s steps(3) infinite;
    background-size: 150px 50px;
}

/* 새 (Bird) - 하늘을 날아다님 */
.animal.bird {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 50' width='150' height='50'%3E%3Cg transform='translate(0,0)'%3E%3Cellipse cx='25' cy='25' rx='10' ry='8' fill='%2355b' /%3E%3Ccircle cx='32' cy='22' r='5' fill='%2355b' /%3E%3Cpolygon points='36,22 40,24 36,25' fill='%23f90' /%3E%3Cpath d='M 25 25 Q 20 10 15 5 Q 25 10 25 25' fill='%2377d' /%3E%3C/g%3E%3Cg transform='translate(50,0)'%3E%3Cellipse cx='25' cy='25' rx='10' ry='8' fill='%2355b' /%3E%3Ccircle cx='32' cy='22' r='5' fill='%2355b' /%3E%3Cpolygon points='36,22 40,24 36,25' fill='%23f90' /%3E%3Cpath d='M 25 25 Q 15 25 5 25 Q 15 28 25 25' fill='%2377d' /%3E%3C/g%3E%3Cg transform='translate(100,0)'%3E%3Cellipse cx='25' cy='25' rx='10' ry='8' fill='%2355b' /%3E%3Ccircle cx='32' cy='22' r='5' fill='%2355b' /%3E%3Cpolygon points='36,22 40,24 36,25' fill='%23f90' /%3E%3Cpath d='M 25 25 Q 20 40 15 45 Q 25 40 25 25' fill='%2377d' /%3E%3C/g%3E%3C/svg%3E");
    animation-duration: 0.4s;
}

/* 강아지 (Dog) - 땅을 총총 걸어다님 */
.animal.dog {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 50' width='150' height='50'%3E%3Cg transform='translate(0,0)'%3E%3Crect x='15' y='25' width='20' height='12' rx='4' fill='%23a65' /%3E%3Ccircle cx='32' cy='20' r='8' fill='%23a65' /%3E%3Ccircle cx='35' cy='18' r='1.5' fill='%23000' /%3E%3Cpath d='M 32 15 Q 28 10 25 15' stroke='%23a65' stroke-width='3' fill='none' /%3E%3Crect x='18' y='35' width='3' height='10' rx='1' fill='%23843' /%3E%3Crect x='30' y='35' width='3' height='10' rx='1' fill='%23843' /%3E%3Cpath d='M 15 28 Q 10 22 5 28' stroke='%23a65' stroke-width='2' fill='none' /%3E%3C/g%3E%3Cg transform='translate(50,0)'%3E%3Crect x='15' y='25' width='20' height='12' rx='4' fill='%23a65' /%3E%3Ccircle cx='32' cy='20' r='8' fill='%23a65' /%3E%3Ccircle cx='35' cy='18' r='1.5' fill='%23000' /%3E%3Cpath d='M 32 15 Q 28 10 25 15' stroke='%23a65' stroke-width='3' fill='none' /%3E%3Crect x='14' y='35' width='3' height='10' rx='1' fill='%23843' transform='rotate(20 15.5 35)' /%3E%3Crect x='34' y='35' width='3' height='10' rx='1' fill='%23843' transform='rotate(-20 35.5 35)' /%3E%3Cpath d='M 15 28 Q 10 28 5 28' stroke='%23a65' stroke-width='2' fill='none' /%3E%3C/g%3E%3Cg transform='translate(100,0)'%3E%3Crect x='15' y='25' width='20' height='12' rx='4' fill='%23a65' /%3E%3Ccircle cx='32' cy='20' r='8' fill='%23a65' /%3E%3Ccircle cx='35' cy='18' r='1.5' fill='%23000' /%3E%3Cpath d='M 32 15 Q 28 10 25 15' stroke='%23a65' stroke-width='3' fill='none' /%3E%3Crect x='18' y='35' width='3' height='10' rx='1' fill='%23843' /%3E%3Crect x='30' y='35' width='3' height='10' rx='1' fill='%23843' /%3E%3Cpath d='M 15 28 Q 10 34 5 28' stroke='%23a65' stroke-width='2' fill='none' /%3E%3C/g%3E%3C/svg%3E");
    animation-duration: 0.5s;
}

/* 토끼 (Rabbit) - 깡총깡총 뛰어다님 */
.animal.rabbit {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 50' width='150' height='50'%3E%3Cg transform='translate(0,0)'%3E%3Cellipse cx='25' cy='35' rx='12' ry='10' fill='%23eee' /%3E%3Ccircle cx='35' cy='25' r='7' fill='%23eee' /%3E%3Ccircle cx='37' cy='23' r='1' fill='%23000' /%3E%3Cpath d='M 32 20 Q 28 5 35 15' stroke='%23eee' stroke-width='4' fill='none' stroke-linecap='round' /%3E%3Cellipse cx='12' cy='35' rx='3' ry='3' fill='%23fff' /%3E%3Crect x='20' y='42' width='6' height='3' rx='1.5' fill='%23ccc' /%3E%3Crect x='30' y='42' width='4' height='3' rx='1.5' fill='%23ccc' /%3E%3C/g%3E%3Cg transform='translate(50,-8)'%3E%3Cellipse cx='25' cy='30' rx='14' ry='8' fill='%23eee' transform='rotate(-15 25 30)' /%3E%3Ccircle cx='38' cy='18' r='7' fill='%23eee' /%3E%3Ccircle cx='40' cy='16' r='1' fill='%23000' /%3E%3Cpath d='M 35 13 Q 30 -2 38 8' stroke='%23eee' stroke-width='4' fill='none' stroke-linecap='round' /%3E%3Cellipse cx='10' cy='35' rx='3' ry='3' fill='%23fff' /%3E%3Crect x='15' y='35' width='8' height='3' rx='1.5' fill='%23ccc' transform='rotate(30 15 35)' /%3E%3Crect x='35' y='25' width='4' height='3' rx='1.5' fill='%23ccc' transform='rotate(45 35 25)' /%3E%3C/g%3E%3Cg transform='translate(100,0)'%3E%3Cellipse cx='25' cy='35' rx='12' ry='10' fill='%23eee' /%3E%3Ccircle cx='35' cy='25' r='7' fill='%23eee' /%3E%3Ccircle cx='37' cy='23' r='1' fill='%23000' /%3E%3Cpath d='M 32 20 Q 28 10 35 18' stroke='%23eee' stroke-width='4' fill='none' stroke-linecap='round' /%3E%3Cellipse cx='12' cy='35' rx='3' ry='3' fill='%23fff' /%3E%3Crect x='18' y='42' width='6' height='3' rx='1.5' fill='%23ccc' /%3E%3Crect x='32' y='42' width='4' height='3' rx='1.5' fill='%23ccc' /%3E%3C/g%3E%3C/svg%3E");
    animation-duration: 0.8s;
}

@keyframes play-sprite {
    0% { background-position: 0 0; }
    100% { background-position: -150px 0; }
}

/* ---------- Animations ---------- */
@keyframes bgShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    50% { transform: translateX(5px) rotate(2deg); }
    75% { transform: translateX(-5px) rotate(-2deg); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

@keyframes tap {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(15px) scale(0.9); }
}

@keyframes keyGlow {
    0%, 100% { box-shadow: 0 0 10px var(--key-active-shadow), 0 6px 0 var(--key-side); }
    50% { box-shadow: 0 0 25px var(--key-active-border), 0 6px 0 var(--key-side); }
}

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

/* ---------- Header Area ---------- */
#header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 20px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.bgm-btn {
    background: #ffe4e1;
    border: none;
    border-radius: 50%;
    width: clamp(35px, 4vw, 45px);
    height: clamp(35px, 4vw, 45px);
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    cursor: pointer;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.05);
    transition: transform 0.2s, filter 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.bgm-btn.off {
    filter: grayscale(100%) opacity(0.5);
}

.bgm-btn:active {
    transform: translateY(2px) scale(0.95);
}

.logo-area h1 {
    font-size: 2.2rem;
    background: linear-gradient(to right, #ff9a9e, #fecfef, #a1c4fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    letter-spacing: 2px;
}

.status-area {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

#timer-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--timer-bg);
    padding: 8px 16px;
    border-radius: 50px;
    color: var(--timer-text);
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.05);
}

#progress-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-track {
    width: 150px;
    height: 20px;
    background: var(--progress-track);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2ed573, var(--progress-fill));
    border-radius: 20px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: progressGlow 2s infinite;
}

#progress-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    min-width: 45px;
}

/* ---------- Main Content (Word Board) ---------- */
#main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
}

#word-board {
    background: var(--board-bg);
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    padding: 50px 80px;
    text-align: center;
    box-shadow: var(--shadow-float);
    backdrop-filter: blur(15px);
    animation: float 6s ease-in-out infinite;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 400px;
    /* 드래그 앤 드롭을 위한 속성 추가 */
    position: relative;
    cursor: grab;
    touch-action: none; /* 모바일에서 드래그 시 화면 스크롤 방지 */
    z-index: 100;
}

#word-board:active {
    cursor: grabbing;
}

#target-word {
    font-size: clamp(4rem, 8vw, 6rem);
    background: linear-gradient(90deg, #ff6b81, #ffa502, #eccc68, #7bed9f, #70a1ff, #a29bfe);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 5px;
    filter: drop-shadow(2px 3px 2px rgba(0,0,0,0.2));
}

#input-container {
    font-size: clamp(3rem, 6vw, 4.5rem);
    color: #ffffff;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.4);
    min-height: clamp(3.5rem, 7vw, 5rem);
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    padding: 10px 30px;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.03);
}

#cursor {
    display: inline-block;
    width: 4px;
    height: clamp(3rem, 6vw, 4.5rem);
    background-color: #ff7675;
    margin-left: 5px;
    border-radius: 4px;
    animation: blink 1s step-end infinite;
}

#success-effect-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    pointer-events: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ---------- Keyboard Area ---------- */
#keyboard-container {
    padding-bottom: 20px;
    display: flex;
    justify-content: center;
}

#keyboard {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vw, 12px);
    background: rgba(255, 255, 255, 0.3);
    padding: clamp(15px, 3vw, 25px);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 12px);
}

/* Staggering rows to mimic real keyboard */
.kb-row:nth-child(2) {
    padding-left: 3%;
}
.kb-row:nth-child(3) {
    padding-left: 8%;
}

.key {
    position: relative;
    width: clamp(45px, 6vw, 70px);
    height: clamp(55px, 7vw, 80px);
    background: var(--key-top);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Jua', sans-serif;
    outline: none;
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s, background-color 0.2s;
    box-shadow: 0 8px 0 var(--key-side), 0 12px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

/* 3D Press Effect */
.key:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 var(--key-side), 0 2px 5px rgba(0,0,0,0.1);
}

.key .kr {
    font-size: clamp(1.5rem, 2.5vw, 2.2rem);
    color: var(--key-text-kr);
    line-height: 1;
}

.key .en {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: clamp(0.7rem, 1vw, 1rem);
    color: var(--key-text-en);
    font-family: sans-serif;
    font-weight: bold;
}

.space-row {
    margin-top: 5px;
}

.space-key {
    width: clamp(250px, 40vw, 400px);
    height: clamp(50px, 6vw, 70px);
}

.space-key .kr {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    color: var(--key-text-en);
}

/* Key States */
.key.active {
    border: 3px solid var(--key-active-border);
    animation: keyGlow 1.5s infinite alternate;
}

.key.correct {
    background-color: var(--key-correct-bg);
    transform: scale(1.05) translateY(4px);
    box-shadow: 0 4px 0 var(--key-side), 0 5px 10px rgba(0,0,0,0.1);
    color: #2c3e50;
}

.key.wrong {
    background-color: var(--key-wrong-bg);
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

/* ---------- Transparent Finger Guide ---------- */
#finger-guide {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: none; /* Hidden by default, toggled via JS */
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin-top: -30px;
    margin-left: -30px;
    border: 4px solid #ff9f43;
    border-radius: 50%;
    animation: pulse 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    box-shadow: 0 0 15px rgba(255, 159, 67, 0.6);
}

.finger-icon {
    position: relative;
    font-size: 4rem;
    text-shadow: 2px 4px 10px rgba(0,0,0,0.2);
    animation: tap 1.2s ease-in-out infinite;
    margin-left: 20px; /* Offset to point at the center of the key */
    margin-top: 10px;
}

/* ---------- Media Queries for Mobile/Tablets ---------- */
@media (max-width: 768px) {
    #header {
        flex-direction: column;
        align-items: stretch;
    }

    #word-board {
        padding: 30px 40px;
        min-width: 90%;
    }
    
    .status-area {
        justify-content: space-between;
        width: 100%;
        gap: 5px;
        flex-wrap: nowrap;
    }
    
    .progress-track {
        width: 80px;
    }
    
    #timer-display {
        font-size: 1rem;
        padding: 6px 10px;
    }
    
    .logo-area h1 {
        font-size: 1.8rem;
    }

    /* 스마트폰에서 가상 키보드가 잘리지 않도록 크기 및 간격 축소 */
    #keyboard {
        padding: 10px;
        gap: 6px;
    }
    .kb-row {
        gap: 4px;
    }
    .key {
        width: clamp(28px, 8.5vw, 45px);
        height: clamp(45px, 11vw, 55px);
        border-radius: 10px;
    }
    .key .kr {
        font-size: clamp(1rem, 3.5vw, 1.4rem);
    }
    .key .en {
        font-size: clamp(0.5rem, 1.5vw, 0.7rem);
        bottom: 4px;
        right: 4px;
    }
    .space-key {
        width: clamp(180px, 60vw, 250px);
    }
}
```