* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Courier New', monospace;
    background: #000;
    overflow: hidden;
    height: 100vh;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Camera Stream */
#camera {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

/* Three.js Overlay */
#scene-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: auto;
}

#scene-container canvas {
    display: block;
}

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

/* Top HUD */
.top-hud {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    pointer-events: none;
}

.score-counter {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 15px;
    border: 2px solid #00FFFF;
    color: white;
    pointer-events: auto;
}

.score-label {
    font-size: 12px;
    color: #00FFFF;
    display: block;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.combo-multiplier {
    background: rgba(0, 255, 0, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    color: #000;
    font-weight: bold;
    font-size: 18px;
    display: none;
    animation: pulse 0.5s ease-in-out infinite alternate;
    pointer-events: auto;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.settings-btn {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid #00FFFF;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: #00FFFF;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Bottom Controls */
.bottom-controls {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    pointer-events: none;
}

.control-btn {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid #00FFFF;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    color: #00FFFF;
    font-size: 24px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: scale(1.1);
}

.power-ups {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

/* Dialogue Bubble */
.dialogue-bubble {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    border: 2px solid #00FFFF;
    border-radius: 20px;
    padding: 15px 20px;
    max-width: 200px;
    color: white;
    font-size: 14px;
    display: none;
    z-index: 15;
    pointer-events: none;
    animation: dialogueIn 0.3s ease-out;
}

@keyframes dialogueIn {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.dialogue-bubble.hyperactive {
    border-color: #ff6600;
    animation: hyperactiveShake 0.1s infinite;
}

.dialogue-bubble.bureaucratic {
    border-color: #4169E1;
    font-family: 'Times New Roman', serif;
}

.dialogue-bubble.mysterious {
    border-color: #8A2BE2;
    text-shadow: 0 0 10px #8A2BE2;
}

.dialogue-bubble.philosophical {
    border-color: #8B4513;
    font-style: italic;
}

.dialogue-bubble.energetic {
    border-color: #00FF7F;
    animation: energeticBounce 0.5s ease-in-out infinite;
}

@keyframes hyperactiveShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes energeticBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.dialogue-pointer {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #00FFFF;
}

/* Panels */
.settings-panel, .journal-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    display: none;
    z-index: 20;
    pointer-events: auto;
}

.settings-content, .journal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.9);
    border: 3px solid #00FFFF;
    border-radius: 20px;
    padding: 30px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: white;
}

.settings-content h2, .journal-content h2 {
    color: #00FFFF;
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
}

.setting-item {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-item label {
    color: #00FFFF;
    font-size: 16px;
}

.setting-item input[type="range"] {
    width: 120px;
    accent-color: #00FFFF;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #00FFFF;
}

.reset-btn, .close-btn {
    background: linear-gradient(45deg, #ff4444, #ff6666);
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
}

.reset-btn:hover, .close-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 68, 68, 0.4);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    font-size: 18px;
}

/* Journal */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.shape-card {
    background: rgba(0, 40, 80, 0.6);
    border: 2px solid #00FFFF;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.shape-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 255, 255, 0.3);
}

.shape-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.shape-icon.locked {
    filter: grayscale(100%) brightness(0.3);
}

.shape-name {
    color: #00FFFF;
    font-weight: bold;
    margin-bottom: 5px;
}

.shape-progress {
    color: #fff;
    font-size: 14px;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00FFFF, #00FF7F);
    transition: width 0.5s ease;
}

.lore {
    font-size: 12px;
    color: #aaa;
    font-style: italic;
}

/* Permission Screen */
.permission-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #000428, #004e92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.permission-content {
    text-align: center;
    color: white;
    padding: 40px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    border: 3px solid #00FFFF;
    border-radius: 25px;
    max-width: 90vw;
}

.permission-content h1 {
    color: #00FFFF;
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #00FFFF;
}

.permission-content p {
    font-size: 16px;
    margin-bottom: 15px;
    line-height: 1.5;
}

.start-btn {
    background: linear-gradient(45deg, #00FFFF, #00FF7F);
    border: none;
    border-radius: 15px;
    padding: 20px 40px;
    color: #000;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 255, 255, 0.5);
}

.warning {
    font-size: 12px;
    color: #ffaa00;
    margin-top: 20px;
}

/* Particles */
#particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.screen-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particleBurst 1s ease-out forwards;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--end-x, 0), var(--end-y, 0)) scale(0);
        opacity: 0;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .top-hud {
        padding: 0 15px;
    }
    
    .score-counter {
        padding: 8px 12px;
    }
    
    .score-value {
        font-size: 20px;
    }
    
    .settings-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .dialogue-bubble {
        max-width: 180px;
        font-size: 13px;
        padding: 12px 16px;
    }
    
    .permission-content {
        padding: 30px 20px;
    }
    
    .permission-content h1 {
        font-size: 28px;
    }
    
    .start-btn {
        padding: 16px 32px;
        font-size: 16px;
    }
    
    .shape-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }
    
    .shape-card {
        padding: 15px;
    }
    
    .shape-icon {
        font-size: 36px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .dialogue-bubble,
    .settings-content,
    .journal-content {
        border-width: 4px;
        background: rgba(0, 0, 0, 0.95);
    }
    
    .score-counter,
    .control-btn,
    .settings-btn {
        border-width: 3px;
        background: rgba(0, 0, 0, 0.9);
    }
}