* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    background: #000;
}

.container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* 视频容器 */
#video-container {
    z-index: 10;
    background: #000;
    position: relative;
}

#intro-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    pointer-events: auto;
}

/* 视频遮罩层（用于iOS点击播放） */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 12;
    background: transparent;
    cursor: pointer;
    display: none;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.video-overlay.active {
    display: block;
}

/* 视频播放按钮 */
.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    opacity: 1;
    visibility: visible;
}

.video-play-btn.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
}

.play-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #333;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.play-icon:active {
    transform: scale(0.9);
}

.play-text {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* 主内容容器 */
#main-container {
    z-index: 5;
    background: #000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 背景图片 */
.bg-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/bg.png?v=1.1');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 2;
    pointer-events: none;
}

/* 图片容器 */
.image-container {
    position: absolute;
    width: 90%;
    max-width: 500px;
    z-index: 1;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* 图片拖动层 */
.image-drag-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 200px;
    z-index: 1;
    pointer-events: all;
    touch-action: none;
    cursor: move;
    background: transparent;
}

.selected-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    transform-origin: center center;
    transition: box-shadow 0.2s ease, outline 0.2s ease;
    outline: none;
}

/* 图片拖动时的高亮边框 */
.selected-image.dragging,
.selected-image.interacting {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.4), 0 4px 20px rgba(102, 126, 234, 0.6);
    outline: 3px solid #667eea;
    outline-offset: -3px;
}

/* 图片控制按钮 */
.image-controls {
    position: absolute;
    top: -50px;
    right: 0;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    user-select: none;
}

.control-btn:active {
    transform: scale(0.9);
    background: rgba(102, 126, 234, 1);
}

.image-drag-handle {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 35px;
    height: 35px;
    background: rgba(255, 107, 107, 0.9);
}

/* 文字输入区域 */
.text-input-wrapper {
    position: absolute;
    width: 90%;
    max-width: 500px;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
}

.text-input-wrapper.hidden {
    display: none;
}

/* 拖动手柄 */
.drag-handle {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    background: rgba(102, 126, 234, 0.8);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: move;
    z-index: 10;
    touch-action: none;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.blessing-text {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    font-size: 18px;
    line-height: 1.6;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    outline: none;
    color: #333;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    touch-action: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    margin-bottom: 10px;
}

.blessing-text:empty:before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
}

/* 确定按钮 */
.confirm-btn {
    width: 100%;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    outline: none;
}

.confirm-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* 文字层容器 */
.text-layers-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* 文字层 */
.text-layer {
    position: absolute;
    z-index: 3;
    pointer-events: all;
    cursor: move;
    user-select: none;
    transform-origin: center center;
}

.text-layer-content {
    padding: 0 20%;
    background-image: var(--text-bg-image, url('assets/w.png?v=1'));
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    border-radius: 8px;
    color: #333;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    min-width: 50px;
    min-height: 30px;
    transition: box-shadow 0.2s ease;
}

/* 文字层拖动时的高亮边框 */
.text-layer.dragging .text-layer-content,
.text-layer.interacting .text-layer-content {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3), 0 4px 20px rgba(102, 126, 234, 0.5);
    outline: none;
}

.text-layer-controls {
    position: absolute;
    top: -30px;
    right: 0;
    display: flex;
    gap: 5px;
    z-index: 10;
}

.text-control-btn {
    width: 30px;
    height: 30px;
    background: rgba(102, 126, 234, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
}

.text-control-btn:active {
    transform: scale(0.9);
}

.blessing-text:focus {
    border-color: #ff6b6b;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.3);
}

.blessing-text::placeholder {
    color: #999;
}

/* 按钮容器 */
.button-container {
    position: fixed;
    width: 90%;
    max-width: 500px;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2001;
    text-align: center;
}

/* 二维码容器 */
.qrcode-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    cursor: move;
    touch-action: none;
    user-select: none;
    transition: box-shadow 0.2s ease;
}

/* 二维码拖动时的高亮边框 */
.qrcode-container.dragging {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3), 0 4px 20px rgba(102, 126, 234, 0.5);
}

.qrcode-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 5px;
}

@media (max-width: 480px) {
    .qrcode-container {
        width: 80px;
        height: 80px;
        bottom: 15px;
        right: 15px;
        padding: 6px;
    }
}

.select-btn {
    width: 100%;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    outline: none;
}

.select-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* 提示信息 */
.hint {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    z-index: 2000;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.hint:active {
    background: rgba(0, 0, 0, 0.5);
    transform: translateX(-50%) scale(0.95);
}

/* 加载提示 */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 20px 40px;
    border-radius: 10px;
    z-index: 1000;
    font-size: 16px;
}

/* 预览图片模态框 */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f8f8;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.close-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    background: #eee;
    color: #333;
}

.close-btn:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-image {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 10px;
    user-select: auto;
    -webkit-user-select: auto;
    -webkit-touch-callout: default;
    -webkit-user-drag: auto;
}

.preview-hint {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
    text-align: center;
}

/* 音乐控制按钮 */
.music-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.music-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.music-toggle-btn:active {
    transform: scale(0.95);
}

/* .music-toggle-btn.muted .music-icon::before {
    content: '🔇';
} */

.music-icon {
    font-size: 24px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}

@media (max-width: 480px) {
    .music-toggle-btn {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
        font-size: 20px;
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .blessing-text {
        font-size: 16px;
        min-height: 100px;
        padding: 12px;
    }

    .select-btn {
        font-size: 16px;
        padding: 12px 25px;
    }

    .hint {
        font-size: 12px;
    }
}

/* 长按效果 */
.image-container:active {
    opacity: 0.8;
}

/* 拖动时的样式 */
.text-input-wrapper.dragging {
    opacity: 0.9;
    z-index: 100;
}

.image-container.dragging {
    opacity: 0.9;
    z-index: 100;
}

