/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, "Microsoft YaHei", sans-serif;
}

body {
    /* 将背景从浅蓝色改为淡绿色 */
    background-color: #d8e8d0; /* 淡绿色背景 */
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    text-align: center;
}

.container {
    max-width: 90%;
    margin: 0 auto;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}

/* 标题样式 */
.title {
    margin-top: 70px; /* 为顶部按钮留出空间 */
    margin-bottom: 15px;
}

h1 {
    font-size: 28px;
    color: #164a25;
    margin-bottom: 10px;
    font-weight: normal;
}

.subtitle {
    font-size: 16px;
    color: #333;
    line-height: 1.4;
}

/* 主内容区域样式 */
.main-content {
    margin-top: 50px; /* 与标题的距离 */
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap; /* 允许在小屏幕上换行 */
}

.sound-level, .timer, .threshold-setting, .tree-speed-setting, .gain-setting, .history-btn-container {
    background-color: rgba(211, 229, 215, 0.7); /* 调整为淡绿色调 */
    border-radius: 20px;
    padding: 15px 20px;
    margin: 5px;
    min-width: 180px;
    max-width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.sound-level p, .timer p, .threshold-setting p, .tree-speed-setting p, .gain-setting p {
    font-size: 15px;
    margin-bottom: 4px;
}

#db-value, #quiet-time, #threshold-value, #tree-speed-value, #gain-value {
    font-weight: bold;
    color: #2a6a40; /* 调整为绿色调 */
    font-size: 16px;
}

/* 阈值滑动条样式 */
.slider-container {
    margin: 8px 0 5px;
    width: 90%;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #cce5cc;
    outline: none;
    border-radius: 4px;
}

.slider-hint {
    font-size: 12px !important;
    color: #666;
    margin-top: 3px;
}

/* 历史记录按钮容器样式 */
.history-btn-container {
    margin: 5px;
}

/* 历史记录按钮样式 */
.history-btn {
    padding: 8px 15px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    white-space: nowrap; /* 防止文字换行 */
}

.history-btn:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.history-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 历史记录弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: #f8faf6;
    margin: 15% auto;
    padding: 0;
    border-radius: 15px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 15px 20px;
    background-color: #2a6a40;
    color: white;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: normal;
}

.close-modal {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.close-modal:hover {
    color: #eee;
    transform: scale(1.1);
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

#history-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e8d8;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#history-list li:last-child {
    border-bottom: none;
}

#history-list .no-records {
    text-align: center;
    color: #777;
    padding: 20px 0;
}

#history-list .record-time {
    font-weight: bold;
    color: #2a6a40;
}

#history-list .record-date {
    color: #666;
    font-size: 14px;
}

/* 小树区域样式 */
.trees-area {
    margin-top: 100px; /* 与功能卡片的距离 */
    height: 300px;
    margin-bottom: 20px;
    padding: 10px;
    width: 95%;
    max-width: 1500px; /* 能容纳更多树 */
    margin-left: auto;
    margin-right: auto;
}

#trees-container {
    display: flex;
    flex-wrap: wrap; /* 允许树木换行 */
    justify-content: space-evenly; /* 更加均匀分布 */
    align-items: center; /* 在垂直方向居中对齐 */
    height: 100%;
    width: 100%;
    gap: 8px; /* 减小间距使一排能放更多树 */
}

.tree {
    font-size: 32px;
    margin: 5px;
    transform-origin: bottom center;
    transition: all 0.8s ease-out; /* 延长过渡时间使生长更平滑 */
    color: #164a25;
    display: inline-block; /* 让树木可以水平排列 */
    position: relative; /* 以便随机定位 */
    cursor: default;
}

/* 树的不同生长阶段样式 */
.tree[data-growth-stage="0"] {
    font-size: 24px;
    opacity: 0.8;
}

.tree[data-growth-stage="1"] {
    font-size: 28px;
    opacity: 0.85;
}

.tree[data-growth-stage="2"] {
    font-size: 32px;
    opacity: 0.9;
}

.tree[data-growth-stage="3"] {
    font-size: 36px;
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 600px) {
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .sound-level, .timer {
        width: 90%;
        padding: 10px 20px;
    }
    
    .slider-hint {
        font-size: 12px !important;
    }
    
    .modal-content {
        width: 90%;
        margin: 30% auto;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    #history-list li {
        font-size: 14px;
    }
    
    .top-buttons {
        top: 10px;
        right: 10px;
        gap: 10px;
    }
    
    .settings-button, .help-button {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .welcome-message {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .welcome-message p:first-child {
        font-size: 16px;
    }
    
    .welcome-message p, .welcome-message li {
        font-size: 13px;
        margin-bottom: 5px;
    }
}

/* 响应式设计 - 针对小屏幕调整 */
@media (max-width: 1024px) {
    /* 删除这个媒体查询，使用更新的版本 */
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .sound-level, .timer, .init-button-container {
        width: 90%;
        max-width: 300px;
    }
    
    .trees-area {
        margin-top: 50px;
    }
    
    .settings-content, .help-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* 初始化按钮样式 */
.init-button {
    padding: 12px 24px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    min-width: 120px;
}

.init-button:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.init-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 声音检测区域样式 */
.sound-level {
    position: relative;
}

/* 人声检测指示器样式 */
.voice-detector {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

.voice-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ccc; /* 默认灰色 */
    margin-right: 6px;
    transition: background-color 0.3s ease;
}

.voice-indicator.active {
    background-color: #e74c3c; /* 检测到人声时为红色 */
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.7);
    animation: pulse 1.5s infinite;
}

.voice-text {
    font-size: 12px;
    color: #666;
}

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

/* 使用说明按钮样式 */
.help-button {
    padding: 8px 15px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 帮助按钮悬停效果 */
.help-button:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 帮助按钮点击效果 */
.help-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 使用说明面板样式 */
.help-panel {
    display: none; /* 默认隐藏 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    overflow: auto;
}

.help-content {
    background-color: #f8faf6;
    margin: 5% auto;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 700px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
    max-height: 85vh;
    overflow-y: auto;
}

.help-section {
    margin-bottom: 25px;
    text-align: left;
    border-bottom: 1px solid #e0e8d8;
    padding-bottom: 15px;
}

.help-section:last-of-type {
    border-bottom: none;
}

.help-section h3 {
    color: #2a6a40;
    margin-bottom: 10px;
    font-size: 18px;
}

.help-section p {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 15px;
}

.help-section ul {
    margin-left: 25px;
    margin-bottom: 10px;
}

.help-section li {
    margin-bottom: 6px;
    font-size: 15px;
}

.help-close {
    text-align: center;
    margin-top: 20px;
}

.close-help {
    padding: 10px 20px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.close-help:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

/* 适配手机设备 */
@media (max-width: 600px) {
    .help-content {
        margin: 10% auto;
        padding: 15px;
        width: 90%;
    }
    
    .help-section h3 {
        font-size: 16px;
    }
    
    .help-section p, .help-section li {
        font-size: 14px;
    }
    
    .help-button {
        padding: 6px 12px;
        font-size: 12px;
    }
}

.timer {
    /* 已经在公共样式中定义了 */
}

/* 滑动条按钮样式 */
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #2a6a40;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #2a6a40;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* 顶部按钮区域 - 修复按钮显示问题 */
.top-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 15px;
    flex-direction: row;
    align-items: center;
}

/* 设置按钮容器 */
.settings-button-container {
    display: inline-block;
}

/* 帮助按钮容器 */
.help-button-container {
    display: inline-block;
}

/* 设置按钮样式 */
.settings-button {
    padding: 8px 15px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 设置按钮图标 */
.settings-button::after {
    content: "⚙️";
    font-size: 14px;
    margin-left: 5px;
}

/* 设置按钮悬停效果 */
.settings-button:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 设置按钮点击效果 */
.settings-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 设置面板样式 */
.settings-panel {
    display: none; /* 默认隐藏 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    overflow: auto;
}

.settings-content {
    background-color: #f8faf6;
    margin: 5% auto;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 600px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
    max-height: 85vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 25px;
    text-align: left;
    border-bottom: 1px solid #e0e8d8;
    padding-bottom: 15px;
}

.settings-section:last-of-type {
    border-bottom: none;
}

.settings-section p {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 15px;
}

.settings-close {
    text-align: center;
    margin-top: 20px;
}

.close-settings {
    padding: 10px 20px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.close-settings:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 标准按钮样式 */
.standard-btn {
    padding: 10px 20px;
    background-color: #2a6a40;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.standard-btn:hover {
    background-color: #3a7a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.standard-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 功能卡片样式统一 */
.sound-level, .timer, .init-button-container {
    background-color: rgba(211, 229, 215, 0.7);
    border-radius: 20px;
    padding: 15px 20px;
    margin: 5px;
    min-width: 180px;
    max-width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 小树区域样式 */
.trees-area {
    margin-top: 100px; /* 与功能卡片的距离 */
    height: 300px;
    margin-bottom: 20px;
    padding: 10px;
    width: 95%;
    max-width: 1500px; /* 能容纳更多树 */
    margin-left: auto;
    margin-right: auto;
}

#trees-container {
    display: flex;
    flex-wrap: wrap; /* 允许树木换行 */
    justify-content: space-evenly; /* 更加均匀分布 */
    align-items: center; /* 在垂直方向居中对齐 */
    height: 100%;
    width: 100%;
    gap: 8px; /* 减小间距使一排能放更多树 */
}

/* 响应式调整 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .sound-level, .timer, .init-button-container {
        width: 90%;
        max-width: 300px;
    }
    
    .trees-area {
        margin-top: 50px;
    }
    
    .settings-content, .help-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* 欢迎提示样式 */
.welcome-message {
    background-color: #eaf3e8;
    border-left: 4px solid #2a6a40;
    padding: 15px;
    margin-bottom: 25px;
    border-radius: 5px;
    text-align: left;
}

.welcome-message p {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 15px;
}

.welcome-message p:first-child {
    font-weight: bold;
    color: #2a6a40;
    font-size: 17px;
}

.welcome-message ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.welcome-message li {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.4;
}

/* 设置内容样式调整 */
.settings-content {
    background-color: #f8faf6;
    margin: 5% auto;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 600px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
    max-height: 85vh;
    overflow-y: auto;
}

/* 返回首页按钮 */
.back-btn {
    position: fixed;
    left: 15px;
    top: 15px;
    background-color: #ff5d5d;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    z-index: 1000;
}

.back-btn:hover {
    background-color: #ff4040;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.back-btn:active {
    transform: translateY(2px);
} 