: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.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.loader {
    width: 52px;
    height: 52px;
    border: 3px solid #e5e7eb;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    animation: rotation 1s linear infinite;
    margin-bottom: 20px;
}

.loader::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid;
    border-color: var(--p-teal) transparent;
}

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

.loading-text {
    color: #64748b;
    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: 180px;
    height: 76px;
    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;
}