* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Space Grotesk', system-ui, sans-serif;
    background: #0a0a0f;
    color: #f8fafc;
    touch-action: auto; /* allow native scrolling where we want it */
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* WebGL canvas - prevent zoom gestures */
#scene-container canvas {
    touch-action: none;
}

#css3d-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* let the canvas receive look-drag by default */
    touch-action: auto;
}

/* Side screen containers - allow touch scrolling */
.screen-container-touch {
    pointer-events: auto !important;
    touch-action: pan-x pan-y !important;
}

.screen-container-touch * {
    pointer-events: auto !important;
}

.screen-container-touch iframe {
    pointer-events: auto !important;
    touch-action: pan-x pan-y !important;
}

/* Crosshair */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 100;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Mode Indicator */
#mode-indicator {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(26, 26, 26, 0.9);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

#mode-indicator.walk { border-color: #22c55e; }
#mode-indicator.placing { border-color: #f97316; }
#mode-indicator.editing { border-color: #eab308; }

#mode-icon {
    font-size: 20px;
}

#mode-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Control Hints */
#control-hints {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 1000;
}

.hint {
    padding: 8px 12px;
    background: rgba(26, 26, 26, 0.8);
    border-radius: 6px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Help Overlay */
#help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

#help-overlay.hidden {
    display: none;
}

#help-panel {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 30px 40px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

#help-panel h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #60a5fa;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h3 {
    font-size: 1.1em;
    color: #94a3b8;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.help-section p {
    margin: 8px 0;
    font-size: 0.9em;
    color: #cbd5e1;
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 4px;
    margin: 0 3px;
}

#close-help {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#close-help:hover {
    background: #2563eb;
}

/* Object Menu */
#object-menu {
    position: fixed;
    z-index: 1500;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

#object-menu.hidden {
    display: none;
}

#object-menu-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#object-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 280px;
}

.object-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.object-item:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
}

.object-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.object-name {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

/* Long Press Indicator */
#long-press-indicator {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.1s;
}

#long-press-indicator.active {
    opacity: 1;
}

#long-press-indicator svg {
    transform: rotate(-90deg);
}

#progress-ring {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 3;
    stroke-dasharray: 0 100;
    stroke-linecap: round;
}

/* Top Buttons */
#top-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

#top-buttons button {
    padding: 10px 14px;
    background: rgba(26, 26, 26, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Space Grotesk', sans-serif;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

#top-buttons button:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

/* Mobile Joystick */
#mobile-joystick {
    display: none;
    touch-action: none;
}

#mobile-joystick.mobile-only {
    display: none;
}

@media (pointer: coarse) {
    #mobile-joystick {
        display: block !important;
        position: fixed;
        bottom: 80px;
        left: 30px;
        z-index: 1000;
        touch-action: none;
    }
    
    #joystick-base {
        width: 120px;
        height: 120px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: none;
    }
    
    #joystick-thumb {
        width: 50px;
        height: 50px;
        background: rgba(59, 130, 246, 0.8);
        border-radius: 50%;
        transition: transform 0.05s;
        touch-action: none;
    }
    
    #control-hints {
        display: none;
    }
    
    #top-buttons {
        top: auto;
        bottom: 20px;
        right: 10px;
        flex-direction: column;
        gap: 6px;
    }
    
    #top-buttons button {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* Start Overlay */
#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

#start-overlay.hidden {
    display: none;
}

#start-content {
    text-align: center;
    padding: 40px;
}

#start-content h1 {
    font-size: 3em;
    margin-bottom: 15px;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#start-content p {
    font-size: 1.2em;
    color: #94a3b8;
    margin-bottom: 30px;
}

#start-button {
    padding: 16px 40px;
    font-size: 1.2em;
    font-weight: 600;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
}

#start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(59, 130, 246, 0.4);
}

.mobile-note {
    font-size: 0.9em !important;
    margin-top: 20px !important;
    opacity: 0.6;
}

/* Footer */
#footer {
    position: fixed;
    bottom: 10px;
    right: 20px;
    z-index: 100;
}

#footer a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
}

#footer a:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* Utility */
.hidden {
    display: none !important;
}