:root {
    --primary-pink: #ff1493;
    --secondary-pink: #ff69b4;
    --accent-gold: #ffd700;
    --neon-blue: #00f0ff;
    --neon-purple: #ff00cc;
    --dark-bg: #0a0a12;
    --card-bg: rgba(30, 30, 45, .95);
    --text-white: #ffffff;

    --header-h: 64px;
    --footer-h: 56px;
    --footer-extra: 0px; /* 额外给内容“垫高”的空间，防止被 footer 盖住 */

    /* 安全天视口高度：默认 dvh，支持 svh 则用 svh，最后可被 JS 覆盖 */
    --app-h: 100dvh;
}
@supports (height: 100svh) {
    :root { --app-h: 100svh; }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 关键修复：不再固定 html/body，避免 iOS 地址栏导致的“半屏” */
html, body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    background: var(--dark-bg);
    color: var(--text-white);
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
}

/* 限定到本页，避免与其它页面冲突 */
.home-body { isolation: isolate; }

/* 背景 */
.background-container {
    position: fixed;
    inset: 0;
    z-index: -2;
}
.background-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
   /* opacity: .25;
    filter: brightness(0.5) contrast(1.3);*/
    transition: opacity 0.5s ease;
    pointer-events: none;
}

/* 主体：由 header/footer 高度扣除，保证完整可视 */
.page-wrap {
    position: relative;
    padding-top: var(--header-h);
    /* 额外把底部再抬高一点，避免被固定 footer 压住；同时兼容安全区 */
    padding-bottom: calc(var(--footer-h) + var(--footer-extra) + max(env(safe-area-inset-bottom, 0px), 8px));
    width: 100%;
    height: calc(var(--app-h) - var(--header-h) - var(--footer-h) - var(--footer-extra));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* 3D 场景 */
.card-carousel {
    width: 100%;
    height: 100%;
    perspective: 1800px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    z-index: 1;
}
.carousel-container {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: visible;
    will-change: transform;
}

/* 整卡 */
.card-shell {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease;
    will-change: transform, opacity;
    --roll: 0;
    clip-path: inset(calc(var(--roll) * 46%) 0 calc(var(--roll) * 46%) 0 round 18px);
    cursor: pointer;
    backface-visibility: hidden;
}
.card-shell::after,
.card-shell::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 18%;
    pointer-events: none;
    transition: transform 0.4s ease, opacity 0.4s ease;
}
.card-shell::after {
    top: 0;
    transform: translateY(calc(var(--roll) * 100%));
    background: linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0));
    opacity: calc(0.2 + var(--roll) * 0.7);
    border-radius: 18px 18px 0 0;
}
.card-shell::before {
    bottom: 0;
    transform: translateY(calc(-1 * var(--roll) * 100%));
    background: linear-gradient(0deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0));
    opacity: calc(0.2 + var(--roll) * 0.7);
    border-radius: 0 0 18px 18px;
}

/* 卡片体 */
.card-3d {
    width: 280px;            /* ← 桌面端稍后在 JS 中会拉到 300px */
    height: 400px;           /* ← 桌面端稍后在 JS 中会拉到 430px */
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .7);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-style: preserve-3d;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

/* 前排高光 */
.card-shell.active .card-image::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow:
            0 0 35px 8px rgba(255, 255, 255, .6) inset,
            0 0 50px rgba(255, 255, 255, .4);
    pointer-events: none;
    z-index: 2;
}
.card-shell.active {
    filter: brightness(1.15) saturate(1.1);
    z-index: 999 !important;
}
.card-shell.active .card-3d {
    box-shadow:
            0 20px 60px rgba(0, 0, 0, .8),
            0 0 0 1px rgba(255, 255, 255, .15);
}

/* 图片 */
.card-image {
    width: 100%;
    height: 52%;
    position: relative;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
    flex-shrink: 0;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform;
    object-position: center 30%;   /* ← 从顶部 10% 开始取图 */
}
.card-shell:hover .card-image img { transform: scale(1.05); }

.card-rank {
    position: absolute;
    top: 10px; left: 10px;
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent-gold), #ffed4e);
    color: #000;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, .6);
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, .3);
}

/* 内容 */
.card-content {
    height: 48%;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    background: linear-gradient(180deg, rgba(10, 10, 18, 0.3), rgba(10, 10, 18, 0.7));
    overflow: hidden;
    flex-shrink: 0;
}
.card-name {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 2px;
    background: linear-gradient(45deg, var(--primary-pink), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-romaji {
    font-size: 11px; color: #e0e1e6; font-style: italic;
    margin-bottom: 6px; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9;
}
.card-details {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 4px; margin-bottom: 6px; flex-shrink: 0;
}
.detail-item {
    background: rgba(255, 255, 255, .08);
    padding: 6px 3px; border-radius: 6px; text-align: center;
    border: 1px solid rgba(255, 255, 255, .12);
    min-width: 0; transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    display: flex; flex-direction: column; justify-content: center;
}
.detail-item:hover { background: rgba(255, 255, 255, .12); transform: translateY(-1px); }
.detail-label { font-size: 9px; color: #b8bac0; margin-bottom: 2px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-value { font-weight: 700; font-size: 10px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-white); }
.card-price {
    background: linear-gradient(135deg, var(--primary-pink), var(--neon-purple));
    color: #fff; padding: 8px; border-radius: 8px; text-align: center;
    font-weight: 800; font-size: 12px;
    box-shadow: 0 6px 20px rgba(255, 20, 147, .4);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, .2);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* 正前方卡片 */
.card-shell.active { --roll: 0 !important; }
.card-shell.active .card-content { padding: 12px 10px; gap: 8px; }
.card-shell.active .card-name { font-size: 18px; }
.card-shell.active .card-romaji { font-size: 12px; }
.card-shell.active .detail-label { font-size: 10px; }
.card-shell.active .detail-value { font-size: 11px; }
.card-shell.active .card-price { font-size: 13px; padding: 9px; }

/* 翻转动画 */
@keyframes cardFlip {
    0% { transform: rotateY(0) scale(1); }
    50% { transform: rotateY(90deg) scale(0.95); }
    100% { transform: rotateY(0) scale(1); }
}

/* 空数据 */
.empty-message { text-align: center; padding: 80px 20px; color: rgba(255, 255, 255, .6); }
.empty-message i { font-size: 80px; margin-bottom: 25px; opacity: .4; }
.empty-message p { font-size: 20px; font-weight: 500; }

/* 移动端优化 - 再小一点 + 再抬高一点 footer 间距，避免覆盖 */
@media (max-width: 768px) {
    :root {
        --header-h: 56px;
        --footer-h: 64px;          /* 移动端 footer 通常更高 */
        --footer-extra: 18px;      /* 额外抬高，避免被盖住 */
    }
    .card-carousel { perspective: 1200px; }

    /* 比之前再小一点点 */
    .card-3d {
        width: 210px;
        height: 305px;
        backdrop-filter: none;
        box-shadow: 0 10px 28px rgba(0,0,0,.55);
    }
    .card-shell::before,
    .card-shell::after { opacity: .35; }

    .card-image { height: 50%; }
    .card-content { height: 50%; padding: 8px 6px; gap: 5px; }
    .card-name { font-size: 13px; margin-bottom: 1px; }
    .card-romaji { font-size: 9px; margin-bottom: 4px; }
    .card-details { gap: 3px; margin-bottom: 4px; }
    .detail-item { padding: 4px 2px; backdrop-filter: none; }
    .detail-label { font-size: 7px; margin-bottom: 1px; }
    .detail-value { font-size: 8px; }
    .card-price { font-size: 10px; padding: 6px; }
    .card-rank { width: 28px; height: 28px; font-size: 11px; }
    .card-shell.active .card-name { font-size: 14px; }
    .card-shell.active .card-romaji { font-size: 10px; }
    .card-shell.active .detail-label { font-size: 8px; }
    .card-shell.active .detail-value { font-size: 9px; }
    .card-shell.active .card-price { font-size: 11px; padding: 7px; }
}

/* 超小屏幕：继续小一丢丢 */
@media (max-width: 480px) {
    .card-3d { width: 192px; height: 280px; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
    .card-content { padding: 6px 5px; gap: 4px; }
    .card-name { font-size: 12px; }
    .card-romaji { font-size: 8px; }
    .detail-label { font-size: 6px; }
    .detail-value { font-size: 7px; }
    .card-price { font-size: 9px; padding: 5px; }
    .card-rank { width: 24px; height: 24px; font-size: 10px; }

    /* 关闭昂贵 clip-path 与额外高光，防卡顿 */
    .card-shell { clip-path: none; }
    .card-shell.active .card-image::before { display: none; }
}

/* 性能优化：减少重绘 */
.card-shell, .carousel-container {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* footer 确保显示（若公共样式使用 fixed） */
.footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
}

/* 让图片/卡片在切换时的滤镜/透明更顺滑 */
.card-image img {
    transition: filter 220ms ease, opacity 220ms ease;
    will-change: filter;
}

/* blur 由 JS 写入的 CSS 变量控制（单位 px）*/
.card-shell .card-image img {
    filter: blur(var(--blur, 0px));
}

