/* 保持原有样式，追加新的样式 */
body {
    margin: 0;
    padding: 0;
    background-color: #111;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: white;
    font-family: 'Arial', sans-serif;
}

/* 外层容器：全屏黑色背景 */
#screen-container {
    position: relative;
    background-color: #000;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Three.js 画布：保持设计宽高比，居中显示 */
#bg-canvas {
    position: absolute;
    /* top 和 left 由 JavaScript 设置 */
    z-index: 1;
}

/* 
 * 固定尺寸 UI 层 - 3840x785 设计分辨率
 * JavaScript 会计算缩放比例并应用 transform
 * 所有子元素使用固定像素值，整体像图片一样缩放
 */
#ui-layer {
    position: absolute;
    width: 3840px;
    height: 785px;
    left: 0;
    top: 0;
    transform-origin: top left;
    z-index: 10;
    pointer-events: none;
    /* 调试时可以加边框看边界 */
    /* border: 2px solid red; */
}

/* 需要交互的元素恢复事件 */
#ui-layer .qr-panel,
#ui-layer .control-panel,
#ui-layer #user-info-panel {
    pointer-events: auto;
}

.zone {
    position: absolute;
    top: 0;
    /* 固定像素尺寸：785x785 正方形 */
    width: 785px;
    height: 785px;
    background: transparent;
    border: none;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

.left-zone {
    left: 0;
}

.right-zone {
    right: 0;
}

.hidden-panel {
    display: none !important;
}

.qr-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    background: transparent;
    padding: 40px;
}

.qr-code {
    /* 固定像素尺寸 */
    width: 350px;
    height: 350px;
    border: none;
    filter: none;
    border-radius: 0;
}

.qr-text {
    color: #fff;
    /* 固定字体大小 */
    font-size: 36px;
    font-weight: bold;
    letter-spacing: 6px;
    text-shadow: none;
    margin-top: 20px;
    font-family: 'Microsoft YaHei', sans-serif;
    text-align: center;
    line-height: 1.4;
}

.zone-label {
    text-align: center;
    font-size: 1.5rem;
    color: #666;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

/* File Upload Styling */
input[type="file"] {
    display: none;
}

.custom-file-upload, .custom-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 15px 0;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-sizing: border-box;
    text-decoration: none;
    text-align: center;
}

.custom-file-upload {
    border: 2px solid #ff0000;
    background: rgba(255, 0, 0, 0.1);
    color: #ff0000;
}

.custom-file-upload:hover {
    background: #ff0000;
    color: white;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.custom-btn {
    border: 2px solid #fff;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: inherit;
}

.custom-btn:hover {
    background: #fff;
    color: #000;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.safe-area {
    /* Hidden visual guide, can be enabled for debugging */
    pointer-events: none;
    position: absolute;
    left: 20.44%;
    right: 20.44%;
    top: 0;
    bottom: 0;
    border: 1px solid rgba(255, 0, 0, 0.1);
}

/* 欢迎横幅样式 - 固定像素尺寸 */
.welcome-banner {
    position: absolute;
    bottom: 80px;
    left: 1920px; /* 画布中心 3840/2 */
    transform: translateX(-50%);
    width: 1200px;
    height: 120px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 0, 0, 0.2) 15%, rgba(255, 0, 0, 0.2) 85%, transparent 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    backdrop-filter: blur(2px);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 15%, black 85%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, black 15%, black 85%, transparent 100%);
}

.welcome-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.welcome-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(30px);
}

.welcome-content {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: 8px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 2;
}

.text-white {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.text-name {
    color: #ff0033;
    font-size: 80px;
    font-weight: 900;
    text-shadow: 0 0 15px #ff0033, 0 0 30px rgba(255, 0, 51, 0.6);
    font-family: 'Microsoft YaHei', sans-serif;
    display: inline-block;
    padding-bottom: 4px;
}

.glow-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    /* 线条也改为渐变，两端消失 */
    background: linear-gradient(90deg, transparent 0%, #ff0033 20%, #ff0033 80%, transparent 100%);
    box-shadow: 0 0 10px 1px #ff0033;
    opacity: 0.8;
}

.glow-line.top {
    top: 0;
}

.glow-line.bottom {
    bottom: 0;
}

/* 扫光动画 */
.welcome-banner::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%; /* 起始位置在容器左侧外 */
    width: 50%;  /* 光束宽度 */
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-25deg);
    animation: shine 3s infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes shine {
    0% { left: -60%; } /* 从容器左侧开始 */
    40% { left: 160%; } /* 移动到容器右侧结束 */
    100% { left: 160%; } /* 停留一段时间 */
}

/* --- 信息展示相关样式 - 固定像素尺寸 --- */

/* 全屏暗遮罩 - 覆盖整个 UI 层 */
.dim-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 3840px;
    height: 785px;
    background: rgba(0, 0, 0, 0.7);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.dim-overlay.active {
    opacity: 1;
}

/* 科幻信息面板 - 固定像素定位 */
.user-info-panel {
    position: absolute;
    /* 画布中心 1920px，头像在左侧 -200px 处，宽 500px，面板在右边 */
    top: 392px; /* 785/2 = 392.5 */
    left: 2100px; /* 1920 + 头像偏移和间距 */
    transform: translateY(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 25px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s ease;
    text-shadow: 0 0 8px rgba(255, 0, 51, 0.5);
}

.user-info-panel.active {
    opacity: 1;
}

.info-line {
    display: flex;
    align-items: baseline;
    gap: 15px;
    background: linear-gradient(90deg, rgba(255,0,0,0.1), transparent);
    padding: 8px 15px;
    border-left: 3px solid #ff0033;
}

.info-label {
    color: #888;
    font-size: 36px;
    letter-spacing: 4px;
}

.info-value {
    color: #fff;
    font-size: 64px;
    font-weight: bold;
    text-transform: uppercase;
}

.info-danmaku {
    margin-top: 20px;
    font-size: 48px;
    color: #ff0033;
    padding: 20px 25px;
    border: 2px solid rgba(255, 0, 51, 0.3);
    background: rgba(0, 0, 0, 0.5);
    max-width: 800px;
    min-height: 70px;
    position: relative;
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.1);
}

.info-danmaku::before {
    content: 'WISH_';
    position: absolute;
    top: -14px;
    left: 15px;
    background: #000;
    color: #888;
    font-size: 18px;
    padding: 0 8px;
}

.cursor {
    animation: blink 1s infinite;
    color: #ff0033;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.tech-deco-line {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #ff0033, transparent);
    margin-top: 15px;
    position: relative;
}

.tech-deco-line::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 8px;
    height: 8px;
    background: #ff0033;
    box-shadow: 0 0 8px #ff0033;
}

/* --- 顶部控制面板 --- */
.top-control-bar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    padding: 10px;
}

.settings-trigger {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    border: 1px solid #333;
    backdrop-filter: blur(5px);
}

.settings-panel {
    display: none;
    position: absolute;
    top: 50px;
    right: 10px;
    background: #111;
    border: 1px solid #333;
    padding: 20px;
    border-radius: 10px;
    min-width: 250px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.8);
}

.top-control-bar:hover .settings-panel {
    display: block;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #ddd;
    font-size: 14px;
}

.setting-divider {
    height: 1px;
    background: #333;
    margin: 15px 0;
}

.lottery-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lottery-btn {
    background: linear-gradient(90deg, #330000, #660000);
    border: 1px solid #ff0033;
    color: #fff;
    padding: 10px;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s;
}

.lottery-btn:hover {
    background: linear-gradient(90deg, #660000, #990000);
    box-shadow: 0 0 10px rgba(255, 0, 51, 0.5);
}

.clear-data-btn {
    background: #333;
    border: 1px solid #555;
    color: #aaa;
    padding: 8px;
    width: 100%;
    cursor: pointer;
    border-radius: 5px;
    font-size: 12px;
}

.clear-data-btn:hover {
    background: #444;
    color: #fff;
}

/* --- 弹幕相关样式 --- */
.danmaku-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50; /* 在头像之上，但低于信息面板 */
    pointer-events: none;
    overflow: hidden;
    display: none; /* 默认隐藏 */
}

.danmaku-layer.active {
    display: block;
}

.danmaku-item {
    position: absolute;
    left: 100%; /* 从屏幕右侧外开始 */
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 0, 51, 0.5);
    border-radius: 50px;
    padding: 10px 30px 10px 10px;
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.3);
    white-space: nowrap;
    animation: danmaku-move linear forwards;
    /* 启用 GPU 加速 */
    will-change: transform;
}

.danmaku-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
}

.danmaku-content {
    display: flex;
    flex-direction: column;
}

.danmaku-name {
    font-size: 24px;
    color: #ff0033;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

.danmaku-text {
    font-size: 32px;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

@keyframes danmaku-move {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-5000px); /* 移动足够远的距离以移出屏幕 */
    }
}

/* 按钮样式 */
.control-btn {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 5px;
    transition: all 0.3s;
}

.control-btn:hover {
    background: #444;
    border-color: #ff0033;
    color: #ff0033;
}

/* --- 音乐控制 --- */
.music-controls {
    padding: 10px 0;
}

.music-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.music-btns {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.music-btns .music-btn {
    flex: 1;
    margin-bottom: 0;
}

.music-btn.playing {
    background: #ff0033;
    border-color: #ff0033;
    color: #fff;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #888;
}

.volume-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #ff0033;
    border-radius: 50%;
    cursor: pointer;
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #ff0033;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* --- 抽奖全屏遮罩 --- */
.lottery-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: background 0.5s ease; /* 添加过渡效果 */
}

.lottery-overlay.active {
    display: flex;
}

/* 跑马灯阶段：背景变透明，让用户看到 Canvas */
.lottery-overlay.transparent {
    background: rgba(0, 0, 0, 0); 
    pointer-events: none; /* 允许点击穿透（虽然跑马灯时不需要点击） */
}

/* 通用隐藏类 */
.lottery-countdown.hidden,
.lottery-result.hidden {
    display: none !important;
}

.lottery-countdown {
    font-size: 250px;
    font-weight: 900;
    color: #ff0033;
    text-shadow: 0 0 80px rgba(255, 0, 51, 1), 0 0 150px rgba(255, 0, 51, 0.6);
    font-family: 'Arial Black', 'Arial', sans-serif;
    animation: pulse-count 0.5s ease-in-out infinite;
    z-index: 2002;
}

@keyframes pulse-count {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 中奖结果 */
.lottery-result {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 60px;
    z-index: 2001;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.lottery-result.show {
    opacity: 1;
}

.winner-avatar {
    width: 450px;
    height: 450px;
    object-fit: cover;
    border: 6px solid #ff0033;
    border-radius: 15px;
    box-shadow: 0 0 60px rgba(255, 0, 51, 0.8), 0 0 120px rgba(255, 0, 51, 0.4);
    animation: winner-pulse 2s ease-in-out infinite;
}

@keyframes winner-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 60px rgba(255, 0, 51, 0.8); }
    50% { transform: scale(1.02); box-shadow: 0 0 100px rgba(255, 0, 51, 1); }
}

.winner-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.prize-label {
    font-size: 40px;
    color: #fff;
    letter-spacing: 5px;
}

.winner-name {
    font-size: 80px;
    font-weight: bold;
    color: #ff0033;
    text-shadow: 0 0 20px rgba(255, 0, 51, 0.8);
    margin: 10px 0;
}

.winner-info {
    font-size: 24px;
    color: #888;
}

.prize-divider {
    font-size: 20px;
    color: #555;
    margin: 10px 0;
}

.prize-name {
    font-size: 50px;
    font-weight: bold;
    color: #ffd700; /* 金色 */
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    background: linear-gradient(180deg, #fff, #ffd700);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 10px;
    border: 2px solid #ffd700;
    border-radius: 10px;
}

.lottery-close-btn {
    margin-top: 40px;
    padding: 15px 40px;
    font-size: 24px;
    background: #ff0033;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 0, 51, 0.5);
    transition: all 0.3s;
}

.lottery-close-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(255, 0, 51, 0.8);
}

/* 确认对话框样式复用，无需更改 */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    border: 2px solid #ff0033;
    border-radius: 10px;
    padding: 30px;
    z-index: 10000;
    text-align: center;
    color: white;
}
.confirm-dialog.show {
    display: block;
}
.confirm-dialog h3 {
    margin: 0 0 20px 0;
    color: #ff0033;
}
.confirm-dialog button {
    margin: 5px;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}
.confirm-dialog .btn-yes {
    background: #ff0033;
    color: white;
}
.confirm-dialog .btn-no {
    background: #333;
    color: white;
}
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 9998;
}
.overlay.show {
    display: block;
}

/* --- 游戏按钮 --- */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-btn {
    display: block;
    background: linear-gradient(90deg, #003366, #0066cc);
    border: 1px solid #00ccff;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s;
}

.game-btn:hover {
    background: linear-gradient(90deg, #0066cc, #0099ff);
    box-shadow: 0 0 10px rgba(0, 204, 255, 0.5);
    transform: scale(1.05);
}

.game-btn.jump-game {
    background: linear-gradient(90deg, #660033, #cc0066);
    border: 1px solid #ff66cc;
}

.game-btn.jump-game:hover {
    background: linear-gradient(90deg, #cc0066, #ff3399);
    box-shadow: 0 0 10px rgba(255, 102, 204, 0.5);
}
