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

:root {
    --bg-dark: #0a0a12;
    --accent-warm: #E8B87D;
    --accent-cool: #7DB8E8;
    --text-primary: #F0EDE8;
    --text-muted: rgba(240, 237, 232, 0.6);
    --glass-bg: rgba(10, 10, 18, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-glow: rgba(232, 184, 125, 0.3);
}

body {
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
}

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

#scene-container canvas {
    display: block;
}

#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 1000;
    pointer-events: none;
    opacity: 1;
    transition: opacity 2s ease-out;
}

#fade-overlay.faded {
    opacity: 0;
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
    animation: crosshair-pulse 2s ease-in-out infinite;
}

.crosshair-dot {
    width: 4px;
    height: 4px;
    background: var(--text-primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.crosshair-line {
    position: absolute;
    background: var(--text-primary);
    opacity: 0.7;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.crosshair-line.top, .crosshair-line.bottom {
    width: 1px;
    height: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair-line.top { bottom: 10px; }
.crosshair-line.bottom { top: 10px; }

.crosshair-line.left, .crosshair-line.right {
    height: 1px;
    width: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.crosshair-line.left { right: 10px; }
.crosshair-line.right { left: 10px; }

@keyframes crosshair-pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.6; }
}

#crosshair.interactive .crosshair-dot {
    background: var(--accent-warm);
    box-shadow: 0 0 8px var(--shadow-glow);
}

#room-name-display {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Crimson Pro', serif;
    font-size: 32px;
    font-weight: 200;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.5s ease;
}

#room-name-display.visible {
    opacity: 1;
    animation: room-fade 3s ease-out forwards;
}

@keyframes room-fade {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

#instructions {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    color: var(--text-muted);
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.5px;
    z-index: 100;
    transition: opacity 0.5s ease;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#instructions p {
    margin: 0;
    text-align: center;
}

#minimap {
    position: fixed;
    top: 20px;
    right: 20px;
    display: none;
    z-index: 100;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    animation: minimap-slide 0.3s ease-out;
}

@keyframes minimap-slide {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

button {
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

#reset-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
}

#reset-button:hover { transform: scale(1.1); }
#reset-button:active, #reset-button.active { transform: scale(0.95); }

#flashlight-button {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F39C12, #E67E22);
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(243, 156, 18, 0.4);
}

#flashlight-button:hover { transform: scale(1.1); }
#flashlight-button:active { transform: scale(0.95); }
#flashlight-button.active {
    background: linear-gradient(135deg, #FFEB3B, #FFC107);
    box-shadow: 0 4px 30px rgba(255, 235, 59, 0.6);
}

#debug-overlay {
    position: fixed;
    top: 20px;
    left: 80px;
    background: var(--glass-bg);
    color: #0f0;
    font-size: 11px;
    padding: 10px 14px;
    border-radius: 8px;
    z-index: 200;
    display: none;
    line-height: 1.6;
    border: 1px solid rgba(0, 255, 0, 0.2);
    backdrop-filter: blur(10px);
}

#debug-overlay.visible { display: block; }
#debug-overlay span { color: #fff; }

#remix-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    z-index: 100;
    transition: color 0.3s ease;
}

#remix-link:hover { color: var(--accent-warm); }

#hedgehog-button, #roguepig-button, #frok-button {
    position: fixed;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-size: 26px;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

#hedgehog-button {
    bottom: 20px;
    background: linear-gradient(135deg, #FF69B4, #FF1493);
    box-shadow: 0 4px 20px rgba(255, 105, 180, 0.5);
}

#roguepig-button {
    bottom: 90px;
    background: linear-gradient(135deg, #9B59B6, #8E44AD);
    box-shadow: 0 4px 20px rgba(155, 89, 182, 0.5);
}

#frok-button {
    bottom: 160px;
    background: linear-gradient(135deg, #2ECC71, #27AE60);
    box-shadow: 0 4px 20px rgba(46, 204, 113, 0.5);
}

#hedgehog-button:hover, #roguepig-button:hover, #frok-button:hover { transform: scale(1.1); }
#hedgehog-button:active, #hedgehog-button.active,
#roguepig-button:active, #roguepig-button.active,
#frok-button:active, #frok-button.active { transform: scale(0.95); }

#summon-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    border: 3px solid rgba(255, 255, 255, 0.5);
    font-size: 28px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 25px rgba(231, 76, 60, 0.5);
    animation: summon-glow 2s ease-in-out infinite;
}

@keyframes summon-glow {
    0%, 100% { box-shadow: 0 4px 25px rgba(231, 76, 60, 0.5); }
    50% { box-shadow: 0 4px 40px rgba(231, 76, 60, 0.8); }
}

#summon-button:hover { transform: translateX(-50%) scale(1.1); }
#summon-button:active { transform: translateX(-50%) scale(0.9); }

#mic-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498DB, #2980B9);
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-size: 26px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.5);
}

#mic-button:hover { transform: scale(1.1); }
#mic-button:active, #mic-button.active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #E74C3C, #C0392B);
    animation: mic-pulse 0.5s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 2px 15px rgba(231, 76, 60, 0.8); }
    50% { box-shadow: 0 2px 30px rgba(231, 76, 60, 1); }
}

#speech-display {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 550px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px 24px;
    z-index: 150;
    display: none;
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#speech-display.visible {
    display: block;
    animation: speech-appear 0.3s ease-out;
}

@keyframes speech-appear {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#speech-text {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

#speech-text.listening { color: var(--accent-cool); }
#speech-text.listening::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

#target-mode-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(255, 105, 180, 0.95), rgba(255, 20, 147, 0.95));
    color: white;
    padding: 16px 28px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#target-mode-indicator.visible {
    opacity: 1;
    animation: indicator-pulse 1.5s ease-in-out infinite;
}

@keyframes indicator-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.03); }
}

#joystick-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    z-index: 200;
    display: none;
    touch-action: none;
}

#joystick-base {
    width: 110px;
    height: 110px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#joystick-stick {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-warm), #D4956A);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.desktop-only { display: block; }
.mobile-only { display: none; }

@media (pointer: coarse), (max-width: 768px) {
    #joystick-container { display: block; }
    #crosshair { display: none; }
    .desktop-only { display: none; }
    .mobile-only { display: block; }
    
    #instructions {
        bottom: 220px;
        font-size: 11px;
        padding: 10px 18px;
    }
    
    #summon-button { bottom: 100px; }
    #mic-button { bottom: 100px; }
    
    #speech-display {
        width: 90%;
        bottom: 25%;
    }
    
    #room-name-display { font-size: 24px; letter-spacing: 6px; }
}