@font-face {
  font-family: 'Aurebesh';
  src: url('fonts/AurebeshAF-Canon.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Predator';
  src: url('fonts/predator.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Klingon';
  src: url('fonts/klingon.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: rgb(16, 16, 18);
  --top: rgb(22, 22, 26);
  --pad: rgb(34, 34, 40);
  --padActive: rgb(70, 40, 120);
  --ribbon: rgb(20, 20, 24);
  --ribbonActive: rgb(26, 26, 38);
  --text: rgb(230, 230, 238);
  --muted: rgba(230, 230, 238, 0.65);
  --hair: rgba(255, 255, 255, 0.06);
}

html {
  height: 100%;
  width: 100%;
  overflow: hidden;
  /* Prevent iOS double-tap zoom and all scrolling */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
}

body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
  /* Prevent all scrolling and panning */
  touch-action: none;
  -webkit-overflow-scrolling: none;
  position: relative;
}

/* Prevent all zoom gestures on touch devices */
* {
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.zone {
  touch-action: none;
  user-select: none;
}

/* Allow controls in zones to be interactive */
/* Override pointer-events: none from parent zones */
.zone .control-select,
.zone .control-group,
.zone .controls-row {
  touch-action: manipulation;
  pointer-events: auto !important;
}

.controls-row {
  pointer-events: auto !important;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto !important;
}

.control-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

.control-label .label-short {
  display: none;
}

.control-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  min-width: 80px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  pointer-events: auto !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* BPM controls */
.bpm-controls-desktop {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.bpm-display {
  min-width: 48px;
  width: 48px;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 4px 8px;
  height: 28px;
  font-family: inherit;
  -moz-appearance: textfield;
}

.bpm-display::-webkit-outer-spin-button,
.bpm-display::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bpm-display:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.bpm-buttons-stacked {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.bpm-button {
  min-width: 12px !important;
  width: 12px !important;
  height: 10px !important;
  padding: 0 !important;
  font-size: 6px !important;
  line-height: 1 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bpm-select-mobile {
  min-width: 60px;
  width: auto;
}

/* Volume controls (desktop only) */
.volume-controls-desktop {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  width: 120px;
}

.volume-slider-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.volume-slider {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.volume-slider-inline {
  width: 120px;
  margin-left: 4px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px;
  height: 8px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--hair);
}

.volume-slider::-moz-range-thumb {
  width: 8px;
  height: 8px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--hair);
}

.volume-slider:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Hide desktop controls on mobile, hide mobile dropdown on desktop */
@media (max-width: 767px) {
  .bpm-controls-desktop {
    display: none !important;
  }
  .volume-controls-desktop {
    display: none !important;
  }
  .bpm-select-mobile {
    display: block !important;
  }
}

@media (min-width: 768px) {
  .bpm-controls-desktop {
    display: flex !important;
  }
  .volume-controls-desktop {
    display: flex !important;
  }
  .bpm-select-mobile {
    display: none !important;
  }
}

.control-select option {
  background: var(--top);
  color: var(--text);
}

.voice-select-wrapper {
  position: relative;
  display: inline-block;
}

.voice-select-wrapper .control-select {
  color: transparent;
}

.voice-select-wrapper .control-select option {
  color: var(--text);
}

.voice-type-display {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  z-index: 1;
}

.voice-type-display .wt-label {
  font-size: 9px;
  opacity: 0.8;
  margin-left: 2px;
}

.button-group {
  display: flex;
  gap: 4px;
  pointer-events: auto !important;
}

.control-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 4px 12px;
  min-width: 36px;
  height: 28px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  pointer-events: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.control-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.control-button:active {
  background: rgba(255, 255, 255, 0.18);
}

.control-button.active {
  background: var(--padActive);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
}

.trash-icon {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Pattern buttons (multi-select) */
.pattern-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.pattern-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  min-width: 44px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  font-family: inherit;
}

.pattern-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.pattern-button.active {
  background: var(--padActive);
  border-color: var(--padActive);
  color: #fff;
  box-shadow: 0 0 8px rgba(70, 40, 120, 0.4);
}

/* Active state for drum kit buttons */
#loadKit1Button.active,
#loadKit2Button.active {
  background: var(--padActive);
  border-color: var(--padActive);
  color: #fff;
  box-shadow: 0 0 8px rgba(70, 40, 120, 0.4);
}

/* Colorize selected items based on tab colors */
/* Settings (General) tab - #9B5DE5 */
#settingsTab .setting-label input[type="checkbox"]:checked {
  accent-color: #9B5DE5;
}

#settingsTab .setting-value {
  color: #9B5DE5;
}

/* Beat (sequencer) tab - #F15BB5 */
#sequencerTab .pattern-button.active {
  background: #F15BB5;
  border-color: #F15BB5;
  box-shadow: 0 0 8px rgba(241, 91, 181, 0.4);
}

#sequencerTab #defaultDrumsButton.active,
#sequencerTab #loadKit1Button.active,
#sequencerTab #loadKit2Button.active {
  background: #F15BB5 !important;
  border-color: #F15BB5 !important;
  box-shadow: 0 0 8px rgba(241, 91, 181, 0.4) !important;
  color: #fff !important;
}

/* Active state for drum loop items */
#sequencerTab .drum-loop-item.active {
  background: rgba(241, 91, 181, 0.2);
  border-left: 3px solid #F15BB5;
  padding-left: 8px;
}

#sequencerTab .control-select:focus {
  border-color: #F15BB5;
  box-shadow: 0 0 4px rgba(241, 91, 181, 0.3);
}

#sequencerTab .control-select option:checked {
  background: #F15BB5;
}

/* Shaper tab - #FEE440 */
#shaperTab .setting-value {
  color: #FEE440;
}

#shaperTab .setting-slider::-webkit-slider-thumb {
  background: #FEE440;
}

#shaperTab .setting-slider::-webkit-slider-thumb:hover {
  background: rgba(254, 228, 64, 0.9);
}

#shaperTab .setting-slider::-moz-range-thumb {
  background: #FEE440;
}

#shaperTab .setting-slider::-moz-range-thumb:hover {
  background: rgba(254, 228, 64, 0.9);
}

#shaperTab .setting-label input[type="checkbox"]:checked {
  accent-color: #FEE440;
}

/* Sequence (stepcounter) tab - #00BBF9 */
#stepcounterTab .step-length-button.active {
  background: #00BBF9;
  border-color: #00BBF9;
  box-shadow: 0 0 8px rgba(0, 187, 249, 0.4);
}

#stepcounterTab .step-length-button.active:hover {
  background: rgba(0, 187, 249, 0.9);
}

#stepcounterTab .step-counter-mode-selector .mode-option:has(input:checked) {
  border-color: #00BBF9;
  background: rgba(0, 187, 249, 0.1);
  outline: 2px solid rgba(0, 187, 249, 0.5);
}

#stepcounterTab .step-counter-mode-selector .mode-option input[type="radio"]:checked {
  accent-color: #00BBF9;
}

#stepcounterTab .setting-value {
  color: #00BBF9;
}

#stepcounterTab .setting-label input[type="checkbox"]:checked {
  accent-color: #00BBF9;
}

/* Also color other checkboxes in Sequence tab (e.g. "Include beat (drums)") */
#stepcounterTab input[type="checkbox"]:checked {
  accent-color: #00BBF9;
}

/* About tab - #00F5D4 */
#aboutTab .setting-label input[type="checkbox"]:checked {
  accent-color: #00F5D4;
}

#aboutTab .setting-value {
  color: #00F5D4;
}

.pattern-button:active {
  transform: scale(0.95);
}

.control-button.active:hover {
  background: rgba(70, 40, 120, 0.9);
}

.record-button {
  min-width: 28px;
  padding: 4px 8px;
}

.erase-button {
  min-width: 28px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.erase-icon {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1); /* Makes SVG white */
  pointer-events: none;
}

/* Record button: red circle when not recording */
.record-button:not(.recording) {
  color: #ff0000;
}

.control-button.recording {
  background: rgba(200, 50, 70, 0.35);
  border-color: rgba(220, 60, 80, 0.7);
  color: rgba(255, 255, 255, 0.95);
}

.control-button.recording:hover {
  background: rgba(200, 50, 70, 0.5);
}

.control-button span {
  display: inline-block;
  line-height: 1;
}

/* Play button in HUD: green play icon when stopped, default styling when running */
#sequencerPlay {
  color: #4CAF50; /* green when showing ▶ */
}

#sequencerPlay.is-playing {
  /* Stop state: only the inner square glyph is blue; button chrome stays the same */
  color: #00BBF9;
}

/* Toggle switch for arpeggiator */
.toggle-switch-container {
  display: flex;
  align-items: center;
  pointer-events: auto !important;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
  pointer-events: auto !important;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  transition: 0.2s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text);
  transition: 0.2s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--padActive);
  border-color: rgba(255, 255, 255, 0.2);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--padActive);
}

.toggle-switch:hover .toggle-slider {
  background-color: rgba(255, 255, 255, 0.12);
}

.toggle-switch input:checked:hover + .toggle-slider {
  background-color: rgba(70, 40, 120, 0.9);
}

.menu-button {
  touch-action: manipulation;
  pointer-events: auto;
}

#topStrip {
  position: relative;
  height: 28px;
  background: var(--top);
  border-bottom: 1px solid var(--hair);
  z-index: 1;
}

#topHud {
  position: absolute;
  inset: 0;
  padding: 2px 12px;
  padding-right: 36px; /* Make room for menu button */
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}

.menu-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 36px;
  height: 28px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--hair);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 1;
  touch-action: manipulation;
  pointer-events: auto;
}

.menu-button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.menu-button:active {
  background: rgba(255, 255, 255, 0.1);
}

.hamburger {
  width: 24px;
  height: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.menu-button[aria-expanded="true"] .hamburger span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.menu-button[aria-expanded="true"] .hamburger span:nth-child(2) {
  opacity: 0;
}

.menu-button[aria-expanded="true"] .hamburger span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.hudRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  white-space: nowrap;
}

#backendStatus {
  color: var(--muted);
  font-size: 12px;
}


#main {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  z-index: 2;
}

#pads {
  width: 46%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  box-sizing: border-box;
  transition: width 0.3s ease, opacity 0.3s ease;
}

#pads.hidden {
  width: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
}

#pads.hidden ~ #ribbon {
  width: 100%;
}

.pad {
  background: var(--pad);
  border: 1px solid var(--hair);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: none;
}

.pad.active {
  background: var(--padActive);
  border-color: rgba(255, 255, 255, 0.14);
}

#ribbon {
  width: 54%;
  position: relative;
  background-color: var(--ribbon);
  background-image: url('background.png');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  border-left: 1px solid var(--hair);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  /* Prevent iOS double-tap zoom and all browser touch gestures */
  touch-action: none;
}

#ribbon::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('background.png');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

#ribbon.active {
  position: relative;
  /* Note: removed overflow: hidden to prevent clipping #ribbonNoteDisplay */
}

.ribbon-light-effect {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  transition: left 0.1s ease-out, top 0.1s ease-out, background 0.1s ease-out, width 0.1s ease-out, height 0.1s ease-out, margin 0.1s ease-out;
}

#ribbonHint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}

#ribbonGrid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.ribbon-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.ribbon-grid-label {
  position: absolute;
  left: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}

.ribbon-grid-label .note-name {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.15s;
}

.ribbon-grid-label .note-hz {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.8;
  transition: color 0.15s;
}

/* Red glow/aura when note is active (ribbon is pressed) - keep original text color */
.ribbon-grid-label.active-note .note-name,
.ribbon-grid-label.active-note .note-hz {
  text-shadow: 
    0 0 6px rgba(139, 0, 0, 1.0),
    0 0 12px rgba(139, 0, 0, 0.9),
    0 0 18px rgba(139, 0, 0, 0.7),
    0 0 24px rgba(139, 0, 0, 0.5),
    0 0 32px rgba(139, 0, 0, 0.3);
}

#ribbonCursor,
.ribbonCursor {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

#ribbon.active #ribbonCursor,
#ribbon.active .ribbonCursor {
  opacity: 1;
}

#ribbonNoteDisplay {
  position: absolute;
  right: 12px;
  top: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 6px 10px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s;
}

#ribbon.active #ribbonNoteDisplay {
  opacity: 1;
}

#ribbonNoteName {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  transition: color 0.15s, font-size 0.15s;
}

#ribbonNoteHz {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.2;
  transition: color 0.15s, font-size 0.15s;
}

/* Deep red color when note is active (ribbon is pressed) */
#ribbonNoteDisplay.active-note #ribbonNoteName {
  color: #8B0000; /* Deep red (dark red) */
  font-size: 16px;
  text-shadow: 
    0 0 8px rgba(139, 0, 0, 1.0),
    0 0 16px rgba(139, 0, 0, 0.9),
    0 0 24px rgba(139, 0, 0, 0.7),
    0 0 32px rgba(139, 0, 0, 0.5),
    0 0 40px rgba(139, 0, 0, 0.3);
}

#ribbonNoteDisplay.active-note #ribbonNoteHz {
  color: #8B0000; /* Deep red (dark red) */
  font-size: 12px;
  text-shadow: 
    0 0 8px rgba(139, 0, 0, 1.0),
    0 0 16px rgba(139, 0, 0, 0.9),
    0 0 24px rgba(139, 0, 0, 0.7),
    0 0 32px rgba(139, 0, 0, 0.5),
    0 0 40px rgba(139, 0, 0, 0.3);
}

/* Enhanced glow for the note display container when active */
#ribbonNoteDisplay.active-note {
  box-shadow: 
    0 0 8px rgba(139, 0, 0, 0.6),
    0 0 16px rgba(139, 0, 0, 0.4),
    0 0 24px rgba(139, 0, 0, 0.2);
  border-color: rgba(139, 0, 0, 0.5);
}

/* Step indicator - centered on screen with circular progress ring */
#stepIndicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  opacity: 0.5;
  transition: opacity 0.1s ease-out;
  font-family: 'Aurebesh', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  /* Visual radius for note-hue markers (overridden on desktop) */
  --step-indicator-radius: 75px;
}

#stepIndicator svg#stepIndicatorRing {
  width: 180px;
  height: 180px;
  display: block;
}

/* Desktop: enlarge circular step indicator by ~30% */
@media (min-width: 769px) {
  #stepIndicator svg#stepIndicatorRing {
    width: 280px;
    height: 280px;
  }
  #stepIndicator {
    /* Increase marker radius proportionally for larger circle */
    --step-indicator-radius: 118px;
  }
}

.step-indicator-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.step-indicator-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  transform-origin: center center;
  /* Radius to sit on the big circle; negative Y to go upward from center */
  transform: rotate(var(--angle)) translate(0, calc(-1 * var(--step-indicator-radius)));
}

.step-indicator-mark.has-note {
  background: hsla(var(--note-hue, 0), 80%, 55%, 1);
  box-shadow:
    0 0 6px hsla(var(--note-hue, 0), 80%, 60%, 0.9),
    0 0 12px hsla(var(--note-hue, 0), 80%, 50%, 0.7);
}

.step-indicator-ring-bg {
  fill: transparent;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 18;
}

.step-indicator-ring-progress {
  fill: transparent;
  stroke: #ffffff;
  stroke-width: 18;
  stroke-linecap: round;
  transform-origin: 50% 50%;
  transform: rotate(-90deg); /* Start at 12 o'clock */
  stroke-dasharray: 1 1; /* Real values set from JS based on radius */
  stroke-dashoffset: 1;
}

#stepIndicatorText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  font-weight: 700;
  color: #ffffff; /* White font */
  white-space: nowrap;
  text-shadow: 
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 20px rgba(255, 255, 255, 0.4);
}

#stepIndicator.hidden,
.step-progress-bar.hidden {
  display: none !important;
}

/* Step progress bar - horizontal bar with configurable sections */
.step-progress-bar {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 1px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.85;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  /* CSS variable for step length - defaults to 64 */
  --step-length: 64;
  /* Scale factor: fewer steps = larger segments (64/base = scale) */
  --segment-scale: calc(64 / var(--step-length));
}

.step-progress-bar .step-segment {
  /* Scale segment size based on step length */
  width: calc(8px * var(--segment-scale));
  height: calc(32px * var(--segment-scale));
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: background 0.05s ease-out, box-shadow 0.05s ease-out;
}

.step-progress-bar .step-segment.active {
  background: #ffffff;
  box-shadow: 
    0 0 8px rgba(255, 255, 255, 0.8),
    0 0 16px rgba(255, 255, 255, 0.5);
}

/* When recording, active step should be red */
body.recording-active .step-progress-bar .step-segment.active {
  background: #D70040;
  box-shadow: 
    0 0 8px rgba(215, 0, 64, 0.8),
    0 0 16px rgba(215, 0, 64, 0.5);
}

/* Beat markers every 16 steps (every 4 beats) */
.step-progress-bar .step-segment.beat-marker {
  background: rgba(255, 255, 255, 0.25);
}

.step-progress-bar .step-segment.beat-marker.active {
  background: #ffffff;
}

/* When recording, active beat marker should be red */
body.recording-active .step-progress-bar .step-segment.beat-marker.active {
  background: #D70040;
}

/* Segments with recorded notes - colored by pitch */
.step-progress-bar .step-segment.has-note {
  background: hsla(var(--note-hue, 0), 70%, 45%, 0.9);
  box-shadow: 0 0 4px hsla(var(--note-hue, 0), 70%, 50%, 0.5);
}

.step-progress-bar .step-segment.has-note.active {
  background: hsla(var(--note-hue, 0), 80%, 55%, 1);
  box-shadow: 
    0 0 8px hsla(var(--note-hue, 0), 80%, 60%, 0.8),
    0 0 16px hsla(var(--note-hue, 0), 80%, 50%, 0.5);
}

/* When recording, active step with note should be red (override note color) */
body.recording-active .step-progress-bar .step-segment.has-note.active {
  background: #D70040;
  box-shadow: 
    0 0 8px rgba(215, 0, 64, 0.8),
    0 0 16px rgba(215, 0, 64, 0.5);
}

/* Step counter mode selector in settings */
.step-counter-mode-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-counter-mode-selector .mode-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.step-counter-mode-selector .mode-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.step-counter-mode-selector .mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.step-counter-mode-selector .mode-option:has(input:checked) {
  background: rgba(255, 51, 51, 0.15);
  outline: 2px solid rgba(255, 51, 51, 0.5);
}

.step-counter-mode-selector .mode-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.step-counter-mode-selector .mode-description {
  font-size: 12px;
  color: var(--muted);
}

/* Desktop: larger progress bar with skew angle to the right */
@media (min-width: 769px) {
  .step-progress-bar {
    padding: calc(8px * var(--segment-scale));
    gap: calc(2px * var(--segment-scale));
    /* Scale factor for progress bar size (default 1.0 = 100%) */
    --progress-bar-scale: 1.0;
    transform: translate(-50%, -50%) skewX(15deg) scale(var(--progress-bar-scale));
  }
  
  .step-progress-bar .step-segment {
    /* Base size for desktop: 16px wide, 64px tall, scaled by step length */
    width: calc(16px * var(--segment-scale));
    height: calc(64px * var(--segment-scale));
  }
  
  /* Desktop HUD: Show Pattern label and Beat label next to play button, hide Beat label next to record */
  .pattern-label-desktop {
    display: inline;
  }
  
  .beat-label-desktop {
    display: inline;
  }
  
  .beat-label-mobile {
    display: none;
  }
  
  /* Show progress bar size control only on desktop */
  .progress-bar-size-control {
    display: block !important;
    margin-top: 12px;
    margin-left: 12px;
    margin-right: 12px;
  }
}

/* iPad/Tablet: vertical layout with skew like mobile */
@media (min-width: 481px) and (max-width: 768px) {
  .step-progress-bar {
    flex-direction: column;
    max-height: 60vh;
    overflow-y: auto;
    /* Fixed width that doesn't scale with step count - keeps container well-proportioned */
    width: min(50vw, 200px);
    min-width: 120px;  /* Ensure minimum width for visibility */
    max-width: 200px;  /* Cap maximum width to prevent expansion on fewer steps */
    padding: calc(8px * var(--segment-scale));
    gap: calc(3px * var(--segment-scale));
    /* Ensure fixed positioning stays centered relative to viewport */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) skewY(-15deg); /* Angle to the right (skewY for vertical bar), same as mobile */
    /* Prevent this element from causing scroll */
    touch-action: none;
    overscroll-behavior: none;
  }
  
  .step-progress-bar .step-segment {
    width: 100%;  /* Use full width of container */
    /* Base height for iPad: 8px, scaled by step length - longer than mobile (6px) */
    height: calc(8px * var(--segment-scale));
  }
}

/* Responsive: smaller segments on mobile phones */
@media (max-width: 480px) {
  /* Shorten Arpeggiator label to Arp on mobile */
  .control-label .label-full {
    display: none;
  }
  .control-label .label-short {
    display: inline;
  }
  .step-progress-bar .step-segment {
    /* Base size for mobile: 4px wide, 24px tall, scaled by step length */
    width: calc(4px * var(--segment-scale));
    height: calc(24px * var(--segment-scale));
  }
  
  .step-progress-bar {
    gap: 0px;
    padding: calc(3px * var(--segment-scale));
  }
}

/* Make step progress bar vertical on mobile phones (not tablets) */
/* Stack vertically and progress from top to bottom */
@media (max-width: 480px) {
  /* Ensure html and body prevent all scrolling on mobile */
  html, body {
    width: 100%;
    height: 100%;
    overflow: hidden !important;
    touch-action: none !important;
    -webkit-overflow-scrolling: none;
    overscroll-behavior: none;
    -webkit-overscroll-behavior: none;
  }
  
  /* Prevent any element from causing scroll */
  #app {
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height on mobile */
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
  }
  
  /* Prevent all child elements from causing scroll */
  #app * {
    overscroll-behavior: none;
    -webkit-overscroll-behavior: none;
  }
  
  .step-progress-bar {
    flex-direction: column;
    max-height: 60vh;  /* Reduced from 85vh */
    overflow-y: auto;
    /* Fixed width that doesn't scale with step count - keeps container well-proportioned */
    width: min(50vw, 200px);
    min-width: 120px;  /* Ensure minimum width for visibility */
    max-width: 200px;  /* Cap maximum width to prevent expansion on fewer steps */
    padding: calc(8px * var(--segment-scale));
    gap: calc(3px * var(--segment-scale));
    /* Ensure fixed positioning stays centered relative to viewport */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) skewY(-15deg); /* Angle to the right (skewY for vertical bar) */
    /* Prevent this element from causing scroll */
    touch-action: none;
    overscroll-behavior: none;
  }
  
  /* Ensure step indicator stays centered relative to viewport */
  #stepIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Prevent this element from causing scroll */
    touch-action: none;
    overscroll-behavior: none;
  }
  
  .step-progress-bar .step-segment {
    width: 100%;  /* Use full width of container */
    /* Base height for mobile: 6px, scaled by step length */
    height: calc(6px * var(--segment-scale));
  }
  
  /* Ensure note colors work on mobile */
  .step-progress-bar .step-segment.has-note {
    background: hsla(var(--note-hue, 0), 70%, 45%, 0.9);
    box-shadow: 0 0 4px hsla(var(--note-hue, 0), 70%, 50%, 0.5);
  }
  
  .step-progress-bar .step-segment.has-note.active {
    background: hsla(var(--note-hue, 0), 80%, 55%, 1);
    box-shadow: 
      0 0 8px hsla(var(--note-hue, 0), 80%, 60%, 0.8),
      0 0 16px hsla(var(--note-hue, 0), 80%, 50%, 0.5);
  }
}


.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: min(480px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  background: var(--top);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--hair);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  touch-action: manipulation;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-close:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Welcome Modal Styles */
.welcome-modal-content {
  max-width: 460px;
  text-align: center;
}

.welcome-modal-body {
  padding: 40px 24px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
}

.welcome-version {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  font-weight: normal;
  letter-spacing: 0.5px;
}

.welcome-title {
  font-family: 'Badeen Display', system-ui, -apple-system, sans-serif;
  font-size: 56px;
  font-weight: normal;
  margin: 0;
  color: var(--text);
  letter-spacing: -2px;
  position: relative;
  display: inline-block;
}

.welcome-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  height: 2px;
  background: var(--welcome-line-gradient, white);
  width: 0;
  animation: draw-line 0.5s ease-out 0.8s forwards;
}

@keyframes draw-line {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

/* On smaller viewports, keep the original sizing to avoid crowding */
@media (max-width: 768px) {
  .welcome-modal-content {
    max-width: 400px;
  }
  .welcome-title {
    font-size: 48px;
  }
}

.welcome-title span {
  display: inline-block;
  animation: letter-arrive 1s ease-out forwards;
}

.welcome-title span:nth-child(1) {
  animation: letter-arrive-top 1s ease-out forwards;
}

.welcome-title span:nth-child(2) {
  animation: letter-arrive-bottom 1s ease-out forwards;
}

.welcome-title span:nth-child(3) {
  animation: letter-arrive-top 1s ease-out forwards;
}

.welcome-title span:nth-child(4) {
  animation: letter-arrive-bottom 1s ease-out forwards;
}

.welcome-title span:nth-child(5) {
  animation: letter-arrive-top 1s ease-out forwards;
}


@keyframes letter-arrive-top {
  0% {
    transform: translate(-8px, -100px);
    opacity: 0;
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  2% {
    transform: translate(8px, -100px);
    text-shadow: -2px 0 #00BBF9, 2px 0 #FEE440;
  }
  4% {
    transform: translate(-8px, -100px);
    text-shadow: 2px 0 #00F5D4, -2px 0 #9B5DE5;
  }
  6% {
    transform: translate(8px, -100px);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  8% {
    transform: translate(-8px, -100px);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #FEE440;
  }
  10% {
    transform: translate(8px, -100px);
    text-shadow: -2px 0 #00BBF9, 2px 0 #00F5D4;
  }
  12% {
    transform: translate(-6px, -50px);
    text-shadow: 2px 0 #F15BB5, -2px 0 #9B5DE5;
  }
  14% {
    transform: translate(6px, -30px);
    text-shadow: -2px 0 #FEE440, 2px 0 #00BBF9;
  }
  16% {
    transform: translate(-4px, -10px);
    text-shadow: 2px 0 #00F5D4, -2px 0 #F15BB5;
  }
  18% {
    transform: translate(4px, 0);
    text-shadow: -2px 0 #9B5DE5, 2px 0 #FEE440;
    opacity: 1;
  }
  20% {
    transform: translate(-2px, 2px);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  40% {
    transform: translate(-2px, -2px);
    text-shadow: 2px 0 #00BBF9, -2px 0 #FEE440;
  }
  60% {
    transform: translate(2px, 2px);
    text-shadow: -2px 0 #00F5D4, 2px 0 #9B5DE5;
  }
  80% {
    transform: translate(2px, -2px);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  90% {
    transform: translate(0);
    text-shadow: none;
  }
  100% {
    transform: translate(0);
    text-shadow: none;
  }
}

@keyframes letter-spin {
  0% {
    transform: rotateZ(0deg);
  }
  50% {
    transform: rotateZ(360deg);
  }
  100% {
    transform: rotateZ(0deg);
  }
}

@keyframes letter-arrive-bottom {
  0% {
    transform: translate(-8px, 100px);
    opacity: 0;
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  2% {
    transform: translate(8px, 100px);
    text-shadow: -2px 0 #00BBF9, 2px 0 #FEE440;
  }
  4% {
    transform: translate(-8px, 100px);
    text-shadow: 2px 0 #00F5D4, -2px 0 #9B5DE5;
  }
  6% {
    transform: translate(8px, 100px);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  8% {
    transform: translate(-8px, 100px);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #FEE440;
  }
  10% {
    transform: translate(8px, 100px);
    text-shadow: -2px 0 #00BBF9, 2px 0 #00F5D4;
  }
  12% {
    transform: translate(-6px, 50px);
    text-shadow: 2px 0 #F15BB5, -2px 0 #9B5DE5;
  }
  14% {
    transform: translate(6px, 30px);
    text-shadow: -2px 0 #FEE440, 2px 0 #00BBF9;
  }
  16% {
    transform: translate(-4px, 10px);
    text-shadow: 2px 0 #00F5D4, -2px 0 #F15BB5;
  }
  18% {
    transform: translate(4px, 0);
    text-shadow: -2px 0 #9B5DE5, 2px 0 #FEE440;
    opacity: 1;
  }
  20% {
    transform: translate(-2px, 2px);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  40% {
    transform: translate(-2px, -2px);
    text-shadow: 2px 0 #00BBF9, -2px 0 #FEE440;
  }
  60% {
    transform: translate(2px, 2px);
    text-shadow: -2px 0 #00F5D4, 2px 0 #9B5DE5;
  }
  80% {
    transform: translate(2px, -2px);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  90% {
    transform: translate(0);
    text-shadow: none;
  }
  100% {
    transform: translate(0);
    text-shadow: none;
  }
}

@keyframes glitch {
  0% {
    transform: translate(-8px, 0);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  2% {
    transform: translate(8px, 0);
    text-shadow: -2px 0 #00BBF9, 2px 0 #FEE440;
  }
  4% {
    transform: translate(-8px, 0);
    text-shadow: 2px 0 #00F5D4, -2px 0 #9B5DE5;
  }
  6% {
    transform: translate(8px, 0);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  8% {
    transform: translate(-8px, 0);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #FEE440;
  }
  10% {
    transform: translate(8px, 0);
    text-shadow: -2px 0 #00BBF9, 2px 0 #00F5D4;
  }
  12% {
    transform: translate(-6px, 0);
    text-shadow: 2px 0 #F15BB5, -2px 0 #9B5DE5;
  }
  14% {
    transform: translate(6px, 0);
    text-shadow: -2px 0 #FEE440, 2px 0 #00BBF9;
  }
  16% {
    transform: translate(-4px, 0);
    text-shadow: 2px 0 #00F5D4, -2px 0 #F15BB5;
  }
  18% {
    transform: translate(4px, 0);
    text-shadow: -2px 0 #9B5DE5, 2px 0 #FEE440;
  }
  20% {
    transform: translate(-2px, 2px);
    text-shadow: 2px 0 #9B5DE5, -2px 0 #F15BB5;
  }
  40% {
    transform: translate(-2px, -2px);
    text-shadow: 2px 0 #00BBF9, -2px 0 #FEE440;
  }
  60% {
    transform: translate(2px, 2px);
    text-shadow: -2px 0 #00F5D4, 2px 0 #9B5DE5;
  }
  80% {
    transform: translate(2px, -2px);
    text-shadow: -2px 0 #F15BB5, 2px 0 #00BBF9;
  }
  90% {
    transform: translate(0);
    text-shadow: none;
  }
  100% {
    transform: translate(0);
    text-shadow: none;
  }
}

.welcome-message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
  max-width: 100%;
}

.welcome-ok-button {
  margin-top: 8px;
  margin-bottom: 24px;
  min-width: 100px;
  padding: 8px 24px;
  font-family: 'Orbitron', system-ui, -apple-system, sans-serif;
  font-weight: 400;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.03);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.modal-tabs::-webkit-scrollbar {
  display: none;
}

.modal-tabs {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.modal-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  /* Color preserved from data-tab attribute selectors */
}

.modal-tab.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Tab label colors */
.modal-tab[data-tab="settings"] {
  color: #9B5DE5;
}

.modal-tab[data-tab="sequencer"] {
  color: #F15BB5;
}

.modal-tab[data-tab="shaper"] {
  color: #FEE440;
}

.modal-tab[data-tab="stepcounter"] {
  color: #00BBF9;
}

.modal-tab[data-tab="about"] {
  color: #00F5D4;
}

/* Active tab keeps its color but brighter */
.modal-tab[data-tab="settings"].active {
  color: #9B5DE5;
  border-bottom-color: #9B5DE5;
}

.modal-tab[data-tab="sequencer"].active {
  color: #F15BB5;
  border-bottom-color: #F15BB5;
}

.modal-tab[data-tab="shaper"].active {
  color: #FEE440;
  border-bottom-color: #FEE440;
}

.modal-tab[data-tab="stepcounter"].active {
  color: #00BBF9;
  border-bottom-color: #00BBF9;
}

.modal-tab[data-tab="about"].active {
  color: #00F5D4;
  border-bottom-color: #00F5D4;
}

.modal-tab-content {
  display: none;
  padding: 20px;
  /* Removed overflow-y and max-height - handled by .modal-body to prevent double scrollbar */
}

.modal-tab-content.active {
  display: block;
}

.modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Custom scrollbar styling for modal body to match site aesthetic */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--top);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--padActive);
  border-radius: 4px;
  border: 1px solid var(--hair);
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(70, 40, 120, 0.8);
}

/* Firefox scrollbar styling */
.modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--padActive) var(--top);
}

/* Sequence (stepcounter) tab: match scrollbar color to tab label (#00BBF9) */
.modal-body.sequence-scroll::-webkit-scrollbar-thumb {
  background: #00BBF9;
  border-color: rgba(0, 187, 249, 0.6);
}

.modal-body.sequence-scroll {
  scrollbar-color: #00BBF9 var(--top);
}

/* Beat (sequencer) tab: match scrollbar color to tab label (#F15BB5) */
.modal-body.beat-scroll::-webkit-scrollbar-thumb {
  background: #F15BB5;
  border-color: rgba(241, 91, 181, 0.6);
}

.modal-body.beat-scroll {
  scrollbar-color: #F15BB5 var(--top);
}

/* Shaper tab: match scrollbar color to tab label (#FEE440) */
.modal-body.shaper-scroll::-webkit-scrollbar-thumb {
  background: #FEE440;
  border-color: rgba(254, 228, 64, 0.6);
}

.modal-body.shaper-scroll {
  scrollbar-color: #FEE440 var(--top);
}

#euclideanModal .modal-body {
  padding: 20px;
}

#euclideanModal .modal-body {
  padding: 20px;
}

.setting-item {
  margin-bottom: 16px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.setting-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--padActive);
}

.setting-label span {
  font-size: 15px;
  color: var(--text);
}

.setting-value {
  font-size: 14px;
  color: var(--padActive);
  font-weight: 600;
  margin-left: auto;
}

.setting-slider {
  width: 100%;
  height: 6px;
  margin-top: 8px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* Step length buttons */
.step-length-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.step-length-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  min-width: 44px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  font-family: inherit;
  flex: 1;
}

.step-length-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.step-length-button.active {
  background: var(--padActive);
  border-color: var(--padActive);
  color: #fff;
  box-shadow: 0 0 8px rgba(70, 40, 120, 0.4);
}

.step-length-button:active {
  transform: scale(0.95);
}

.step-length-button.active:hover {
  background: rgba(70, 40, 120, 0.9);
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--padActive);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.setting-slider::-webkit-slider-thumb:hover {
  background: rgba(70, 40, 120, 0.9);
}

.setting-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--padActive);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.setting-slider::-moz-range-thumb:hover {
  background: rgba(70, 40, 120, 0.9);
}

/* Project Save/Load Buttons */
.button-primary,
.button-secondary {
  background: rgba(70, 40, 120, 0.2);
  border: 1px solid var(--padActive);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  height: 32px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  transform: skew(-2deg);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(70, 40, 120, 0.2);
}

.button-primary {
  background: linear-gradient(135deg, rgba(70, 40, 120, 0.3), rgba(70, 40, 120, 0.15));
  border-color: var(--padActive);
  color: rgba(255, 255, 255, 0.95);
}

.button-primary:hover {
  background: linear-gradient(135deg, rgba(70, 40, 120, 0.4), rgba(70, 40, 120, 0.25));
  border-color: rgba(70, 40, 120, 0.8);
  transform: skew(-2deg) translateY(-1px);
  box-shadow: 0 4px 10px rgba(70, 40, 120, 0.4);
}

.button-primary:active {
  transform: skew(-2deg) translateY(0);
  box-shadow: 0 2px 4px rgba(70, 40, 120, 0.3);
}

.button-secondary {
  background: linear-gradient(135deg, rgba(70, 40, 120, 0.2), rgba(70, 40, 120, 0.1));
  border-color: rgba(70, 40, 120, 0.5);
}

.button-secondary:hover {
  background: linear-gradient(135deg, rgba(70, 40, 120, 0.3), rgba(70, 40, 120, 0.2));
  border-color: rgba(70, 40, 120, 0.7);
  transform: skew(-2deg) translateY(-1px);
  box-shadow: 0 4px 10px rgba(70, 40, 120, 0.3);
}

.button-secondary:active {
  transform: skew(-2deg) translateY(0);
  box-shadow: 0 2px 4px rgba(70, 40, 120, 0.2);
}

.setting-hint {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  pointer-events: none;
}

/* Step length hint with 4 values */
#stepcounterTab .setting-hint {
  justify-content: space-between;
}

#stepcounterTab .setting-hint span {
  flex: 1;
  text-align: center;
}

/* Device compatibility table */
.compatibility-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.compatibility-table th:first-child,
.compatibility-table td:first-child {
  width: 45%;
}

.compatibility-table th:nth-child(2),
.compatibility-table td:nth-child(2) {
  width: 12%;
}

.compatibility-table th:nth-child(3),
.compatibility-table td:nth-child(3) {
  width: 43%;
}

.compatibility-table th,
.compatibility-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
}

.compatibility-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

.compatibility-table td {
  color: var(--text);
}

.compatibility-table .status-ok {
  color: #4CAF50;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
}

.compatibility-table .status-fail {
  color: #F44336;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
}

.compatibility-table td:last-child {
  color: var(--muted);
  font-size: 12px;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  /* Reduce top strip height on mobile */
  #topStrip {
    height: auto;
    min-height: 40px;
    max-height: 40px;
    overflow: hidden;
  }

  #topHud {
    padding: 2px 10px;
    padding-right: 40px;
    gap: 3px;
  }
  
  .menu-button {
    width: 40px;
    height: auto;
    min-height: 40px;
  }

  .hudRow {
    flex-wrap: wrap;
    gap: 6px;
  }

  .control-group {
    gap: 4px;
    flex-wrap: wrap;
  }

  .control-label {
    font-size: 11px;
  }

  .control-select {
    font-size: 11px;
    padding: 3px 6px;
    min-width: 60px;
  }

  .control-button {
    font-size: 12px;
    padding: 3px 8px;
    min-width: 32px;
    height: 24px;
  }

  .button-group {
    gap: 3px;
  }
}

@media (max-width: 480px) {
  #topStrip {
    min-height: 36px;
    max-height: 36px;
    overflow: hidden;
  }
  
  .menu-button {
    width: 36px;
    min-height: 36px;
  }

  #topHud {
    padding: 2px 6px;
    padding-right: 36px;
    gap: 1px;
  }
  
  .controls-row {
    flex-wrap: nowrap;
  }
  
  /* Hide Pattern and Beat (desktop) labels on mobile, show Beat (mobile) label */
  .pattern-label-desktop {
    display: none;
  }
  
  .beat-label-desktop {
    display: none;
  }
  
  .beat-label-mobile {
    display: inline;
  }
  
  /* Hide Pattern label on mobile (first label) - beat-label-mobile will show instead */
  .control-group:has(#sequencerPlay) > label.control-label.pattern-label-desktop {
    display: none;
  }
  
  /* Rename Arpeggiator to Arp on mobile */
  .control-group:has(#arpeggiatorToggle) > label.control-label:first-of-type {
    font-size: 0;
  }
  
  .control-group:has(#arpeggiatorToggle) > label.control-label:first-of-type::after {
    content: "Arp";
    font-size: 9px;
    display: inline-block;
  }

  .hudRow {
    gap: 2px;
    flex-wrap: nowrap;
    overflow: hidden;
    justify-content: flex-end;
  }

  .control-group {
    gap: 2px;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
    display: flex;
    align-items: center;
  }
  
  /* Give voice dropdown more space by making it grow */
  .control-group:has(#voiceTypeSelect) {
    flex-grow: 1;
    flex-shrink: 0;
    min-width: 80px;
  }
  
  /* Push other items to the right */
  .control-group:has(#voiceTypeSelect) ~ .control-group {
    flex-shrink: 0;
  }
  
  /* Add spacing to Beat control group to create equal distance between Voice dropdown and BPM label */
  .control-group:has(#sequencerPlay) {
    margin-left: 8px;
    gap: 8px;
  }

  .control-label {
    font-size: 9px;
    white-space: nowrap;
  }

  .control-select {
    font-size: 9px;
    padding: 1px 3px;
    min-width: 0;
    flex-shrink: 1;
  }
  
  /* Make voice dropdown wider to accommodate voice names */
  #voiceTypeSelect {
    min-width: 85px;
    width: auto;
    flex-shrink: 0;
  }
  
  .voice-select-wrapper {
    min-width: 85px;
    flex-shrink: 0;
    position: relative;
  }
  
  /* Ensure the control group can expand */
  .control-group:has(#voiceTypeSelect) {
    min-width: 85px;
  }
  
  /* Fix text alignment in voice display overlay */
  .voice-type-display {
    left: 0;
    right: 0;
    padding: 3px 3px 1px 3px;
    font-size: 9px;
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .control-button {
    font-size: 10px;
    padding: 1px 4px;
    min-width: 24px;
    height: 20px;
    flex-shrink: 0;
  }
  
  .toggle-switch {
    width: 36px;
    height: 18px;
  }
  
  .toggle-slider:before {
    height: 14px;
    width: 14px;
  }
  
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
  }
}

@media (max-width: 360px) {
  #topStrip {
    min-height: 32px;
    max-height: 32px;
  }
  
  #topHud {
    padding: 2px 4px;
    padding-right: 36px;
    gap: 1px;
  }
  
  .menu-button {
    min-height: 32px;
  }
  
  .controls-row {
    flex-wrap: nowrap;
  }
  
  .hudRow {
    gap: 1px;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .control-group {
    gap: 1px;
    flex-wrap: nowrap;
    display: flex;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
  }

  .control-label {
    font-size: 8px;
  }

  .control-select {
    font-size: 8px;
    padding: 1px 2px;
    min-width: 0;
  }

  .control-button {
    font-size: 9px;
    padding: 1px 3px;
    min-width: 20px;
    height: 18px;
  }
  
  .toggle-switch {
    width: 32px;
    height: 16px;
  }
  
  .toggle-slider:before {
    height: 12px;
    width: 12px;
  }
  
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
  }
}

/* Shaper modal styles */
/* Removed overflow-y and max-height from #shaperTab to prevent double scrollbar - handled by .modal-body */

.shaper-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hair);
}

.shaper-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.shaper-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.shaper-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.shaper-actions .control-button {
  min-width: 160px;
}

.modal-content {
  max-width: 600px;
}

/* Debug Console */
.debug-console {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: var(--bg);
  border-top: 2px solid var(--hair);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.debug-console.minimized {
  height: 40px;
}

.debug-console.minimized .debug-console-content,
.debug-console.minimized .debug-console-filters {
  display: none;
}

/* Hand Gesture Preview */
.hand-preview-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 80px; /* Further reduced for better performance */
  height: 60px; /* Further reduced for better performance */
  border-radius: 8px;
  border: 2px solid var(--padActive);
  background: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  pointer-events: none;
  overflow: hidden;
  display: none; /* Hidden by default, shown when hand tracking is enabled */
}

.hand-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.debug-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--top);
  border-bottom: 1px solid var(--hair);
  flex-shrink: 0;
}

.debug-console-title {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.debug-console-controls {
  display: flex;
  gap: 8px;
}

.debug-console-btn {
  background: var(--pad);
  border: 1px solid var(--hair);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: background 0.2s;
}

.debug-console-btn:hover {
  background: var(--ribbonActive);
}

.debug-console-filters {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--top);
  border-bottom: 1px solid var(--hair);
  flex-shrink: 0;
}

.debug-console-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  user-select: none;
}

.debug-console-filter input[type="checkbox"] {
  cursor: pointer;
}

.debug-console-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px;
  background: var(--bg);
  font-size: 11px;
  line-height: 1.5;
}

.debug-console-content::-webkit-scrollbar {
  width: 8px;
}

.debug-console-content::-webkit-scrollbar-track {
  background: var(--top);
}

.debug-console-content::-webkit-scrollbar-thumb {
  background: var(--pad);
  border-radius: 4px;
}

.debug-console-content::-webkit-scrollbar-thumb:hover {
  background: var(--ribbonActive);
}

.debug-log-entry {
  margin: 2px 0;
  padding: 2px 0;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
}

.debug-log-entry.log {
  color: var(--text);
}

.debug-log-entry.info {
  color: #4CAF50;
}

.debug-log-entry.warn {
  color: #FF9800;
}

.debug-log-entry.error {
  color: #f44336;
  font-weight: 600;
}

.debug-log-timestamp {
  color: var(--muted);
  margin-right: 8px;
  font-size: 10px;
}

.debug-log-level {
  display: inline-block;
  min-width: 50px;
  margin-right: 8px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
}

.debug-log-level.log {
  color: var(--muted);
}

.debug-log-level.info {
  color: #4CAF50;
}

.debug-log-level.warn {
  color: #FF9800;
}

.debug-log-level.error {
  color: #f44336;
}

.debug-log-message {
  display: inline;
}

.debug-log-entry.hidden {
  display: none;
}
