/* 1. 確保所有元素的寬度計算包含 padding 與 border，防止水平破版 */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    height: 100vh;
    display: flex;
    overflow: hidden;
    user-select: none;
}

.sidebar {
    width: 320px;
    background: #ffffff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 25px;
    flex-shrink: 0;
    
    /* 側邊欄在桌機版內容過長時可捲動 */
    overflow-y: auto; 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

.sidebar::-webkit-scrollbar {
    display: none;
}

/* 預設標題樣式 */
.sidebar-header {
    display: block;
    margin-bottom: 20px;
}

.sidebar-header h1 {
    font-size: 1.4rem;
    color: #2c3e50;
    margin: 15px 0 10px 0;
}

.back-link {
    text-decoration: none;
    color: #78909c;
    font-size: 0.9rem;
    font-weight: bold;
    display: inline-block;
    transition: color 0.2s;
}
.back-link:hover { color: #3498db; }

.control-group {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.label-row label {
    font-weight: bold;
    color: #455a64;
}

.badge {
    background: #e1f5fe;
    color: #0288d1;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.info-card {
    border-top: 1px solid #eceff1;
    padding-top: 20px;
}

.info-card h3 {
    font-size: 1rem;
    color: #37474f;
    margin-bottom: 15px;
}

.info-card ul { list-style: none; padding: 0; }
.info-card li {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #546e7a;
    line-height: 1.5;
    position: relative;
    padding-left: 20px;
}

.dot {
    position: absolute; left: 0; top: 6px;
    width: 10px; height: 10px; border-radius: 50%;
}
.dot.purple { background-color: #AB47BC; }
.dot.green { background-color: #43A047; }
.dot.orange { background-color: #FF9800; }

.canvas-area {
    flex: 1;
    background: #E3F2FD;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

svg { width: 100%; height: 100%; display: block; }

/* --- 動畫設定 --- */
#flower-head {
    transform-origin: bottom center; 
    transform-box: fill-box;
}

@keyframes sway {
    0% { transform: translate(400px, 180px) rotate(0deg); }
    25% { transform: translate(400px, 180px) rotate(3deg); }
    50% { transform: translate(400px, 180px) rotate(-2deg); }
    75% { transform: translate(400px, 180px) rotate(1deg); }
    100% { transform: translate(400px, 180px) rotate(0deg); }
}

.swaying { animation: sway 2.5s ease-in-out; }

@keyframes swimLeftToRight { from { transform: translateX(-150px); } to { transform: translateX(950px); } }
@keyframes swimRightToLeft { from { transform: translateX(950px) scaleX(-1); } to { transform: translateX(-150px) scaleX(-1); } }
.swim-lr { animation-name: swimLeftToRight; animation-timing-function: linear; }
.swim-rl { animation-name: swimRightToLeft; animation-timing-function: linear; }
.paused { animation-play-state: paused !important; }

@keyframes gentleWave {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-10px); }
    75% { transform: translateY(10px); }
}
.swimming-wave { animation: gentleWave 5s ease-in-out infinite; }

/* --- 手機版 RWD 修正 --- */
@media (max-width: 768px) {
    body { 
        flex-direction: column-reverse; 
        overflow-y: auto; 
        height: auto;
        overflow-x: hidden; 
    }

    .canvas-area { 
        height: 50vh; /* 確保手機版畫布有固定高度 */
        width: 100%;
        flex-shrink: 0;
    }

    .sidebar { 
        width: 100%; 
        height: auto; 
        padding: 20px; 
        border-radius: 20px 20px 0 0;
        margin-top: -20px;
        overflow: visible; 
        box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
    }

    /* 手機版標題與返回鍵橫向排列 */
    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
    }

    .sidebar-header h1 {
        margin: 0;
        font-size: 1.1rem;
    }

    .back-link { font-size: 0.8rem; }

    /* 恢復顯示觀察重點，因為現在可以滾動了 */
    .info-card { display: block; }
}

/* --- 天氣與蜻蜓特效 --- */
#sun-group { cursor: pointer; transition: filter 0.3s; transform-box: fill-box; transform-origin: center; }
#sun-group:hover { filter: drop-shadow(0 0 8px #FFF176); }
.sun-rotating { animation: sun-spin 8s linear infinite; }
@keyframes sun-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

#cloud-middle-group { cursor: pointer; transition: transform 0.3s; transform-box: fill-box; transform-origin: center; }
#cloud-middle-group:hover { transform: scale(1.1); }
.raining-cloud .cloud-path { fill: #CFD8DC !important; transition: fill 0.5s; }

.rain-drop {
    stroke: #64B5F6;
    stroke-width: 2;
    stroke-linecap: round;
    animation: rainfall 0.7s linear forwards;
}
@keyframes rainfall {
    0% { transform: translateY(0); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateY(300px); opacity: 0; }
}

/* 蜻蜓翅膀振動 */
.dragonfly-wings {
    animation: wing-flutter 0.08s infinite linear;
    transform-origin: center;
    transform-box: fill-box;
}
@keyframes wing-flutter {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}
.wings-stop .dragonfly-wings { animation: none !important; }

/* 讓睡蓮的部分可以點擊 */
#flower-head, #leaf-1, #leaf-2, #leaf-3, #leaf-4 {
    cursor: pointer;
}