/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 50%, #f0f4f8 100%);
    min-height: 100vh;
}

/* 头部样式 */
header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    color: #1e40af;
    text-align: center;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e5e7eb;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* 练习区域样式 */
.exercise {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.exercise:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.exercise h2 {
    color: #1e40af;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #3b82f6;
    display: inline-block;
}

/* 演示区域 */
.demo-area {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    margin-top: 1rem;
}

/* 按钮样式 */
button {
    background: linear-gradient(45deg, #dbeafe, #bfdbfe);
    color: #1f2937;
    border: 1px solid #93c5fd;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    margin: 0.25rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

button:hover {
    background: linear-gradient(45deg, #bfdbfe, #93c5fd);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
}

button:active {
    transform: translateY(0);
}

/* 控制区域 */
.controls {
    margin-top: 1rem;
    text-align: center;
}

/* 练习1样式 */
#greeting {
    color: #2d3748;
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

#description {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 1rem;
    color: #4a5568;
}

/* 练习2样式 */
.color-box {
    width: 200px;
    height: 100px;
    background-color: #e2e8f0;
    margin: 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: bold;
    transition: all 0.3s ease;
}

/* 练习3样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #4a5568;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.user-info {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    min-height: 50px;
    border-left: 4px solid #3b82f6;
}

/* 练习4样式 */
.todo-list {
    list-style: none;
    margin: 1rem 0;
}

.todo-list li {
    background: white;
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.todo-list li button {
    background: #fecaca;
    color: #dc2626;
    border: 1px solid #f87171;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.todo-list li button:hover {
    background: #f87171;
    color: #991b1b;
    border-color: #ef4444;
}

#todoInput {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-right: 0.5rem;
}

#todoCount {
    background: #bee3f8;
    color: #2b6cb0;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: bold;
}

/* 练习5样式 */
.event-box {
    width: 300px;
    height: 150px;
    background: linear-gradient(45deg, #60a5fa, #3b82f6);
    color: white;
    margin: 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
}

.event-box:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#keyInput {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin: 1rem 0;
}

.event-log {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.event-log h4 {
    color: #fbb6ce;
    margin-bottom: 0.5rem;
}

/* 练习6样式 - 计算器 */
.calculator {
    background: #2d3748;
    border-radius: 15px;
    padding: 1.5rem;
    max-width: 300px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.display {
    width: 100%;
    height: 60px;
    background: #1a202c;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.8rem;
    text-align: right;
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.calculator button {
    height: 50px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    background: #4a5568;
    margin: 0;
}

.calculator button:hover {
    background: #2d3748;
    transform: none;
}

.equals {
    grid-row: span 2;
    background: #48bb78 !important;
}

.equals:hover {
    background: #38a169 !important;
}

.zero {
    grid-column: span 2;
}

/* 底部样式 */
footer {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    color: #4b5563;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .exercise {
        padding: 1rem;
    }
    
    .demo-area {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .calculator {
        max-width: 280px;
        padding: 1rem;
    }
    
    .buttons {
        gap: 0.25rem;
    }
    
    .calculator button {
        height: 45px;
        font-size: 1rem;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.exercise {
    animation: fadeIn 0.6s ease-out;
}

.exercise:nth-child(even) {
    animation-delay: 0.1s;
}

.exercise:nth-child(odd) {
    animation-delay: 0.2s;
}