/* 引入 Google Fonts - Roboto */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

body {
    font-family: 'Roboto', Arial, sans-serif; /* 使用 Roboto 字體，備用 Arial */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: #2d2d2d; /* 深灰背景 */
    background-size: cover; /* 覆蓋整個螢幕 */
    color: #ffffff; /* 白字 */
}

.timer-container {
    background: rgba(30, 30, 40, 0.95); /* 深灰半透明背景，與圖片對比 */
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); /* 深色陰影 */
    text-align: center;
    width: 100%;
    max-width: 550px; /* 稍寬一點 */
    transition: all 0.3s ease;
    margin: 15px; /* 增加邊距 */
    border: 1px solid rgba(255, 255, 255, 0.3); /* 微白色邊框 */
}

.mode-selector {
    display: flex;
    margin-bottom: 25px;
    border-radius: 8px;
    overflow: hidden;
    background: #2d2d2d; /* 深灰背景 */
}

.mode-selector .mode-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.2em; /* 按鈕文字稍大 */
    color: #ffffff; /* 白字 */
    transition: all 0.3s ease;
}

.mode-selector .mode-btn.active {
    background: #F97316; /* 主色調：橘色 */
    color: #ffffff;
}

.mode-selector .mode-btn:hover {
    background: #fb923c; /* 懸停時變為較亮的橘色 */
    color: #ffffff;
}

.mode-title {
    margin: 10px 0;
    font-size: 1.7em;
    color: #ffffff; /* 白字標題 */
    font-weight: 700;
}

.timer-settings {
    display: flex;
    justify-content: space-between;
    margin: 15px 0;
    flex-wrap: wrap;
    gap: 10px; /* 增加間距 */
    width: 100%; /* 確保佔滿容器 */
    min-width: 300px; /* 設置最小寬度，避免過窄 */
    max-width: 600px; /* 設置最大寬度，避免過寬 */
}

.timer-settings .duration-btn {
    flex: 1;
    margin: 0 5px;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #2d2d2d; /* 深灰按鈕 */
    cursor: pointer;
    font-weight: 600;
    color: #ffffff; /* 白字 */
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    min-width: 80px; /* 確保按鈕有最小寬度 */
}

.timer-settings .duration-btn:hover {
    background: #F97316; /* 懸停時變為橘色 */
    color: #ffffff;
    transform: translateY(-2px); /* 輕微上移效果 */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.custom-duration {
    display: flex;
    gap: 10px; /* 增加間距 */
    flex: 3;
    align-items: center;
    width: 100%; /* 確保佔滿可用空間 */
}

.custom-duration select {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2); /* 微白色邊框 */
    border-radius: 6px;
    font-size: 1em;
    width: 30%; /* 每個選單占 30% */
    background-color: #2d2d2d; /* 深灰背景 */
    color: #ffffff; /* 白字 */
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.custom-duration select:focus {
    outline: none;
    border-color: #F97316; /* 聚焦時邊框變橘色 */
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.3); /* 聚焦光暈 */
}

.custom-duration select option {
    background: #2d2d2d; /* 選項背景 */
    color: #ffffff; /* 白字 */
}

.custom-duration .set-custom-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    background: #F97316; /* 主色調按鈕：橘色 */
    color: #ffffff; /* 白字 */
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.custom-duration .set-custom-btn:hover {
    background: #fb923c; /* 懸停時變亮 */
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.display {
    font-size: 3.5em;
    margin: 30px 0;
    font-family: monospace;
    font-weight: bold;
    background: #2d2d2d; /* 深灰背景 */
    padding: 20px;
    border-radius: 10px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    color: #ffffff; /* 白字 */
    border: 1px solid rgba(255, 255, 255, 0.1); /* 微白色邊框 */
}

.buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 25px 0;
}

.buttons .control-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #F97316; /* 主色調按鈕：橘色 */
    color: #ffffff; /* 白字 */
    font-weight: 700;
    font-size: 1.1em;
    transition: all 0.2s ease;
    min-width: 110px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.buttons .control-btn:hover {
    background-color: #fb923c; /* 懸停時變亮 */
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.buttons .control-btn:disabled {
    background-color: #4b4b4b; /* 禁用時為較淺的灰色 */
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.laps {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 15px;
}

.laps h3 {
    margin-bottom: 12px;
    font-size: 1.3em;
    color: #ffffff; /* 白字 */
    font-weight: 700;
}

.laps-list {
    display: flex;
    flex-direction: column-reverse; /* 最新分圈顯示在頂部 */
}

.lap-item {
    padding: 10px;
    margin: 6px 0;
    border-radius: 6px;
    background-color: #3a3a3a; /* 深灰背景 */
    transition: all 0.3s ease;
    font-family: monospace;
    color: #ffffff; /* 白字 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.lap-item:nth-child(odd) {
    background-color: #2d2d2d; /* 交替顏色 */
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* 手機版 RWD 優化 */
@media (max-width: 500px) {
    .timer-container {
        width: 90%;
        padding: 20px;
        margin: 15px auto; /* 確保居中 */
        border-radius: 12px;
    }

    .mode-selector {
        margin-bottom: 20px;
    }

    .mode-selector .mode-btn {
        font-size: 1.1em;
        padding: 10px;
    }

    .mode-title {
        font-size: 1.4em;
    }

    .display {
        font-size: 2.2em; /* 縮小時間顯示 */
        margin: 20px 0;
        padding: 15px;
    }

    .timer-settings {
        flex-direction: column;
        gap: 12px;
        width: 100%; /* 手機版仍占滿 */
        min-width: unset; /* 手機版移除最小寬度限制 */
    }

    .timer-settings .duration-btn {
        width: 100%;
        margin: 0;
        padding: 12px;
        font-size: 1.1em;
        border-radius: 6px;
    }

    .custom-duration {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 10px;
    }

    .custom-duration select {
        width: 30%; /* 每個選單占 30% */
        font-size: 1em;
        padding: 8px;
        border-radius: 6px;
    }

    .custom-duration .set-custom-btn {
        width: 100%;
        padding: 12px;
        font-size: 1.1em;
        border-radius: 6px;
    }

    .buttons {
        flex-direction: column;
        gap: 12px;
    }

    .buttons .control-btn {
        width: 100%;
        padding: 14px;
        font-size: 1.2em; /* 按鈕文字稍大 */
        min-width: unset; /* 移除最小寬度 */
        border-radius: 6px;
    }

    .laps {
        max-height: 150px; /* 縮短分圈區域 */
    }

    .laps h3 {
        font-size: 1.1em;
    }

    .lap-item {
        font-size: 0.95em;
        padding: 8px;
        border-radius: 5px;
    }
}
