:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --text-main: #ffffff;
    --text-muted: #888888;
    
    --neon-green: #39ff14;
    --neon-blue: #00f0ff;
    --neon-pink: #ff007f;
    --neon-purple: #b026ff;
    
    --step-bg: #2a2a2a;
    --step-border: #333333;
    --step-active: var(--neon-blue);
    --step-playing: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    background-color: var(--bg-panel);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 240, 255, 0.1);
    width: 95%;
    max-width: 1000px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    margin-right: 2rem;
}

.transport-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    background: #2a2a2a;
    border: none;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.control-btn:hover {
    background: #3a3a3a;
}

.control-btn:active {
    transform: scale(0.95);
}

.play-btn {
    background: rgba(57, 255, 20, 0.2);
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
}

.play-btn:hover {
    background: rgba(57, 255, 20, 0.4);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.3);
}

.play-btn.active {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 20px var(--neon-green);
}

.export-btn {
    background: rgba(255, 0, 127, 0.2);
    border: 1px solid var(--neon-pink);
    color: var(--neon-pink);
    margin-left: 1rem;
}

.export-btn:hover {
    background: rgba(255, 0, 127, 0.4);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.3);
}

.bpm-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #222;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.bpm-control label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

#bpm-display {
    color: var(--neon-blue);
    font-weight: bold;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--neon-blue);
    cursor: pointer;
    margin-top: -5px;
    box-shadow: 0 0 10px var(--neon-blue);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #444;
    border-radius: 2px;
}

/* Sequencer Grid */
.sequencer {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.channel {
    display: flex;
    align-items: center;
}

.channel-label {
    width: 120px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.steps {
    display: flex;
    gap: 4px;
    flex: 1;
}

/* Group steps into logic blocks of 4 */
.steps .step:nth-child(4n+1) {
    margin-left: 6px;
}

.steps .step:first-child {
    margin-left: 0;
}

.step {
    flex: 0 0 45px;
    height: 45px;
    background-color: var(--step-bg);
    border: 1px solid var(--step-border);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.1s ease, box-shadow 0.1s ease;
    position: relative;
}

.step:hover {
    background-color: #383838;
}

/* Channel specific active colors */
.channel[data-instrument="kick"] .step.active {
    background-color: var(--neon-pink);
    box-shadow: 0 0 12px rgba(255, 0, 127, 0.6);
    border-color: var(--neon-pink);
}

.channel[data-instrument="snare"] .step.active {
    background-color: var(--neon-blue);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
    border-color: var(--neon-blue);
}

.channel[data-instrument="closedHat"] .step.active {
    background-color: var(--neon-purple);
    box-shadow: 0 0 12px rgba(176, 38, 255, 0.6);
    border-color: var(--neon-purple);
}

.channel[data-instrument="openHat"] .step.active {
    background-color: var(--neon-green);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.6);
    border-color: var(--neon-green);
}

/* Playing state indicator */
.step.playing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Playhead Row */
.playhead-channel {
    margin-bottom: 0.5rem;
}

.playhead-step {
    flex: 0 0 45px;
    height: 10px;
    background-color: transparent;
    border-radius: 5px;
    transition: background-color 0.05s ease;
}

/* Maintain margins for visual alignment */
.playhead-steps .playhead-step:nth-child(4n+1) {
    margin-left: 6px;
}

.playhead-steps .playhead-step:first-child {
    margin-left: 0;
}

.playhead-step.active {
    background-color: #fff;
    box-shadow: 0 0 8px #fff;
}

#status-message {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--neon-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    animation: pulse 1.5s infinite;
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@media (max-width: 800px) {
    .channel-label {
        width: 80px;
        font-size: 0.75rem;
    }
    .transport-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 1rem;
    }
    h1 { margin-right: 0; width: 100%; text-align: center; }
}

/* Custom instrument colors */
.channel[data-instrument="clap"] .step.active {
    background-color: #ff9900;
    box-shadow: 0 0 12px rgba(255, 153, 0, 0.6);
    border-color: #ff9900;
}
.channel[data-instrument="tomLow"] .step.active {
    background-color: #ff00ff;
    box-shadow: 0 0 12px rgba(255, 0, 255, 0.6);
    border-color: #ff00ff;
}
.channel[data-instrument="tomHigh"] .step.active {
    background-color: #00ffcc;
    box-shadow: 0 0 12px rgba(0, 255, 204, 0.6);
    border-color: #00ffcc;
}
.channel[data-instrument="cowbell"] .step.active {
    background-color: #ffffff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
    border-color: #ffffff;
}

/* Scrollbar specific for sequencer wrapper */
.sequencer-wrapper::-webkit-scrollbar {
    height: 10px;
}
.sequencer-wrapper::-webkit-scrollbar-track {
    background: #222; 
    border-radius: 5px;
}
.sequencer-wrapper::-webkit-scrollbar-thumb {
    background: var(--neon-blue); 
    border-radius: 5px;
}
