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

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 255, 255, 0.8); }
    100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    transition: background-color 0.8s ease, color 0.8s ease;
    overflow: hidden;
}

.container {
    text-align: center;
    padding: 2rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    width: 90%;
    max-width: 500px;
    animation: fadeIn 0.8s ease-in-out;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.5s ease;
    position: relative;
    z-index: 1;
}

.timer-container {
    margin-bottom: 2rem;
}

.timer {
    font-size: 4rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
    transition: transform 0.3s ease, color 0.5s ease, text-shadow 0.5s ease;
    position: relative;
}

.timer-description {
    font-size: 1.2rem;
    color: #666;
    font-weight: 300;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
    transition: opacity 0.5s ease, color 0.5s ease, transform 0.3s ease;
    position: relative;
}

.timer-rule {
    font-size: 0.9rem;
    color: #888;
    font-weight: 300;
    letter-spacing: 0.5px;
    margin-bottom: 1.5rem;
    transition: opacity 0.5s ease, color 0.5s ease;
    opacity: 0.8;
}
.buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.btn {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    background-color: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    outline: none;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

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

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

#rest-btn {
    color: #4CAF50;
    border-color: #4CAF50;
}

#rest-btn:hover, #rest-btn.active {
    background-color: #4CAF50;
    color: white;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

#rest-btn.active {
    animation: pulse 2s infinite ease-in-out, glow 3s infinite ease-in-out;
    transform-origin: center;
}

#work-btn {
    color: #F44336;
    border-color: #F44336;
}

#work-btn:hover, #work-btn.active {
    background-color: #F44336;
    color: white;
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
}

#work-btn.active {
    animation: pulse 2s infinite ease-in-out, glow 3s infinite ease-in-out;
    transform-origin: center;
}

#reset-btn {
    color: #607D8B;
    border-color: #607D8B;
}

#reset-btn:hover {
    background-color: #607D8B;
    color: white;
    box-shadow: 0 4px 8px rgba(96, 125, 139, 0.3);
}

/* 休息模式下的背景色 */
body.rest-mode {
    background-color: #e8f5e9;
    animation: fadeIn 0.8s ease-in-out;
}

body.rest-mode .container {
    box-shadow: 0 4px 25px rgba(76, 175, 80, 0.15);
    background-color: rgba(255, 255, 255, 0.95);
}

body.rest-mode .timer {
    color: #2E7D32;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.2);
}

body.rest-mode .timer-description {
    color: #388E3C;
    animation: fadeIn 0.5s ease-in-out;
}

/* 工作模式下的背景色 */
body.work-mode {
    background-color: #ffebee;
    animation: fadeIn 0.8s ease-in-out;
}

body.work-mode .container {
    box-shadow: 0 4px 25px rgba(244, 67, 54, 0.15);
    background-color: rgba(255, 255, 255, 0.95);
}

body.work-mode .timer {
    color: #C62828;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.2);
}

body.work-mode .timer-description {
    color: #D32F2F;
    animation: fadeIn 0.5s ease-in-out;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .timer {
        font-size: 3rem;
    }
    
    .buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .btn {
        width: 100%;
    }
}


/* 夜间模式切换按钮 */
.mode-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: transparent;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.mode-toggle:hover {
    transform: scale(1.1);
}

.mode-toggle svg {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

/* 夜间模式样式 */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

body.dark-mode .timer {
    color: #e0e0e0;
}

body.dark-mode .timer-description {
    color: #b0b0b0;
}

body.dark-mode .btn {
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode #rest-btn {
    color: #81c784;
    border-color: #81c784;
}

body.dark-mode #rest-btn:hover, body.dark-mode #rest-btn.active {
    background-color: #2e7d32;
    color: #e0e0e0;
    box-shadow: 0 4px 8px rgba(46, 125, 50, 0.3);
}

body.dark-mode #work-btn {
    color: #e57373;
    border-color: #e57373;
}

body.dark-mode #work-btn:hover, body.dark-mode #work-btn.active {
    background-color: #c62828;
    color: #e0e0e0;
    box-shadow: 0 4px 8px rgba(198, 40, 40, 0.3);
}

/* 夜间模式下的休息模式 */
body.dark-mode.rest-mode {
    background-color: #1a2e1a;
}

body.dark-mode.rest-mode .container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 25px rgba(46, 125, 50, 0.15);
}

body.dark-mode.rest-mode .timer {
    color: #81c784;
    text-shadow: 0 0 10px rgba(46, 125, 50, 0.3);
}

body.dark-mode.rest-mode .timer-description {
    color: #66bb6a;
}

/* 夜间模式下的工作模式 */
body.dark-mode.work-mode {
    background-color: #2e1a1a;
}

body.dark-mode.work-mode .container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 25px rgba(198, 40, 40, 0.15);
}

body.dark-mode.work-mode .timer {
    color: #e57373;
    text-shadow: 0 0 10px rgba(198, 40, 40, 0.3);
}

body.dark-mode.work-mode .timer-description {
    color: #ef5350;
}