:root {
    --primary-gold: #f0e6da;
    --bright-gold: #ffeb3b;
    --deep-purple: #0f0a1e;
    --nebula-purple: #2d0f3e;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-strong: rgba(255, 255, 255, 0.08);
    --accent: #8b5cf6;
    color-scheme: dark;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; } /* 全局移除默认轮廓线及点击高亮 */
body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow-y: auto; /* 允许垂直滚动，适应 Flex 布局 */
    font-family: 'Inter', 'PingFang SC', sans-serif;
    background: radial-gradient(circle at center, var(--deep-purple) 0%, var(--nebula-purple) 100%);
    background-attachment: fixed; /* 修复移动端滚动时背景色差问题 */
    display: flex; flex-direction: column; align-items: center;
    justify-content: flex-start; padding-top: 8vh; /* 改为顶部对齐，并增加上边距 */
    justify-content: flex-start; padding-top: 0;
}

#canvas { position: fixed; top: 0; left: 0; z-index: 1; }

/* --- 核心面板样式：严格还原 28px 圆角与大布局 --- */
.glass-panel {
    position: relative; top: auto; left: auto; transform: none; /* 移除绝对定位，回归文档流 */
    z-index: 10; width: 90%; max-width: 600px;
    background: var(--glass);
    backdrop-filter: blur(35px); -webkit-backdrop-filter: blur(35px);
    border-radius: 28px; border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    padding: 1.5rem; color: var(--primary-gold);
    height: 580px; display: flex; flex-direction: column;
    transition: height 0.3s ease;
}

h1 {
    position: relative; top: auto; width: auto; z-index: 20;
    margin: 15px 0 10px 0; text-align: center; flex-shrink: 0;
    font-size: 2.2rem; font-weight: 800; letter-spacing: 4px;
    background: linear-gradient(180deg, #fff 20%, var(--primary-gold) 100%);
    -webkit-background-clip: text; color: transparent; /* 金色渐变文字 */
    text-shadow: 0 10px 30px rgba(0,0,0,0.3);
    filter: drop-shadow(0 0 15px rgba(255, 235, 59, 0.15)); /* 柔和发光 */
}

.main-wrapper {
    flex: 1; /* 占据剩余空间 */
    display: flex; flex-direction: column;
    justify-content: flex-start; /* 改为顶部对齐，消除过大间距 */
    align-items: center;
    width: 100%;
    padding-top: 10px; /* 调整顶部间距 */
    padding-bottom: 60px; /* 预留底部空间给星核和签名 */
}

.carousel-container {
    position: relative; height: 60px; width: 100%;
    max-width: 600px; /* 限制宽度与面板一致 */
    margin-bottom: 10px; perspective: 1000px;
    overflow: hidden; /* 防止左右溢出 */
    display: flex; justify-content: center;
    touch-action: pan-y; /* 允许垂直滚动，拦截水平滑动 */
    flex-shrink: 0; z-index: 15; /* 确保层级高于面板 */
}

.carousel-btn {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); /* 初始居中 */
    width: 120px; padding: 10px 0; text-align: center; /* 固定宽度统一尺寸 */
    border-radius: 12px;
    background: rgba(20, 15, 30, 0.6); /* 加深背景，增强对比 */
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); /* 强磨砂效果 */
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    cursor: pointer; white-space: nowrap; user-select: none;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 1rem; box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.carousel-btn.active {
    background: var(--accent); color: white; border-color: rgba(255,255,255,0.3);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.5);
}

.tool-content { display: none; flex-direction: column; gap: 20px; }
.tool-content.active {
    display: flex; animation: slideIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding-right: 5px;
}
/* 美化滚动条 */
.tool-content::-webkit-scrollbar { width: 4px; }
.tool-content::-webkit-scrollbar-track { background: transparent; }
.tool-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.tool-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* 密码生成器容器回归 */
.pw-container { background: rgba(0,0,0,0.25); border-radius: 20px; padding: 24px; border: 1px solid rgba(255,255,255,0.05); }

.pw-display-box {
    position: relative; background: rgba(0,0,0,0.4); padding: 15px; border-radius: 12px;
    margin-bottom: 10px; border: 1px solid rgba(139, 92, 246, 0.3); min-height: 60px;
    display: flex; align-items: center; justify-content: center; font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  font-size: 1.3rem; color: var(--bright-gold); cursor: pointer; transition: 0.2s;
  word-break: break-all; white-space: pre-wrap; text-align: center;
}
.pw-display-box:active { transform: scale(0.98); }

.strength-meter { height: 4px; width: 100%; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; margin-bottom: 20px;}
.strength-bar { height: 100%; width: 0%; transition: 0.5s; background: #ef4444; }

.slider-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 12px; color: rgba(255,255,255,0.7); }
input[type=range] { -webkit-appearance: none; width: 100%; background: rgba(255,255,255,0.1); height: 6px; border-radius: 3px; outline: none; touch-action: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%; background: var(--bright-gold); cursor: pointer; }

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.toggle-opt {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5); padding: 12px; border-radius: 12px;
    cursor: pointer; text-align: center; font-size: 0.7rem; transition: all 0.3s;
}
.toggle-opt.active { background: rgba(139, 92, 246, 0.2); border-color: var(--accent); color: white; }

.input-glass {
    background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);
    color: var(--bright-gold); padding: 15px; border-radius: 12px;
    width: 100%; outline: none; font-family: inherit;
    transition: 0.3s; font-size: 1.1rem; text-align: center; cursor: pointer;
}
.input-glass:focus { border-color: var(--accent); background: rgba(0,0,0,0.5); }

.btn-gen-large {
    width: 100%; margin-top: 20px; padding: 14px; border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white; border: none; font-weight: 600; cursor: pointer; transition: 0.3s; font-size: 1.1rem;
    outline: none;
}
.btn-gen-large:active { transform: scale(0.98); filter: brightness(1.1); }

/* 游戏计数器中文回归 */
.fixed-bottom-group {
    position: fixed; bottom: 0; left: 0; width: 100%;
    z-index: 5; pointer-events: none;
    display: flex; flex-direction: column; align-items: center;
    padding-bottom: 15px; gap: 15px;
}

.game-ui { position: static; transform: none; pointer-events: none; }

#counter-wrapper {
  padding: 8px 22px; border-radius: 50px; background: var(--glass-strong);
  backdrop-filter: blur(10px); border: 1px solid rgba(255,235,59,0.1);
  pointer-events: auto; position: relative; cursor: help;
}
#counter-wrapper::after {
  content: "集齐100颗星核领取意外奖励！";
  position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(15, 10, 30, 0.9); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; white-space: nowrap;
  opacity: 0; visibility: hidden; transition: 0.3s; pointer-events: none;
}
#counter-wrapper:hover::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
#counter { color: var(--bright-gold); font-size: 0.95rem; font-weight: bold; }

.toast {
    position: fixed;
    left: 50%;
    top: auto; /* 强制覆盖可能存在的 top 定位 */
    bottom: -100px; /* 初始位置在屏幕外 */
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.15); /* 毛玻璃背景 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 18px;
    border-radius: 25px; /* 更圆润的边角 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10000;
    font-size: 0.85rem; /* 缩小字体，避免移动端换行 */
    white-space: nowrap; /* 强制不换行 */
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* 带有回弹效果的动画 */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    pointer-events: none; /* 避免遮挡下方元素 */
}
.toast.show { bottom: 80px; opacity: 1; top: auto; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }

.footer-signature {
    position: static; width: auto;
    text-align: center; font-size: 0.7rem;
    color: rgba(255,255,255,0.2); letter-spacing: 2px;
}

/* --- 自定义玻璃拟态日历组件 --- */
.calendar-popup {
    position: absolute;
    top: 0; left: 0;
    width: 300px;
    background: rgba(15, 10, 30, 0.95); /* 深色背景确保可读性 */
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px;
    z-index: 1000;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
}

.calendar-popup.active {
    opacity: 1; visibility: visible; transform: translateY(0);
}

.calendar-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; color: var(--primary-gold); font-weight: bold; font-size: 1.1rem;
}
.calendar-header button {
    background: transparent; border: none; color: var(--accent);
    font-size: 1.2rem; cursor: pointer; padding: 5px 10px; transition: 0.2s;
}
.calendar-header button:focus { outline: none; }
.calendar-header button:hover { color: var(--bright-gold); transform: scale(1.2); }
.calendar-header button:active { transform: scale(0.9); }

.calendar-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    text-align: center; font-size: 0.85rem; color: rgba(255,255,255,0.4); margin-bottom: 10px;
}

.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.calendar-day {
    height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer; transition: 0.2s; color: rgba(255,255,255,0.8);
}
.calendar-day:hover { background: rgba(255,255,255,0.1); color: white; }
.calendar-day.today { border: 1px solid var(--accent); color: var(--accent); font-weight: bold; }
.calendar-day:active { background: var(--accent); color: white; transform: scale(0.95); }

/* --- 帮我选工具样式 --- */
.picker-input-group { display: flex; gap: 10px; margin-bottom: 15px; }
#picker-input { padding: 8px 12px; font-size: 1rem; height: 50px; } /* 进一步缩小输入框 */
.picker-input-group { position: relative; display: block; margin-bottom: 15px; }
#picker-input { padding: 8px 55px 8px 15px; font-size: 1rem; height: 50px; width: 100%; } /* 预留右侧按钮空间 */
.btn-icon-add {
    position: absolute; top: 5px; right: 5px;
    width: 40px; height: 40px; background: transparent; border: none; border-radius: 8px;
    color: #3b82f6; font-size: 2rem; cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center;
    outline: none;
}
.btn-icon-add:hover { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.btn-icon-add:active { transform: scale(0.9); }

.picker-options-container {
    display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px;
    padding: 15px; background: rgba(0,0,0,0.2); border-radius: 12px; /* 增大内边距 */
    margin-bottom: 15px; transition: 0.3s;
    align-content: center;
    justify-content: center; /* 选项居中对齐 */
    width: 100%; box-sizing: border-box;
}

.picker-options-container:empty::after {
    content: '请添加一些午餐选项...';
    width: 100%;
    text-align: center;
    color: rgba(255,255,255,0.3);
}

/* 紧凑模式：当选项较多时自动缩小间距和字号 */
.picker-options-container.dense { gap: 6px; padding: 12px; }
.picker-options-container.dense .option-tag { padding: 4px 10px; font-size: 0.8rem; }

/* 超紧凑模式：选项非常多时进一步缩小 */
.picker-options-container.super-dense { gap: 4px; padding: 10px; }
.picker-options-container.super-dense .option-tag { padding: 3px 8px; font-size: 0.75rem; border-radius: 15px; }

.option-tag {
    background: rgba(255,255,255,0.1); padding: 6px 12px; border-radius: 20px;
    font-size: 0.85rem; color: rgba(255,255,255,0.8); cursor: pointer;
    display: flex; align-items: center; gap: 6px; transition: 0.2s; border: 1px solid transparent;
    max-width: 100%; /* 防止单行溢出 */
    flex: 0 1 auto; /* 允许在必要时收缩 */
    min-width: 0; /* 修复 Flex 子元素溢出问题 */
}
.option-tag:hover { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; color: #ef4444; }
.option-tag:active { transform: scale(0.95); }
.option-tag span:first-child { 
    pointer-events: none; 
    flex: 1; min-width: 0; /* 自适应宽度，不再硬性限制 */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.picker-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.btn-small {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6); padding: 6px 12px; border-radius: 8px;
    cursor: pointer; font-size: 0.8rem; transition: 0.2s;
    outline: none;
}
.btn-small:hover { background: rgba(255,255,255,0.1); color: white; }
.btn-small:active { transform: scale(0.95); }

.picker-result-box {
    height: 120px; display: flex; align-items: center; justify-content: center;
    font-size: 3rem; font-weight: bold; color: var(--primary-gold);
    background: rgba(0,0,0,0.3); border-radius: 20px; border: 2px solid rgba(255,255,255,0.05);
    text-shadow: 0 0 15px rgba(0,0,0,0.5); transition: 0.3s;
    margin: 0 25px;
}

/* 动画状态 */
.picker-result-box.shuffling {
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent);
    animation: shuffleEffect 0.08s infinite; /* 快速抖动特效 */
}

@keyframes shuffleEffect {
    0% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg); }
    25% { transform: scale(1.02) rotate(-1deg); }
    50% { transform: scale(1.05) rotate(0deg); filter: hue-rotate(30deg); }
    75% { transform: scale(1.02) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg); }
}
.picker-result-box.winner {
    color: var(--bright-gold);
    border-color: var(--bright-gold);
    box-shadow: 0 0 30px rgba(255, 235, 59, 0.3);
    animation: winnerPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.picker-counter-text {
    text-align: center; font-size: 0.75rem; color: rgba(255,255,255,0.3);
    margin-top: 15px; font-family: "JetBrains Mono", monospace;
    opacity: 0; transition: opacity 0.5s ease; /* 初始隐藏，加载数据后显示 */
}

@keyframes winnerPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- 移动端适配 --- */
@media (max-width: 768px) {
    html, body { overflow-y: auto; height: auto; min-height: 100%; justify-content: flex-start; padding-top: 0; }
    
    .carousel-container { height: 50px !important; margin-bottom: 5px !important; }
    
    h1 { margin-top: 20px; margin-bottom: 10px; font-size: 1.8rem; letter-spacing: 2px; }
    
    .glass-panel {
        width: 94%; margin: 10px auto 80px;
        padding: 1.2rem;
        height: 580px; /* 移动端强制统一高度，防止切换闪烁 */
    }
    
    .carousel-btn {
        width: 80px; padding: 6px 0; /* 移动端适配尺寸 */
        font-size: 0.8rem;
    }
    
    .pw-display-box { font-size: 1rem; padding: 12px; min-height: 60px; }

    .picker-result-box { height: 90px; font-size: 2.2rem; margin: 0 10px; }

    .btn-gen-large { padding: 14px; margin-top: 15px; font-size: 1rem; }
    .input-glass { padding: 10px; font-size: 1rem; }
    .picker-options-container { padding: 10px; }
    .fixed-bottom-group { padding-bottom: 10px; gap: 8px; }
    
    .game-ui {
        position: static; width: auto; display: block;
    }
    
    /* 移动端日历居中弹窗 */
    .calendar-popup {
        position: fixed; top: 50% !important; left: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0; width: 90%; max-width: 320px;
    }
    .calendar-popup.active { transform: translate(-50%, -50%) !important; }

}

/* --- 闲人警告弹窗 --- */
.idle-alert-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 99999;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: 0.3s;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.idle-alert-overlay.show { opacity: 1; visibility: visible; }

.idle-alert-box {
    background: rgba(30, 5, 5, 0.95); border: 2px solid #ef4444;
    box-shadow: 0 0 60px rgba(239, 68, 68, 0.6);
    padding: 60px; border-radius: 30px; text-align: center;
    transform: scale(0.5); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%; width: 600px;
}
.idle-alert-overlay.show .idle-alert-box { transform: scale(1); }

.idle-alert-text { font-size: 2.2rem; color: #fff; font-weight:bold; line-height: 1.6; }
.idle-alert-highlight { color:#ef4444; font-size:2.8rem; }

.idle-alert-btn {
    background: #ef4444; color: white; border: none; padding: 12px 35px;
    font-size: 1.1rem; border-radius: 50px; cursor: pointer; margin-top: 25px;
    font-weight: bold; box-shadow: 0 5px 20px rgba(239, 68, 68, 0.4); transition: 0.2s;
    outline: none;
}
.idle-alert-btn:hover { transform: scale(1.05); background: #ff5555; box-shadow: 0 0 30px #ef4444; }
.idle-alert-btn:active { transform: scale(0.95); }

/* --- 通用磨砂弹窗 (Glass Modal) --- */
.glass-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 10000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: 0.3s;
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.glass-modal-overlay.show { opacity: 1; visibility: visible; }

.glass-modal-box {
    background: rgba(20, 15, 30, 0.9); /* 深色磨砂背景 */
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
    padding: 30px; border-radius: 24px; text-align: center;
    transform: scale(0.9); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 85%; width: 340px; color: #fff;
}
.glass-modal-overlay.show .glass-modal-box { transform: scale(1); }

.glass-modal-text { font-size: 1.1rem; margin-bottom: 25px; line-height: 1.6; color: rgba(255,255,255,0.9); }

.glass-modal-actions { display: flex; justify-content: center; gap: 15px; }
.glass-modal-actions button {
    padding: 10px 28px; border-radius: 12px; border: none; cursor: pointer;
    font-size: 0.95rem; transition: 0.2s; font-family: inherit; font-weight: 600;
    outline: none;
}
.glass-modal-actions button:active { transform: scale(0.95); }
.glass-btn-cancel { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); }
.glass-btn-cancel:hover { background: rgba(255,255,255,0.2); color: #fff; }
.glass-btn-confirm { background: var(--accent); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4); }
.glass-btn-confirm:hover { filter: brightness(1.2); transform: scale(1.05); }

/* --- 绚丽光晕特效组件 --- */
.halo-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}
.halo-overlay.active {
    display: block;
    opacity: 1;
}
.halo-box {
    position: absolute;
    overflow: hidden;
    /* 恢复边框遮罩样式，确保线条清晰 */
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    padding: 6px; /* 设定光晕边框宽度 */
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); /* 弹性动画 */
    box-sizing: border-box;
}
.halo-spinner {
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        #ffd700 40deg,
        #00d2ff 120deg,
        #9d4edd 180deg,
        #00d2ff 240deg,
        #ffd700 320deg,
        transparent 360deg
    );
    animation: halo-spin 0.5s linear infinite;
    filter: blur(4px); /* 增加光晕感 */
}
.halo-spinner.slow {
    animation-duration: 3s;
}
@keyframes halo-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}