body {
    margin: 0;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(to bottom right, #0f0c29, #302b63, #24243e);
    perspective: 1000px;
    transform-style: preserve-3d;
    font-family: Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    /* 移除移动端点击高亮 */
    touch-action: manipulation;
    /* 优化触摸操作 */
}

/* 确保全屏覆盖 */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #191970;
    /* 深蓝色背景 */
    /* 添加以下属性确保背景完全覆盖 */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.container, body {
    background: #181848; /* 你的主色调 */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
    /* 下面这句有时能缓解 */
    perspective: 1000px;
}


/* 移动设备适配 */
@media screen and (max-width: 768px) {
    .input-box {
        width: 90%;
        padding: 15px;
        max-width: 320px;
    }

    .input-box h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .input-box input {
        font-size: 14px;
        padding: 8px;
        margin-bottom: 8px;
    }

    .input-box button {
        padding: 10px 20px;
        font-size: 14px;
    }

    #front .text {
        font-size: 60px;
    }

    #middle .text {
        font-size: 36px;
    }

    #back .text {
        font-size: 18px;
    }

    #qrcode-container {
        width: 85%;
        max-width: 300px;
        padding: 15px;
    }

    #qrcode {
        width: 180px;
        height: 180px;
    }

    #qrcode-tip {
        font-size: 14px;
    }

    #qrcode-container button {
        padding: 10px;
        font-size: 14px;
    }

    /* 移动端减小旋转角度，减少黑边 */
    .container {
           /* 减小旋转角度，减少黑边 */
           transform: rotateY(8deg) rotateX(5deg);
           scale: 1.05;
    }

    /* 确保移动端没有滚动条和溢出 */
    body,
    html {
        overflow: hidden;
        position: fixed;
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
    }
     /* 增加层之间的距离 */
     #front { transform: translateZ(150px) }
     #middle { transform: translateZ(0px) }
     #back { transform: translateZ(-150px) }
     
     /* 调整文字大小，使分层更明显 */
     #front .text { font-size: 64px !important; }
     #middle .text { font-size: 36px !important; }
     #back .text { font-size: 18px !important; }
}

/* 小屏幕设备进一步优化 */
@media screen and (max-width: 480px) {
    #front .text {
        font-size: 42px;
    }

    #middle .text {
        font-size: 28px;
    }

    #back .text {
        font-size: 16px;
    }

    .heart {
        width: 24px;
        height: 24px;
    }
}


.input-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    width: 80%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.input-box h3 {
    color: #4a0a8a;
    margin-bottom: 15px;
    font-size: 18px;
}

.input-box input {
    width: calc(100% - 22px);
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 16px;
    color: #333;
}

.input-box input::placeholder {
    color: #999;
}

.input-tip {
    color: #777;
    font-size: 14px;
    margin: 5px 0 15px 0;
    font-style: italic;
}

.input-box button {
    background: #4a0a8a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 5px;
    transition: background 0.3s;
    width: 100%;
}

.input-box button:hover {
    background: #6a0daa;
}

/* 确保容器不会限制内容显示 */
.container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: visible;
    transform-style: preserve-3d;
}
.layer {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: visible;
}


.text {
    position: absolute;
    white-space: nowrap;
    font-weight: bold;
    left: calc(100vw * var(--start-pos));
    bottom: 0;
    transform: translateX(-50%) translate3d(0, 0, 0);
    opacity: 0;
    animation: scroll 20S linear infinite;
    will-change: transform, opacity;
    /* 添加硬件加速 */
    backface-visibility: hidden;
    perspective: 1000;
    -webkit-font-smoothing: antialiased;
    /* 确保文字不会被截断 */
    max-width: 90vw;
    overflow: visible;
    text-overflow: clip;
}


.text.animation-completed {
    display: none;
}

#front .text {
    font-size: 88px;
}

#middle .text {
    font-size: 48px;
}

#back .text {
    font-size: 24px;
}

/* 修改动画，确保文字完全显示 */
@keyframes scroll {
    0% {
        transform: translate3d(-50%, 0, 0) scale(1);
        opacity: 0;
    }

    5% {
        opacity: 1;
    }

    95% {
        opacity: 1;
    }

    100% {
        transform: translate3d(-50%, -200vh, 0) scale(0.5);
        opacity: 0.3;
    }
}

#front {
    transform: translateZ(200px);
    /* 增加z-index确保前层显示在最前面 */
    z-index: 3;
}

#middle {
    transform: translateZ(0px);
    /* 设置中间层的z-index */
    z-index: 2;
}

#back {
    transform: translateZ(-200px);
    /* 设置后层的z-index */
    z-index: 1;
}

.heart {
    position: absolute;
    width: 30px;
    height: 30px;
    background: none;
    transform: translate3d(0, 0, 0);
    animation: floatImg 10s linear infinite;
    opacity: 0.9;
    will-change: transform;
    z-index: 10;
    contain: layout style paint;
}

@keyframes floatImg {
    0% {
        transform: translateY(100vh);
        opacity: 0.9;
    }

    100% {
        transform: translateY(-100vh);
        opacity: 0;
    }
}

#qrcode-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* 确保移动端可以长按 */
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
    touch-action: auto;
}

#saveBtn {
    margin-top: 20px;
    padding: 12px 24px;
    background: #4a0a8a;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

#saveBtn:hover {
    background: #6a0daa;
}

#qrcode {
    margin: 0 auto;
    width: 300px; /* 增加宽度 */
    height: 300px; /* 增加高度 */
    /* 确保移动端可以长按 */
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
    touch-action: auto;
}

#qrcode canvas {
    /* 确保移动端可以长按 */
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
    touch-action: auto;
}

#qrcode-tip {
    margin: 15px 0;
    font-size: 16px;
    color: #333;
    /* 修改为深色文字，提高可读性 */
}

#qrcode-container button {
    background: #4a0a8a;
    color: white;
    border: none;
    padding: 12px 16px; /* 增加按钮大小，方便点击 */
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
    margin: 10px auto; /* 增加间距 */
    width: 80%;
    max-width: 200px;
    display: block; /* 确保按钮独占一行 */
}

#qrcode-container button:hover {
    background: #6a0daa;
}