/* Scroll Selection UI - Vampire Survivors style */
.scroll-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: scrollFadeIn 0.3s ease-out;
}

.scroll-selection-overlay.active {
    display: flex;
}

.scroll-selection-container {
    max-width: 900px;
    width: 90%;
    text-align: center;
    position: relative;
    z-index: 1;
}

.scroll-title h2 {
    font-family: 'SFPixelate', 'Impact', 'Arial Black', sans-serif;
    font-size: 56px;
    font-weight: bold;
    color: #ffff00;
    text-shadow: 
        3px 3px 0px #000000,
        0 0 15px rgba(255, 255, 0, 0.8);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 40px 0 30px 0;
    animation: scrollPulse 1s ease-in-out infinite alternate;
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer */
}

.scroll-title p {
    font-family: 'Arial', sans-serif;
    font-size: 18px;
    color: #cccccc;
    margin-bottom: 40px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.scroll-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 0 auto 30px auto;
    max-width: 800px;
}

/* VS-style scroll cards */
.scroll-option {
    background: linear-gradient(135deg, 
        rgba(40, 20, 80, 0.9) 0%,
        rgba(60, 30, 120, 0.8) 100%
    );
    border: 3px solid #4a0e78;
    border-radius: 12px;
    padding: 20px;
    cursor: var(--cm-cursor-action, pointer);
    position: relative;
    transition: all 0.2s ease-out;
    animation: scrollCardSlideIn 0.4s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 180px;
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer */
}

.scroll-option:nth-child(1) { animation-delay: 0.1s; }
.scroll-option:nth-child(2) { animation-delay: 0.2s; }
.scroll-option:nth-child(3) { animation-delay: 0.3s; }

/* Number badge */
.scroll-option::before {
    content: attr(data-number);
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ffff00, #ffaa00);
    color: #000;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Impact', 'Arial Black', sans-serif;
    padding: 8px;
    border-radius: 50%;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 0, 0.6);
    z-index: 2;
}

/* Icon area */
.scroll-option-icon {
    font-size: 48px;
    color: #ffff00;
    text-shadow: 
        0 0 10px rgba(255, 255, 0, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    filter: drop-shadow(0 0 8px rgba(255, 255, 0, 0.5));
    margin-bottom: 15px;
    transition: all 0.3s ease;
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer */
}

/* Text content */
.scroll-option-name {
    font-family: 'Impact', 'Arial Black', sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.scroll-option-description {
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    color: #cccccc;
    line-height: 1.3;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

/* Hover effect */
.scroll-option:hover:where(body:not(.gamepad-active) *) {
    border-color: #00ff88;
    transform: scale(1.05);
    box-shadow: 
        0 0 30px rgba(0, 255, 136, 0.5),
        0 8px 25px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, 
        rgba(0, 255, 136, 0.2) 0%,
        rgba(40, 20, 80, 0.9) 100%
    );
}

.scroll-option:hover:where(body:not(.gamepad-active) *)::before {
    background: linear-gradient(135deg, #00ff88, #ffff00);
    transform: scale(1.1);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 25px rgba(0, 255, 136, 0.8);
}

.scroll-option:hover:where(body:not(.gamepad-active) *) .scroll-option-icon {
    color: #00ff88;
    text-shadow: 
        0 0 15px rgba(0, 255, 136, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    filter: drop-shadow(0 0 12px rgba(0, 255, 136, 0.7));
    animation: scrollIconFloat 0.6s ease-in-out infinite alternate;
}

/* Selected state */
.scroll-option.selected {
    border-color: #ffff00;
    transform: scale(1.08);
    box-shadow: 
        0 0 40px rgba(255, 255, 0, 0.8),
        0 0 80px rgba(255, 255, 0, 0.4),
        0 10px 30px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, 
        rgba(255, 255, 0, 0.3) 0%,
        rgba(255, 165, 0, 0.2) 50%,
        rgba(40, 20, 80, 0.9) 100%
    );
    animation: scrollSelectedGlow 1s ease-in-out infinite alternate;
}

.scroll-option.selected::before {
    background: linear-gradient(135deg, #ffffff, #ffff00);
    transform: scale(1.2);
    animation: scrollSelectedBadge 1s ease-in-out infinite alternate;
}

.scroll-option.selected .scroll-option-icon {
    color: #ffff00;
    animation: scrollSelectedIconPulse 0.8s ease-in-out infinite alternate;
}

/* Sparkle effect for selected card */
.scroll-option.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3) 2px, transparent 3px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 0, 0.4) 1px, transparent 2px),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.2) 2px, transparent 3px),
        radial-gradient(circle at 60% 20%, rgba(255, 255, 0, 0.3) 1px, transparent 2px);
    border-radius: 12px;
    pointer-events: none;
    animation: scrollSparkle 2s ease-in-out infinite;
}

.scroll-actions {
    margin-top: 3rem;
    text-align: center;
}

.scroll-pass-btn {
    background: linear-gradient(135deg, rgba(60, 60, 60, 0.95), rgba(80, 80, 80, 0.95));
    color: #e6e6fa;
    border: 2px solid rgba(138, 43, 226, 0.4);
    padding: 1.2rem 2.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: var(--cm-cursor-action, pointer);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: 'Georgia', serif;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.scroll-pass-btn:hover:where(body:not(.gamepad-active) *) {
    background: linear-gradient(135deg, rgba(80, 80, 80, 0.9), rgba(100, 100, 100, 0.9));
    border-color: rgba(138, 43, 226, 0.6);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(138, 43, 226, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.scroll-hints {
    margin-top: 2rem;
    color: #E6E6FA;
    opacity: 0.9;
}

.scroll-hints > div {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.scroll-hints span {
    background: rgba(0, 0, 0, 0.85);
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid rgba(138, 43, 226, 0.3);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
}

.scroll-hints span:hover:where(body:not(.gamepad-active) *) {
    border-color: rgba(138, 43, 226, 0.6);
    box-shadow: 
        0 6px 18px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(138, 43, 226, 0.3);
}

.selection-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #228B22, #32CD32);
    color: white;
    padding: 1.5rem 3rem;
    border-radius: 15px;
    font-size: 1.3rem;
    font-weight: bold;
    box-shadow: 0 0 30px rgba(34, 139, 34, 0.8);
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: feedbackSlideIn 0.5s ease-out;
}

.selection-feedback.pass {
    background: linear-gradient(135deg, #DC143C, #FF6347);
    box-shadow: 0 0 30px rgba(220, 20, 60, 0.8);
}

.selection-feedback .feedback-icon {
    font-size: 2rem;
    animation: iconBounce 0.6s ease-out;
}

/* Vampire Survivors style animations */
@keyframes scrollFadeIn {
    0% { 
        opacity: 0; 
    }
    100% { 
        opacity: 1; 
    }
}

@keyframes scrollPulse {
    0% {
        text-shadow: 
            3px 3px 0px #000000,
            0 0 15px rgba(255, 255, 0, 0.8);
        transform: scale3d(1, 1, 1);
    }
    100% {
        text-shadow: 
            3px 3px 0px #000000,
            0 0 20px rgba(255, 255, 0, 1),
            0 0 50px rgba(255, 255, 0, 0.6);
        transform: scale3d(1.02, 1.02, 1);
    }
}

@keyframes scrollCardSlideIn {
    0% {
        opacity: 0;
        transform: translate3d(0, 30px, 0) scale3d(0.8, 0.8, 1);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
    }
}

@keyframes scrollIconFloat {
    0% { transform: translate3d(0, 0px, 0); }
    100% { transform: translate3d(0, -3px, 0); }
}

@keyframes scrollSelectedGlow {
    0% { 
        box-shadow: 
            0 0 40px rgba(255, 255, 0, 0.8),
            0 0 80px rgba(255, 255, 0, 0.4),
            0 10px 30px rgba(0, 0, 0, 0.5);
    }
    100% { 
        box-shadow: 
            0 0 50px rgba(255, 255, 0, 1),
            0 0 100px rgba(255, 255, 0, 0.6),
            0 12px 35px rgba(0, 0, 0, 0.6);
    }
}

@keyframes scrollSelectedBadge {
    0% { 
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.5),
            0 0 25px rgba(255, 255, 0, 0.8);
    }
    100% { 
        box-shadow: 
            0 6px 12px rgba(0, 0, 0, 0.6),
            0 0 35px rgba(255, 255, 0, 1),
            0 0 60px rgba(255, 255, 255, 0.4);
    }
}

@keyframes scrollSelectedIconPulse {
    0% { 
        text-shadow: 
            0 0 15px rgba(255, 255, 0, 0.8),
            2px 2px 4px rgba(0, 0, 0, 0.8);
        filter: drop-shadow(0 0 12px rgba(255, 255, 0, 0.7));
        transform: scale(1);
    }
    100% { 
        text-shadow: 
            0 0 25px rgba(255, 255, 0, 1),
            0 0 50px rgba(255, 255, 0, 0.6),
            2px 2px 4px rgba(0, 0, 0, 0.8);
        filter: drop-shadow(0 0 20px rgba(255, 255, 0, 1));
        transform: scale(1.05);
    }
}

@keyframes scrollSparkle {
    0% { 
        opacity: 0.8;
        background-size: 100% 100%;
    }
    50% { 
        opacity: 1;
        background-size: 120% 120%;
    }
    100% { 
        opacity: 0.8;
        background-size: 100% 100%;
    }
}

@keyframes feedbackSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes iconBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes legendaryGlow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
    50% { 
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 50px rgba(255, 165, 0, 0.6);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .scroll-selection-container {
        padding: 1rem;
    }
    
    .scroll-title h2 {
        font-size: 2rem;
    }
    
    .scroll-options {
        gap: 0.8rem;
    }
    
    .scroll-option {
        padding: 0.8rem;
    }
    
    .scroll-option-inner {
        gap: 0.8rem;
    }
    
    .scroll-option-icon {
        font-size: 2rem;
    }
    
    .scroll-hints > div {
        gap: 1rem;
    }
    
    .scroll-hints span {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .scroll-title h2 {
        font-size: 1.5rem;
    }
    
    .scroll-title p {
        font-size: 1rem;
    }
    
    .scroll-option {
        padding: 0.6rem;
    }
    
    .scroll-option-inner {
        gap: 0.6rem;
    }
    
    .scroll-option-icon {
        font-size: 1.8rem;
    }
    
    .scroll-option-name {
        font-size: 1.1rem;
    }
    
    .scroll-option-description {
        font-size: 0.85rem;
    }
    
    .selection-feedback {
        padding: 1rem 2rem;
        font-size: 1.1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .scroll-selection-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
    
    .scroll-option {
        border-width: 3px;
    }
    
    .scroll-option.selected {
        border-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .scroll-option,
    .scroll-pass-btn,
    .scroll-option-icon {
        animation: none;
        transition: none;
    }
    
    .scroll-option:hover:where(body:not(.gamepad-active) *),
    .scroll-option.selected {
        transform: none;
    }
    
    .selection-feedback {
        animation: none;
    }
}
