* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #0f0f1a;
    color: #e0e0ff;
    overflow: hidden;
    position: fixed;
    height: 100vh;
    width: 100vw;
    -webkit-overflow-scrolling: touch;
}

.hidden { display: none !important; }

.glow-btn { 
    background: #00d4ff; 
    color: #fff; 
    border: none; 
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 16px);
    border-radius: 5px; 
    cursor: pointer; 
    box-shadow: 0 0 10px #00d4ff;
    font-size: clamp(12px, 3vw, 14px);
    min-height: 44px;
    touch-action: manipulation;
    transition: all 0.3s ease;
}

.glow-btn:hover { 
    background: #00aaff;
    transform: scale(1.02);
}

.glow-btn:active {
    transform: scale(0.98);
}

.status-indicator { 
    margin-left: 5px;
    font-size: clamp(14px, 3vw, 16px);
}

.success { color: #28a745; }
.error { color: #dc3545; }
.loading { color: #00d4ff; }

.preview-container { 
    display: flex; 
    flex-wrap: wrap;
    gap: clamp(5px, 1.5vw, 10px);
    justify-content: center;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.preview-thumbnail { 
    width: clamp(50px, 12vw, 60px);
    height: clamp(50px, 12vw, 60px);
    margin: 5px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #00d4ff;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.preview-thumbnail:hover {
    transform: scale(1.05);
}

.action-group {
    display: flex;
    align-items: center;
    gap: clamp(5px, 1.5vw, 10px);
    flex-wrap: wrap;
}

.status-indicator.hidden {
    display: none;
}

.status-indicator.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease;
    touch-action: none;
    -webkit-touch-callout: none;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.control-panel {
    pointer-events: auto;
    background: rgba(20, 20, 40, 0.95);
    border-radius: clamp(10px, 2vw, 15px);
    padding: clamp(10px, 2.5vw, 20px);
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hidden-panel {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.toggle-controls-btn {
    position: fixed;
    top: clamp(10px, 2vw, 20px);
    right: clamp(10px, 2vw, 20px);
    padding: clamp(8px, 2vw, 10px) clamp(15px, 3vw, 20px);
    background: linear-gradient(45deg, #00d4ff, #007bff);
    border: none;
    border-radius: 25px;
    color: #fff;
    cursor: pointer;
    font-size: clamp(12px, 3vw, 14px);
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: auto;
    min-height: 44px;
}

.toggle-controls-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.8);
}

.toggle-controls-btn:active {
    transform: scale(0.95);
}

.top-panel {
    position: absolute;
    top: clamp(10px, 2vw, 20px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(90%, 800px);
    flex-wrap: wrap;
    gap: 10px;
}

.title {
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    white-space: nowrap;
}

.button-group {
    display: flex;
    gap: clamp(5px, 1.5vw, 10px);
    flex-wrap: wrap;
    justify-content: center;
}

/* NEW Feature Panel Styles */
.feature-panel {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    padding: 15px;
    z-index: 9;
}

.feature-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-group label {
    color: #00d4ff;
    font-size: 14px;
    white-space: nowrap;
}

.feature-select {
    padding: 8px 12px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid #00d4ff;
    border-radius: 5px;
    color: #e0e0ff;
    font-size: 14px;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.2s;
}

.feature-select:hover {
    background: rgba(0, 212, 255, 0.2);
}

.feature-select:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* Bookmark Section Styles */
.bookmark-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 212, 255, 0.3);
}

.bookmark-section h3 {
    color: #00d4ff;
    margin-bottom: 10px;
    font-size: 16px;
}

.bookmark-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 10px;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 5px 0;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 5px;
    transition: background 0.2s;
}

.bookmark-item:hover {
    background: rgba(0, 212, 255, 0.2);
}

.bookmark-item span {
    flex: 1;
    color: #00d4ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.bookmark-item button {
    padding: 5px 10px;
    font-size: 12px;
    margin-left: 5px;
    min-height: 32px;
}

.sidebar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(200px, 25vw, 280px);
    padding: clamp(15px, 3vw, 25px);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.left-sidebar {
    left: clamp(10px, 2vw, 20px);
}

.right-sidebar {
    right: clamp(10px, 2vw, 20px);
}

.bottom-panel {
    position: absolute;
    bottom: clamp(10px, 2vw, 20px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.danger-btn {
    background: linear-gradient(45deg, #dc3545, #ff6b6b);
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.5);
}

.danger-btn:hover {
    box-shadow: 0 0 25px rgba(220, 53, 69, 0.8);
}

.form-group {
    margin-bottom: clamp(15px, 3vw, 25px);
}

.form-group h3 {
    margin-bottom: clamp(8px, 2vw, 12px);
    color: #00d4ff;
    text-shadow: 0 0 5px rgba(0, 212, 255, 0.3);
    font-size: clamp(14px, 3.5vw, 18px);
}

input[type="file"],
input[type="text"] {
    width: 100%;
    padding: clamp(8px, 2vw, 12px);
    margin-bottom: 10px;
    border: 1px solid #00d4ff;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0ff;
    font-size: clamp(14px, 3.5vw, 16px);
    min-height: 44px;
}

input[type="file"]::file-selector-button {
    background: #00d4ff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: clamp(12px, 3vw, 14px);
    margin-right: 10px;
}

.submit-btn {
    width: 100%;
}

.slider-group {
    margin-bottom: clamp(15px, 3vw, 20px);
}

.slider-group label {
    display: block;
    margin-bottom: clamp(5px, 1.5vw, 8px);
    color: #00d4ff;
    font-size: clamp(13px, 3vw, 15px);
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 5px;
    height: clamp(4px, 1vw, 6px);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: clamp(18px, 4vw, 22px);
    height: clamp(18px, 4vw, 22px);
    background: #00d4ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: clamp(18px, 4vw, 22px);
    height: clamp(18px, 4vw, 22px);
    background: #00d4ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    border: none;
}

.recording-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recording-indicator {
    margin-top: 10px;
    color: #ff6b6b;
    font-size: clamp(13px, 3vw, 15px);
    text-align: center;
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.5);
}

.nav-btn {
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 15px);
    font-size: clamp(14px, 3.5vw, 16px);
}

.remove-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.env-map-group {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.env-map-group label {
    color: #fff;
    font-size: clamp(13px, 3vw, 15px);
    margin-bottom: 5px;
}

.env-map-group input[type="file"] {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 5px;
    border-radius: 5px;
}

.status-indicator[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    z-index: 1000;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 5px;
}

/* Tablet Responsive (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 220px;
        padding: 18px;
    }
    
    .top-panel {
        width: 95%;
    }
    
    .feature-panel {
        top: 90px;
        width: 95%;
    }
}

/* Mobile Responsive (max-width: 768px) */
@media (max-width: 768px) {
    .top-panel {
        flex-direction: column;
        width: 95%;
        top: 10px;
        gap: 8px;
    }
    
    .title {
        font-size: 1.2rem;
        order: -1;
        width: 100%;
        text-align: center;
    }

    .button-group {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .action-group {
        flex: 0 1 auto;
    }

    .feature-panel {
        top: 120px;
        width: 95%;
        padding: 10px;
        flex-direction: column;
        gap: 10px;
    }
    
    .feature-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .feature-select {
        flex: 1;
        max-width: 150px;
    }

    .sidebar {
        width: 90%;
        max-width: 300px;
        padding: 15px;
        max-height: 70vh;
    }

    .left-sidebar {
        left: 5%;
        top: auto;
        bottom: 10px;
        transform: none;
    }

    .right-sidebar {
        right: 5%;
        top: auto;
        bottom: 10px;
        transform: none;
    }

    .bottom-panel {
        flex-direction: column;
        bottom: 10px;
        gap: 10px;
    }

    .preview-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .control-panel {
        border-radius: 10px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .toggle-controls-btn {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .top-panel {
        top: 8px;
        padding: 10px;
    }
    
    .title {
        font-size: 1rem;
    }

    .glow-btn {
        padding: 10px 12px;
        font-size: 12px;
    }

    .feature-panel {
        top: 100px;
    }

    .sidebar {
        width: 95%;
        max-width: none;
        padding: 12px;
        position: fixed;
        transform: none;
    }
    
    .left-sidebar, .right-sidebar {
        left: 2.5%;
        right: 2.5%;
        bottom: 10px;
        top: auto;
    }

    .preview-thumbnail {
        width: 45px;
        height: 45px;
    }
    
    input[type="file"],
    input[type="text"] {
        font-size: 16px !important;
        padding: 12px;
    }
    
    .feature-select {
        font-size: 14px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        max-height: 60vh;
        font-size: 12px;
    }
    
    .top-panel {
        padding: 8px;
    }
    
    .feature-panel {
        top: 70px;
        padding: 8px;
    }
    
    .title {
        font-size: 0.9rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    * {
        -webkit-user-select: none;
        user-select: none;
    }
    
    input, textarea, button, select {
        -webkit-user-select: text;
        user-select: text;
    }
    
    .glow-btn,
    button,
    input[type="range"]::-webkit-slider-thumb,
    .feature-select {
        cursor: pointer;
    }
    
    .glow-btn,
    input[type="file"]::file-selector-button,
    .feature-select {
        min-height: 48px;
        min-width: 48px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .glow-btn {
        box-shadow: 0 0 12px #00d4ff;
    }
}

/* Prevent horizontal scroll */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-left)) {
    .top-panel, .feature-panel {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    .sidebar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .bottom-panel {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 212, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

/* Add to your virtual.css or in a <style> tag */
#treasureHUD,
#progressionUI,
#treasureCompass,
#treasureMapContainer,
#artworkProgress,
#skyIslandsUI {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#treasureHUD.hidden,
#progressionUI.hidden,
#treasureCompass.hidden,
#artworkProgress.hidden,
#skyIslandsUI.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}