* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.container {
    width: 100%;
    max-width: 500px;
    min-height: 90vh;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

.screen {
    display: none;
    padding: 20px;
    min-height: calc(90vh - 20px);
}

.screen.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 欢迎页面 */
#welcome-screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#welcome-screen.active {
    display: flex;
}

.title-container {
    margin-bottom: 30px;
}

.main-title {
    font-size: 42px;
    color: #764ba2;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px #f0f0f0;
}

.subtitle {
    font-size: 20px;
    color: #666;
}

.magic-castle {
    font-size: 100px;
    margin: 30px 0;
    animation: bounce 2s infinite;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 22px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin: 10px;
}

.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: none;
    padding: 14px 36px;
    font-size: 18px;
    border-radius: 40px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    margin: 8px;
}

.btn-secondary:active {
    background: #e0e0e0;
    transform: scale(0.95);
}

/* 关卡选择页面 */
#level-select-screen {
    display: none;
}

#level-select-screen.active {
    display: block;
}

.level-select-container {
    text-align: center;
    padding: 10px;
}

.level-select-title {
    font-size: 32px;
    color: #764ba2;
    margin-bottom: 10px;
}

.level-select-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.level-btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #666;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.level-btn:hover {
    transform: scale(1.05);
}

.level-btn:active {
    transform: scale(0.95);
}

.level-btn.unlocked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.level-btn.current {
    border: 4px solid #FFD700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4), 0 0 0 5px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4), 0 0 0 15px rgba(255, 215, 0, 0); }
}

.level-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.level-lock {
    font-size: 20px;
}

.level-select-info {
    background: #f8f8f8;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.level-select-info p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* 关卡选择页面 - 响应式 */
@media (max-width: 400px) {
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .level-btn {
        font-size: 24px;
    }
}

@media (max-width: 320px) {
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

/* 游戏页面 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.level-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 16px;
}

.stars {
    display: flex;
    gap: 5px;
}

.star {
    font-size: 28px;
    transition: transform 0.3s;
}

.star-inactive {
    opacity: 0.3;
}

.star.active {
    transform: scale(1.2);
    animation: starPulse 0.5s ease;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); }
}

/* 提示区域 */
.hint-area {
    text-align: center;
    margin-bottom: 20px;
}

.hint-image {
    font-size: 80px;
    margin-bottom: 10px;
    min-height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hint-text {
    font-size: 22px;
    color: #333;
    background: #f8f8f8;
    padding: 10px 20px;
    border-radius: 15px;
    display: inline-block;
}

.current-word-display {
    font-size: 36px;
    font-weight: bold;
    color: #764ba2;
    margin: 10px 0;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 跟读区域 */
.pronunciation-area {
    margin-top: 15px;
    text-align: center;
}

.btn-pronunciation {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    color: white;
}

.btn-listen {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
    box-shadow: 0 4px 10px rgba(168, 237, 234, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4);
}

.btn-pronunciation:active {
    transform: scale(0.95);
}

.score-display {
    margin-top: 10px;
    padding: 10px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
}

.score-display.good {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.score-display.medium {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
    color: white;
}

.score-display.bad {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

/* 单词显示区域 */
.word-display {
    margin: 20px 0;
}

.word-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.slot {
    width: 50px;
    height: 60px;
    border: 3px solid #667eea;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    color: #764ba2;
    background: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.slot.filled {
    background: #667eea;
    color: white;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 魔法阵字母按钮 */
.magic-circle {
    background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.05) 70%);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    border: 2px dashed rgba(102, 126, 234, 0.3);
}

.letter-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    justify-content: center;
}

.letter-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(245, 87, 108, 0.3);
}

.letter-btn:active {
    transform: scale(0.9);
}

.letter-btn.used {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* 控制按钮 */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-control {
    flex: 1;
    min-width: 80px;
    max-width: 110px;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.btn-speak {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(79, 172, 254, 0.3);
}

.btn-clear {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(250, 112, 154, 0.3);
}

.btn-check {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(48, 207, 208, 0.3);
}

.btn-skip {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: #764ba2;
    box-shadow: 0 4px 10px rgba(255, 154, 158, 0.3);
}

.btn-control:active {
    transform: scale(0.95);
}

/* 结果页面 */
#result-screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#result-screen.active {
    display: flex;
}

.result-icon {
    font-size: 100px;
    margin-bottom: 20px;
    animation: resultBounce 0.8s ease;
}

@keyframes resultBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-title {
    font-size: 32px;
    color: #333;
    margin-bottom: 15px;
}

.result-message {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 响应式适配 */
@media (max-width: 400px) {
    .letter-buttons {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .letter-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .slot {
        width: 42px;
        height: 52px;
        font-size: 26px;
    }
    
    .main-title {
        font-size: 36px;
    }
    
    .hint-image {
        font-size: 60px;
    }
}

@media (max-width: 320px) {
    .letter-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .control-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-control {
        width: 200px;
        max-width: none;
    }
}

/* 禁止选中文本 */
* {
    -webkit-user-select: none;
    user-select: none;
}

/* 正确答案动画 */
@keyframes correctShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.correct {
    animation: correctShake 0.5s ease;
}
