/* --- 全局设置 --- */
:root {
    --primary-color: #ffb7b2;
    --accent-color: #ff9aa2;
    --text-color: #6d4c41;
    --bg-overlay: rgba(255, 248, 240, 0.6);
    --card-bg: rgba(255, 255, 255, 0.95);
    --slot-border: #d7ccc8;
    --slot-active: #8d6e63;
}

body {
    font-family: 'Quicksand', 'Segoe UI', sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    background: url('https://images.unsplash.com/photo-1425082661705-1834bfd09dca?q=80&w=2076&auto=format&fit=crop') no-repeat center center fixed;
    background-size: cover;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(3px);
    z-index: -1;
}

.app-container {
    width: 90%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

header { text-align: center; width: 100%; }

h1 {
    font-family: 'Zcool KuaiLe', cursive;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-size: 2em;
    margin: 0 0 10px 0;
}

.mode-switch-container { margin-bottom: 8px; }

.mode-btn {
    padding: 8px 20px;
    border-radius: 20px;
    border: 2px solid #fff;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.study-active { background-color: #ffecb3; color: #f57f17; }
.exam-active { background-color: #b3e5fc; color: #0277bd; border-color: #0277bd; }

.progress-badge {
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #8d6e63;
    display: inline-block;
}

/* --- 卡片主体 --- */
.word-card {
    background: var(--card-bg);
    width: 100%;
    padding: 30px 25px;
    border-radius: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    text-align: center;
    border: 4px solid #fff;
    box-sizing: border-box;
    transition: transform 0.3s ease;
    position: relative;
}

.word-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 50px;
}

#current-word {
    font-size: 2.2em;
    color: #5d4037;
    margin: 0;
}

.icon-btn {
    background: #fff0f0;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover { transform: scale(1.1); background: #ffcdd2; }

.phonetics-badge {
    color: #8d6e63;
    background-color: #efebe9;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
    font-size: 1rem;
    margin-top: 5px;
    min-height: 25px;
}

.divider {
    height: 2px;
    background: #fce4ec;
    margin: 20px 40px;
    border-radius: 2px;
}

/* --- 下划线区域 (考试模式核心) --- */
.slots-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px; 
    margin: 10px 0 20px 0;
    min-height: 60px; /* 增加高度，方便手指点击 */
    cursor: text; 
    position: relative; /* 关键：作为定位参考 */
}

/* 透明的考试输入框：覆盖在整个 slots 区域上 */
#exam-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* 完全透明，看不见但点得到 */
    z-index: 10; /* 确保在最上层 */
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: transparent; /* 隐藏原生光标 */
    padding: 0;
    margin: 0;
}

/* 每一个字母的下划线样式 */
.char-slot {
    width: 30px;
    height: 40px;
    border-bottom: 3px solid var(--slot-border);
    font-size: 24px;
    font-weight: bold;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: border-color 0.2s;
    z-index: 1; /* 在输入框下面 */
}

.space-slot {
    width: 20px;
    height: 40px;
    border-bottom: none; 
}

.char-slot.active {
    border-color: var(--accent-color);
}

/* --- 释义区域 --- */
.definition-box {
    background-color: #fff8e1;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    text-align: left;
}
.def-item { margin-bottom: 10px; }
.tag {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 8px;
    margin-right: 5px;
    font-weight: bold;
}
.definition-box p { margin: 5px 0 0 0; line-height: 1.5; font-size: 1rem; }

/* --- 输入控制区域 --- */
.typing-area {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.input-wrapper {
    width: 60%;
    max-width: 300px;
    position: relative;
}

#study-input {
    border: 2px solid #e0e0e0;
    border-radius: 15px 0 0 15px;
    padding: 12px;
    font-size: 1rem;
    width: 100%;
    outline: none;
    font-family: inherit;
    transition: border 0.3s;
    box-sizing: border-box; 
}

#study-input:focus { border-color: var(--accent-color); }

/* 📝 考试模式下，隐藏底部的学习输入框 */
.exam-mode-input .input-wrapper {
    display: none; 
}

/* 考试模式下，让 Check 按钮占满宽度 */
.exam-mode-input #check-btn {
    width: 100%;
    border-radius: 15px;
    margin-top: 0;
}

#check-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 0 15px 15px 0;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    height: 46px; 
}

#check-btn:hover { background-color: #ff7eb3; }

.feedback { height: 20px; font-weight: bold; margin-top: 10px; font-size: 0.9rem; }
.correct { color: #66bb6a; }
.incorrect { color: #ef5350; }

.controls-container { width: 100%; }
.learning-controls { display: flex; flex-direction: column; gap: 10px; }
.feedback-btns { display: flex; gap: 10px; justify-content: center; }
.action-btn {
    border: none; padding: 12px 20px; border-radius: 15px;
    font-size: 1rem; font-weight: bold; cursor: pointer;
    transition: transform 0.1s; box-shadow: 0 4px 0 rgba(0,0,0,0.1); width: 100%;
}
.action-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.1); }
.secondary { background-color: #fff; color: #8d6e63; border: 2px solid #efebe9; }
.success { background-color: #b9f6ca; color: #1b5e20; }
.danger { background-color: #ffccbc; color: #bf360c; }
.primary { background-color: #81d4fa; color: #01579b; }

.hidden { display: none !important; }
