/* CSS 变量定义 */
:root {
    --bg-start: #0a0a1a;
    --bg-mid: #0d0d2b;
    --bg-end: #1a1a3a;
    --star-color: rgba(255, 255, 255, 0.8);
    --star-glow: rgba(200, 220, 255, 0.3);
    --sheep-color: rgba(255, 255, 255, 0.15);
    --sheep-glow: rgba(255, 255, 255, 0.4);
    --panel-bg: rgba(20, 20, 40, 0.6);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(255, 255, 255, 0.5);
    --accent: rgba(150, 180, 255, 0.6);
}

/* 基础重置 */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 全局样式 */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
    color: var(--text-primary);
}

/* Canvas 样式 */
#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#app {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 羊容器 */
#sheep-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    transition: transform 0.3s ease;
}

/* 羊图标 */
#sheep-icon {
    font-size: 8rem;
    opacity: 0.3;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
    transition: all 0.3s ease;
}

#sheep-icon.pulse {
    animation: pulse-animation 0.6s ease-out;
}

@keyframes pulse-animation {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
    }
    50% {
        transform: scale(1.15);
        filter: drop-shadow(0 0 40px rgba(150, 180, 255, 0.6));
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
    }
}

/* 呼吸动画（空闲时） */
#sheep-icon.idle {
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 0.25;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.35;
    }
}

/* 计数显示 */
#counter-display {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--text-primary);
    text-align: center;
    min-height: 3.5rem;
}

#counter-display .number {
    font-size: 4rem;
    font-weight: 200;
    color: var(--accent);
}

/* 小屏适配 */
@media (max-width: 600px) {
    #sheep-icon {
        font-size: 5rem;
    }
    #counter-display {
        font-size: 1.8rem;
    }
    #counter-display .number {
        font-size: 3rem;
    }
}

/* 底部控制按钮 */
#bottom-controls {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 10;
}

/* 右侧设置面板切换按钮 */
#settings-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

#settings-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

#settings-toggle.active {
    right: calc(320px + 1.5rem);
}

/* 右侧设置面板 */
#settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    z-index: 15;
    background: var(--panel-bg);
    border-left: 1px solid var(--panel-border);
    backdrop-filter: blur(15px);
    transform: translateX(0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#settings-panel.collapsed {
    transform: translateX(100%);
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
}

.settings-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.settings-close-btn:hover {
    color: var(--text-primary);
}

.settings-panel-body {
    padding: 1.2rem 1.5rem;
    flex: 1;
    overflow-y: auto;
}

/* 面板区域 */
.panel-section {
    margin-bottom: 1rem;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* 按钮样式 */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.btn.active {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    font-size: 1rem;
    padding: 0.75rem 2rem;
    min-width: 120px;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary.paused {
    background: rgba(255, 200, 100, 0.6);
    border-color: rgba(255, 200, 100, 0.6);
}

/* 输入框 */
.input-number {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 300;
    width: 100px;
    text-align: center;
}

.input-number:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(150, 180, 255, 0.25);
}

/* 快捷预设按钮 */
.btn-preset {
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.4rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-preset:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* 滑块 */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* 开关 */
.switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.switch input {
    display: none;
}

.switch-track {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s ease;
}

.switch-knob {
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track .switch-knob {
    transform: translateX(18px);
}

/* 隐藏功能 */
.hidden {
    display: none !important;
}

/* 完成动画 */
@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.goodnight-message {
    animation: fade-out 3s ease-out forwards;
}

/* 快捷键提示 */
.keyboard-hint {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.3;
    pointer-events: none;
}

/* 移动端适配 */
@media (max-width: 600px) {
    #settings-panel {
        width: 280px;
    }

    #settings-toggle.active {
        right: calc(280px + 1rem);
    }

    #bottom-controls {
        bottom: 1rem;
    }

    .button-group {
        justify-content: center;
    }

    .btn {
        flex: 1;
        min-width: 60px;
        text-align: center;
    }

    .keyboard-hint {
        display: none;
    }
}
