:root {
    --p-teal: #2dd4bf;
    --p-cyan: #22d3ee;
    --p-pink: #f9a8d4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Miku Loader Container */
.miku-loader-container {
    position: relative;
    width: min(400px, 80vw);
    aspect-ratio: 6 / 1;
    margin-bottom: 20px;
}

/* Miku Layer - 定义遮罩模具 */
.miku-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-mask-image: url('/data/loading.webp');
    mask-image: url('/data/loading.webp');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* 底层：浅青色 (未加载) */
.miku-base {
    background-color: #bfece8;
    opacity: 0.5;
    z-index: 1;
}

/* 进度条外层包装器 */
.miku-progress-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    overflow: hidden;
    z-index: 2;
    transition: width 0.3s ease-out;
}

/* 阶段1: 快速加载到90% */
.miku-progress-wrapper.loading {
    animation: miku-load-fast 0.5s ease-out forwards;
}

/* 阶段2: 在90%处等待 */
.miku-progress-wrapper.waiting {
    width: 90%;
}

/* 阶段3: 加载完成，到100% */
.miku-progress-wrapper.complete {
    width: 100%;
}

/* 进度条颜色层 */
.miku-progress-color {
    width: min(400px, 80vw);
    height: 100%;
    background-color: #39c5bb;
    filter: drop-shadow(0 0 5px #39c5bb);
}

/* 快速加载动画：0.5秒内从0%到90% */
@keyframes miku-load-fast {
    0% {
        width: 0%;
    }

    100% {
        width: 90%;
    }
}

.loading-text {
    color: #2a9d94;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* Card Thumbnail */
.card-thumbnail {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 2.5px solid;
    flex-shrink: 0;
    background: #f9fafb;
    transition: transform 0.2s ease;
}

.card-thumbnail:hover {
    transform: scale(1.05);
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rarity-4 {
    border-color: #f9a8d4;
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    box-shadow: 0 2px 8px rgba(249, 168, 212, 0.3);
}

.rarity-3 {
    border-color: #fbbf24;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.rarity-2 {
    border-color: #d1d5db;
    background: #f9fafb;
}

.rarity-birthday {
    border-color: #a78bfa;
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.3);
}

/* Pull Count Badge */
.pull-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Rate Up Badge */
.rate-up-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 8px;
    padding: 2px 5px;
    border-radius: 0 8px 0 6px;
    font-weight: bold;
    z-index: 10;
}

/* Rarity Stars */
.rarity-stars {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 8px 0 3px;
    gap: 1px;
}

.star {
    font-size: 9px;
    line-height: 1;
}

.star-4 {
    color: #f9a8d4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.star-3 {
    color: #fbbf24;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.star-birthday {
    color: #a78bfa;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Pool Banner */
.pool-banner {
    width: 130px;
    aspect-ratio: 2.37;
    height: auto;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    flex-shrink: 0;
}

.pool-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Pool Card - Horizontal Layout */
.pool-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pool-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Selection Card for Unknown Pools */
.selection-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.selection-card:hover {
    border-color: #14b8a6;
    background: #f0fdfa;
}

.selection-card.selected {
    border-color: #14b8a6;
    background: linear-gradient(135deg, #f0fdfa, #ccfbf1);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

/* Checkbox Styles */
.custom-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.custom-checkbox.checked {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    border-color: #0d9488;
}

.custom-checkbox svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.custom-checkbox.checked svg {
    opacity: 1;
    transform: scale(1);
}

/* Pull Preview */
.pull-preview {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pull-preview-card {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid;
}

/* Action Bar */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

/* Merged Pool Indicator */
.merged-pool-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

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

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

.animate-slide-up {
    animation: slideUp 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Gacha Selector Modal Animation */
@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

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

.animate-slide-up-modal {
    animation: slideUpModal 0.3s ease forwards;
}

/* Mobile Adjustments */
@media (max-width: 360px) {
    .pool-card .flex {
        flex-direction: column;
    }

    .pool-banner {
        width: 100%;
        aspect-ratio: 2.5;
    }

    .p-3.flex-shrink-0 {
        padding-bottom: 0;
        width: 100%;
    }
}