@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Roboto:wght@300;400;500&display=swap');

/* CSS Variables */
:root {
    --primary-color: #00ffff;
    --secondary-color: #ff00ff;
    --accent-color: #ffff00;
    --background-primary: #0a0a0a;
    --background-secondary: #1a1a1a;
    --background-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: #333333;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-primary: 0 4px 20px rgba(0, 255, 255, 0.3);
    --shadow-secondary: 0 2px 10px rgba(0, 0, 0, 0.5);
    --gradient-primary: linear-gradient(135deg, #00ffff 0%, #ff00ff 100%);
    --gradient-secondary: linear-gradient(135deg, #ff00ff 0%, #ffff00 100%);
    --font-primary: 'Orbitron', monospace;
    --font-secondary: 'Roboto', sans-serif;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-secondary);
    background: var(--background-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(255, 255, 0, 0.05) 0%, transparent 50%);
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-secondary);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.title {
    font-family: var(--font-primary);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.title-main {
    font-size: 2rem;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.title-sub {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: -0.2rem;
}

.stats-display {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    min-width: 120px;
    text-align: right;
    display: inline-block;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    width: 100%;
}

/* Simulation Container */
.simulation-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-primary);
    overflow: hidden;
}

.simulation-canvas,
.webgl-container {
    border-radius: 16px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.webgl-container {
    position: relative;
    display: none;
}

.webgl-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
}

.simulation-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.fps-counter,
.particle-count {
    background: rgba(0, 0, 0, 0.7);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: var(--font-primary);
    backdrop-filter: blur(5px);
}

/* Controls Panel */
.controls-panel {
    width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-secondary);
    overflow: hidden;
    max-height: 80vh;
    overflow-y: auto;
}

.control-tabs {
    display: flex;
    background: var(--background-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(0, 255, 255, 0.1);
}

.tab-btn.active {
    color: var(--primary-color);
    background: var(--glass-bg);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
}

.tab-content {
    display: none;
    padding: 1.5rem;
}

.tab-content.active {
    display: block;
}

.control-section {
    margin-bottom: 2rem;
}

.section-title {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-group {
    transition: all 0.3s ease;
}

.control-group.hidden {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    margin: 0;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.label-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.label-value {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--primary-color);
    padding: 0.2rem 0.5rem;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 10px;
    min-width: 3rem;
    text-align: center;
}

.slider-container {
    position: relative;
}

.slider {
    width: 100%;
    height: 6px;
    background: var(--background-tertiary);
    border-radius: 3px;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.toggle-group {
    transition: all 0.3s ease;
}

.toggle-group.hidden {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.toggle-label:hover {
    color: var(--primary-color);
}

.toggle-input {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--background-tertiary);
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-input:checked + .toggle-switch {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.toggle-input:checked + .toggle-switch::before {
    transform: translateX(24px);
    background: white;
}

.shape-controls {
    display: flex;
    gap: 1rem;
}

.shape-select-group {
    flex: 1;
}

.select-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.shape-select {
    width: 100%;
    padding: 0.8rem;
    background: var(--background-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.shape-select:hover,
.shape-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
    outline: none;
}

.shape-select option {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.shape-select option:disabled {
    color: var(--text-muted);
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.rebirth-info {
    background: rgba(255, 255, 0, 0.1);
    border: 1px solid rgba(255, 255, 0, 0.3);
    border-radius: 10px;
    padding: 1rem;
}

.rebirth-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.rebirth-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.rebirth-value {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    color: var(--accent-color);
    font-weight: 700;
}

.rebirth-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Button Styles */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 255, 255, 0.4);
}

.btn-secondary {
    background: var(--background-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--glass-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ff6666, #ff0000);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.1rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-primary);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-secondary);
}

.modal-title {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    color: var(--primary-color);
    background: rgba(0, 255, 255, 0.1);
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--background-secondary);
    text-align: center;
}

/* Shop Styles */
.shop-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.shop-item {
    background: var(--background-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.shop-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
    transform: translateY(-2px);
}

.shop-item-info h3 {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.shop-item-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.shop-item-buy {
    display: flex;
    justify-content: flex-end;
}

.shop-item-buy button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 10px;
    background: var(--gradient-primary);
    color: white;
    font-family: var(--font-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop-item-buy button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.shop-item-buy button:disabled {
    background: var(--background-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.shop-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

#reset-progress-button {
    background-color: #c0392b;
    border-color: #a03024;
    color: white;
}
#reset-progress-button:hover {
    background-color: #e74c3c;
}

/* Theme Item Styles - Reusing shop-item for consistency */
.theme-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.theme-item:hover {
    background-color: var(--bg-color);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
}

.theme-item:last-child {
    border-bottom: none;
}

.theme-item-info {
    display: flex;
    flex-direction: column;
}

.theme-item-info h3 {
    margin: 0;
    font-size: 1.05em;
}

.theme-item-info p {
    margin: 0;
    font-size: 0.8em;
    opacity: 0.8;
}

.theme-item-select button {
    padding: 8px 12px;
    font-size: 0.9em;
}

/* Theme Switcher Styles */
.theme-switch-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Specific styling for standard checkboxes for smoothness */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

input[type="checkbox"]:checked {
    background-color: #2196F3;
    border-color: #2196F3;
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.5);
}

input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background-color: white;
    border-radius: 2px;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s ease-in-out;
}

input[type="checkbox"]:checked::before {
    transform: translate(-50%, -50%) scale(1);
}

/* Achievement Toast */
.achievement-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: var(--shadow-primary);
    display: none;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    z-index: 1001;
    animation: toastSlideIn 0.5s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.achievement-toast.show {
    display: flex;
}

.achievement-icon {
    font-size: 2rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.achievement-content {
    flex: 1;
}

.achievement-title {
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

.achievement-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .main {
        flex-direction: column;
        padding: 1rem;
    }
    
    .controls-panel {
        width: 100%;
        max-height: none;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .stats-display {
        order: 1;
    }
    
    .title {
        order: 2;
        align-items: center;
    }
    
    .header-actions {
        order: 3;
    }
    
    .toggle-grid {
        grid-template-columns: 1fr;
    }
    
    .shape-controls {
        flex-direction: column;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: none;
    }
    
    .achievement-toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        min-width: auto;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--background-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gradient-secondary);
}

/* Loading and transition effects */
.loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loaded {
    opacity: 1;
}

/* Particle effects for enhanced visual appeal */
.particle-effect {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: particleFloat 3s linear infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0);
    }
}

/* Glow effects for interactive elements */
.glow-effect {
    position: relative;
}

.glow-effect::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glow-effect:hover::before {
    opacity: 0.3;
}