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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f0f0;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    /* Limit width for larger screens */
    margin: 0 auto;
    position: relative;
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p1/bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center top;
    overflow: hidden;
}

/* Logo Area */
.logo {
    position: absolute;
    top: 2%;
    right: 5%;
    width: 25%;
    z-index: 10;
    text-align: right;
    animation: fadeInDown 1s ease-out forwards;
}

.logo img {
    width: 100%;
    height: auto;
}

/* Title Area */
.title {
    position: absolute;
    top: 18%;
    /* Adjusted slightly for new logo position */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    z-index: 20;
    animation: titleEnter 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, float-title 4s ease-in-out infinite 1s;
}

.title img {
    width: 100%;
    height: auto;
}

/* Floating Camera - Now positioned at bottom right as requested */
.camera-icon {
    position: absolute;
    bottom: -2%;
    right: -5%;
    width: 45%;
    /* Slightly larger */
    z-index: 25;
    transform-origin: bottom right;
    animation: float-foreground 5s ease-in-out infinite;
}

.camera-icon img {
    width: 100%;
    height: auto;
    display: block;
}

/* People */
.people {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60%;
    z-index: 15;
    display: flex;
    justify-content: flex-end;
    animation: slideInRight 1s ease-out forwards, breathe 4s ease-in-out infinite 1s;
}

.people img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Button */
.btn-enter {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    z-index: 30;
    cursor: pointer;
    animation: pulse 2s infinite, btn-entrance 0.5s ease-out 1s backwards;
}

.btn-enter img {
    width: 100%;
    height: auto;
    display: block;
}

/* Animations */
@keyframes titleEnter {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float-title {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

@keyframes float-foreground {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(5px) rotate(1deg);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

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

    50% {
        transform: translateX(-50%) scale(1.05);
    }

    100% {
        transform: translateX(-50%) scale(1);
    }
}

@keyframes btn-entrance {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* Responsive adjustments for very tall screens (iPhone X+) */
@media (min-aspect-ratio: 9/16) {
    .container {
        background-size: cover;
    }
}

/* --- P2: Intro / Rules --- */
.page-p2 {
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p2/p2_bg.png');
    display: block;
    position: relative;
}

/* 蓝色半透明面板 */
.rules-container {
    position: absolute;
    top: 12%;
    left: 9%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 420px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.7) 70%, rgba(255, 255, 255, 0) 100%);
    border-radius: 2px;
    padding: 25px 20px;
    animation: fadeInUpStatic 0.8s ease-out forwards;
    color: #1e65b2;
    z-index: 5;
    text-align: center;
}

/* 文本样式重置 */
.rules-text-block {
    font-size: 16px;
    line-height: 1.6;
    text-align: left;
    color: #1e65b2;
}

.rules-text-block .highlight {
    color: #ff4400;
    font-weight: bold;
}

.rules-text-block p {
    margin-bottom: 10px;
}

/* P2 Bottom Area for Camera and Button */
.p2-bottom-area {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    height: auto;
    z-index: 20;
    pointer-events: none;
}

.p2-camera {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 45%;
    z-index: 10;
    pointer-events: none;
}

.p2-camera img {
    width: 100%;
    height: auto;
    display: block;
}

.p2-btn-start {
    position: absolute;
    bottom: 28%;
    left: 50%;
    transform: translateX(-50%);
    width: 48%;
    z-index: 30;
    cursor: pointer;
    pointer-events: auto;
    animation: pulse 2s infinite;
}

.p2-btn-start img {
    width: 100%;
    height: auto;
    display: block;
}

/* Animation for static position */
@keyframes fadeInUpStatic {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- P3: Scene Selection --- */
.page-p3 {
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p3/p3_bg.png');
    position: relative;
    /* overflow-y: auto; Removed, internal scrolling now */
}

.scene-title {
    text-align: center;
    color: #fff;
    font-size: 22px;
    position: absolute;
    top: 10%;
    width: 100%;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    z-index: 10;
}

.scene-selection-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 90%;

    background: rgba(164, 111, 74, 0.86);
    /* Semi-transparent blue */

    /* White stroke */

    /* Rounded rectangle */
    overflow-y: auto;
    /* Scroll inside the box */
    padding: 15px;

}

.scene-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding-bottom: 20px;
}

/* P3: Scene Selection Item Styling */
.scene-item {
    background: transparent;
    /* Changed from white to transparent */
    border-radius: 10px;

    /* box-shadow: 0 2px 5px rgba(0,0,0,0.1); Removed shadow from container */
    cursor: pointer;
    transition: transform 0.2s;
    border: none;
    /* Handled by internal border or removed */
    position: relative;
    /* For absolute positioning of label */
    margin-bottom: 10px;
}

.scene-item.active {
    /* border-color: #FF7E5F;  Removed border highlight style */
    transform: scale(0.98);
}

.scene-item.active img {
    border: 3px solid #FF7E5F;
    /* Highlight image instead */
}

.scene-item:active {
    transform: scale(0.95);
}

.scene-item img {
    width: 100%;
    height: 100px;
    /* Adjust height as needed */
    object-fit: cover;
    display: block;
    border-radius: 5px;
    /* Slight radius for image */
    box-sizing: border-box;
    border: 3px solid transparent;
    /* Reserve space for border */
}

.scene-name {
    position: absolute;
    bottom: -8px;
    /* Overlap the bottom of the image */
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 15px;
    /* Pill shape */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    z-index: 5;
    min-width: 80%;
    /* Ensure it's not too narrow */
    text-align: center;
}

.p3-btn-start {
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    z-index: 30;
    cursor: pointer;
    animation: pulse 2s infinite;
}

.p3-btn-start img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- P4: Upload --- */
.page-p4 {
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p4/p4_bg.png');
    position: relative;
}

.upload-panel {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    background: rgba(63, 192, 255, 0.86);
    /* Blue translucent box */
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    /* White outer glow */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Upload Area */
.upload-area {
    width: 100%;
    height: 200px;
    position: relative;
    margin-bottom: 20px;
    cursor: pointer;
    overflow: hidden;
    border-radius: 10px;
}

.upload-bg-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    /* Slight dim for contrast */
}

.upload-icon-img {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
    object-fit: contain;
}

.upload-text {
    font-size: 16px;
    color: #fff;
    font-weight: bold;
}

.user-photo-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Contain to show full photo */
    z-index: 3;
    background: #000;
    /* Black bg for aspect ratio gaps */
}

/* Instructions */
.upload-instructions {
    width: 100%;
    color: #fff;
    font-size: 13px;
    line-height: 1.6;
    text-align: left;
}

.upload-instructions p {
    margin-bottom: 5px;
}

/* Bottom Buttons */
.p4-btn-group {
    position: absolute;
    bottom: 8%;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    z-index: 30;
}

.p4-btn {
    width: 40%;
    cursor: pointer;
    transition: transform 0.1s;
}

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

.p4-btn img {
    width: 100%;
    height: auto;
    display: block;
}

/* Modal Styles */
.custom-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 30px;
    cursor: pointer;
    font-weight: bold;
}

/* Loading Modal */
.loading-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    animation: zoomIn 0.3s ease-out;
}

.loading-spinner {
    margin-bottom: 20px;
}

.spinner-icon {
    font-size: 40px;
    animation: spin 2s infinite linear;
    display: inline-block;
}

.loading-text {
    color: #333;
    font-size: 16px;
    line-height: 1.5;
    font-weight: bold;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- P5: Editor / Preview --- */
.page-p5 {
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p5/p5_bg.png');
    position: relative;
}

.editor-main-content {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 80%;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.editor-preview-container {
    width: 100%;
    padding: 8px;
    background: rgba(63, 192, 255, 0.86);
    border: 2px solid #8ed8ff;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    height: auto;
}

.editor-preview {
    width: 100%;
    padding-bottom: 61.5%;
    /* Align with P7 poster frame (317:195) */
    height: 0;
    background: #fff;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.editor-bg-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    z-index: 0;
}

.editor-scene-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

.editor-title-area {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

.editor-current-scene-name {
    display: inline-block;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    /* Add the subtitle styling if needed */
}

.editor-current-scene-name::after {
    /* Optional: placeholder for English name if needed like in design */
    /* content: 'Scenic Spot Name'; */
    /* display: block; font-size: 10px; opacity: 0.8; */
}

.editor-grid-container {
    width: 100%;
    min-height: 0;
    height: 300px;
    padding: 12px;
    background: rgba(63, 192, 255, 0.86);
    border: 2px solid #8ed8ff;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
}

.editor-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Bottom Buttons P5 */
.p5-btn-group {
    position: absolute;
    bottom: 5%;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    z-index: 30;
}

.p5-btn {
    width: 40%;
    cursor: pointer;
    transition: transform 0.1s;
}

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

.p5-btn img {
    width: 100%;
    height: auto;
    display: block;
}

.editor-scene-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 3 columns */
    gap: 15px;
}

.editor-scene-item {
    cursor: pointer;
    position: relative;
    transition: transform 0.1s;
}

.editor-scene-item:active {
    transform: scale(0.95);
}

.editor-scene-item img {
    width: 100%;
    height: 90px;
    /* Smaller thumbnails */
    object-fit: cover;
    border-radius: 5px;
    display: block;
    margin-bottom: 5px;
    /* Space for caption */
}

.editor-scene-name {
    background: #fff;
    color: #000;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* P5 Control Frame */
.control-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px dotted red;
    box-sizing: border-box;
    pointer-events: none;
    /* Let touches pass through to image for moving */
}

.btn-close {
    position: absolute;
    top: -15px;
    left: -15px;
    width: 30px;
    height: 30px;
    background: red;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    /* Enable clicking */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-resize {
    position: absolute;
    bottom: -15px;
    right: -15px;
    width: 30px;
    height: 30px;
    background: #007bff;
    /* Blue */
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: nwse-resize;
    pointer-events: auto;
    /* Enable dragging */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-resize svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* --- P6: Text Selection --- */
.page-p6 {
    background-image: url('https://yhy-1251131015.cos.ap-guangzhou.myqcloud.com/ih5/images/p6/p6_bg.png');
}

.greeting-list-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 90%;
    height: 70%;
    overflow-y: auto;
    padding: 10px;
}

.greeting-item {
    background: rgba(63, 192, 255, 0.86);
    /* Blue fill with transparency */
    border: 2px dashed #fff;
    /* White dashed border */
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    text-align: left;
    line-height: 1.5;
}

.greeting-item.active {
    background: rgb(39, 152, 209);
    /* Darker blue active state */
    transform: scale(1.02);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    border-style: solid;
    /* Solid border for active */
}

.p6-btn-start {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    z-index: 30;
    cursor: pointer;
    transition: transform 0.1s;
}

.p6-btn-start:active {
    transform: translateX(-50%) scale(0.95);
}

.p6-btn-start img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- P7: Final Poster Display --- */
.page-p7 {
    background-color: #000;
    /* Dark bg for image viewing */
}

.save-tip {
    text-align: center;
    color: #fff;
    font-size: 14px;
    margin-top: 20px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    position: absolute;
    bottom: 20px;
    width: 100%;
}

/* Animations Helper */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}