:root {
    /* Default Theme */
    --background: #1a1a1a;
    --foreground: #00ff41; /* Green */
    --accent: #ff007f; /* Pink/Magenta */
    --error: #ff3333;
    --text: #e0e0e0;

    /* Theme definitions for JS to apply */
    --theme-default-background: #1a1a1a;
    --theme-default-foreground: #00ff41;
    --theme-default-accent: #ff007f;
    --theme-default-error: #ff3333;
    --theme-default-text: #e0e0e0;

    --theme-red-background: #2a0000;
    --theme-red-foreground: #ff3333;
    --theme-red-accent: #ff9900;
    --theme-red-error: #ff0000;
    --theme-red-text: #ffe0e0;

    --theme-orange-background: #2a1100;
    --theme-orange-foreground: #ffaa00;
    --theme-orange-accent: #ff5500;
    --theme-orange-error: #ff3333;
    --theme-orange-text: #fff0e0;

    --theme-yellow-background: #2a2a00;
    --theme-yellow-foreground: #ffff00;
    --theme-yellow-accent: #ffcc00;
    --theme-yellow-error: #ff3333;
    --theme-yellow-text: #ffffcc;

    --theme-green-background: #002a00;
    --theme-green-foreground: #00ff00;
    --theme-green-accent: #00cc00;
    --theme-green-error: #ff3333;
    --theme-green-text: #e0ffe0;

    --theme-teal-background: #002a2a;
    --theme-teal-foreground: #00ffff;
    --theme-teal-accent: #00cccc;
    --theme-teal-error: #ff3333;
    --theme-teal-text: #e0ffff;

    --theme-cyan-background: #002a2a; /* Can be slightly different from teal */
    --theme-cyan-foreground: #00eeee;
    --theme-cyan-accent: #00aaaa;
    --theme-cyan-error: #ff3333;
    --theme-cyan-text: #e0eeee;

    --theme-blue-background: #00002a;
    --theme-blue-foreground: #007bff;
    --theme-blue-accent: #0056b3;
    --theme-blue-error: #ff3333;
    --theme-blue-text: #e0e0ff;

    --theme-purple-background: #2a002a;
    --theme-purple-foreground: #8a2be2;
    --theme-purple-accent: #6a0dad;
    --theme-purple-error: #ff3333;
    --theme-purple-text: #ffe0ff;

    --theme-pink-background: #2a001a;
    --theme-pink-foreground: #ff69b4;
    --theme-pink-accent: #ff1493;
    --theme-pink-error: #ff3333;
    --theme-pink-text: #fff0f5;
}

body {
    background-color: var(--background);
    color: var(--text);
    font-family: 'VT323', monospace;
    display: flex;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    font-size: 1.2rem;
    padding: 20px;
    box-sizing: border-box;
}

#app {
    width: 90%;
    max-width: 600px;
    background-color: #2a2a2a;
    border: 2px solid var(--foreground);
    box-shadow: 0 0 15px var(--foreground);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    position: relative;
    z-index: 1;
    margin-right: 20px;
}

h1 {
    color: var(--foreground);
    text-shadow: 0 0 5px var(--foreground);
    margin-top: 0;
}

.description {
    margin-bottom: 20px;
    line-height: 1.5;
}

#visualizer-container {
    position: relative;
    margin-bottom: 20px;
}

#visualizer {
    width: 100%;
    height: 150px;
    background-color: var(--background);
    border: 1px solid var(--foreground);
    border-radius: 4px;
    display: block;
}

#zoom-controls {
    position: absolute;
    bottom: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    align-items: center; /* Align items vertically */
}

#zoom-controls button {
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--foreground);
    border: 1px solid var(--foreground);
    border-radius: 4px;
    width: 25px;
    height: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#zoom-controls button:hover {
    background-color: var(--foreground);
    color: var(--background);
}

#zoomValue {
    color: var(--text);
    font-size: 1rem;
    width: 40px; /* Give it a fixed width to prevent shifting */
    text-align: center;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.time-display {
    background-color: #333;
    border: 1px solid var(--foreground);
    padding: 5px 10px;
    border-radius: 4px;
    flex-shrink: 0;
}

#timeValue {
    color: var(--text);
    cursor: pointer;
    min-width: 70px;
    display: inline-block;
    text-align: left;
}

.volume-control {
    flex-grow: 1;
    min-width: 100px;
}

.volume-control input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    margin-bottom: 5px;
    color: var(--foreground);
}

.control-group select,
.control-group input[type="number"] { /* Style for new number input */
    background-color: #333;
    color: var(--text);
    border: 1px solid var(--foreground);
    padding: 8px;
    font-family: 'VT323', monospace;
    font-size: 1.1rem;
    border-radius: 4px;
}

.control-group select:focus,
.control-group input[type="number"]:focus { /* Focus style for new input */
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.code-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.code-actions button {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.code-actions button:hover {
    background-color: var(--foreground);
    box-shadow: 0 0 10px var(--foreground);
}

textarea#code {
    width: calc(100% - 20px);
    height: 80px;
    background-color: #111;
    border: 1px solid var(--foreground);
    color: var(--foreground);
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 4px;
    resize: vertical;
    margin-bottom: 20px;
    box-shadow: inset 0 0 5px rgba(0, 255, 65, 0.5);
}

textarea#code:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 8px rgba(255, 0, 127, 0.7), 0 0 10px var(--accent);
}

#code-stats {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: #aaa;
    padding: 0 5px;
    margin-top: -15px;
    margin-bottom: 20px;
}

.speed-control-container {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speed-control-container label {
    color: var(--foreground);
    margin-bottom: 5px;
}

.speed-control-container input[type="range"] {
    width: 80%;
    max-width: 400px;
    cursor: pointer;
}

.play-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

button#playBtn, button#playReverseBtn, button#pauseBtn {
    background-color: var(--foreground);
    color: var(--background);
    border: none;
    padding: 12px 25px;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

button#playBtn:hover, button#playReverseBtn:hover, button#pauseBtn:hover {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 0 10px var(--accent);
}

button#playBtn:disabled, button#playReverseBtn:disabled, button#pauseBtn:disabled {
    background-color: #555;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
}

#error {
    color: var(--error);
    min-height: 1.2em;
    font-weight: bold;
}

#examples-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    background-color: #2a2a2a;
    border: 2px solid var(--foreground);
    box-shadow: 0 0 15px var(--foreground);
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    z-index: 100;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.examples {
    border-top: none;
    padding-top: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.examples h3 {
    margin-top: 0;
    color: var(--foreground);
    text-align: center;
    margin-bottom: 10px;
}

.examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px;
}

.examples ul::-webkit-scrollbar {
    width: 8px;
}

.examples ul::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

.examples ul::-webkit-scrollbar-thumb {
    background: var(--foreground);
    border-radius: 4px;
}

.examples li {
    background: #333;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 1rem;
    word-break: break-all;
}

.examples li:hover {
    background-color: var(--accent);
    color: white;
}

#toggleSettingsBtn {
    margin-top: 15px;
    width: 100%;
    background-color: var(--foreground);
    color: var(--background);
    border: none;
    padding: 8px 15px;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#toggleSettingsBtn:hover {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 0 10px var(--accent);
}

#settings-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    background-color: #2a2a2a;
    border: 2px solid var(--foreground);
    box-shadow: 0 0 15px var(--foreground);
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    z-index: 99; /* Slightly lower z-index than examples if they overlap */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

#settings-container.hidden {
    display: none;
}

.settings-panel h3 {
    margin-top: 0;
    color: var(--foreground);
    text-align: center;
    margin-bottom: 15px;
}

.setting-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed rgba(0, 255, 65, 0.3);
    position: relative; /* For absolute positioning of close button */
}

.setting-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.setting-group h4 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

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

.setting-item label {
    color: var(--text);
    font-size: 1rem;
}

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

.color-setting label {
    color: var(--text);
    font-size: 1rem;
}

.color-setting input[type="color"] {
    border: none;
    width: 40px;
    height: 25px;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
    background: none;
}

.color-setting input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.color-setting input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--foreground);
    border-radius: 3px;
}

.font-options label {
    display: block;
    margin-bottom: 5px;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
}

.font-options input[type="radio"],
.setting-item input[type="checkbox"] { /* Style for new checkbox */
    margin-right: 8px;
    cursor: pointer;
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.theme-btn {
    background-color: #333;
    color: var(--text);
    border: 1px solid var(--foreground);
    padding: 5px 10px;
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-btn:hover, .theme-btn.active {
    background-color: var(--foreground);
    color: var(--background);
    border-color: var(--accent);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 1.2rem;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s;
}

.close-btn:hover {
    background-color: var(--accent);
    color: var(--background);
}

/* Scrollbar for settings panel */
#settings-container::-webkit-scrollbar {
    width: 8px;
}

#settings-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

#settings-container::-webkit-scrollbar-thumb {
    background: var(--foreground);
    border-radius: 4px;
}

@media (max-width: 900px) {
    #examples-container,
    #settings-container {
        position: static;
        width: auto;
        margin: 20px auto;
        max-height: none;
    }
    body {
        flex-direction: column;
        align-items: center;
    }
}