/*
 * 照片合成小游戏 · A「回忆礼盒」样式系统
 * 规范：奶油底 #FFF8EE、奶白表面 #FFFCF6、珊瑚红 #E65342、鼠尾草绿 #7F8D6A、深棕文字 #342C27
 */

:root {
    --bg-page: #FFF8EE;
    --bg-surface: #FFFCF6;
    --text-primary: #342C27;
    --text-muted: #827568;
    --color-primary: #E65342;
    --color-primary-dark: #D74737;
    --color-sage: #7F8D6A;
    --color-sage-light: #EDF0E4;
    --color-sage-dark: #56654A;
    --color-border: #E6D8C6;
    --color-danger: #D44232;
    --color-gold: #B79B51;
    --color-gold-light: #F6E7BC;

    --radius-btn: 16px;
    --radius-card: 22px;
    --radius-photo: 10px;

    --motion-fast: 180ms;
    --motion-standard: 240ms;
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-page);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text-primary);
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    background-image: radial-gradient(circle at 50% 0%, #FFFDF9 0%, var(--bg-page) 75%);
    box-shadow: 0 0 50px rgba(120, 99, 66, 0.12);
}

canvas#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ================= 顶部轻奢仪表盘 (A01 规范) ================= */
.top-dashboard {
    position: absolute;
    top: 8px;
    left: 14px;
    right: 14px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* 顶部第一行：游戏标题 + 体力爱心胶囊 */
.dashboard-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-title-pill {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
    pointer-events: auto;
}

/* 体力胶囊：珊瑚红 88x32 rx=16 */
.stamina-pill {
    background-color: var(--color-primary);
    color: #ffffff;
    height: 32px;
    padding: 0 14px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(230, 83, 66, 0.28);
    transition: transform 0.12s;
    pointer-events: auto;
}

.stamina-pill:active {
    transform: scale(0.95);
}

.stamina-pill .heart-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 顶部第二行：4 枚鼠尾草绿按钮 + 回忆进度 */
.dashboard-row-mid {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-actions {
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 15px;
    background-color: var(--color-sage);
    border: none;
    color: #ffffff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(127, 141, 106, 0.25);
    transition: transform 0.12s, background-color 0.12s;
}

.action-btn:active {
    transform: scale(0.92);
    background-color: var(--color-sage-dark);
}

.action-btn svg, .action-btn span {
    pointer-events: none;
}

/* 回忆收集进度胶囊 */
.album-progress-pill {
    background-color: var(--color-sage-light);
    color: var(--color-sage-dark);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    pointer-events: auto;
    cursor: pointer;
    border: 1px solid rgba(127, 141, 106, 0.15);
}

/* 顶部第三行：得分大卡片 (354x67 rx=18) */
.score-dashboard {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 8px 16px;
    box-shadow: 0 8px 16px rgba(120, 99, 66, 0.08);
    pointer-events: auto;
}

.score-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.score-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.score-val {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.score-divider {
    width: 1px;
    height: 38px;
    background: var(--color-border);
}

/* ================= 底部浮动引流入口 (对齐 01 母版 coral red pill) ================= */
.viral-floating-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    background: linear-gradient(135deg, #EB6551 0%, #D74737 100%);
    border: none;
    height: 32px;
    padding: 0 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #FFFFFF;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(230, 83, 66, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.viral-floating-bar:active {
    transform: translateX(-50%) scale(0.96);
    box-shadow: 0 2px 8px rgba(230, 83, 66, 0.4);
}

.viral-gift-icon {
    width: 16px;
    height: 16px;
    stroke: #FFFFFF;
    flex-shrink: 0;
}

.viral-text {
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 700;
}

.viral-arrow {
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 700;
    margin-left: -2px;
}

/* 针对小屏手机 (如 iPhone SE/8) 或紧凑视口的高度自适应 */
@media (max-height: 720px) {
    .top-dashboard {
        top: 4px;
        gap: 5px;
    }
    .game-title-pill {
        font-size: 15px;
        max-width: 170px;
    }
    .stamina-pill {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
    }
    .action-btn {
        width: 34px;
        height: 34px;
    }
    .action-btn svg {
        width: 17px;
        height: 17px;
    }
    .album-progress-pill {
        height: 24px;
        padding: 0 10px;
        font-size: 10px;
    }
    .score-dashboard {
        height: 52px;
        padding: 4px 14px;
        border-radius: 14px;
    }
    .score-label {
        font-size: 10px;
    }
    .score-val {
        font-size: 22px;
    }
    .score-divider {
        height: 28px;
    }
}

/* ================= 通用弹窗模态层 (Modal Overlays) ================= */
.modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(52, 44, 39, 0.52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s var(--ease-out);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 弹窗通用卡片容器 */
.modal-card {
    position: relative;
    width: 100%;
    max-width: 358px;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 36px rgba(52, 44, 39, 0.22);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.24s var(--ease-out);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

/* 关闭按钮 */
.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F4E9D8;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    z-index: 5;
}

.modal-close-btn:active {
    transform: scale(0.9);
    background: var(--color-border);
}

/* ================= 1. 成就战报结算卡 (02-成就战报) ================= */
.share-poster-card {
    position: relative;
    width: 100%;
    max-width: 358px;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: 0 18px 40px rgba(52, 44, 39, 0.25);
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.24s var(--ease-out);
}

.modal-overlay.active .share-poster-card {
    transform: translateY(0) scale(1);
}

.poster-header-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.poster-header-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* 主视觉照片展示相框 */
.hero-photo-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    background: #FFFCF6;
    border-radius: 16px;
    border: 2px solid var(--color-gold);
    padding: 6px;
    margin-bottom: 12px;
    box-shadow: 0 8px 18px rgba(183, 155, 81, 0.22);
}

.hero-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}

.hero-photo-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-gold);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.funny-title-tag {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    background: #FFF0ED;
    border: 1px solid rgba(230, 83, 66, 0.2);
    border-radius: 12px;
    padding: 6px 14px;
    margin: 6px 0 14px;
}

/* 战报三列数据 */
.score-stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    background: #FFF9F0;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 10px 4px;
    margin-bottom: 14px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-primary);
}

.stat-val.best {
    color: var(--color-gold);
}

.stat-val.combo {
    color: var(--color-sage-dark);
}

/* 昵称打榜行 */
.ranking-submit-box {
    width: 100%;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ranking-input {
    flex: 1;
    height: 44px;
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-btn);
    padding: 0 14px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.ranking-input:focus {
    border-color: var(--color-primary);
}

.ranking-btn {
    height: 44px;
    padding: 0 18px;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(230, 83, 66, 0.25);
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap;
}

.ranking-btn:active {
    transform: scale(0.96);
    background: var(--color-primary-dark);
}

.ranking-status-msg {
    width: 100%;
    padding: 8px;
    background: #E8F5E9;
    border: 1px solid #C8E6C9;
    border-radius: 10px;
    font-size: 12px;
    color: #2E7D32;
    font-weight: 600;
    margin-bottom: 12px;
    display: none;
}

/* 按钮组 */
.btn-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-viral {
    width: 100%;
    height: 46px;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(230, 83, 66, 0.3);
    transition: background 0.15s, transform 0.12s;
}

.btn-viral:active {
    background: var(--color-primary-dark);
    transform: scale(0.97);
}

.btn-secondary {
    width: 100%;
    height: 44px;
    background: #FFFDF9;
    color: var(--text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.btn-secondary:active {
    background: #F4E9D8;
    transform: scale(0.97);
}

.poster-tip {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ================= 2. 濒死复活弹窗 (12-弹窗-濒死复活) ================= */
.near-death-card {
    position: relative;
    width: 100%;
    max-width: 350px;
    background: var(--bg-surface);
    border: 2px solid var(--color-danger);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 36px rgba(212, 66, 50, 0.22);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.countdown-box {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 12px 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-svg-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}

.countdown-num {
    font-size: 32px;
    font-weight: 900;
    color: var(--color-danger);
}

/* ================= 3. 好友排行榜弹窗 (09-弹窗-好友排行榜) ================= */
.leaderboard-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 36px rgba(52, 44, 39, 0.22);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
}

.modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.lb-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    padding-right: 2px;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #FFFDF9;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 8px 12px;
}

.lb-item.top-1 {
    background: #FFFBF0;
    border-color: #F6E7BC;
}

.lb-rank {
    width: 28px;
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    color: var(--text-muted);
}

.lb-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lb-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-milestone {
    font-size: 10px;
    color: var(--text-muted);
}

.lb-score {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
}

/* ================= 4. 回忆相册图鉴 (10-弹窗-回忆相册) ================= */
.gallery-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: 0 16px 36px rgba(52, 44, 39, 0.22);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
}

.gallery-progress-bar {
    width: 100%;
    height: 8px;
    background: #F4E9D8;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 14px;
}

.gallery-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-sage), var(--color-primary));
    border-radius: 4px;
    transition: width 0.3s;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 330px;
    overflow-y: auto;
    padding-right: 2px;
    margin-bottom: 8px;
}

.gallery-item {
    position: relative;
    background: #FFFDF9;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.12s;
}

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

.gallery-item.locked {
    filter: grayscale(0.85);
    opacity: 0.65;
}

.gallery-thumb-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #F4E9D8;
    margin-bottom: 4px;
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lock-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(52, 44, 39, 0.45);
    font-size: 20px;
}

.gallery-lvl-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary);
}

.gallery-lvl-desc {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ================= 5. 照片放大查看 (11-照片放大查看) ================= */
.zoom-card {
    position: relative;
    width: 100%;
    max-width: 330px;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.zoom-photo-box {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 18px;
    border: 3px solid var(--color-gold);
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(183, 155, 81, 0.25);
}

.zoom-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ================= 6. 分享引导蒙层 (14-弹窗-分享引导) ================= */
.share-guide-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    background: rgba(52, 44, 39, 0.85);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 24px 24px 0 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease-out);
}

.share-guide-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.share-guide-arrow {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.share-guide-text {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.6;
    text-align: right;
}

/* ================= 动画关键帧 (Tokens & Motion) ================= */
@keyframes score-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes warning-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 66, 50, 0); }
    50% { box-shadow: 0 0 18px 2px rgba(212, 66, 50, 0.45); }
}

@keyframes launcher-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.score-updated {
    animation: score-pop var(--motion-standard) var(--ease-out);
}

.near-death-card {
    animation: warning-pulse 900ms ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
