/* 훈민정음 게임 스타일 */

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

body {
    font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* 게임 컨테이너 */
.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    min-height: 100vh;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

/* 상단 헤더 */
.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}

.header-title {
    font-size: 40px;
    font-weight: 900;
    flex: 1;
}

.header-icons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    padding: 4px;
}

.btn-icon:hover {
    color: #000;
}

.timer {
    width: 100%;
    text-align: right;
    color: #e00;
    font-size: 14px;
    font-weight: bold;
    margin-top: 4px;
}

/* 초성 표시 */
.title-section {
    text-align: center;
    margin-bottom: 24px;
}

.choseong-display {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.choseong-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 8px;
    font-size: 32px;
    font-weight: bold;
    background: #e8e8e8;
    color: #222;
}

/* 게임 바디: CSS Grid 레이아웃 */
.game-body {
    display: grid;
    grid-template-columns: 1fr 240px;
    grid-template-rows: auto auto;
    gap: 12px 32px;
    margin-bottom: 24px;
}

.word-section {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.input-section {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    gap: 12px;
}

.rank-section {
    grid-column: 2;
    grid-row: 1 / 3;
}

/* 단어 섹션 */
.word-count {
    color: #e00;
    font-weight: bold;
    margin-bottom: 8px;
}

.word-list {
    border: 1px solid #ccc;
    border-radius: 4px;
    height: 300px;
    overflow-y: auto;
    padding: 8px 12px;
    background: #fafafa;
}

.word-item {
    padding: 4px 0;
    font-size: 15px;
    border-bottom: 1px solid #eee;
}

.word-item:last-child {
    border-bottom: none;
}

.word-item.new {
    color: #00a000;
    font-weight: bold;
}

/* 순위 섹션 */
.rank-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.rank-title {
    font-size: 22px;
    font-weight: bold;
}

.btn-refresh {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    padding: 4px;
}

.btn-refresh:hover {
    color: #000;
}

.btn-refresh.spinning svg {
    animation: spin 0.6s linear;
}

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

.rank-list {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px 12px;
    background: #fafafa;
    list-style: none;
    font-size: 15px;
}

.rank-list li {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

.rank-list li:last-child {
    border-bottom: none;
}

.rank-list li.rank-me {
    color: #00a000;
    font-weight: bold;
}

.rank-name {
    flex: 1;
}

.rank-count {
    text-align: right;
    white-space: nowrap;
}

/* 입력란 */
.word-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
}

.word-input:focus {
    border-color: #666;
}

.btn-submit {
    padding: 12px 32px;
    font-size: 16px;
    font-weight: bold;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-submit:hover {
    background: #555;
}

/* 하단 네비게이션 */
.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px 0;
}

.nav-btn {
    display: inline-block;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: bold;
    background: none;
    color: #00a000;
    border: 2px solid #00a000;
    border-radius: 0;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

.nav-btn:hover {
    background: #00a000;
    color: #fff;
}

/* 모달 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    min-width: 320px;
    max-width: 400px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-close:hover {
    color: #000;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ddd;
}

.modal-message {
    font-size: 16px;
    margin-bottom: 24px;
    margin-top: 8px;
}

.nickname-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    margin-bottom: 24px;
}

.nickname-input:focus {
    border-color: #666;
}

.modal-confirm {
    float: right;
    padding: 8px 24px;
    font-size: 14px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.modal-confirm:hover {
    background: #555;
}

/* 도움말 모달 */
.modal-hint {
    padding: 28px 32px;
}

.modal-hint-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ddd;
}

.modal-hint-list {
    list-style: disc;
    padding-left: 20px;
    font-size: 15px;
    line-height: 1.8;
}

.modal-hint-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.modal-hint-choseong {
    display: flex;
    gap: 8px;
}

.modal-hint-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 8px;
    font-size: 28px;
    font-weight: bold;
    background: #e8e8e8;
    color: #222;
}

.modal-hint-input {
    display: flex;
    gap: 8px;
    width: 100%;
}

.modal-hint-field {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    color: #999;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

.modal-hint-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: bold;
    background: #333;
    color: #fff;
    border-radius: 4px;
}

/* 함께하기 모달 */
.modal-together {
    min-width: 340px;
}

.together-choices {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.together-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s;
}

.together-choice:hover {
    border-color: #333;
}

.together-choice-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 4px;
}

.together-choice-desc {
    font-size: 13px;
    color: #777;
}

.together-label {
    font-size: 15px;
    margin-bottom: 12px;
}

.together-choseong-inputs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.together-choseong-input {
    width: 52px;
    height: 52px;
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    border: 2px solid #333;
    border-radius: 4px;
    outline: none;
}

.together-choseong-input:focus {
    border-color: #00a000;
}

/* 달성 팝업 */
.complete-highlight {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 24px;
    margin-top: 8px;
}

/* 달성 팝업 가로 확장 (긴 축하 문구 줄바꿈 방지) */
#modalMilestone .modal {
    max-width: 480px;
}

#modalMilestone .complete-share-text {
    text-align: center;
    font-size: 14px;
    color: #777;
}

.medal-icon {
    margin-right: 4px;
    flex-shrink: 0;
}

/* 토스트 */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
}

/* 반응형: 태블릿 */
@media (max-width: 1200px) {
    .game-container {
        border-left: none;
        border-right: none;
    }
}

/* 반응형: 모바일 */
@media (max-width: 640px) {
    .game-container {
        padding: 16px 12px;
    }

    .header-title {
        font-size: 32px;
    }

    .choseong-box {
        width: 50px;
        height: 50px;
        font-size: 26px;
    }

    .game-body {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .word-list {
        height: 240px;
    }

    .input-section {
        gap: 8px;
    }

    .word-input {
        padding: 10px 12px;
        font-size: 16px;
    }

    .btn-submit {
        padding: 10px 20px;
        font-size: 15px;
    }

    .modal {
        min-width: 0;
        max-width: calc(100vw - 32px);
        margin: 0 16px;
        padding: 24px;
    }

    /* 달성 팝업 — 모바일 줄바꿈 방지용 폰트 축소 */
    .complete-highlight {
        font-size: 16px;
    }

    #modalMilestone .complete-share-text {
        font-size: 13px;
    }

    .modal-together {
        min-width: 0;
    }
}
