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

:root {
    --primary-color: #6366f1;
    --secondary-color: #e5e7eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --background: #f8fafc;
    --app-bg: #ffffff;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 800px;
    background: var(--app-bg);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    animation: app-entrance 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes app-entrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.app-header {
    padding: 40px 20px 20px;
    text-align: center;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.app-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    animation: title-fade-in 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

@keyframes title-fade-in {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 60px;
}

.noise-meter {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: meter-entrance 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.6s both;
}

@keyframes meter-entrance {
    0% {
        opacity: 0;
        transform: scale(0.8) rotate(-10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.circular-progress {
    position: relative;
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
    filter: drop-shadow(0 8px 16px rgba(99, 102, 241, 0.2));
}

.progress-ring-background {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-ring-fill {
    stroke-dasharray: 628.32; /* 2 * π * 100 */
    stroke-dashoffset: 628.32;
    transition: stroke-dashoffset 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                stroke 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulse-ring 2s ease-in-out infinite;
    will-change: stroke-dashoffset, stroke;
    transform: translateZ(0); /* 启用硬件加速 */
}

@keyframes pulse-ring {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 24px rgba(99, 102, 241, 0.8));
    }
}

.noise-value {
    position: absolute;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    z-index: 5;
}

.noise-number {
    font-size: 64px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    animation: number-pulse 2s ease-in-out infinite;
    will-change: transform, color;
    transform: translateZ(0); /* 启用硬件加速 */
}

@keyframes number-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.noise-unit {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 32px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: status-entrance 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.9s both;
}

@keyframes status-entrance {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--success-color);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.status-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.controls {
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    animation: controls-entrance 2.1s cubic-bezier(0.4, 0, 0.2, 1) 1.2s both;
}

@keyframes controls-entrance {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.control-btn {
    width: 90px;
    height: 90px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
    transform: translateZ(0); /* 启用硬件加速 */
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    transform: scale(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-btn:hover::before {
    transform: scale(1);
}

.control-btn:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.5);
}

.control-btn:active {
    transform: translateY(-2px) scale(1.02);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.start-btn {
    animation: btn-entrance 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.stop-btn {
    background: #6b7280;
    box-shadow: 0 12px 30px rgba(107, 114, 128, 0.4);
    animation: btn-entrance 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.stop-btn:hover {
    background: #4b5563;
    box-shadow: 0 20px 40px rgba(107, 114, 128, 0.5);
}

@keyframes btn-entrance {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(180deg);
    }
    60% {
        opacity: 0.8;
        transform: scale(1.15) rotate(20deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.btn-exit {
    animation: btn-exit 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes btn-exit {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) rotate(-180deg);
    }
}

/* 状态样式 */
.status-normal .status-dot {
    background: var(--success-color);
}

.status-warning .status-dot {
    background: var(--warning-color);
}

.status-danger .status-dot {
    background: var(--danger-color);
}

.status-active .progress-ring-fill {
    animation: pulse-ring 1.2s ease-in-out infinite;
}

.status-active .noise-number {
    animation: number-pulse 1s ease-in-out infinite;
}

/* 响应式设计 - 优化手机端 */
@media (max-width: 480px) {
    body {
        padding: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .app-container {
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
        /* 优化手机端比例 */
        aspect-ratio: 9/16; /* 标准手机比例 */
        max-width: 100vw;
    }
    
    .app-header {
        padding: max(env(safe-area-inset-top), 50px) 20px 20px;
        flex-shrink: 0;
    }
    
    .app-title {
        font-size: 28px;
    }
    
    .main-content {
        flex: 1;
        gap: 40px;
        padding: 40px 20px;
        min-height: 0; /* 防止内容溢出 */
        justify-content: space-evenly; /* 均匀分布内容 */
    }
    
    .circular-progress {
        width: min(60vw, 220px);
        height: min(60vw, 220px);
    }
    
    .progress-ring {
        width: 100%;
        height: 100%;
    }
    
    .progress-ring circle {
        cx: 50%;
        cy: 50%;
        r: calc(50% - 6px);
    }
    
    .noise-number {
        font-size: clamp(48px, 12vw, 56px);
    }
    
    .noise-unit {
        font-size: clamp(18px, 5vw, 22px);
        margin-bottom: 10px;
    }
    
    .status-indicator {
        padding: 16px 28px;
        gap: 14px;
        flex-shrink: 0;
    }
    
    .status-text {
        font-size: 16px;
    }
    
    .controls {
        gap: 25px;
        padding: 30px 20px max(env(safe-area-inset-bottom), 40px);
        flex-shrink: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
        backdrop-filter: blur(10px);
    }
    
    .control-btn {
        width: 75px;
        height: 75px;
        /* 按钮位置固定，不随屏幕大小调整 */
        position: relative;
    }
}

/* 针对超高屏幕的优化 */
@media (max-width: 480px) and (min-aspect-ratio: 9/20) {
    .app-container {
        aspect-ratio: auto;
        height: 100vh;
    }
    
    .main-content {
        padding: 60px 20px 120px; /* 为固定底部按钮留出空间 */
    }
}

/* 针对较矮屏幕的优化 */
@media (max-height: 700px) and (max-width: 480px) {
    .main-content {
        gap: 30px;
        padding: 30px 20px 120px;
    }
    
    .app-header {
        padding: max(env(safe-area-inset-top), 40px) 20px 15px;
    }
    
    .circular-progress {
        width: min(50vw, 180px);
        height: min(50vw, 180px);
    }
    
    .noise-number {
        font-size: clamp(40px, 10vw, 48px);
    }
    
    .controls {
        padding: 20px 20px max(env(safe-area-inset-bottom), 30px);
    }
}

/* 横屏模式优化 */
@media (max-width: 896px) and (orientation: landscape) {
    .app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        flex-direction: row;
        max-width: none;
    }
    
    .app-header {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        width: 120px;
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .main-content {
        flex: 1;
        flex-direction: row;
        align-items: center;
        gap: 60px;
        padding: 20px 40px;
    }
    
    .controls {
        position: static;
        flex-direction: column;
        width: 120px;
        gap: 20px;
        padding: 20px;
        background: linear-gradient(90deg, rgba(248, 250, 252, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
    }
    
    .control-btn {
        width: 60px;
        height: 60px;
    }
}

/* 声音按钮样式 */
.sound-btn {
    background: #10b981;
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.4);
}

.sound-btn:hover {
    background: #059669;
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.5);
}

.sound-btn.muted {
    background: #6b7280;
    box-shadow: 0 12px 30px rgba(107, 114, 128, 0.4);
}

.sound-btn.muted:hover {
    background: #4b5563;
    box-shadow: 0 20px 40px rgba(107, 114, 128, 0.5);
}

/* 高级动画效果 */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    animation: ripple 0.8s ease-out;
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 性能优化 */
.progress-ring-fill,
.noise-number,
.status-dot,
.control-btn {
    will-change: transform;
}

/* 添加更多硬件加速优化 */
.app-container,
.circular-progress,
.noise-meter,
.status-indicator {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 优化动画帧率 */
@media (prefers-reduced-motion: no-preference) {
    .progress-ring-fill {
        animation-duration: 2s;
        animation-timing-function: ease-in-out;
    }
    
    .noise-number {
        animation-duration: 2s;
        animation-timing-function: ease-in-out;
    }
}

/* 减少动画对于偏好减少动画的用户 */
@media (prefers-reduced-motion: reduce) {
    .progress-ring-fill,
    .noise-number,
    .status-dot,
    .control-btn {
        animation: none;
        transition-duration: 0.1s;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --app-bg: #1f2937;
        --background: #111827;
    }
    
    body {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }
    
    .app-header,
    .controls {
        background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    }
    
    .status-indicator {
        background: rgba(99, 102, 241, 0.15);
    }
}

