/* Mobile-Specific Redesign - Does not affect desktop */
/* Only applies to screens 768px and below */

@media only screen and (max-width: 768px) {
    /* Hide desktop element scrolls completely on mobile */
    .elements-container {
        display: none !important;
    }
    
    /* Hide radial menus on mobile - we'll use a different approach */
    .radial-menu {
        display: none !important;
    }
    
    /* Compact header for mobile */
    .game-header {
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 3px 8px !important;
    }
    
    .game-title {
        font-size: 12px !important;
        letter-spacing: 0.5px !important;
    }
    
    .stat-item {
        padding: 1px 4px !important;
        height: 32px !important;
    }
    
    .stat-label {
        font-size: 8px !important;
    }
    
    .stat-value {
        font-size: 11px !important;
    }
    
    /* Mobile Element Drawer - Bottom sliding panel */
    .mobile-element-drawer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        background: linear-gradient(to top, 
            rgba(20, 20, 30, 0.98) 0%, 
            rgba(30, 30, 40, 0.95) 100%) !important;
        border-top: 2px solid rgba(255, 215, 0, 0.3) !important;
        z-index: 100 !important;
        transition: height 0.3s ease !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .mobile-element-drawer.expanded {
        height: 50vh !important;
        max-height: 400px !important;
    }
    
    /* Drawer handle */
    .drawer-handle {
        width: 100% !important;
        height: 25px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        background: rgba(255, 215, 0, 0.1) !important;
    }
    
    .drawer-handle::before {
        content: '' !important;
        width: 40px !important;
        height: 4px !important;
        background: rgba(255, 215, 0, 0.5) !important;
        border-radius: 2px !important;
    }
    
    /* Element tabs in drawer */
    .element-tabs {
        display: flex !important;
        height: 35px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
    
    .element-tab {
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        background: transparent !important;
        border: none !important;
        position: relative !important;
        transition: background 0.2s !important;
    }
    
    .element-tab.active {
        background: rgba(255, 215, 0, 0.1) !important;
    }
    
    .element-tab.active::after {
        content: '' !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 2px !important;
        background: rgba(255, 215, 0, 0.8) !important;
    }
    
    .element-tab img {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Element grid in drawer */
    .element-grid {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 8px !important;
        display: none !important;
    }
    
    .element-grid.active {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 8px !important;
        align-content: start !important;
    }
    
    .grid-element {
        width: 100% !important;
        aspect-ratio: 1 !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        transition: all 0.2s !important;
        padding: 4px !important;
    }
    
    .grid-element:active {
        transform: scale(0.9) !important;
        background: rgba(255, 215, 0, 0.2) !important;
    }
    
    .grid-element img {
        width: 80% !important;
        height: 60% !important;
        object-fit: contain !important;
    }
    
    .grid-element-name {
        font-size: 9px !important;
        color: rgba(255, 255, 255, 0.8) !important;
        text-align: center !important;
        margin-top: 2px !important;
        line-height: 1 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        width: 100% !important;
    }
    
    /* Compact workshop for mobile */
    .workshop-area {
        position: fixed !important;
        top: 40px !important; /* Just below header */
        left: 0 !important;
        right: 0 !important;
        bottom: 60px !important; /* Above drawer */
        padding: 10px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        background: radial-gradient(ellipse at center, 
            rgba(30, 25, 20, 0.4) 0%, 
            transparent 60%) !important;
    }
    
    /* Mobile combination zone */
    .combination-zone {
        width: 100% !important;
        max-width: 320px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 15px !important;
        padding: 20px 10px !important;
        background: radial-gradient(ellipse at center,
            rgba(20, 15, 10, 0.6) 0%,
            transparent 70%) !important;
    }
    
    /* Smaller drop slots for mobile */
    .drop-slot {
        width: 100px !important;
        height: 100px !important;
        border-radius: 12px !important;
        border: 2px dashed rgba(255, 215, 0, 0.3) !important;
        background: rgba(0, 0, 0, 0.3) !important;
    }
    
    .drop-slot.drag-over {
        transform: scale(1.05) !important;
        border-color: rgba(255, 215, 0, 0.8) !important;
    }
    
    .slot-placeholder {
        font-size: 10px !important;
    }
    
    .slot-top-text {
        font-size: 11px !important;
    }
    
    .slot-bottom-text {
        font-size: 9px !important;
        margin-top: 2px !important;
    }
    
    /* Adjust slot elements for mobile */
    .slot-element img {
        width: 70px !important;
        height: 70px !important;
    }
    
    .slot-element .element-name {
        font-size: 10px !important;
    }
    
    /* Smaller swirl for mobile */
    .swirl-container {
        width: 50px !important;
        height: 50px !important;
        order: 2 !important;
    }
    
    .swirl-element img {
        width: 35px !important;
        height: 35px !important;
    }
    
    /* Discovery notification adjustments */
    .discovery-notification {
        width: 90% !important;
        max-width: 320px !important;
        padding: 15px !important;
    }
    
    .discovery-title {
        font-size: 18px !important;
    }
    
    .discovery-element-name {
        font-size: 22px !important;
    }
    
    .discovery-recipe {
        padding: 8px !important;
        gap: 8px !important;
    }
    
    .discovery-recipe img {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Quick access core elements bar */
    .mobile-core-elements {
        position: fixed !important;
        top: 40px !important;
        left: 0 !important;
        right: 0 !important;
        height: 50px !important;
        background: linear-gradient(to bottom,
            rgba(10, 10, 15, 0.9) 0%,
            rgba(10, 10, 15, 0.7) 100%) !important;
        display: flex !important;
        justify-content: space-around !important;
        align-items: center !important;
        padding: 0 20px !important;
        z-index: 50 !important;
        border-bottom: 1px solid rgba(255, 215, 0, 0.2) !important;
    }
    
    .mobile-core-element {
        width: 40px !important;
        height: 40px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 60%) !important;
        border: 2px solid rgba(255, 215, 0, 0.4) !important;
        cursor: pointer !important;
        transition: all 0.2s !important;
    }
    
    .mobile-core-element:active {
        transform: scale(0.9) !important;
        background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 60%) !important;
    }
    
    .mobile-core-element img {
        width: 28px !important;
        height: 28px !important;
    }
    
    /* Adjust workshop position with core elements bar */
    .workshop-area {
        top: 90px !important; /* Header + core elements bar */
    }
    
    /* Hide completed toggle on mobile - move to drawer */
    #toggle-completed-btn {
        display: none !important;
    }
    
    /* Mobile completed toggle in drawer */
    .mobile-completed-toggle {
        position: absolute !important;
        right: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
        font-size: 10px !important;
        color: rgba(255, 255, 255, 0.7) !important;
    }
    
    .mobile-completed-toggle input {
        width: 14px !important;
        height: 14px !important;
    }
}

/* iPhone 13 specific adjustments */
@media only screen and (max-width: 390px) and (max-height: 844px) {
    .combination-zone {
        max-width: 280px !important;
    }
    
    .drop-slot {
        width: 90px !important;
        height: 90px !important;
    }
    
    .slot-element img {
        width: 60px !important;
        height: 60px !important;
    }
    
    .swirl-container {
        width: 45px !important;
        height: 45px !important;
    }
    
    .element-grid.active {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Small phones */
@media only screen and (max-width: 375px) {
    .element-grid.active {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    
    .drop-slot {
        width: 85px !important;
        height: 85px !important;
    }
    
    .combination-zone {
        gap: 12px !important;
    }
}

/* Animations for drawer */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(calc(100% - 60px));
    }
}

.mobile-element-drawer {
    animation: slideDown 0.3s ease forwards;
}

.mobile-element-drawer.expanded {
    animation: slideUp 0.3s ease forwards;
}

/* Ensure tooltips work on mobile */
@media only screen and (max-width: 768px) {
    .game-tooltip {
        max-width: 280px !important;
        font-size: 10px !important;
    }
    
    .game-tooltip .tooltip-name {
        font-size: 12px !important;
    }
    
    .game-tooltip .tooltip-tier {
        font-size: 9px !important;
    }
    
    /* Enhanced discovery notification mobile adjustments */
    .discovery-notification {
        min-width: 280px;
        max-width: 95vw;
        padding: 20px 15px;
        margin: 0 2.5vw;
    }
    
    .discovery-header {
        flex-direction: row;
        gap: 15px;
    }
    
    .discovery-tier-badge {
        width: 50px;
        height: 50px;
    }
    
    .tier-number {
        font-size: 20px;
    }
    
    .tier-label {
        font-size: 8px;
    }
    
    .discovery-title {
        font-size: 16px;
    }
    
    .discovered-element {
        width: 80px;
        height: 80px;
    }
    
    .discovered-element img {
        width: 60px;
        height: 60px;
    }
    
    .discovery-element-name {
        font-size: 20px;
    }
    
    .discovery-tier-name {
        font-size: 11px;
        padding: 3px 10px;
    }
    
    .discovery-description {
        font-size: 12px;
        padding: 10px;
        max-height: 60px;
    }
    
    .discovery-recipe {
        font-size: 12px;
        gap: 8px;
    }
}