* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

header {
    background: rgba(255, 255, 255, 0.97);
    padding: 1rem 1rem 0.8rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.5rem;
    color: #4a3f8a;
}

.subtitle {
    color: #7c6fb5;
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
}

nav {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

nav a {
    color: #5a4fa0;
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border-radius: 16px;
    border: 1px solid #d4cff0;
    font-size: 0.8rem;
    transition: all 0.2s;
}

nav a:hover, nav a:active {
    background: #5a4fa0;
    color: white;
}

main {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem 0.8rem;
}

.section {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 14px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.section h2 {
    color: #4a3f8a;
    font-size: 1.2rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e8e4f8;
}

.section > p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.tip {
    background: #f0edff;
    border-left: 3px solid #7c6fb5;
    padding: 0.8rem 1rem;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    margin-top: 0.8rem;
}

/* 卡片网格 - 移动优先 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.card {
    background: white;
    border: 2px solid #e8e4f8;
    border-radius: 10px;
    padding: 0.6rem 0.3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.card:active {
    transform: scale(0.95);
    border-color: #7c6fb5;
}

.card .korean {
    font-size: 1.8rem;
    font-weight: bold;
    color: #4a3f8a;
    line-height: 1.2;
}

.card .romanization {
    font-size: 0.7rem;
    color: #e8590c;
    font-weight: 600;
    margin-top: 0.1rem;
}

.card .play-icon {
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 0.1rem;
}

/* 弹窗 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
    padding: 0;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.2rem;
    position: relative;
    animation: slideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: sticky;
    top: 0;
    float: right;
    background: #f0f0f0;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 10;
}

.modal-header {
    text-align: center;
    margin-bottom: 1rem;
    padding-top: 0.5rem;
}

.modal-header .char-big {
    font-size: 4rem;
    color: #4a3f8a;
    font-weight: bold;
}

.modal-header .char-info {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.modal-header .play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding: 0.5rem 1.2rem;
    background: #5a4fa0;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
}

.modal-header .play-btn:active {
    background: #4a3f8a;
}

.word-list {
    list-style: none;
}

.word-item {
    display: flex;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.6rem;
}

.word-item:last-child {
    border-bottom: none;
}

.word-item .word-play {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0edff;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-item .word-play:active {
    background: #d4cff0;
}

.word-item .word-text {
    flex: 1;
}

.word-item .word-korean {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.word-item .word-roman {
    font-size: 0.8rem;
    color: #e8590c;
}

.word-item .word-meaning {
    font-size: 0.85rem;
    color: #666;
    text-align: right;
    flex-shrink: 0;
}

/* 组合示例 */
.combine-examples {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.combine-item {
    background: #f8f6ff;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    border: 1px solid #e8e4f8;
}

.formula {
    font-size: 1.2rem;
    color: #4a3f8a;
}

.formula .result {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e8590c;
}

.combine-desc {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.2rem;
}

/* 练习区 */
#quiz-container {
    text-align: center;
    padding: 0.5rem 0;
}

.quiz-question {
    font-size: 3rem;
    color: #4a3f8a;
    font-weight: bold;
    margin-bottom: 1rem;
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.quiz-options button {
    padding: 0.8rem;
    font-size: 1rem;
    border: 2px solid #e8e4f8;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    color: #333;
    -webkit-tap-highlight-color: transparent;
}

.quiz-options button:active {
    background: #f8f6ff;
}

.quiz-options button.correct {
    background: #d3f9d8;
    border-color: #37b24d;
    color: #2b8a3e;
}

.quiz-options button.wrong {
    background: #ffe3e3;
    border-color: #f03e3e;
    color: #c92a2a;
}

.quiz-feedback {
    font-size: 1rem;
    min-height: 1.5rem;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.btn {
    background: #5a4fa0;
    color: white;
    border: none;
    padding: 0.7rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    background: #4a3f8a;
}

.quiz-score {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.8rem;
}

footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
}

footer p + p {
    margin-top: 0.2rem;
}

/* 大屏适配 */
@media (min-width: 768px) {
    main {
        max-width: 800px;
        padding: 2rem 1.5rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .card-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.8rem;
    }

    .card .korean {
        font-size: 2.4rem;
    }

    .card .romanization {
        font-size: 0.85rem;
    }

    .modal {
        border-radius: 16px;
        max-height: 80vh;
        margin: auto;
    }

    .modal-overlay.active {
        align-items: center;
        padding: 2rem;
    }
}
