/* Pull Game - Dramatic Card Reveal */

/* ============ OVERLAY & CONTAINER ============ */
.pull-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.pull-machine {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    max-height: 800px;
}

/* ============ HEADER ============ */
.pull-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.pull-title {
    font-size: 1.4rem;
    margin: 0;
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #fbbf24);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

.pull-karma-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(251, 191, 36, 0.15);
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.pull-karma-display .karma-icon {
    font-size: 1.2rem;
}

.pull-karma-display .karma-amount {
    font-weight: bold;
    font-size: 1.1rem;
    color: #fbbf24;
}

.pull-karma-display .karma-delta {
    position: absolute;
    right: -8px;
    top: -8px;
    font-size: 0.85rem;
    font-weight: bold;
    opacity: 0;
    transition: all 0.3s;
}

.pull-karma-display .karma-delta.show {
    opacity: 1;
    animation: floatUp 1.5s ease forwards;
}

.pull-karma-display .karma-delta.positive { color: #4ade80; }
.pull-karma-display .karma-delta.negative { color: #f87171; }

/* ============ STAGE ============ */
.pull-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    perspective: 1000px;
    overflow: hidden;
}

.pull-stage::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.3) 100%);
    pointer-events: none;
}

.pull-stage.pulling::before {
    animation: stagePulse 0.5s ease infinite alternate;
}

/* ============ CARD CONTAINER ============ */
.card-container {
    position: relative;
    width: 180px;
    height: 260px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.card-container:hover:not(.active) {
    transform: scale(1.02);
}

.card-container.active {
    cursor: default;
}

/* ============ THE CARD ============ */
.pull-card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-back,
.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, #2a2a4a 0%, #1a1a2e 100%);
    border: 3px solid #3a3a5a;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.card-pattern {
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255,255,255,0.02) 10px,
        rgba(255,255,255,0.02) 20px
    );
}

.card-symbol {
    font-size: 4rem;
    color: rgba(255,255,255,0.3);
    text-shadow: 0 0 20px rgba(255,255,255,0.2);
    z-index: 1;
}

.card-front {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f23 100%);
    border: 3px solid var(--rarity-color, #888);
    transform: rotateY(180deg);
}

/* ============ CARD GLOW ============ */
.card-glow {
    position: absolute;
    inset: -20px;
    border-radius: 20px;
    pointer-events: none;
    transition: box-shadow 0.2s ease;
}

/* ============ CARD CRACKS ============ */
.card-cracks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 12px;
}

.crack-line {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: var(--crack-length, 50%);
    background: linear-gradient(to top, var(--crack-color, #fff), transparent);
    transform-origin: bottom center;
    transform: rotate(var(--crack-angle, 0deg));
    opacity: 0;
    animation: crackAppear 0.3s ease forwards;
    animation-delay: var(--animation-delay, 0ms);
    box-shadow: 0 0 10px var(--crack-color, #fff);
}

.card-cracks.intense .crack-line {
    width: 6px;
    box-shadow: 0 0 20px var(--crack-color, #fff), 0 0 40px var(--crack-color, #fff);
}

/* ============ CARD STATES ============ */
.pull-card.anticipating {
    animation: cardFloat 0.8s ease-in-out infinite, cardShake 0.15s ease-in-out infinite;
}

.pull-card.cracking {
    animation: cardShake 0.1s ease-in-out infinite;
}

.pull-card.revealing {
    animation: cardReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.pull-card.resetting {
    animation: cardReset 0.4s ease forwards;
}

/* ============ REVEAL CONTENT ============ */
.reveal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    animation: revealContentPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reveal-rarity {
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--rarity-color);
    text-shadow: 0 0 10px var(--rarity-color);
}

.reveal-icon-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reveal-icon {
    font-size: 3.5rem;
    z-index: 1;
    animation: iconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reveal-icon-glow {
    position: absolute;
    font-size: 3.5rem;
    filter: blur(15px);
    opacity: 0.5;
    color: var(--rarity-color);
    animation: iconGlowPulse 1s ease-in-out infinite;
}

.reveal-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    text-align: center;
}

.reveal-desc {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    text-align: center;
}

/* ============ PARTICLES ============ */
.particles-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.anticipation-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: particleToCenter var(--animation-duration, 0.8s) ease-in forwards;
}

.reveal-particle {
    position: absolute;
    border-radius: 50%;
    animation: particleExplode 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ============ SILHOUETTE TEASE ============ */
.silhouette-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.silhouette-layer.active {
    opacity: 1;
}

.silhouette-icon {
    font-size: 6rem;
    filter: blur(8px);
    animation: silhouetteFlash 0.3s ease;
}

/* ============ INSTRUCTION ============ */
.pull-instruction {
    text-align: center;
    padding: 8px;
    transition: opacity 0.3s;
}

.pull-instruction.hidden {
    opacity: 0;
    pointer-events: none;
}

.instruction-text {
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
    animation: pulseOpacity 2s ease-in-out infinite;
}

/* ============ BUTTONS ============ */
.pull-buttons {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.pull-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 40px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.pull-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.pull-btn:active:not(:disabled) {
    transform: translateY(0);
}

.pull-btn:disabled,
.pull-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #444;
    box-shadow: none;
}

.pull-btn .btn-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
}

.pull-btn .btn-cost {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
}

/* ============ RATES ============ */
.pull-rates {
    text-align: center;
}

.rate-toggle {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.2s;
}

.rate-toggle:hover {
    color: rgba(255,255,255,0.8);
}

.rates-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    margin-top: 8px;
}

.rates-panel.open {
    max-height: 200px;
    padding: 12px;
}

.rate-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.rate-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.rate-name {
    flex: 1;
    text-align: left;
    font-size: 0.85rem;
}

.rate-pct {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
}

.rate-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    font-style: italic;
}

/* ============ FOOTER ============ */
.pull-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 8px;
}

.pull-btn-secondary {
    padding: 10px 20px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pull-btn-secondary:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

/* ============ INVENTORY OVERLAY ============ */
.inventory-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    z-index: 100;
}

.inventory-panel {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 20px;
    max-width: 90%;
    max-height: 80%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inventory-title {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    color: #fbbf24;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.inventory-item {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--rarity-color);
    border-radius: 10px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5), 0 0 10px var(--rarity-color);
}

.inventory-item .item-icon {
    font-size: 1.8rem;
}

.inventory-item .item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.8);
    background: rgba(0,0,0,0.6);
    padding: 1px 4px;
    border-radius: 4px;
}

.inventory-panel .empty {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255,255,255,0.5);
    padding: 20px;
}

.inventory-close {
    align-self: center;
}

/* ============ DEBUG ============ */
.pull-debug {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.75rem;
}

.pull-debug .debug-title {
    font-weight: bold;
    margin-bottom: 6px;
}

.pull-debug .debug-row {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.pull-debug .debug-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-size: 0.7rem;
}

.pull-debug .debug-btn:hover {
    background: #555;
}

.pull-debug .debug-stats {
    color: rgba(255,255,255,0.6);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-20px); opacity: 0; }
}

@keyframes stagePulse {
    from { opacity: 0.3; }
    to { opacity: 0.5; }
}

@keyframes cardFloat {
    0%, 100% { transform: translateY(0) rotateX(0); }
    50% { transform: translateY(-8px) rotateX(3deg); }
}

@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes cardReveal {
    0% { transform: rotateY(0) scale(1); }
    50% { transform: rotateY(90deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

@keyframes cardReset {
    0% { transform: rotateY(180deg) scale(1); }
    100% { transform: rotateY(0deg) scale(1); opacity: 0.8; }
}

@keyframes crackAppear {
    from { opacity: 0; height: 0; }
    to { opacity: 1; height: var(--crack-length, 50%); }
}

@keyframes revealContentPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes iconBounce {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes iconGlowPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

@keyframes particleToCenter {
    from { 
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    to { 
        transform: translate(var(--end-x, 0), var(--end-y, 0)) scale(0);
        opacity: 0;
    }
}

@keyframes particleExplode {
    0% { 
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% { 
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(0);
        opacity: 0;
    }
}

@keyframes silhouetteFlash {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.3; transform: scale(1); }
}

@keyframes pulseOpacity {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* ============ SCREEN EFFECTS (from shared, but pull-specific adjustments) ============ */
.screen-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
    animation: flashFade 0.4s ease forwards;
}

@keyframes flashFade {
    0% { opacity: var(--flash-opacity, 0.3); }
    100% { opacity: 0; }
}

.mega-shake {
    animation: megaShake 0.5s ease !important;
}

@keyframes megaShake {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    10% { transform: translate(-5px, -3px) rotate(-1deg); }
    20% { transform: translate(5px, 3px) rotate(1deg); }
    30% { transform: translate(-4px, 2px) rotate(-0.5deg); }
    40% { transform: translate(4px, -2px) rotate(0.5deg); }
    50% { transform: translate(-3px, 3px) rotate(-0.5deg); }
    60% { transform: translate(3px, -1px) rotate(0.5deg); }
    70% { transform: translate(-2px, 2px) rotate(0); }
    80% { transform: translate(2px, -1px) rotate(0); }
    90% { transform: translate(-1px, 1px) rotate(0); }
}

/* Firework particles */
.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: fireworkBurst 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fireworkBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--dx, 0), var(--dy, 0)) scale(0);
        opacity: 0;
    }
}
