/* 重置和基礎樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 莫蘭迪色系 */
    --primary-color: #C9A3A0;        /* 主色 - 柔霧玫瑰紅 */
    --secondary-color: #A67873;      /* 次色 - 乾燥紅棕 */
    --tertiary-color: #D8B8B2;       /* 次次色 - 灰粉杏紅 */
    --accent-dark: #7C5552;          /* 深強調色 - 深莫蘭迪酒紅 */
    --background: #E6D8D5;           /* 淺背景色 - 灰杏米粉 */
    --neutral-color: #B9A7A3;        /* 中性平衡色 - 莫蘭迪灰紫棕 */

    /* 保留原有的功能色 */
    --line-green: #06C755;
    --facebook-blue: #1877F2;

    /* 調整後的語意色彩 */
    --card-background: #FFFFFF;
    --text-primary: #7C5552;         /* 使用深強調色作為主要文字色 */
    --text-secondary: #A67873;       /* 使用次色作為次要文字色 */
    --border-color: #D8B8B2;         /* 使用次次色作為邊框色 */
    --shadow: 0 2px 10px rgba(166, 120, 115, 0.15);
    --shadow-hover: 0 4px 20px rgba(166, 120, 115, 0.25);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', '微軟正黑體', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 登入頁時移除 container padding */
.container:has(#login-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(219, 6, 50, 0.7);
}

/* 輸入頁時移除 container padding */
.container:has(#input-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(255, 230, 160, 0.7);
}

/* 頁面切換 */
.page {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-content {
    background: var(--card-background);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
}

/* 標題樣式 */
h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
}

h1 {
    font-size: 28px;
    text-align: center;
}

h2 {
    font-size: 24px;
    text-align: center;
}

/* Logo 區域 */
.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
}

/* 分享計數器 */
.share-counter {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
    font-size: 18px;
}

.share-counter .count {
    font-size: 32px;
    font-weight: bold;
    display: block;
    margin: 10px 0;
}

/* 登入資訊 */
.login-info {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: var(--tertiary-color);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.login-info p {
    margin: 5px 0;
}

.small-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 按鈕樣式 */
.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--neutral-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--text-secondary);
}

.btn-line {
    background: var(--line-green);
    color: white;
}

.btn-line:hover {
    background: #05B04A;
}

.btn-facebook {
    background: var(--facebook-blue);
    color: white;
}

.btn-facebook:hover {
    background: #1564D1;
}

.line-icon {
    margin-right: 8px;
}

/* 表單樣式 */
.form-group {
    margin: 20px 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
}

.select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.char-counter {
    text-align: right;
    margin-top: 5px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* 載入動畫 */
.loading {
    text-align: center;
    padding: 30px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* 預覽和結果容器 */
.preview-container,
.result-container {
    text-align: center;
    margin: 20px 0;
    background: var(--background);
    padding: 20px;
    border-radius: 12px;
}

.preview-container img,
.result-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.preview-info {
    text-align: center;
    margin: 15px 0;
    color: var(--text-secondary);
}

/* 按鈕群組 */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.action-buttons {
    margin: 20px 0;
}

.share-buttons {
    margin-top: 30px;
    padding: 20px;
    background: var(--background);
    border-radius: 12px;
}

.share-buttons p {
    text-align: center;
    margin-bottom: 15px;
    font-weight: 600;
}

/* 隱藏版解鎖訊息 */
.hidden-message {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-dark) 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
    animation: slideIn 0.5s ease-out;
}

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

.success-animation {
    font-size: 48px;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ========== 結束頁樣式 ========== */
#end-page {
    padding: 0;
    margin: 0;
    background-color: rgba(255, 170, 183, 0.7);
}

.end-page-content {
    background-color: rgba(255, 170, 183, 0.7);
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.end-image {
    height: 100vh;
    height: 100dvh;
    width: auto;
    display: block;
    object-fit: cover;
}

/* 結束頁 container padding 移除 */
.container:has(#end-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(255, 170, 183, 0.7);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .page-content {
        padding: 20px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    .share-counter {
        padding: 15px;
        font-size: 16px;
    }

    .share-counter .count {
        font-size: 28px;
    }

    .button-group {
        grid-template-columns: 1fr;
    }
}

/* 工具類 */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* 錯誤訊息 */
.error-message {
    background: #fff3f3;
    border: 1px solid #e57373;
    color: #c62828;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
}

.error-message p {
    margin: 5px 0;
}

.error-message .small-text {
    color: #ef5350;
    font-size: 14px;
}

/* ========== 輸入頁樣式 ========== */
#input-page {
    padding: 0;
    margin: 0;
    background-color: rgba(255, 230, 160, 0.7);
}

.input-page-content {
    background-image: url('/static/backgrounds/background-2.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5vh 5vw;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 祈願文疏標題區 */
.prayer-header {
    position: relative;
    width: 80vw;
    max-width: 400px;
    margin-bottom: 4vh;
}

.prayer-title-frame {
    width: 100%;
    height: auto;
}

.prayer-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(28px, 8vw, 48px);
    font-weight: bold;
    color: #C4252E;
    letter-spacing: 0.3em;
    white-space: nowrap;
    margin: 0;
    text-shadow: none;
}

/* 說明文字區 */
.instruction-text {
    text-align: center;
    margin-bottom: 4vh;
}

.instruction-text p {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(26px, 6.6vw, 38px);
    font-weight: bold;
    color: #C4252E;
    line-height: 1.6;
    margin: 0;
}

.instruction-text .char-limit {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(18px, 4.5vw, 24px);
    margin-top: 0.5em;
}

/* 輸入框區域 */
.input-area {
    width: 85vw;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3vh;
}

.input-field-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wish-input {
    width: 90%;
    min-height: 3em;
    padding: 1vw 0;
    font-size: clamp(16px, 5vw, 24px);
    font-family: inherit;
    text-align: center;
    background: transparent;
    border: none;
    color: #C4252E;
    caret-color: #C4252E;
    outline: none;
    resize: none;
    overflow: hidden;
    line-height: 1.4;
}

.wish-input::placeholder {
    color: rgba(196, 37, 46, 0.4);
}

.input-underline {
    width: 100%;
    height: auto;
    margin-top: -5px;
}

.input-area .char-counter {
    text-align: center;
    margin-top: 1.5vh;
    font-size: clamp(12px, 3vw, 14px);
    color: rgba(196, 37, 46, 0.6);
}

/* 送出按鈕 */
.generate-btn {
    margin-top: 3vh;
    margin-bottom: 12vh;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.generate-btn img {
    width: 75vw;
    max-width: 320px;
    height: auto;
}

.generate-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 快速許願提示 */
.quick-wish-hint {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(16px, 4vw, 20px);
    color: #C4252E;
    text-align: center;
    margin-bottom: 2vh;
}

/* 快速許願按鈕 */
.quick-wish-buttons {
    display: flex;
    justify-content: center;
    gap: 3vw;
    width: 90vw;
    max-width: 400px;
    padding-bottom: 3vh;
}

.quick-wish-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    flex: 1;
    max-width: 28vw;
    transition: transform 0.2s;
}

.quick-wish-btn img {
    width: 100%;
    height: auto;
}

.quick-wish-btn:hover {
    transform: scale(1.08);
}

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

/* 輸入頁 loading */
#input-page .loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 10vw;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

/* RWD 響應式設計 */

/* 小螢幕 (375px 以下, 高度適配 667px) */
@media (max-width: 375px) {
    .input-page-content {
        padding: 3vh 4vw;
        justify-content: flex-start;
    }

    .prayer-header {
        width: 88vw;
        margin-bottom: 3vh;
    }

    .prayer-title {
        font-size: 26px;
        letter-spacing: 0.18em;
    }

    .instruction-text {
        margin-bottom: 3vh;
    }

    .instruction-text p {
        font-size: 20px;
        line-height: 1.5;
    }

    .instruction-text .char-limit {
        font-size: 16px;
        margin-top: 0.4em;
    }

    .input-area {
        width: 90vw;
        margin-bottom: 2vh;
    }

    .wish-input {
        min-height: 2.8em;
        font-size: 18px;
    }

    .input-area .char-counter {
        margin-top: 1vh;
        font-size: 12px;
    }

    .generate-btn {
        margin-top: 2vh;
        margin-bottom: 6vh;
    }

    .generate-btn img {
        width: 75vw;
        max-width: 280px;
    }

    .quick-wish-hint {
        font-size: 14px;
        margin-bottom: 2vh;
    }

    .quick-wish-buttons {
        width: 90vw;
        gap: 2.5vw;
        padding-bottom: 3vh;
    }

    .quick-wish-btn {
        max-width: 28vw;
    }
}

/* 中螢幕 (376px - 768px, 高度適配 1024px) */
@media (min-width: 376px) and (max-width: 768px) {
    .input-page-content {
        padding: 4vh 5vw;
        justify-content: flex-start;
    }

    .prayer-header {
        width: 75vw;
        max-width: 480px;
        margin-bottom: 4vh;
    }

    .prayer-title {
        font-size: clamp(32px, 7vw, 44px);
        letter-spacing: 0.28em;
    }

    .instruction-text {
        margin-bottom: 4vh;
    }

    .instruction-text p {
        font-size: clamp(22px, 4.5vw, 30px);
        line-height: 1.6;
    }

    .instruction-text .char-limit {
        font-size: clamp(18px, 3.5vw, 22px);
    }

    .input-area {
        width: 78vw;
        max-width: 500px;
        margin-bottom: 3vh;
    }

    .wish-input {
        min-height: 3em;
        font-size: clamp(20px, 4vw, 24px);
    }

    .input-area .char-counter {
        margin-top: 1.5vh;
        font-size: 14px;
    }

    .generate-btn {
        margin-top: 3vh;
        margin-bottom: 8vh;
    }

    .generate-btn img {
        width: 65vw;
        max-width: 340px;
    }

    .quick-wish-hint {
        font-size: clamp(16px, 3vw, 19px);
        margin-bottom: 2.5vh;
    }

    .quick-wish-buttons {
        width: 82vw;
        max-width: 480px;
        gap: 3.5vw;
        padding-bottom: 4vh;
    }

    .quick-wish-btn {
        max-width: 140px;
    }
}

/* 大螢幕 (768px 以上) */
@media (min-width: 769px) {
    .input-page-content {
        padding: 6vh 40px;
    }

    .prayer-header {
        width: 500px;
        max-width: 500px;
    }

    .prayer-title {
        font-size: 48px;
    }

    .instruction-text p {
        font-size: 32px;
    }

    .instruction-text .char-limit {
        font-size: 24px;
    }

    .input-area {
        width: 550px;
        max-width: 550px;
    }

    .wish-input {
        font-size: 24px;
    }

    .generate-btn img {
        width: 360px;
    }

    .quick-wish-hint {
        font-size: 20px;
    }

    .quick-wish-buttons {
        width: 500px;
        max-width: 500px;
        gap: 20px;
    }

    .quick-wish-btn {
        max-width: 150px;
    }
}

/* ========== 等待頁樣式 ========== */
#waiting-page {
    padding: 0;
    margin: 0;
    background-color: rgba(255, 170, 183, 0.7); /* 粉紅底色填滿 */
}

/* 等待頁 container padding 移除 */
.container:has(#waiting-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(255, 170, 183, 0.7);
}

.waiting-page-content {
    background-image: url('/static/backgrounds/background-3.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(255, 170, 183, 0.7);
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 3vh 5vw;
}

/* 廠商商品圖 */
.sponsor-product {
    margin-bottom: 2vh;
}

.sponsor-product img {
    width: 400px;
    height: auto;
}

/* 廠商宣傳文字 */
.sponsor-text {
    text-align: center;
    margin-bottom: 3vh;
}

.sponsor-logo-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.tino-logo {
    height: clamp(41px, 10vw, 58px);
    width: auto;
}

.sponsor-title {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(16px, 4vw, 22px);
    color: #C4252E;
    font-weight: 900;
    text-shadow:
        -1.5px -1.5px 0 white,
        1.5px -1.5px 0 white,
        -1.5px 1.5px 0 white,
        1.5px 1.5px 0 white,
        0 -1.5px 0 white,
        0 1.5px 0 white,
        -1.5px 0 0 white,
        1.5px 0 0 white;
}

.sponsor-desc {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(16px, 4vw, 22px);
    color: #C4252E;
    font-weight: 900;
    margin: 0;
    text-shadow:
        -1.5px -1.5px 0 white,
        1.5px -1.5px 0 white,
        -1.5px 1.5px 0 white,
        1.5px 1.5px 0 white,
        0 -1.5px 0 white,
        0 1.5px 0 white,
        -1.5px 0 0 white,
        1.5px 0 0 white;
}

/* 等待文字 */
.waiting-text {
    text-align: center;
    margin-bottom: 3vh;
}

.waiting-text p {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(18px, 4.5vw, 24px);
    color: #333333;
    font-weight: bold;
    line-height: 1.8;
    margin: 0;
}

/* 進度條容器 */
.progress-container {
    width: 85vw;
    max-width: 500px;
    position: relative;
    padding-top: 60px;
}

/* 媽祖圖示包裝器 */
.mazu-icon-wrapper {
    position: absolute;
    bottom: calc(100% - 80px);
    transition: left 0.3s ease-out;
    left: 0;
    transform: translateX(-50%);
    z-index: 10;
    animation: mazuSway 1s ease-in-out infinite;
}

@keyframes mazuSway {
    0%, 100% {
        transform: translateX(-50%) rotate(-3deg);
    }
    50% {
        transform: translateX(-50%) rotate(3deg);
    }
}

.mazu-icon {
    width: 50px;
    height: auto;
}

/* 進度條背景 */
.progress-bar-bg {
    width: 100%;
    height: 28px;
    background: linear-gradient(to bottom, #DEE1E2, #D2D2D2);
    border-radius: 14px;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Loading 文字共用樣式 */
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 5;
}

/* 底層紅色文字 */
.progress-text-bg {
    color: #DB0032;
}

/* 頂層白色文字（在進度條內） */
.progress-text-fill {
    color: white;
    /* 位置會由 JS 動態計算 */
}

/* 進度條填充 */
.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #FF8300, #DB0032);
    border-radius: 12px;
    transition: width 0.3s ease-out;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* 進度條斜紋效果 */
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        -60deg,
        transparent,
        transparent 8px,
        rgba(255, 255, 255, 0.2) 8px,
        rgba(255, 255, 255, 0.2) 16px
    );
    animation: progressStripes 0.5s linear infinite;
}

@keyframes progressStripes {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 32px 0;
    }
}

/* 等待頁 RWD */
@media (max-width: 375px) {
    .sponsor-product img {
        width: 340px;
    }

    .tino-logo {
        height: 35px;
    }

    .sponsor-title {
        font-size: 14px;
    }

    .sponsor-desc {
        font-size: 14px;
    }

    .waiting-text p {
        font-size: 14px;
    }

    .waiting-text {
        margin-bottom: 2vh;
    }

    .mazu-icon {
        width: 40px;
    }

    .progress-bar-bg {
        height: 24px;
    }

    .progress-text {
        font-size: 12px;
    }

    .progress-container {
        padding-top: 50px;
    }
}

@media (min-width: 376px) and (max-width: 768px) {
    .sponsor-product img {
        width: 400px;
    }

    .tino-logo {
        height: clamp(37px, 8.6vw, 52px);
    }

    .sponsor-title {
        font-size: clamp(15px, 3.8vw, 20px);
    }

    .sponsor-desc {
        font-size: clamp(15px, 3.8vw, 20px);
    }

    .waiting-text p {
        font-size: clamp(16px, 4vw, 20px);
    }

    .mazu-icon {
        width: 55px;
    }

    .progress-bar-bg {
        height: 28px;
    }

    .progress-text {
        font-size: 14px;
    }
}

@media (min-width: 769px) {
    .sponsor-product img {
        width: 480px;
    }

    .tino-logo {
        height: 64px;
    }

    .sponsor-title {
        font-size: 24px;
    }

    .sponsor-desc {
        font-size: 24px;
    }

    .waiting-text p {
        font-size: 24px;
    }

    .mazu-icon {
        width: 60px;
    }

    .progress-bar-bg {
        height: 32px;
    }

    .progress-text {
        font-size: 16px;
    }

    .progress-container {
        padding-top: 70px;
    }
}

/* ========== 中繼頁樣式 ========== */
#transition-page {
    padding: 0;
    margin: 0;
    background-color: rgba(255, 170, 183, 0.7);
}

.transition-page-content {
    background-image: url('/static/backgrounds/background-3.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5vh 5vw;
    cursor: pointer;
}

/* 白色光暈圓圈 */
.glow-circle {
    width: 75vw;
    height: 75vw;
    max-width: 360px;
    max-height: 360px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 8vh;
    box-shadow:
        0 0 8px 8px rgba(255, 255, 255, 1),
        0 0 22px 22px rgba(255, 255, 255, 0.7),
        0 0 36px 36px rgba(255, 255, 255, 0.4),
        0 0 50px 50px rgba(255, 255, 255, 0.15),
        0 0 65px 65px rgba(255, 255, 255, 0.05);
}

/* 祈禱手勢圖示 */
.pray-icon {
    width: 60px;
    height: auto;
    margin-bottom: 12px;
}

.pray-icon img {
    width: 100%;
    height: auto;
}

/* 祝福文字 */
.blessing-text {
    text-align: center;
}

.blessing-text p {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(18px, 4.5vw, 22px);
    color: #C4252E;
    line-height: 1.6;
    margin: 0;
    font-weight: bold;
}

/* 閃爍提示文字 */
.transition-hint {
    text-align: center;
    animation: blinkHint 2s ease-in-out infinite;
}

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

.transition-hint p {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-weight: bold;
    font-size: clamp(18px, 4.5vw, 22px);
    color: #333;
    margin: 0;
    line-height: 1.6;
}

.transition-hint .hint-small {
    font-size: clamp(14px, 3.5vw, 16px);
    margin-top: 8px;
}

/* 中繼頁 container padding 移除 */
.container:has(#transition-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(255, 170, 183, 0.7);
}

/* 中繼頁 RWD */
@media (max-width: 375px) {
    .glow-circle {
        width: 75vw;
        height: 75vw;
        margin-bottom: 6vh;
    }

    .pray-icon {
        width: 48px;
        margin-bottom: 8px;
    }

    .blessing-text p {
        font-size: 16px;
    }

    .transition-hint p {
        font-size: 16px;
    }

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

@media (min-width: 376px) and (max-width: 768px) {
    .glow-circle {
        width: 75vw;
        height: 75vw;
    }

    .pray-icon {
        width: 55px;
    }

    .blessing-text p {
        font-size: clamp(17px, 4vw, 20px);
    }

    .transition-hint p {
        font-size: clamp(17px, 4vw, 20px);
    }
}

@media (min-width: 769px) {
    .glow-circle {
        width: 360px;
        height: 360px;
    }

    .pray-icon {
        width: 70px;
    }

    .blessing-text p {
        font-size: 24px;
    }

    .transition-hint p {
        font-size: 22px;
    }

    .transition-hint .hint-small {
        font-size: 18px;
    }
}

/* ========== 結果頁樣式 ========== */
#result-page,
#hidden-result-page {
    padding: 0;
    margin: 0;
    background-color: #FFFFFF;
}

.result-page-content {
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 禁止滾動 */
}

/* 上半部：白色區塊 */
.result-white-section {
    flex: 1;
    background: #FFFFFF;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    min-height: 0; /* 允許 flex 子項目縮小 */
    overflow: hidden;
}

.result-wallpaper-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-wallpaper-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* 下半部：紅色區塊 */
.result-red-section {
    --red-section-height: 120px;
    --btn-height: calc(var(--red-section-height) * 0.5);
    background: #C4252E;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: var(--red-section-height);
    /* 延伸至全寬 */
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
}

/* 主要操作列（下載按鈕 + 社群 icon） */
.result-main-actions {
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--btn-height);
}

/* 下載按鈕區域 */
.download-btn-wrapper {
    width: 65%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 下載按鈕 */
.download-btn-styled {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-btn-styled img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.download-btn-styled:hover {
    transform: scale(1.05);
}

.download-btn-styled:active {
    transform: scale(0.98);
}

/* 社群分享區域 */
.social-share-group {
    width: 35%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* 分享對話框 */
.share-bubble {
    position: absolute;
    bottom: 65%;
    left: 50%;
    transform: translateX(-50%);
}

.share-bubble img {
    width: 240px;
    height: auto;
}

/* 分享數字疊加層（在「完成祈福」圖片上） */
.share-count-overlay {
    position: absolute;
    top: 37%;
    right: 27%;
    transform: translateY(-50%);
    pointer-events: none;
    text-align: right;
}

.share-count-overlay span {
    color: #C4252E;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* 社群 Icon */
.social-icons {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 100%;
}

.social-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    height: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    transition: transform 0.2s;
}

.social-icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.social-icon-btn:hover {
    transform: scale(1.1);
}

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

/* 隱藏版解鎖訊息 */
#result-page .hidden-message {
    background: rgba(255, 255, 255, 0.95);
    color: #C4252E;
    padding: 15px 25px;
    border-radius: 12px;
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

#result-page .hidden-message h3 {
    color: #C4252E;
    margin-bottom: 5px;
    font-size: 18px;
}

#result-page .hidden-message p {
    font-size: 14px;
    margin: 0;
}

/* 再玩一次按鈕 */
.play-again-btn {
    background: transparent;
    border: 2px solid white;
    color: white;
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.play-again-btn:hover {
    background: white;
    color: #C4252E;
}

/* 結果頁 container padding 移除 */
.container:has(#result-page.active),
.container:has(#hidden-result-page.active) {
    padding: 0;
    max-width: none;
    background-color: #FFFFFF;
}

/* 結果頁 RWD */
@media (max-width: 375px) {
    .result-red-section {
        --red-section-height: 100px;
        padding: 10px;
    }

    .share-bubble img {
        width: 150px;
    }

    .share-count-overlay {
        top: 37%;
        right: 27%;
    }

    .share-count-overlay span {
        font-size: 10px;
    }
}

@media (min-width: 376px) and (max-width: 768px) {
    .result-red-section {
        --red-section-height: 110px;
        padding: 12px;
    }

    .share-bubble img {
        width: 185px;
    }

    .share-count-overlay {
        top: 37%;
        right: 27%;
    }

    .share-count-overlay span {
        font-size: 14px;
    }
}

@media (min-width: 769px) {
    .result-red-section {
        --red-section-height: 130px;
        padding: 15px calc((100vw - 768px) / 2 + 15px);
    }

    .share-bubble img {
        width: 240px;
    }

    .share-count-overlay {
        top: 37%;
        right: 27%;
    }

    .share-count-overlay span {
        font-size: 18px;
    }
}

/* ========== Loading 頁樣式 ========== */
#loading-page {
    padding: 0;
    margin: 0;
    background-color: rgba(255, 230, 160, 0.7);
}

.loading-page-content {
    background-image: url('/static/backgrounds/background-2.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(196, 37, 46, 0.2);
    border-top: 5px solid #C4252E;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(18px, 4.5vw, 24px);
    color: #C4252E;
    font-weight: bold;
    margin: 0;
}

/* Loading 頁 container padding 移除 */
.container:has(#loading-page.active) {
    padding: 0;
    max-width: none;
    background-color: rgba(255, 230, 160, 0.7);
}

/* ========== 登入頁樣式 ========== */
#login-page {
    padding: 0;
    margin: 0;
    background-color: rgba(219, 6, 50, 0.7);
}

.login-page-content {
    background-image: url('/static/backgrounds/background-1.jpg');
    background-size: 100% auto;
    background-position: top center;
    background-repeat: no-repeat;
    background-color: rgba(219, 6, 50, 0.7);
    width: 100%;
    max-width: 768px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    /* 按鈕位置：圖片高度 = 寬度 * 1.778，按鈕約在圖片 85% 高度處 */
    padding-top: calc(100vw * 1.5);
}

/* 主要內容區 */
.login-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* LINE 加入好友按鈕 */
.line-friend-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
}

.line-friend-btn img {
    display: block;
}

.line-friend-btn:hover {
    transform: scale(1.05);
}

.line-friend-btn:active {
    transform: scale(0.98);
}

/* 登入提示文字 */
.login-hint {
    font-family: "DFPYuanW9-B5", "華康粗圓體", "華康圓體", sans-serif;
    font-size: clamp(14px, 3.5vw, 16px);
    color: #FFFFFF;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
    margin: 0;
    text-align: center;
}

/* 登入頁 RWD */
@media (max-width: 375px) {
    .login-page-content {
        padding-top: calc(100vw * 1.45);
    }

    .login-main {
        gap: 10px;
    }

    .line-friend-btn img {
        height: 44px;
    }

    .login-hint {
        font-size: 13px;
    }
}

@media (min-width: 376px) and (max-width: 768px) {
    .login-page-content {
        padding-top: calc(100vw * 1.5);
    }

    .login-main {
        gap: 12px;
    }

    .line-friend-btn img {
        height: 48px;
    }

    .login-hint {
        font-size: 15px;
    }
}

@media (min-width: 769px) {
    .login-page-content {
        /* 768px 寬度時，圖片高度約 1365px */
        padding-top: calc(768px * 1.5);
    }

    .login-main {
        gap: 15px;
    }

    .line-friend-btn img {
        height: 56px;
    }

    .login-hint {
        font-size: 18px;
    }
}

/* ========================================
   隱藏版桌布彈窗樣式
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: linear-gradient(180deg, #FFF5F5 0%, #FFFFFF 100%);
    border-radius: 20px;
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #DB0632 0%, #FF4D6D 100%);
    padding: 15px 20px;
    text-align: center;
}

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

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.hidden-wallpaper-preview {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.hidden-wallpaper-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hidden-wallpaper-hint {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.modal-footer {
    padding: 15px 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.modal-footer .download-btn-styled {
    width: 80%;
    max-width: 240px;
}

.close-modal-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: var(--border-color);
    color: #FFFFFF;
}

/* 模態框 RWD */
@media (max-width: 375px) {
    .modal-content {
        max-width: 95%;
    }

    .modal-header {
        padding: 12px 15px;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .modal-body {
        padding: 15px;
    }

    .hidden-wallpaper-preview {
        max-width: 220px;
    }

    .modal-footer {
        padding: 12px 15px 20px;
    }
}
