/* Cosmic CSS Design System */
:root {
    --bg-dark: #070714;
    --primary: #9d4edd;
    --primary-glow: rgba(157, 78, 221, 0.4);
    --secondary: #3f37c9;
    --secondary-glow: rgba(63, 55, 201, 0.3);
    --accent: #4cc9f0;
    --accent-glow: rgba(76, 201, 240, 0.4);
    --text-light: #f3f0fc;
    --text-muted: #b5aed6;
    --glass-bg: rgba(15, 12, 38, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-orbitron: 'Orbitron', sans-serif;
    --font-outfit: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-outfit);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Fullscreen Canvas */
#physics-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: radial-gradient(circle at 50% 50%, #110e2e 0%, #060514 80%);
}

/* UI Container */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to canvas when UI is not active */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Make interactive elements respond to pointer events */
#ui-container * {
    pointer-events: auto;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 20;
}

.glass-panel.active {
    display: flex;
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Ambient glow inside panel */
.glow-bg {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: rotateGlow 20s linear infinite;
}

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

/* Typography */
h1 {
    font-family: var(--font-orbitron);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 3px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 30%, var(--primary) 70%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    text-shadow: 0 0 20px var(--primary-glow);
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
}

/* Emojis selection grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
    margin-bottom: 24px;
}

.emoji-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px 6px;
    font-size: 1.6rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    outline: none;
}

.emoji-item .label {
    font-size: 0.7rem;
    font-family: var(--font-outfit);
    color: var(--text-muted);
    font-weight: 300;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.emoji-item.selected {
    background: rgba(157, 78, 221, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.emoji-item.selected .label {
    color: var(--text-light);
    font-weight: 600;
}

/* Configs */
.config-section {
    width: 100%;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.config-item label span {
    color: var(--accent);
    font-weight: 600;
}

/* Custom Range Input */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Buttons */
.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    padding: 12px 24px;
    border-radius: 12px;
    font-family: var(--font-orbitron);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    padding: 16px 36px;
    font-size: 1rem;
    border-radius: 16px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(157, 78, 221, 0.3);
    text-transform: uppercase;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #b5179e, var(--primary));
    box-shadow: 0 15px 30px rgba(157, 78, 221, 0.5);
    transform: translateY(-2px) scale(1.01);
}

.btn-secondary {
    padding: 10px 20px;
    font-size: 0.8rem;
    border-radius: 10px;
}

.btn-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* Floating Audio Button */
#sound-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    pointer-events: auto;
}

/* Gameplay HUD */
#gameplay-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    pointer-events: none;
    z-index: 15;
}

#gameplay-hud.active {
    display: flex;
}

.instruction-box {
    margin-top: 80px;
    background: rgba(7, 7, 20, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.instruction-box p {
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-align: center;
    font-weight: 400;
    color: var(--text-muted);
}

.hud-buttons {
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
}

/* Device specific visibility */
.mobile-only {
    display: none;
}

/* Responsive Styles */
@media (max-width: 600px) {
    .desktop-only {
        display: none;
    }
    .mobile-only {
        display: block;
    }
    .emoji-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .glass-panel {
        padding: 24px;
    }
    h1 {
        font-size: 1.8rem;
    }
    .instruction-box {
        margin-top: 90px;
        padding: 8px 16px;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
