:root {
    --primary-blue: #0077BE;
    --deep-blue: #000B18;
    --glow-blue: #00A6FB;
    --text-color: #E0F2F1;
    --accent-blue: #00E5FF;
    --bg-gradient: radial-gradient(circle at center, #001A33 0%, #000B18 100%);
}

/* 注释主题 (Zhushi) - 星夜: 深邃、静谧、繁星点点 */
body.theme-zhushi {
    --primary-blue: #001021;
    --deep-blue: #00050A;
    --glow-blue: #003366;
    --accent-blue: #4A90E2;
    --bg-gradient: radial-gradient(circle at center, #001A33 0%, #00050A 100%);
    --text-color: #E1F5FE;
}

/* 借时主题 (Jieshi) - 深海: 幽蓝、流动、波光粼粼 */
body.theme-jieshi {
    --primary-blue: #002B5B;
    --deep-blue: #001524;
    --glow-blue: #004E92;
    --accent-blue: #00B4D8;
    --bg-gradient: linear-gradient(to bottom, #001524 0%, #003366 50%, #001524 100%);
    --text-color: #CAF0F8;
}

/* 主题切换开关 */
.theme-toggle {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    touch-action: manipulation;
}

.toggle-track {
    width: 150px;
    height: 54px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 27px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transition: all 0.6s ease;
}

body.theme-jieshi .toggle-track {
    background: rgba(0, 43, 91, 0.4);
    border-color: rgba(0, 180, 216, 0.4);
    box-shadow: 0 0 20px rgba(0, 180, 216, 0.15);
}

body.theme-zhushi .toggle-track {
    background: rgba(0, 5, 10, 0.6);
    border-color: rgba(74, 144, 226, 0.3);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.toggle-thumb {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 44px;
    height: 44px;
    background: #FFFFFF;
    border-radius: 50%;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.9);
}

body.theme-jieshi .toggle-thumb {
    background: #ADE8F4;
    box-shadow: 0 0 25px #00B4D8;
}

body.theme-zhushi .toggle-thumb {
    background: #E1F5FE;
    box-shadow: 0 0 25px #4A90E2;
}

.toggle-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 2px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.toggle-label.left { left: 58px; }
.toggle-label.right { right: 58px; opacity: 0.4; }

/* 借时在左 (深海)，注释在右 (星夜) */
body.theme-zhushi .toggle-thumb {
    transform: translateX(96px);
}

body.theme-zhushi .toggle-label.left { opacity: 0.4; }
body.theme-zhushi .toggle-label.right { opacity: 1; }

body.theme-jieshi .toggle-label.left { opacity: 1; }
body.theme-jieshi .toggle-label.right { opacity: 0.4; }

.theme-names {
    display: flex;
    gap: 60px;
    font-size: 1.1rem;
    letter-spacing: 5px;
    opacity: 0.9;
}

.name-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
}

.avatar-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    transition: all 0.5s ease;
    background: rgba(255, 255, 255, 0.1);
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.9) contrast(1.1);
}

.name-item span {
    font-weight: 600;
    transition: all 0.4s ease;
}

body.theme-zhushi .name-zhushi .avatar-wrapper {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px var(--accent-blue);
    transform: scale(1.1);
}

body.theme-zhushi .name-zhushi span {
    color: var(--accent-blue);
    text-shadow: 0 0 15px var(--accent-blue);
    transform: scale(1.1);
}

body.theme-jieshi .name-jieshi .avatar-wrapper {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px var(--accent-blue);
    transform: scale(1.1);
}

body.theme-jieshi .name-jieshi span {
    color: var(--accent-blue);
    text-shadow: 0 0 15px var(--accent-blue);
    transform: scale(1.1);
}

body.theme-zhushi .name-jieshi, 
body.theme-jieshi .name-zhushi { 
    opacity: 0.3; 
    transform: scale(0.9); 
}

body.theme-zhushi .name-jieshi .avatar-wrapper,
body.theme-jieshi .name-zhushi .avatar-wrapper {
    filter: grayscale(0.5) blur(1px);
}

@media (max-width: 768px) {
    .theme-names {
        gap: 40px;
    }
    
    .avatar-wrapper {
        width: 50px;
        height: 50px;
    }
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--deep-blue);
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-color);
    transition: background-color 1s ease;
    /* 禁止 iOS 上的默认行为 */
    position: fixed;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    transition: background 1s ease;
}

canvas {
    display: block;
    cursor: crosshair;
    width: 100%;
    height: 100%;
}

.ui {
    position: absolute;
    top: 40%; /* 向上稍微移动，补偿标题消失后的视觉中心 */
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 10;
    transition: opacity 1s ease;
    width: 90%;
}

h1 {
    display: none; /* 彻底隐藏标题 */
}

p {
    font-size: clamp(1rem, 4.5vw, 1.35rem);
    font-weight: 300;
    opacity: 0.85;
    letter-spacing: 0.15rem;
    line-height: 1.8;
    white-space: pre-line; /* 支持换行 */
    background: linear-gradient(to bottom, #FFFFFF, var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.controls {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200; /* 提高层级 */
    display: flex;
    gap: 20px;
    padding: 20px 35px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 60px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
    max-width: 95%;
    pointer-events: auto;
    touch-action: manipulation;
}

button:not(.theme-btn) {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    touch-action: manipulation;
}

button:not(.theme-btn) svg {
    width: 36px;
    height: 36px;
    display: block;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

button:not(.theme-btn)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, var(--accent-blue) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

button:not(.theme-btn):hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #FFFFFF;
    transform: translateY(-10px) scale(1.1);
    box-shadow: 0 10px 30px rgba(0, 229, 255, 0.4);
}

button:not(.theme-btn):hover::after {
    opacity: 0.3;
}

button:not(.theme-btn):active {
    transform: scale(0.9);
}

@media (max-width: 768px) {
    .controls {
        bottom: 30px;
        padding: 12px 20px;
        gap: 12px;
    }
    
    button:not(.theme-btn) {
        width: 60px;
        height: 60px;
    }

    button:not(.theme-btn) svg {
        width: 28px;
        height: 28px;
    }

    .theme-toggle {
        top: 30px;
    }
}

/* iPad 适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    h1 {
        font-size: 4rem;
    }
    
    .controls {
        gap: 20px;
        padding: 15px 30px;
    }
}

button {
    background: transparent;
    border: 1px solid rgba(0, 119, 190, 0.3);
    color: var(--text-color);
    padding: 12px 24px;
    cursor: pointer;
    border-radius: 30px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.85rem;
    letter-spacing: 1px;
    outline: none;
}

button:hover {
    background: rgba(0, 119, 190, 0.2);
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
    transform: translateY(-5px);
}

button:active {
    transform: scale(0.95);
}

/* 隐藏 UI 时的效果 */
.ui-hidden {
    opacity: 0;
}
