/* World Selection Overlay */
.world-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(26, 15, 31, 0.98) 0%, 
        rgba(75, 0, 130, 0.95) 50%, 
        rgba(26, 15, 31, 0.98) 100%);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.world-selection-overlay.active {
    display: flex;
    opacity: 1;
}

.world-selection-overlay.fade-out {
    opacity: 0;
}

.world-selection-container {
    width: 90%;
    max-width: 1200px;
    height: 85%;
    background: linear-gradient(145deg, 
        rgba(16, 8, 24, 0.95) 0%, 
        rgba(32, 16, 48, 0.9) 100%);
    border: 2px solid #8a2be2;
    border-radius: 20px;
    box-shadow: 
        0 0 50px rgba(138, 43, 226, 0.5),
        inset 0 0 30px rgba(138, 43, 226, 0.1);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow: hidden;
    position: relative;
}

/* Mystical background effects */
.world-selection-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, 
        transparent 20%, 
        rgba(138, 43, 226, 0.1) 50%, 
        transparent 80%);
    animation: mysticalPulse 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes mysticalPulse {
    0%, 100% { transform: rotate(0deg) scale3d(1, 1, 1); }
    50% { transform: rotate(180deg) scale3d(1.1, 1.1, 1); }
}

/* Header */
.world-selection-header {
    text-align: center;
    z-index: 2;
    position: relative;
}

.world-selection-header h1 {
    font-size: 2.5rem;
    color: #dda0dd;
    text-shadow: 0 0 20px rgba(221, 160, 221, 0.8);
    margin: 0 0 10px 0;
    font-weight: bold;
}

.world-selection-header p {
    font-size: 1.2rem;
    color: #c9c9c9;
    margin: 0;
    opacity: 0.9;
}

/* Main content grid */
.worlds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    z-index: 2;
    position: relative;
}

/* World cards */
.world-card {
    background: linear-gradient(145deg, 
        rgba(64, 32, 96, 0.8) 0%, 
        rgba(32, 16, 48, 0.9) 100%);
    border: 2px solid #6a4c93;
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: var(--cm-cursor-action, pointer);
    position: relative;
    overflow: hidden;
    transform: translateY(0); /* Bazowy stan dla płynnych animacji */
}

.world-card:hover:where(body:not(.gamepad-active) *) {
    border-color: #8a2be2;
    box-shadow: 0 0 25px rgba(138, 43, 226, 0.4);
    transform: translateY(-5px);
}

.world-card.selected {
    border-color: #dda0dd;
    box-shadow: 0 0 30px rgba(221, 160, 221, 0.6);
    transform: translateY(-3px);
}

.world-card.locked {
    opacity: 0.5;
    cursor: var(--cm-cursor-disabled, not-allowed);
    border-color: #555;
}

.world-card.locked:hover:where(body:not(.gamepad-active) *) {
    transform: none;
    box-shadow: none;
}

/* World header */
.world-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.world-header h3 {
    color: #dda0dd;
    font-size: 1.4rem;
    margin: 0;
    text-shadow: 0 0 10px rgba(221, 160, 221, 0.5);
}

.lock-icon {
    font-size: 1.5rem;
    color: #888;
}

/* World modes */
.world-modes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(138, 43, 226, 0.2);
    border: 1px solid rgba(138, 43, 226, 0.4);
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: var(--cm-cursor-action, pointer);
}

.mode-item:hover:where(body:not(.gamepad-active) *) {
    background: rgba(138, 43, 226, 0.3);
    border-color: rgba(138, 43, 226, 0.6);
}

.mode-item.selected {
    background: rgba(221, 160, 221, 0.3);
    border-color: #dda0dd;
    box-shadow: 0 0 15px rgba(221, 160, 221, 0.4);
}

.mode-item.locked {
    opacity: 0.5;
    cursor: var(--cm-cursor-disabled, not-allowed);
    background: rgba(85, 85, 85, 0.2);
    border-color: rgba(85, 85, 85, 0.4);
}

.mode-item.locked:hover:where(body:not(.gamepad-active) *) {
    background: rgba(85, 85, 85, 0.2);
    border-color: rgba(85, 85, 85, 0.4);
}

.mode-name {
    color: #e6e6e6;
    font-weight: 500;
}

.mode-item.selected .mode-name {
    color: #dda0dd;
    font-weight: bold;
}

.lock-indicator {
    color: #888;
    font-size: 1.05rem;
}

/* Mode details panel */
.mode-details {
    background: linear-gradient(145deg, 
        rgba(32, 16, 48, 0.9) 0%, 
        rgba(64, 32, 96, 0.8) 100%);
    border: 2px solid #6a4c93;
    border-radius: 15px;
    padding: 25px;
    z-index: 2;
    position: relative;
}

.mode-detail-card h3 {
    color: #dda0dd;
    font-size: 1.8rem;
    margin: 0 0 15px 0;
    text-shadow: 0 0 15px rgba(221, 160, 221, 0.6);
}

.mode-description {
    color: #c9c9c9;
    font-size: 1.25rem;
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.world-info {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.world-label {
    color: #9d4edd;
    font-weight: bold;
}

.world-name {
    color: #e6e6e6;
}

.unlock-status {
    margin: 15px 0;
}

.status-unlocked {
    color: #4ade80;
    font-weight: bold;
}

.status-locked {
    color: #f87171;
    font-weight: bold;
}

.continue-hint {
    color: #4ade80;
    font-style: italic;
    margin-top: 15px;
}

.locked-hint {
    color: #f87171;
    font-style: italic;
    margin-top: 15px;
}

.no-selection {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 40px;
}

/* Navigation hints */
.navigation-hints {
    text-align: center;
    z-index: 2;
    position: relative;
}

.hint-row {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.hint {
    color: #9d4edd;
    font-size: 1.05rem;
    padding: 5px 10px;
    background: rgba(157, 78, 221, 0.2);
    border-radius: 5px;
    border: 1px solid rgba(157, 78, 221, 0.4);
}

.gamepad-hints {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.gamepad-hints .hint {
    background: rgba(106, 76, 147, 0.2);
    border-color: rgba(106, 76, 147, 0.4);
    color: #6a4c93;
}

/* Responsive design */
@media (max-width: 1024px) {
    .world-selection-container {
        width: 95%;
        height: 90%;
        padding: 20px;
    }
    
    .worlds-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .world-selection-header h1 {
        font-size: 2rem;
    }
    
    .hint-row {
        gap: 15px;
    }
    
    .hint {
        font-size: 0.95rem;
        padding: 4px 8px;
    }
}

@media (max-width: 768px) {
    .world-selection-container {
        padding: 15px;
        gap: 20px;
    }
    
    .worlds-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .world-selection-header h1 {
        font-size: 1.8rem;
    }
    
    .world-selection-header p {
        font-size: 1rem;
    }
    
    .world-card {
        padding: 15px;
    }
    
    .mode-details {
        padding: 20px;
    }
    
    .hint-row {
        flex-direction: column;
        gap: 10px;
    }
}

/* Animation for world cards appearing */
.world-card {
    animation: worldCardAppear 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

.world-card:nth-child(1) { animation-delay: 0.1s; }
.world-card:nth-child(2) { animation-delay: 0.2s; }
.world-card:nth-child(3) { animation-delay: 0.3s; }
.world-card:nth-child(4) { animation-delay: 0.4s; }
.world-card:nth-child(5) { animation-delay: 0.5s; }

@keyframes worldCardAppear {
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Enhanced glow effects for selected elements */
.world-card.selected::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
        transparent, 
        rgba(221, 160, 221, 0.3), 
        transparent, 
        rgba(221, 160, 221, 0.3), 
        transparent);
    border-radius: 17px;
    z-index: -1;
    animation: borderGlow 2s linear infinite;
}

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