:root {
    --bg: #f8f9fa;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --blue-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --orange-grad: linear-gradient(135deg, #f6ad55 0%, #f76b1c 100%);
    --green-grad: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    --text: #2d3748;
    --text-muted: #a0aec0;
    --shadow: 0 10px 25px rgba(0,0,0,0.05);
    --shadow-btn: 0 4px 0 rgba(0,0,0,0.1);
    --border: #edf2f7;
}

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

body {
    background: var(--bg);
    font-family: 'Pretendard', sans-serif;
    color: var(--text);
    overflow-y: auto;
    overflow-x: hidden;
}

#game-view {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

/* Header */
header {
    height: 60px;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.logo-wrapper { font-weight: 900; font-size: 1.4rem; }
.logo-main { color: var(--text); }
.logo-sub { color: #667eea; }
.version-tag { 
    font-size: 0.6rem; background: #667eea; color: white; 
    padding: 2px 6px; border-radius: 4px; vertical-align: middle; 
    margin-left: 8px; font-weight: 500;
}

#score { font-weight: 700; color: var(--text); }

/* Main Game Area */
main {
    flex: 1;
    position: relative;
    background: #ffffff;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

#game-canvas { width: 100%; height: 100%; display: block; }
#particle-canvas { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 100; }

#mission-tag {
    position: absolute;
    top: 20px;
    background: white;
    padding: 8px 25px;
    border-radius: 50px;
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
    font-weight: 800;
    font-size: 1.1rem;
    z-index: 5;
}

/* Control Panel (Responsive vh) */
#control-panel {
    height: 38vh;
    background: var(--panel-bg);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: 1.2fr 2fr 2fr 300px;
    grid-template-rows: 1fr auto;
    padding: 1.5rem;
    gap: 1.5rem;
    box-sizing: border-box;
}

#ad-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Voice Toggle Button */
.voice-toggle-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    padding: 10px 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Pretendard', sans-serif;
    background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.voice-toggle-btn.active {
    background: var(--blue-grad);
    box-shadow: 0 4px 18px rgba(102,126,234,0.45);
}
.voice-toggle-btn:hover { transform: translateY(-2px); }
.voice-toggle-btn:active { transform: scale(0.97); }

.voice-icon {
    font-size: 1.35rem;
    line-height: 1;
    transition: filter 0.3s, opacity 0.3s;
}
.voice-toggle-btn:not(.active) .voice-icon {
    filter: grayscale(1);
    opacity: 0.45;
}

.voice-label {
    display: flex;
    flex-direction: column;
    text-align: left;
    flex: 1;
}
.voice-ko {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    line-height: 1.3;
}
.voice-en {
    font-size: 0.68rem;
    font-weight: 400;
    color: rgba(255,255,255,0.75);
    line-height: 1.3;
}
.voice-toggle-btn:not(.active) .voice-ko { color: #4a5568; }
.voice-toggle-btn:not(.active) .voice-en { color: #a0aec0; }

/* Toggle pill (switch) */
.voice-pill {
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255,255,255,0.3);
    position: relative;
    flex-shrink: 0;
    transition: background 0.3s;
}
.voice-toggle-btn:not(.active) .voice-pill { background: rgba(0,0,0,0.15); }

.voice-pill-knob {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.voice-toggle-btn.active .voice-pill-knob { transform: translateX(16px); }

@media (max-width: 768px) {
    #game-view { height: auto; min-height: 100vh; overflow: visible; display: flex; flex-direction: column; }

    main { flex: initial; height: 32vh; min-height: 160px; }

    #mission-tag {
        font-size: 0.88rem;
        padding: 5px 14px;
        top: 8px;
        border-radius: 40px;
    }

    #control-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto auto;
        height: auto;
        gap: 0.6rem;
        padding: 0.7rem;
        overflow-y: visible;
    }

    /* Build station: 전체 너비 상단 바, 가로 flex */
    #build-station {
        grid-column: 1 / -1;
        grid-row: 1;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        padding: 10px 16px;
        min-height: 72px;
        border-radius: 14px;
    }

    #build-station .section-title { display: none; }
    #current-syllable { font-size: 2.8rem; margin-bottom: 0; min-width: 70px; text-align: center; }
    #fire-btn { width: auto; padding: 12px 28px; font-size: 1rem; border-radius: 10px; }
    .reset-link { margin-top: 0; }

    /* 자음: col 1, row 2 */
    #control-panel > .panel-column:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
    }

    /* 모음: col 2, row 2 */
    #control-panel > .panel-column:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    /* 사용설명: full width, row 3 (광고 위) */
    .shift-hint {
        grid-column: 1 / -1;
        grid-row: 3;
        padding-bottom: 0.4rem;
    }

    /* 광고: full width, row 4 */
    #ad-panel {
        grid-column: 1 / -1;
        grid-row: 4;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        overflow: visible;
        max-height: none;
        padding-bottom: 8px;
    }

    .voice-toggle-btn {
        max-width: 100%;
        width: 100%;
        padding: 10px 14px;
    }

    /* jamo grid: 5열 */
    .jamo-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }

    .btn-jamo { font-size: 0.78rem; border-radius: 9px; }
    .section-title { margin-bottom: 5px; font-size: 0.58rem; }
}

.section-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

/* Jamo Grid */
.jamo-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

@media (max-width: 480px) {
    .jamo-grid { grid-template-columns: repeat(5, 1fr); }
}

.btn-jamo {
    aspect-ratio: 1/1;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-btn);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-jamo:hover { transform: translateY(-2px); }
.btn-jamo:active { transform: scale(0.9) translateY(0); box-shadow: none; }

.consonant { background: var(--blue-grad); }
.vowel { background: var(--orange-grad); }

.btn-shift {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    font-size: 1.3rem;
}
.btn-shift.active {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 0 0 3px rgba(229,62,62,0.4);
}

/* Mission English Translation */
.mission-en {
    font-size: 0.75em;
    font-weight: 500;
    color: #718096;
    margin-left: 6px;
}

/* 힌트 (자음+모음 컬럼 전체 너비) */
.shift-hint {
    grid-column: 2 / 4;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-self: end;
    padding-bottom: 0.5rem;
}
.how-ko {
    font-size: 0.80rem;
    color: #667eea;
    font-weight: 600;
    line-height: 1.4;
}
.how-en {
    font-size: 0.74rem;
    color: #a0aec0;
    font-weight: 400;
    line-height: 1.4;
}

/* Build Station */
#build-station {
    background: white;
    border-radius: 20px;
    border: 3px dashed var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 10px;
}

#current-syllable {
    font-size: 3.5rem;
    font-weight: 900;
    color: #1a202c;
    margin-bottom: 0.5rem;
    line-height: 1;
}

#fire-btn {
    width: 90%;
    padding: 12px;
    background: var(--green-grad);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-btn);
}

#fire-btn:active { transform: scale(0.95); box-shadow: none; }

.reset-link {
    font-size: 0.7rem;
    margin-top: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: underline;
}

/* Overlays */
.overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.overlay.hidden { display: none; }
.overlay-content { text-align: center; }
.btn-primary { 
    background: var(--blue-grad); color: #fff; border: none; padding: 12px 30px; 
    font-weight: 700; border-radius: 50px; cursor: pointer; margin-top: 20px;
    box-shadow: var(--shadow);
}

/* --- Content View (SEO & AdSense Text Area) --- */
#content-view {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
    font-family: 'Pretendard', sans-serif;
    line-height: 1.6;
    color: #2d3748;
}

.game-info-section h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: #1a202c;
    border-bottom: 3px solid #667eea;
    padding-bottom: 0.5rem;
    display: inline-block;
}

.game-info-section h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
    color: #2d3748;
}

.game-info-section p {
    margin-bottom: 1.2rem;
    font-size: 1.05rem;
    color: #4a5568;
    word-break: keep-all;
}

.guide-list {
    list-style-type: none;
    padding-left: 0;
}
.guide-list li {
    margin-bottom: 0.8rem;
    padding-left: 1.8rem;
    position: relative;
    font-size: 1.05rem;
    color: #4a5568;
}
.guide-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
    font-size: 1.2rem;
}

.patch-notes-box {
    background: white;
    padding: 1.8rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.patch-notes-box p {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}
.patch-notes-box p:last-child {
    margin-bottom: 0;
}
.badge {
    background: #edf2f7;
    color: #4a5568;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-right: 8px;
}
.badge.new {
    background: #e53e3e;
    color: white;
}

/* Footer Links */
.site-footer {
    margin-top: 5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: #718096;
    font-size: 0.95rem;
}
.footer-links {
    margin-bottom: 1.2rem;
}
.footer-links a {
    color: #4a5568;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: #667eea;
    text-decoration: underline;
}
.separator {
    margin: 0 12px;
    color: #cbd5e0;
}
.copyright {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.contact-info a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}
