:root {
    --bg-color: #0a0a12;
    --panel-bg: #161622;
    --text-color: #e0e0e0;
    --accent-color: #007bff;
    --accent-glow: 0 0 10px rgba(0, 123, 255, 0.5);
    --led-off: #2a2a35;
    --led-on: #007bff;
    --led-on-glow: 0 0 15px #007bff, 0 0 30px #007bff;
    --border-color: #333;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

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

h1 {
    margin: 0;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: var(--accent-glow);
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 5px;
    background-color: #000;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.led {
    width: 30px;
    height: 30px;
    background-color: var(--led-off);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.led.active {
    background-color: var(--led-on);
    box-shadow: var(--led-on-glow);
}

.controls {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

button {
    background-color: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    text-transform: uppercase;
}

button:hover {
    background-color: var(--accent-color);
    box-shadow: var(--accent-glow);
}

button.danger {
    border-color: #ff4444;
    color: #ff4444;
}

button.danger:hover {
    background-color: #ff4444;
    color: white;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.frame-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.frame-item {
    background-color: var(--bg-color);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.frame-item.active {
    border-color: var(--accent-color);
    background-color: rgba(0, 123, 255, 0.1);
}

.frame-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.output-panel {
    height: 150px;
    background-color: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

textarea {
    flex: 1;
    background-color: #000;
    color: #0f0;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    resize: none;
    font-size: 0.9rem;
}

.delay-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.delay-container label {
    font-size: 0.9rem;
}

.delay-container #delayValue {
    color: var(--accent-color);
    font-weight: bold;
    min-width: 30px;
    display: inline-block;
}

.delay-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 200px;
    height: 8px;
    background: var(--led-off);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.delay-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--accent-glow);
}

.delay-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--accent-glow);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .main-container {
        flex-direction: column;
        height: calc(100vh - 160px);
    }

    header {
        padding: 0.5rem 1rem;
    }

    h1 {
        font-size: 1.2rem;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 120px;
        /* Limit height */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        align-items: center;
        padding: 0.5rem;
        flex-shrink: 0;
        /* Don't shrink */
    }

    .sidebar-header {
        margin-bottom: 0;
        margin-right: 0.5rem;
        flex-direction: column;
        align-items: flex-start;
        min-width: 50px;
    }

    .sidebar-header h3 {
        font-size: 0.9rem;
        margin: 0 0 5px 0;
    }

    .frame-list {
        flex-direction: row;
        overflow-x: auto;
        align-items: center;
        height: 100%;
        padding-bottom: 5px;
        flex: 1;
        gap: 5px;
    }

    .frame-item {
        min-width: 80px;
        margin-right: 0;
        justify-content: center;
        flex-direction: column;
        text-align: center;
        padding: 0.3rem;
        font-size: 0.8rem;
    }

    .editor-area {
        padding: 0.5rem;
        flex: 1;
        overflow-y: auto;
        justify-content: flex-start;
    }

    .matrix-grid {
        gap: 3px;
        padding: 10px;
        margin-bottom: 1rem;
        max-width: 100%;
        overflow-x: auto;
    }

    .led {
        width: 6.5vw;
        height: 6.5vw;
        max-width: 35px;
        max-height: 35px;
        min-width: 20px;
        min-height: 20px;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        margin-top: 0.5rem;
    }

    button {
        padding: 0.6rem 0.5rem;
        font-size: 0.9rem;
        flex: 1 1 30%;
    }

    .output-panel {
        height: 100px;
        padding: 0.5rem;
        flex-shrink: 0;
    }

    .output-panel textarea {
        font-size: 0.8rem;
    }

    header div {
        display: flex;
        gap: 5px;
    }

    header button {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .delay-container {
        width: 100%;
        margin-top: 0.5rem;
    }

    .delay-slider {
        width: 80%;
        max-width: 250px;
    }
}