:root {
    --bg-color: #121212;
    --sidebar-bg: rgba(30, 30, 30, 0.4);
    --text-color: #e0e0e0;
    --accent-color: #4facfe;
    --accent-hover: #00f2fe;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
    --sidebar-width: 320px;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#tsparticles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: none;
}

/* Sidebar Styling */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 20px;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed) ease;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
}

#sidebar.hidden-mobile {
    transform: translateX(-100%);
}

@media (min-width: 769px) {
    #sidebar.hidden-mobile {
        transform: translateX(0);
    }
}

/* Header */
.header h1 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
    background: linear-gradient(to right, var(--accent-color), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Preset Selector */
.preset-selector-container {
    margin-bottom: 25px;
}

.preset-selector-container label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    margin-bottom: 8px;
}

#preset-select,
#matrix-charset {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition-speed);
}

#preset-select:focus,
#matrix-charset:focus {
    outline: none;
    border-color: var(--accent-color);
}

#preset-select option,
#matrix-charset option {
    background: #222;
}

/* Controls */
.section {
    margin-bottom: 25px;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #ccc;
}

input[type="range"] {
    width: 100%;
    background: transparent;
    -webkit-appearance: none;
    margin: 8px 0;
}

input[type="range"]:focus {
    outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.5);
    transition: transform 0.1s;
}

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

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 40px;
    background: none;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}

/* Pro Effects */
.pro-effects {
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.pro-effects h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.toggle-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.toggle-group span {
    margin-left: 10px;
    font-size: 0.9rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

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

/* Interaction Mode Select */
#interaction-mode {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: white;
    font-family: inherit;
    cursor: pointer;
}

#interaction-mode option {
    background: #222;
}

/* Buttons */
.primary-btn,
.secondary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    display: none;
    /* Hidden on desktop */
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    #sidebar {
        width: 100%;
        /* Full width on mobile when open */
    }
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #1e1e1e;
    width: 90%;
    max-width: 700px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    margin: 0;
    color: #ffffff;
}

#btn-close-modal {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

#btn-close-modal:hover {
    color: white;
}

.modal-body {
    padding: 0;
    flex-grow: 1;
    overflow: hidden;
}

#export-code {
    width: 100%;
    height: 400px;
    background: #111;
    color: #ffffff;
    font-family: 'Fira Code', monospace;
    padding: 20px;
    border: none;
    resize: none;
    font-size: 0.9rem;
    line-height: 1.5;
}

#export-code:focus {
    outline: none;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

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

.semplicemente-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    text-align: center;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 15px;
    margin-top: 0;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.3);
}

.semplicemente-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 82, 152, 0.4);
}