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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: #1a1a2e;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── App Layout ── */
#app {
    display: flex; flex-direction: column;
    width: 100%; height: 100%;
    position: relative;
}

/* ── Top Bar ── */
#topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    z-index: 10;
    flex-shrink: 0;
}
#topbar .left { display: flex; align-items: center; gap: 10px; font-size: 18px; }
#topbar .class-icon { font-size: 24px; }
#topbar .class-name { font-weight: 600; }
#topbar .center { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
#topbar .right { display: flex; align-items: center; gap: 16px; }
#btn-settings {
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.15); color: #fff; font-size: 20px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
#btn-settings:hover { background: rgba(255,255,255,0.25); }
#quiet-timer {
    font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
    min-width: 70px; text-align: right; color: #ffd54f;
}

/* ── Canvas Container ── */
#canvas-container {
    flex: 1; position: relative; overflow: hidden;
}

/* ── Bottom Bar ── */
#bottombar {
    flex-shrink: 0;
    padding: 16px 24px 20px;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    z-index: 10;
}
#volume-area { display: flex; align-items: center; gap: 12px; }
.volume-label { font-size: 14px; opacity: 0.7; min-width: 36px; text-align: center; }
#volume-bar-wrap {
    flex: 1; height: 14px; border-radius: 7px;
    background: rgba(255,255,255,0.12);
    position: relative; overflow: visible;
}
#volume-bar-fill {
    height: 100%; border-radius: 7px;
    background: linear-gradient(90deg, #66bb6a 0%, #ffa726 60%, #ef5350 100%);
    transition: width 0.2s ease-out;
}
#quiet-marker, #noisy-marker {
    position: absolute; top: -5px; bottom: -5px;
    width: 3px; border-radius: 2px;
    z-index: 2;
}
#quiet-marker { background: #66bb6a; box-shadow: 0 0 6px rgba(102,187,106,0.6); }
#noisy-marker { background: #ef5350; box-shadow: 0 0 6px rgba(239,83,80,0.6); }
#monitor-controls { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
#btn-monitor {
    padding: 10px 36px; font-size: 18px; font-weight: 700;
    border: none; border-radius: 50px;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 14px rgba(102,187,106,0.4);
}
#btn-monitor:hover { transform: scale(1.04); }
#btn-monitor:active { transform: scale(0.97); }
#btn-monitor.running {
    background: linear-gradient(135deg, #ef5350, #c62828);
    box-shadow: 0 3px 14px rgba(239,83,80,0.4);
}
#info-area {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 10px; font-size: 16px;
}
#info-area .star { font-size: 20px; }
#info-area .streak-text { color: #ffd54f; font-weight: 600; }
#state-text { opacity: 0.8; font-size: 14px; }

/* ── Start Screen ── */
#start-screen {
    position: fixed; inset: 0; z-index: 100;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1a1a3e 0%, #2d1b69 40%, #4a2a5e 100%);
}
#start-screen .start-icon { font-size: 80px; margin-bottom: 20px; animation: float 3s ease-in-out infinite; }
#start-screen .start-title { font-size: 32px; font-weight: 700; color: #fff; margin-bottom: 8px; }
#start-screen .start-subtitle { font-size: 16px; color: rgba(255,255,255,0.6); margin-bottom: 40px; }
#btn-start {
    padding: 16px 60px; font-size: 22px; font-weight: 700;
    border: none; border-radius: 50px;
    background: linear-gradient(135deg, #7c4dff, #536dfe);
    color: #fff; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(124,77,255,0.4);
}
#btn-start:hover { transform: scale(1.05); box-shadow: 0 6px 28px rgba(124,77,255,0.5); }
#btn-start:active { transform: scale(0.97); }
#start-screen .start-hint { margin-top: 24px; font-size: 13px; color: rgba(255,255,255,0.35); }

/* ── Settings Panel ── */
#settings-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
}
#settings-overlay.open { opacity: 1; pointer-events: auto; }
#settings-card {
    background: #2a2a40; border-radius: 20px;
    padding: 32px; width: min(420px, 90vw);
    color: #fff; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
#settings-card h3 { font-size: 22px; margin-bottom: 24px; text-align: center; }
.setting-row { margin-bottom: 20px; }
.setting-row label { display: block; font-size: 14px; opacity: 0.7; margin-bottom: 8px; }
.setting-row input[type="text"] {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08); color: #fff; font-size: 16px;
    outline: none; transition: border-color 0.2s;
}
.setting-row input[type="text"]:focus { border-color: #7c4dff; }
#btn-calibrate {
    width: 100%; padding: 12px; border-radius: 10px;
    border: 2px solid #ff9800; background: rgba(255,152,0,0.1);
    color: #ffb74d; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
#btn-calibrate:hover { background: rgba(255,152,0,0.2); }
#btn-calibrate:disabled { opacity: 0.5; cursor: not-allowed; }
#calibrate-result { text-align: center; font-size: 14px; margin-top: 8px; min-height: 20px; color: #ffb74d; }
.threshold-slider-wrap { margin-top: 10px; }
.threshold-slider-wrap .slider-header {
    display: flex; justify-content: space-between; align-items: baseline;
}
.threshold-slider-wrap .slider-val { font-size: 16px; font-weight: 600; }
.threshold-slider-wrap .slider-val.quiet { color: #66bb6a; }
.threshold-slider-wrap .slider-val.noisy { color: #ef5350; }
.threshold-slider-wrap input[type="range"] {
    width: 100%; margin-top: 6px;
    -webkit-appearance: none; appearance: none;
    height: 8px; border-radius: 4px;
    background: linear-gradient(90deg, #66bb6a 0%, #ffa726 50%, #ef5350 100%);
    outline: none;
}
.threshold-slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 24px; height: 24px; border-radius: 50%;
    background: #fff; border: 3px solid #7c4dff;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.threshold-zone-preview {
    display: flex; height: 20px; border-radius: 4px;
    overflow: hidden; margin-top: 12px;
}
.threshold-zone-preview .zone { transition: flex 0.3s; }
.threshold-zone-preview .zone-quiet { background: rgba(102,187,106,0.4); }
.threshold-zone-preview .zone-warning { background: rgba(255,167,38,0.4); }
.threshold-zone-preview .zone-noisy { background: rgba(239,83,80,0.4); }
.animal-options { display: flex; gap: 12px; }
.animal-btn {
    flex: 1; padding: 14px; border-radius: 14px;
    border: 2px solid rgba(255,255,255,0.15);
    background: transparent; font-size: 36px;
    cursor: pointer; transition: all 0.2s;
}
.animal-btn.active { border-color: #ffd54f; background: rgba(255,213,79,0.12); }
#btn-reset-timer {
    width: 100%; padding: 12px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06); color: #fff; font-size: 15px;
    cursor: pointer; transition: background 0.2s;
}
#btn-reset-timer:hover { background: rgba(255,255,255,0.12); }
#btn-close-settings {
    width: 100%; padding: 12px; margin-top: 12px; border-radius: 10px;
    border: none; background: #7c4dff; color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}
#btn-close-settings:hover { background: #6c3ce0; }

/* ── Animations ── */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* ── Fullscreen adjustments ── */
@media (min-width: 1200px) {
    #topbar { padding: 16px 32px; }
    #topbar .center { font-size: 28px; }
    #bottombar { padding: 20px 32px 24px; }
    #info-area { font-size: 18px; }
}
