* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #333;
    /* 默认移动端布局 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端优先布局 */
@media (max-width: 768px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }
    
    .container {
        max-width: 100%;
        padding: 20px;
        margin-top: 10px;
    }
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 600px;
    width: 100%;
    backdrop-filter: blur(10px);
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #2d3748;
}

/* Tab切换 */
.tab-container {
    display: flex;
    gap: 8px;
    margin-bottom: 30px;
    background: #f7fafc;
    padding: 4px;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.tab-btn:hover {
    color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 能量显示页 - 简洁解压风格 */
#energyPage {
    min-height: 500px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.energy-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.tank-wrapper {
    position: relative;
}

.tank {
    position: relative;
    width: 320px;
    height: 450px;
    background: #f7fafc;
    border-radius: 24px;
    border: 4px solid #e2e8f0;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.08), 0 10px 40px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tank:hover {
    transform: scale(1.02);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.08), 0 15px 50px rgba(102, 126, 234, 0.2);
}

.tank:active {
    transform: scale(0.98);
}

.water {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    height: 0%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

/* 波浪遮罩层 */
.wave-svg {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

.wave-path {
    fill: url(#waterGradient);
}

.wave-1,
.wave-2 {
    transition: d 0.3s ease-out;
    filter: blur(0.5px);
}

.water::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.08) 3px,
        rgba(255, 255, 255, 0.08) 6px
    );
    animation: wave 8s linear infinite;
    opacity: 0.6;
}

.water::after {
    content: '';
    position: absolute;
    top: -30%;
    left: -30%;
    width: 160%;
    height: 160%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.05) 4px,
        rgba(255, 255, 255, 0.05) 8px
    );
    animation: wave 12s linear infinite reverse;
    opacity: 0.4;
}

@keyframes wave {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(-20px) rotate(360deg);
    }
}

.water-text {
    position: relative;
    z-index: 2;
    color: white;
    font-size: 48px;
    font-weight: 700;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.tank:hover .water-text {
    transform: scale(1.1);
}

.particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    --vx: 0px;
    --vy: -100px;
    animation: float 2s ease-out forwards;
}

@keyframes float {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--vx), var(--vy)) scale(0);
    }
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    pointer-events: none;
    z-index: 4;
}

.ripple.active {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.tank-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 25px 25px;
    pointer-events: none;
    opacity: 0.5;
}

.energy-stats {
    display: flex;
    gap: 40px;
    justify-content: center;
}

.stat-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-mini-label {
    font-size: 12px;
    color: #a0aec0;
    font-weight: 500;
}

.stat-mini-value {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

/* 设置页 */
#settingsPage {
    min-height: 500px;
}

.input-section {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #718096;
    margin-bottom: 8px;
}

/* 主题选择 */
.theme-section {
    display: flex;
    flex-direction: column;
}

.theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.theme-grid .theme-btn {
    flex: 1 1 calc(33.333% - 8px);
    min-width: calc(33.333% - 8px);
    max-width: calc(33.333% - 8px);
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 12px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    /* 确保按钮可点击 */
    position: relative;
    z-index: 1;
    /* 确保按钮可见 */
    min-height: 80px;
    box-sizing: border-box;
    width: 100%;
}

.theme-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.theme-btn:active {
    transform: translateY(0);
    background: #f0f0f0;
}

.theme-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.theme-btn.active:active {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
}

.theme-icon {
    font-size: 28px;
    line-height: 1;
}

.theme-name {
    font-size: 12px;
    font-weight: 500;
}

.theme-btn.active .theme-name {
    color: white;
}

.unit-type-section,
.unit-name-section,
.period-section,
.value-input-section,
.time-section {
    display: flex;
    flex-direction: column;
}

.toggle-buttons {
    display: flex;
    gap: 8px;
    background: #f7fafc;
    padding: 4px;
    border-radius: 12px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.toggle-btn:hover {
    color: #667eea;
}

.preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.preset-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.preset-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.preset-btn.active:hover {
    background: #5568d3;
    color: white;
}

.custom-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f7fafc;
    color: #2d3748;
    transition: all 0.3s ease;
}

.custom-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.time-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f7fafc;
    color: #2d3748;
    transition: all 0.3s ease;
}

.time-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.input-group {
    display: flex;
    align-items: center;
    background: #f7fafc;
    border-radius: 12px;
    padding: 4px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.input-group:focus-within {
    border-color: #667eea;
    background: white;
}

#valueInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 16px;
    font-size: 18px;
    outline: none;
    color: #2d3748;
}

#valueInput::placeholder {
    color: #cbd5e0;
}

.unit {
    padding: 0 16px;
    color: #718096;
    font-size: 14px;
    white-space: nowrap;
}

.confirm-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    margin-top: 8px;
}

.confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.confirm-btn:active {
    transform: translateY(0);
}

.settings-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.stat-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #667eea;
}

/* ========== 主题样式 ========== */

/* 气泡主题 */
.theme-bubbles .bubbles-container {
    display: block;
}

.theme-bubbles .light-flow,
.theme-bubbles .progress-ring,
.theme-bubbles .celebration {
    display: none;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: bubbleRise 4s ease-in infinite;
    pointer-events: auto;
    user-select: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.bubble:hover {
    transform: scale(1.1);
}

@keyframes bubbleRise {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100%) scale(1);
        opacity: 0;
    }
}

.bubble-fragment {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
    pointer-events: none;
    animation: fragmentFly 0.6s ease-out forwards;
    --vx: 0px;
    --vy: 0px;
}

@keyframes fragmentFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--vx), var(--vy)) scale(0);
        opacity: 0;
    }
}

/* 庆祝主题 */
.theme-celebration .celebration {
    display: block;
}

.theme-celebration .bubbles-container,
.theme-celebration .light-flow,
.theme-celebration .progress-ring {
    display: none;
}

.celebration {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    display: none;
}

.celebration.active {
    display: block;
}

.celebration-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffd700;
    border-radius: 50%;
    animation: celebrate 1.5s ease-out forwards;
    box-shadow: 0 0 10px #ffd700;
}

@keyframes celebrate {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx, 0), var(--ty, -200px)) scale(0);
        opacity: 0;
    }
}

/* 强烈反馈主题 */
.theme-strong .tank:active {
    transform: scale(0.95);
    animation: strongShake 0.3s ease;
}

.theme-strong .water-text {
    transition: transform 0.2s ease;
}

.theme-strong .tank:active .water-text {
    transform: scale(1.3);
    animation: textPulse 0.3s ease;
}

@keyframes strongShake {
    0%, 100% { transform: translateX(0) scale(0.95); }
    25% { transform: translateX(-5px) scale(0.95); }
    75% { transform: translateX(5px) scale(0.95); }
}

@keyframes textPulse {
    0%, 100% { transform: scale(1.3); }
    50% { transform: scale(1.5); }
}

/* 流动光效主题 */
.theme-lightflow .light-flow {
    display: block;
}

.theme-lightflow .bubbles-container,
.theme-lightflow .progress-ring,
.theme-lightflow .celebration {
    display: none;
}

.light-flow {
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    animation: lightFlow 3s linear infinite;
    pointer-events: none;
    z-index: 2;
    display: none;
}

@keyframes lightFlow {
    0% {
        top: -100%;
    }
    100% {
        top: 100%;
    }
}

/* 进度条主题 */
.theme-progress .progress-ring {
    display: block;
}

.theme-progress .bubbles-container,
.theme-progress .light-flow,
.theme-progress .celebration {
    display: none;
}

.progress-ring {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    z-index: 3;
    display: none;
}

.progress-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.8);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.5s ease;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

.progress-ring.milestone .progress-circle {
    animation: progressGlow 0.5s ease;
}

@keyframes progressGlow {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 1));
        stroke-width: 5;
    }
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* 组合主题 - 显示所有效果 */
.theme-combo .bubbles-container,
.theme-combo .light-flow,
.theme-combo .progress-ring,
.theme-combo .celebration {
    display: block;
}

/* 默认隐藏所有主题元素 */
.bubbles-container,
.light-flow,
.progress-ring,
.celebration {
    display: none;
}

/* 响应式设计 - 移动端优先 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
        max-width: 100%;
        border-radius: 16px;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    .tab-container {
        margin-bottom: 20px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .tank {
        width: 100%;
        max-width: 280px;
        height: 400px;
        margin: 0 auto 20px;
    }

    .water-text {
        font-size: 32px;
    }

    .energy-stats {
        gap: 20px;
        flex-wrap: wrap;
    }

    .stat-mini {
        flex: 1;
        min-width: 120px;
    }

    .theme-grid {
        gap: 10px;
    }
    
    .theme-grid .theme-btn {
        flex: 1 1 calc(50% - 5px);
        min-width: calc(50% - 5px);
        max-width: calc(50% - 5px);
    }

    .theme-btn {
        padding: 12px 8px;
    }

    .theme-icon {
        font-size: 24px;
    }

    .theme-name {
        font-size: 11px;
    }

    .input-section {
        gap: 16px;
    }

    .section-label {
        font-size: 12px;
    }

    .toggle-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .preset-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .settings-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .tank {
        width: 100%;
        max-width: 240px;
        height: 340px;
    }

    .water-text {
        font-size: 28px;
    }

    .theme-grid {
        gap: 8px;
    }
    
    .theme-grid .theme-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: calc(50% - 4px);
        max-width: calc(50% - 4px);
    }

    .theme-btn {
        padding: 10px 6px;
    }

    .theme-icon {
        font-size: 20px;
    }

    .theme-name {
        font-size: 10px;
    }
}