/* Radial Menu System - Mobile Optimized */
.radial-menu {
    position: absolute;
    width: 280px;
    height: 280px;
    pointer-events: none;
    z-index: 500;
    opacity: 0;
    transform: scale(0.1);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.radial-menu.active {
    opacity: 1 !important;
    transform: scale(1);
    pointer-events: none; /* Container should not block, only items should be clickable */
}

/* Keep menus always open */
.radial-menu {
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* Position radial menus from corners - all open inward */
.element-corner.top-left .radial-menu {
    /* Fire - open inward (toward bottom-right) */
    top: -20px;
    left: -20px;
    transform-origin: 50px 50px;
}

.element-corner.top-right .radial-menu {
    /* Water - open inward (toward bottom-left) */
    top: -20px;
    right: -20px;
    transform-origin: calc(100% - 50px) 50px;
}

.element-corner.bottom-left .radial-menu {
    /* Earth - open inward (toward top-right) */
    bottom: -20px;
    left: -20px;
    transform-origin: 50px calc(100% - 50px);
}

.element-corner.bottom-right .radial-menu {
    /* Air - open inward (toward top-left) */
    bottom: -20px;
    right: -20px;
    transform-origin: calc(100% - 50px) calc(100% - 50px);
}

/* Radial menu center hub - hidden since base elements are in flyout line */
.radial-center {
    display: none;
}

.radial-center:hover {
    transform: translate(-50%, -50%) scale(1.1);
    border-color: rgba(255,215,0,0.8);
    box-shadow: 0 0 25px rgba(255,215,0,0.4);
    background: rgba(30,30,30,0.95);
}

.radial-center:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.radial-center-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: brightness(1.2) contrast(1.15) saturate(1.05) drop-shadow(0 0 4px rgba(255,255,255,0.4));
}

/* Center button tooltip */
.radial-center::after {
    content: 'Click or drag to use';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20,20,20,0.95);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 10px;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

.radial-center:hover::after {
    opacity: 1;
}

/* Radial menu items - reduced by 20% for 2-row layout */
.radial-item {
    position: absolute;
    width: 50px;  /* was 63px, now ~20% smaller */
    height: 50px; /* was 63px, now ~20% smaller */
    background: rgba(60,60,60,0.8);
    border: 2px solid rgba(139,69,19,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.2s ease;
    pointer-events: auto !important;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 1000;
    /* Touch-friendly */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: auto;
    -webkit-user-drag: element !important;
}

.radial-menu.active .radial-item {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto !important;
}

.radial-item:hover {
    transform: translate(-50%, -50%) scale(1.15);
    background: rgba(80,80,80,0.9);
    border-color: rgba(255,215,0,0.6);
    box-shadow: 0 0 15px rgba(255,215,0,0.4);
    z-index: 1001;
}

.radial-item:active {
    transform: translate(-50%, -50%) scale(0.95);
    cursor: grabbing !important;
}

.radial-item img {
    width: 38px;  /* was 48px, now ~20% smaller */
    height: 38px; /* was 48px, now ~20% smaller */
    object-fit: contain;
    filter: brightness(1.3) contrast(1.2) saturate(1.1) drop-shadow(0 0 3px rgba(255,255,255,0.5));
}

.radial-item .element-icon {
    font-size: 20px;
    filter: brightness(1.2) contrast(1.1) drop-shadow(0 0 2px rgba(255,255,255,0.6));
}

/* Dynamic spiral positioning is now handled by JavaScript */

/* All spiral positioning is now handled dynamically by JavaScript */

/* All radial item positioning handled by JavaScript */

/* Tier indicator dots */
.tier-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 1px solid rgba(0,0,0,0.5);
}

.tier-indicator.tier-1 { background: #87ceeb; }
.tier-indicator.tier-2 { background: #98d8c8; }
.tier-indicator.tier-3 { background: #ffd700; }
.tier-indicator.tier-4 { background: #ff9f40; }
.tier-indicator.tier-5 { background: #ff6b6b; } /* Brighter red for better visibility */
.tier-indicator.tier-6 { background: #ffd700; } /* Golden for mythical */

/* Tooltip for radial items */
.radial-tooltip {
    position: absolute;
    background: rgba(20,20,20,0.98);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    color: white;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2000;
}

/* Default tooltip positioning - bottom */
.radial-tooltip {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 5px;
}

/* Fire corner (top-left) - tooltips to the right */
.element-corner.top-left .radial-tooltip {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 5px;
    margin-bottom: 0;
}

/* Water corner (top-right) - tooltips to the left */
.element-corner.top-right .radial-tooltip {
    bottom: auto;
    left: auto;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 5px;
    margin-bottom: 0;
}

/* Earth corner (bottom-left) - tooltips to the right */
.element-corner.bottom-left .radial-tooltip {
    bottom: auto;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 5px;
    margin-bottom: 0;
}

/* Air corner (bottom-right) - tooltips to the left */
.element-corner.bottom-right .radial-tooltip {
    bottom: auto;
    left: auto;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 5px;
    margin-bottom: 0;
}

.radial-item:hover .radial-tooltip {
    opacity: 1;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .radial-menu {
        width: 240px;
        height: 240px;
    }
    
    /* Move fire menu (top-left) 1/3 button width to the left on mobile */
    .element-corner.top-left .radial-menu {
        left: -47px; /* -20px base - 27px (1/3 of 80px button) */
    }
    
    /* Move air menu (bottom-right) 1/8 button width to the right on mobile */
    .element-corner.bottom-right .radial-menu {
        right: -30px; /* -20px base - 10px (1/8 of 80px button) */
    }
    
    .radial-item {
        width: 43px;  /* was 54px, now ~20% smaller */
        height: 43px; /* was 54px, now ~20% smaller */
    }
    
    .radial-item img {
        width: 34px;  /* was 42px, now ~20% smaller */
        height: 34px; /* was 42px, now ~20% smaller */
    }
    
    .radial-center {
        width: 50px;
        height: 50px;
    }
    
    /* Single cycling arrow mobile optimization - 1/2 size */
    .corner-cycle-arrow {
        width: 14px;
        height: 14px;
        font-size: 10px;
        /* Smaller touch targets for mobile */
        min-width: 24px;
        min-height: 24px;
        /* Adjust positioning for smaller touch targets */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile-specific pagination control - ensure all corners are consistent */
    .corner-pagination-control {
        padding: 2px 4px !important;
        font-size: 9px !important;
        width: auto !important;
        height: auto !important;
        min-width: 0 !important;
        max-width: 42px !important;
        min-height: 0 !important;
        max-height: 20px !important;
        line-height: 1 !important;
        display: inline-flex !important;
        flex-shrink: 0 !important;
        align-items: center !important;
        gap: 2px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .pagination-arrow {
        font-size: 8px !important;
        line-height: 1 !important;
    }
    
    .pagination-count {
        font-size: 8px !important;
        line-height: 1 !important;
    }
    
    /* Consistent positioning for all corners on mobile */
    .element-corner.top-left .corner-pagination-control {
        top: 2px;
        left: 2px;
        bottom: auto;
        right: auto;
    }
    
    .element-corner.top-right .corner-pagination-control {
        top: 2px;
        right: 2px;
        bottom: auto;
        left: auto;
    }
    
    /* Bottom corners positioned at top of button for easier access */
    .element-corner.bottom-left .corner-pagination-control {
        top: 2px;
        left: 2px;
        bottom: auto;
        right: auto;
        width: auto !important;
        max-width: 42px !important;
    }
    
    .element-corner.bottom-right .corner-pagination-control {
        top: 2px;
        right: 2px;
        bottom: auto;
        left: auto;
        width: auto !important;
        max-width: 42px !important;
    }
    
    /* Enhanced touch feedback for mobile */
    .corner-cycle-arrow:active {
        transform: scale(0.9);
        background: rgba(255,255,255,0.8);
    }
    
    /* Maintain centered position for bottom corners on active */
    .element-corner.bottom-left .corner-cycle-arrow:active,
    .element-corner.bottom-right .corner-cycle-arrow:active {
        transform: translateX(50%) scale(0.9);
    }
    
    /* Radial menu touch optimizations */
    .radial-item {
        /* Larger touch targets for mobile */
        min-width: 44px;
        min-height: 44px;
        /* Better touch feedback */
        transition: all 0.2s ease;
        pointer-events: auto !important;
        cursor: pointer;
    }
    
    .radial-item:active {
        transform: translate(-50%, -50%) scale(0.95);
        background: rgba(255,215,0,0.3);
    }
    
    .radial-center {
        /* Larger touch target for center button */
        min-width: 60px;
        min-height: 60px;
    }
    
    .radial-center:active {
        transform: translate(-50%, -50%) scale(0.9);
    }
    
    /* Corner headers touch optimization */
    .corner-header {
        /* Larger touch targets */
        min-width: 60px;
        min-height: 60px;
        /* Better touch feedback */
        transition: all 0.2s ease;
    }
    
    .corner-header:active {
        transform: scale(0.95);
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .radial-item {
        width: 38px;  /* was 48px, now ~20% smaller */
        height: 38px; /* was 48px, now ~20% smaller */
    }
    
    .radial-item img {
        width: 30px;  /* was 38px, now ~20% smaller */
        height: 30px; /* was 38px, now ~20% smaller */
    }
    
    /* Ensure all pagination controls are same size on small mobile */
    .corner-pagination-control {
        padding: 2px 4px !important;
        font-size: 8px !important;
        min-width: auto !important;
        min-height: auto !important;
        width: auto !important;
        height: auto !important;
        max-width: 40px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 2px !important;
        line-height: 1 !important;
    }
    
    .pagination-arrow {
        font-size: 7px !important;
        line-height: 1 !important;
    }
    
    .pagination-count {
        font-size: 7px !important;
        line-height: 1 !important;
    }
    
    /* Keep all corners consistent - positioned inside corner for visibility */
    .element-corner.top-left .corner-pagination-control {
        top: 2px;
        left: 2px;
        bottom: auto;
        right: auto;
        transform: none !important;
    }
    
    .element-corner.top-right .corner-pagination-control {
        top: 2px;
        right: 2px;
        bottom: auto;
        left: auto;
        transform: none !important;
    }
    
    .element-corner.bottom-left .corner-pagination-control {
        top: 2px;
        left: 2px;
        bottom: auto;
        right: auto;
        transform: none !important;
    }
    
    .element-corner.bottom-right .corner-pagination-control {
        top: 2px;
        right: 2px;
        bottom: auto;
        left: auto;
        transform: none !important;
    }
}

/* New element glow effect */
.radial-item.new-element-glow {
    animation: newElementPulse 2s ease-in-out infinite;
    border-color: rgba(255,215,0,0.8);
    box-shadow: 0 0 20px rgba(255,215,0,0.6), 0 0 40px rgba(255,215,0,0.3), inset 0 0 15px rgba(255,215,0,0.2);
}

@keyframes newElementPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px rgba(255,215,0,0.6), 0 0 40px rgba(255,215,0,0.3), inset 0 0 15px rgba(255,215,0,0.2);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,215,0,0.5), inset 0 0 20px rgba(255,215,0,0.3);
    }
}

.radial-item.new-element-glow:hover {
    animation: none;
    transform: translate(-50%, -50%) scale(1.15);
}

/* Touch feedback */
@media (hover: none) {
    .radial-item {
        pointer-events: auto !important;
        cursor: pointer;
    }
    
    .radial-item:active {
        transform: translate(-50%, -50%) scale(0.95);
        background: rgba(255,215,0,0.2);
    }
    
    .radial-item.new-element-glow:active {
        animation: none;
    }
}

/* Combined pagination control - REMOVED, now using corner header for pagination */
.corner-pagination-control {
    display: none !important; /* Force hide old pagination controls */
    position: absolute;
    background: rgba(20,20,20,0.9);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 3px 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 11px;
    font-weight: bold;
    color: rgba(255,255,255,0.9);
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    pointer-events: auto;
    z-index: 1000;
    /* Prevent growing too large */
    box-sizing: border-box;
    max-width: 60px;
    overflow: hidden;
}

.element-corner.has-pages .corner-pagination-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: auto;
    white-space: nowrap;
}

.corner-pagination-control:hover {
    background: rgba(30,30,30,0.95);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    transform: scale(1.05);
}

/* Prevent hover scale on mobile touch devices */
@media (hover: none) and (pointer: coarse) {
    .corner-pagination-control:hover {
        transform: none;
    }
}

.pagination-arrow {
    display: inline-block;
    transition: transform 0.3s;
}

.pagination-count {
    font-size: 11px;
    color: rgba(255,255,255,0.9);
}

/* Position pagination controls in respective corners */
/* Fire (top-left) - position in outer top-left */
.element-corner.top-left .corner-pagination-control {
    top: -12px;
    left: -12px;
}

/* Water (top-right) - position in outer top-right */
.element-corner.top-right .corner-pagination-control {
    top: -12px;
    right: -12px;
}

/* Earth (bottom-left) - position in outer bottom-left */
.element-corner.bottom-left .corner-pagination-control {
    bottom: -12px;
    left: -12px;
}

/* Air (bottom-right) - position in outer bottom-right */
.element-corner.bottom-right .corner-pagination-control {
    bottom: -12px;
    right: -12px;
}

/* Old navigation controls - DEPRECATED but kept for compatibility */
.corner-nav-cycle {
    display: none;
    position: absolute;
    pointer-events: none;
    z-index: 510;
}

.element-corner.has-pages .corner-nav-cycle {
    display: none;
}

.corner-cycle-arrow {
    position: absolute;
    width: 22px;
    height: 22px;
    background: rgba(255,215,0,0.9);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 11px;
    font-weight: bold;
    color: rgba(20,20,20,1);
    box-shadow: 0 0 12px rgba(255,215,0,0.5);
    pointer-events: auto;
}

.corner-cycle-arrow:hover {
    background: rgba(255,255,255,0.95);
    border-color: rgba(255,215,0,0.9);
    box-shadow: 0 0 18px rgba(255,215,0,0.7);
    transform: scale(1.4);
}

/* Position single cycling arrow to the right of corner button */
.element-corner.top-left .corner-cycle-arrow {
    top: 0;
    right: -30px;
}

.element-corner.top-right .corner-cycle-arrow {
    top: 0;
    left: -30px;
}

.element-corner.bottom-left .corner-cycle-arrow {
    bottom: 0;
    right: -30px;
}

.element-corner.bottom-right .corner-cycle-arrow {
    top: 0;
    right: -30px;
}

/* Page indicator - positioned near corner button */
.corner-page-indicator {
    position: absolute;
    background: rgba(255,215,0,0.9);
    border-radius: 8px;
    padding: 2px 5px;
    font-size: 8px;
    font-weight: bold;
    color: rgba(20,20,20,1);
    pointer-events: none;
    box-shadow: 0 0 8px rgba(255,215,0,0.4);
    opacity: 0;
    transition: opacity 0.3s;
}

.element-corner.has-pages .corner-page-indicator {
    opacity: 1;
}

/* Position page indicator for each corner */
.element-corner.top-left .corner-page-indicator {
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
}

.element-corner.top-right .corner-page-indicator {
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
}

.element-corner.bottom-left .corner-page-indicator {
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
}

.element-corner.bottom-right .corner-page-indicator {
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
}

/* Swipe hint animation */
@keyframes swipeHint {
    0%, 100% { transform: translateX(0); opacity: 0.3; }
    50% { transform: translateX(10px); opacity: 1; }
}

.swipe-hint {
    position: absolute;
    top: 50%;
    right: -30px;
    transform: translateY(-50%);
    color: rgba(255,215,0,0.5);
    font-size: 20px;
    animation: swipeHint 2s ease-in-out infinite;
    pointer-events: none;
}