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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #0a0a0a;
    color: #fff;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}

header {
    padding: 1rem;
    background-color: rgba(20, 20, 20, 0.9);
    border-bottom: 1px solid #333;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.info {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #888;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.sequencer-container {
    flex: 1;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.note-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 40px;
    font-size: 0.75rem;
    color: #666;
    padding: 0.5rem 0;
}

.note-label {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.grid-wrapper {
    flex: 1;
    position: relative;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.playhead {
    position: absolute;
    top: 0;
    width: 3px;
    height: 100%;
    background-color: #4ecdc4;
    box-shadow: 0 0 10px #4ecdc4;
    z-index: 10;
    pointer-events: none;
    transition: transform 0.1s linear;
}

.sequencer-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 2px;
    min-width: 100%;
    padding: 0.5rem 0;
}

.grid-cell {
    aspect-ratio: 1;
    background-color: #222;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.grid-cell:hover {
    background-color: #333;
}

.grid-cell.active {
    background-color: #4ecdc4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

.grid-cell.active.playing {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(20, 20, 20, 0.9);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: #333;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.control-btn:hover {
    background-color: #444;
}

.control-btn.play {
    background-color: #4ecdc4;
}

.control-btn.play:hover {
    background-color: #3dbdb5;
}

.control-btn.stop {
    background-color: #ff6b6b;
}

.control-btn.stop:hover {
    background-color: #ff5252;
}

.control-btn.clear:hover {
    background-color: #666;
}

label {
    font-size: 0.875rem;
    color: #888;
}

input[type="range"] {
    width: 100px;
    height: 4px;
    background-color: #333;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background-color: #4ecdc4;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background-color: #4ecdc4;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

select {
    padding: 0.25rem 0.5rem;
    background-color: #333;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}

select:hover {
    background-color: #444;
}

.pattern-presets {
    padding: 1rem;
    background-color: rgba(20, 20, 20, 0.9);
    border-radius: 8px;
}

.pattern-presets h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #888;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem 1rem;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background-color: #444;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.25rem;
    }
    
    .controls {
        justify-content: center;
    }
    
    .sequencer-grid {
        grid-template-columns: repeat(16, 40px);
    }
    
    input[type="range"] {
        width: 80px;
    }
}