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

:root {
  --bg: #0a0a14;
  --surface: rgba(6, 6, 18, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e8f0;
  --dim: #777;
  --accent: #00d4ff;
  --green: #00ff88;
  --red: #ff4466;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* Loading */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  gap: 14px;
  background: var(--bg);
}

.loader-ring {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 22px; font-weight: 700; }
.loader-subtitle { font-size: 13px; color: var(--dim); }
.error-message { color: var(--red); font-size: 15px; }
.error-detail { color: var(--dim); font-size: 13px; margin-top: 6px; }

/* Main layout */
#main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Top bar — single row, left-to-right workflow */
#top-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  flex-shrink: 0;
  z-index: 20;
  position: relative;
  min-height: 42px;
}

.title-group {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

#top-bar h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  color: var(--text);
  flex-shrink: 0;
}

.tagline {
  font-size: 10px;
  color: var(--dim);
  font-weight: 400;
  white-space: nowrap;
  margin-top: -1px;
}

.bar-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.08);
  margin: 0 10px;
  flex-shrink: 0;
}

.bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}

#song-group { flex-shrink: 1; min-width: 0; }

/* Current song button (top bar) */
.current-song-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  transition: border-color 0.15s, color 0.15s;
}
.current-song-btn:hover { border-color: var(--accent); }
.current-song-change {
  color: var(--dim);
  font-size: 10px;
  flex-shrink: 0;
}

/* Step labels */
.step-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--dim);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s, transform 0.4s;
}

.step-label.step-active {
  color: var(--accent);
  animation: step-bounce 1.2s ease-in-out infinite;
}

.step-label.step-optional {
  color: rgba(255,255,255,0.3);
  font-style: italic;
}

.step-label.step-done {
  opacity: 0;
  transform: translateX(-50%) translateY(-6px);
}

@keyframes step-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

#top-bar.steps-done {
  padding-top: 6px;
  transition: padding-top 0.3s;
}
#top-bar.steps-done .step-label { display: none; }

/* Bar buttons (shared style) */
#top-bar button.bar-btn {
  background: rgba(255,255,255,0.06);
  color: var(--dim);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
#top-bar button.bar-btn:hover { color: var(--text); border-color: var(--accent); }
#upstrum-btn.active { background: var(--green); color: #000; border-color: var(--green); font-weight: 600; }
#calibrate-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
#metronome-btn.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

/* Icon buttons (gear, help) */
.icon-btn {
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border-radius: 50% !important;
}

#help-btn {
  font-size: 13px;
  font-weight: 700;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 6px;
}
#help-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Settings panel */
#settings-group {
  position: relative;
}

#settings-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: rgba(16, 16, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 14px 16px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dim);
}

.settings-row {
  display: flex;
  gap: 6px;
}

.bar-btn-disabled {
  opacity: 0.3;
  cursor: not-allowed !important;
  pointer-events: none;
}

.input-disabled {
  opacity: 0.3;
  pointer-events: none;
}

#custom-song-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.play-disabled {
  opacity: 0.3;
  cursor: not-allowed !important;
}

#calibrate-btn.needs-attention {
  border-color: var(--red);
  color: var(--red);
  animation: pulse-attention 1.5s ease-in-out infinite;
}

@keyframes pulse-attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
  50% { box-shadow: 0 0 8px 2px rgba(255, 68, 68, 0.4); }
}

/* Color swatches */
#color-swatches {
  display: flex;
  gap: 4px;
  align-items: center;
}

.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.3); }

/* + Song button */
#custom-song-btn {
  background: rgba(255,255,255,0.06);
  color: var(--dim);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
#custom-song-btn:hover { color: var(--text); border-color: var(--accent); }

/* Pattern label */
#pattern-label { min-width: 80px; text-align: center; }

/* Playback group */
/* Speed control */
.speed-control {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.speed-btn {
  background: rgba(255,255,255,0.06);
  color: var(--dim);
  border: 1px solid rgba(255,255,255,0.08);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.speed-btn:hover { color: var(--text); border-color: var(--accent); }

#speed-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  min-width: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.playback-group {
  display: flex;
  flex-shrink: 0;
}

#play-btn, #auto-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 5px 13px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.1s;
}
#play-btn {
  border-radius: 5px 0 0 5px;
  border-right: 1px solid rgba(0,0,0,0.15);
}
#auto-btn {
  border-radius: 0 5px 5px 0;
}
#play-btn:hover, #auto-btn:hover { filter: brightness(1.15); }
#play-btn.active { background: var(--red); color: #fff; }
#auto-btn.active { background: var(--green); color: #000; }

/* Transport */
.transport {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding-left: 6px;
}

#chord-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#beat-dots {
  display: flex;
  gap: 3px;
}

#beat-dots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: background 0.1s;
}

#beat-dots .dot.on {
  background: var(--accent);
}

/* ── First-visit intro overlay ── */
#intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 16;
  background: radial-gradient(ellipse at center, rgba(6,6,18,0.85) 0%, rgba(6,6,18,0.96) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}
.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  max-width: 400px;
  padding: 20px;
}
.intro-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #fff;
}
.intro-tagline {
  font-size: 17px;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
}
.intro-start-btn {
  margin-top: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: filter 0.15s, transform 0.15s;
}
.intro-start-btn:hover { filter: brightness(1.15); transform: scale(1.03); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── First-visit button swap: demo becomes primary ── */
.first-visit .welcome-play-btn {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 15px;
  padding: 12px 36px;
  font-weight: 600;
  order: 2;
}
.first-visit .welcome-play-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.08);
  transform: scale(1.02);
  filter: none;
}
.first-visit .welcome-demo-btn {
  background: var(--accent);
  color: #000;
  border: none;
  font-size: 18px;
  padding: 14px 48px;
  font-weight: 700;
  order: 1;
}
.first-visit .welcome-demo-btn:hover {
  border-color: transparent;
  background: var(--accent);
  filter: brightness(1.15);
  transform: scale(1.03);
}

/* ── Camera pre-prompt ── */
.camera-prompt-content {
  max-width: 360px;
}
.camera-prompt-desc {
  font-size: 14px;
  color: var(--dim);
  line-height: 1.5;
  margin: 4px 0 8px;
}

/* ── In-play nudge toasts ── */
.play-nudge {
  position: fixed;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16,16,28,0.92);
  color: var(--accent);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  z-index: 30;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
  animation: nudge-fade 4s ease-in-out forwards;
}
@keyframes nudge-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Welcome overlay — the main CTA on the guitar area */
#welcome-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: radial-gradient(ellipse at center, rgba(6,6,18,0.75) 0%, rgba(6,6,18,0.92) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  transition: opacity 0.4s;
}

#welcome-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  max-width: min(440px, 92vw);
  padding: 20px;
}

.welcome-song-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.welcome-song {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcome-song-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}

.welcome-song-artist {
  font-size: 15px;
  color: var(--dim);
  font-weight: 400;
}

.welcome-change-song {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.welcome-change-song:hover { color: #fff; }

.welcome-search-wrap {
  width: 100%;
  max-width: min(400px, 92vw);
  position: relative;
}
.welcome-search-wrap .difficulty-filters + .welcome-search-results,
.welcome-search-wrap .difficulty-filters {
  /* filters + results sit inside the dropdown panel */
}
.welcome-search-wrap .difficulty-filters {
  background: rgba(16, 16, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.welcome-search-wrap .welcome-search-results {
  background: rgba(16, 16, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

#welcome-search {
  appearance: none;
  width: 100%;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 10px;
  padding: 10px 14px 10px 36px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='7' stroke='%2300d4ff' stroke-width='2'/%3E%3Cpath d='M16 16l4 4' stroke='%2300d4ff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#welcome-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}
#welcome-search::placeholder { color: rgba(255,255,255,0.4); }

.welcome-search-results {
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.difficulty-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px 4px;
}
.diff-filter {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-filter:hover { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.7); }
.diff-filter.active { background: rgba(0, 212, 255, 0.2); color: var(--accent); border-color: rgba(0, 212, 255, 0.4); }

.welcome-search-results:empty { display: none; }

.welcome-search-result {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background 0.1s;
}
.welcome-search-result:first-child { border-radius: 10px 10px 0 0; }
.welcome-search-result:last-child { border-radius: 0 0 10px 10px; }
.welcome-search-result:hover { background: rgba(0, 212, 255, 0.10); }
.welcome-search-result.searching { color: var(--dim); font-style: italic; pointer-events: none; }

.sr-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sr-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-artist {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.demo-pattern-btn {
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 50%;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}
.demo-pattern-btn:hover {
  background: rgba(0, 212, 255, 0.3);
  transform: scale(1.05);
}
.demo-pattern-btn:active {
  transform: scale(0.95);
}

.welcome-steps {
  display: flex;
  align-items: center;
  gap: 16px;
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}

.welcome-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid rgba(0, 212, 255, 0.4);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.welcome-step-text {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
}

.welcome-step-arrow {
  font-size: 20px;
  color: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.welcome-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.welcome-link:hover { color: #fff; }

/* Strum pattern in welcome overlay */
.welcome-pattern {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.welcome-pattern-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dim);
}

.welcome-pattern-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s;
}
.welcome-pattern-display:hover { border-color: var(--accent); }

#welcome-pattern-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 40px;
}

.pattern-slots {
  display: flex;
  gap: 2px;
  align-items: center;
}

.pattern-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 18px;
  gap: 1px;
}

.pattern-slot-beat {
  font-size: 8px;
  color: rgba(255,255,255,0.25);
  font-weight: 600;
}

.pattern-slot-arrow {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.pattern-slot-arrow.down { color: var(--accent); }
.pattern-slot-arrow.up { color: var(--green); }
.pattern-slot-arrow.rest { color: rgba(255,255,255,0.12); }

.welcome-pattern-change {
  font-size: 10px;
  color: var(--dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Speed in welcome overlay */
.welcome-speed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.welcome-speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.welcome-speed-row .speed-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

.welcome-speed-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.welcome-play-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: filter 0.15s, transform 0.15s;
  width: 100%;
}
.welcome-play-btn:hover { filter: brightness(1.15); transform: scale(1.03); }

.welcome-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}
.welcome-hint-score {
  margin-top: 2px;
  color: rgba(0, 212, 255, 0.4);
  font-style: italic;
}
.welcome-hint strong {
  color: rgba(255,255,255,0.5);
}
.welcome-hint kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
}

.welcome-step.done .welcome-step-num {
  background: rgba(0, 255, 136, 0.15);
  border-color: rgba(0, 255, 136, 0.4);
  color: var(--green);
}
.welcome-step.done .welcome-step-num::after {
  content: '\2713';
}
.welcome-step.done .welcome-step-text {
  color: rgba(0, 255, 136, 0.6);
}

/* Skip calibration link */
.welcome-skip-link {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}
.welcome-skip-link:hover { color: rgba(255,255,255,0.6); }

/* Keyboard hint */
.welcome-kb-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
  display: inline-block;
}
.welcome-kb-hint kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
}

/* Strum zone diagram in welcome */
.welcome-zones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.zone-diagram {
  display: flex;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
}

.zone-half {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 24px;
}

.zone-down { background: rgba(0, 212, 255, 0.08); }
.zone-both { background: rgba(0, 255, 136, 0.08); }

.zone-arrow {
  font-size: 16px;
  line-height: 1;
}
.zone-down .zone-arrow { color: var(--accent); }
.zone-both .zone-arrow { color: var(--green); }

.zone-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
}

.zone-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,0.15);
}

.zone-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
}

/* Camera PIP states */
#camera-pip.pip-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

#camera-pip.pip-visible {
  opacity: 0.75;
  pointer-events: auto;
  transition: opacity 0.4s;
}

.pip-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: rgba(255,255,255,0.5);
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


/* Calibrate skip button */
.calibrate-skip-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s, border-color 0.15s;
}
.calibrate-skip-btn:hover { color: #fff; border-color: var(--accent); }
.calibrate-skip-btn kbd {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 3px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 11px;
  min-width: 16px;
  text-align: center;
}

/* Calibrate reset button */
.calibrate-reset-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.6);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s, border-color 0.15s;
}
.calibrate-reset-btn:hover { color: #fff; border-color: var(--accent); }

/* Score tooltip */
.score-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: rgba(16, 16, 28, 0.95);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  animation: tooltip-fade 4s ease-in-out forwards;
  pointer-events: none;
}
.score-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 16px;
  border: 5px solid transparent;
  border-top-color: rgba(0, 212, 255, 0.3);
}
@keyframes tooltip-fade {
  0% { opacity: 0; transform: translateY(4px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Progressive reveal — hidden until first play */
.bar-advanced.hidden { display: none; }
.bar-advanced { display: flex; }

/* Bottom bar idle label */
.progression-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#calibrate-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

#calibrate-overlay video {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
  opacity: 0.7;
}

#calibrate-canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#calibrate-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: var(--accent);
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  text-align: center;
  max-width: 90%;
}

#calibrate-hint br ~ span {
  white-space: normal;
}

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
}

#chord-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#beat-dots {
  display: flex;
  gap: 5px;
}

#beat-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: background 0.1s;
}

#beat-dots .dot.on {
  background: var(--accent);
}

/* Stage */
#stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#guitar-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Camera picture-in-picture */
#camera-pip {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 160px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0.75;
  z-index: 14;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

#camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

#pip-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
}

/* Bottom bar: chord progression */
#bottom-bar {
  padding: 8px 16px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

#section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-width: 0;
}

#progression {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.chord-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.35);
  transition: all 0.15s;
}

.chord-pill.active {
  background: rgba(0, 212, 255, 0.18);
  color: #fff;
  font-weight: 600;
}

.chord-pill.past {
  background: rgba(255,255,255,0.02);
  color: rgba(255,255,255,0.18);
}

.chord-pill.next {
  color: rgba(255,255,255,0.55);
}

/* Score display */
#score-display {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
  position: relative;
}

#score-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

#streak-value {
  font-size: 11px;
  font-weight: 600;
  color: #00ff88;
}

/* Difficulty badge */
.song-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pattern-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Welcome action buttons */
.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.welcome-demo-btn {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 12px 36px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  width: 100%;
}
.welcome-demo-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.08);
  transform: scale(1.02);
}

/* Beginner difficulty badge */
.welcome-difficulty-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(0, 255, 136, 0.12);
  color: var(--green);
  border: 1px solid rgba(0, 255, 136, 0.25);
  letter-spacing: 0.3px;
}

.welcome-pattern-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.25);
  letter-spacing: 0.3px;
}

/* Advanced section (hidden initially) */
.welcome-advanced {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-more-link {
  background: none;
  border: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.welcome-more-link:hover { color: var(--text); }

/* Custom song button inherits from #settings-row button */

/* Modal */
#custom-song-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-content {
  position: relative;
  background: #141420;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 28px 32px;
  width: min(380px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-content label span {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
}

.modal-content input {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.modal-content input:focus { border-color: var(--accent); }

.modal-hint {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.modal-primary:hover { filter: brightness(1.1); }

.modal-secondary {
  background: none;
  color: var(--dim);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.modal-secondary:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }

/* Song meta badges in welcome */
.welcome-song-meta {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}

.meta-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--dim);
  letter-spacing: 0.3px;
}

/* YouTube link in welcome */
.welcome-youtube-link {
  font-size: 12px;
  color: var(--dim);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.welcome-youtube-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Loop button active state */
#loop-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

/* ── Landscape rotation prompt ── */
#rotate-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  color: var(--text);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 32px;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
#rotate-prompt p {
  max-width: 280px;
  word-wrap: break-word;
}
#rotate-prompt .rotate-icon {
  font-size: 48px;
  animation: rotate-hint 2s ease-in-out infinite;
}
.rotate-reason {
  font-size: 13px;
  color: var(--dim);
  margin-top: 0;
}
@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
@media (max-width: 700px) and (orientation: portrait) {
  #rotate-prompt { display: flex; }
  #app { display: none; }
}

/* ── Responsive: Mobile landscape ── */
@media (max-height: 500px) and (orientation: landscape) {
  #camera-pip {
    width: 100px;
    height: 75px;
    top: auto;
    bottom: 8px;
    right: 8px;
    border-radius: 6px;
  }
  #top-bar { min-height: 34px; padding: 2px 10px; }
  #top-bar h1 { font-size: 14px; }
  .tagline { display: none; }
  .bar-sep { display: none; }
  #strum-setup-group { display: none; }
  #intro-overlay { align-items: center; }
  .intro-title { font-size: 28px; }
  .intro-tagline { font-size: 14px; }
  .intro-start-btn { padding: 10px 32px; font-size: 15px; }
  #welcome-overlay { align-items: flex-start; }
  .welcome-content { gap: 6px; padding: 6px 8px; }
  .welcome-song-title { font-size: 18px; }
  .welcome-song-artist { font-size: 12px; }
  .welcome-difficulty-badge { font-size: 10px; padding: 2px 8px; }
  .welcome-pattern-badge { font-size: 10px; padding: 2px 8px; }
  .welcome-song-meta { margin-top: 0; }
  .welcome-song-meta span { font-size: 9px; padding: 1px 5px; }
  .welcome-actions { gap: 6px; }
  .welcome-play-btn { padding: 8px 20px; font-size: 14px; border-radius: 8px; }
  .welcome-demo-btn { padding: 5px 16px; font-size: 11px; border-radius: 8px; }
  .first-visit .welcome-demo-btn { padding: 8px 20px; font-size: 14px; }
  .first-visit .welcome-play-btn { padding: 5px 16px; font-size: 11px; }
  .welcome-hint { font-size: 10px; }
  .welcome-hint-score { display: none; }
  .welcome-change-song { font-size: 11px; }
  .welcome-more-link { font-size: 11px; }
  .welcome-pattern-display { padding: 4px 8px; }
  #settings-panel { max-height: 50vh; max-height: 50dvh; overflow-y: auto; }
  #bottom-bar { padding: 4px 10px; }
}

/* ── Responsive: Tablet ── */
@media (max-width: 700px) {
  #top-bar { flex-wrap: wrap; padding: 6px 10px; gap: 4px; }
  .bar-sep { display: none; }
  .tagline { display: none; }
  #song-group { flex-basis: auto; }
  #settings-panel { right: 0; left: auto; min-width: 200px; }
  #camera-pip { width: 120px; height: 90px; top: 8px; right: 8px; }
  .welcome-song-title { font-size: 24px; }
  .welcome-search-wrap { max-width: 100%; }
  .welcome-steps { flex-direction: column; gap: 10px; }
  .welcome-step-arrow { transform: rotate(90deg); }
  .welcome-content { gap: 18px; padding: 14px; }
  .welcome-play-btn { padding: 12px 36px; font-size: 16px; }
  .welcome-demo-btn { padding: 10px 28px; font-size: 13px; }
  .welcome-pattern-display { padding: 6px 10px; gap: 8px; }
  .zone-half { padding: 8px 16px; }
  .zone-hint { display: none; }
  .welcome-speed-row .speed-btn { width: 36px; height: 36px; }
  .calibrate-skip-btn { bottom: 48px; }
  .calibrate-reset-btn { top: 8px; right: 8px; font-size: 11px; padding: 4px 10px; }
  .welcome-song-meta { flex-wrap: wrap; }
}

/* ── Responsive: Mobile ── */
@media (max-width: 480px) {
  #top-bar { padding: 4px 8px; min-height: 38px; }
  #top-bar h1 { font-size: 14px; }
  .title-group { margin-right: 4px; }

  /* Collapse toolbar: hide less-essential controls */
  #strum-setup-group { display: none; }

  /* Bigger tap targets */
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  #help-btn { width: 32px; height: 32px; font-size: 14px; }
  #top-bar button.bar-btn { padding: 6px 10px; font-size: 11px; min-height: 32px; }
  .color-swatch { width: 24px !important; height: 24px !important; }

  /* Current song button */
  .current-song-btn { max-width: 140px; font-size: 11px; padding: 4px 8px; }

  /* Settings panel */
  #settings-panel { right: -8px; min-width: 180px; padding: 10px 12px; max-height: 60vh; max-height: 60dvh; overflow-y: auto; }
  .settings-label { font-size: 10px; }
  #settings-panel .bar-btn { font-size: 10px; padding: 4px 8px; }

  /* Camera PIP smaller */
  #camera-pip { width: 90px; height: 68px; top: 6px; right: 6px; border-radius: 6px; }

  /* Welcome overlay */
  .welcome-content { gap: 12px; padding: 10px; }
  .welcome-song-title { font-size: 20px; }
  .welcome-song-artist { font-size: 13px; }
  .welcome-song-meta span { font-size: 10px; padding: 2px 6px; }
  .welcome-play-btn { padding: 10px 24px; font-size: 15px; }
  .welcome-demo-btn { padding: 8px 20px; font-size: 12px; }
  .welcome-hint { font-size: 11px; }

  /* Search */
  #welcome-search { font-size: 13px; padding: 8px 12px 8px 32px; }
  .diff-filter { font-size: 10px; padding: 3px 7px; }
  .welcome-search-results { max-height: 180px; }
  .sr-title { font-size: 12px; }
  .sr-artist { font-size: 10px; }

  /* Bottom bar */
  #bottom-bar { padding: 6px 10px; }
  .chord-pill { font-size: 11px; padding: 3px 10px; }
  #score-display { font-size: 13px; padding: 4px 10px; }

  /* Pattern display */
  .pattern-slot { width: 14px; }
  .pattern-slot .strum-arrow { font-size: 10px; }
  .pattern-slot .strum-key { font-size: 7px; }
}

/* ── Responsive: Small phone ── */
@media (max-width: 360px) {
  #top-bar h1 { font-size: 12px; }
  .current-song-btn { max-width: 100px; }
  .welcome-song-title { font-size: 18px; }
  .welcome-play-btn { padding: 10px 16px; font-size: 14px; }
  .welcome-demo-btn { padding: 8px 14px; font-size: 11px; }
  #camera-pip { width: 72px; height: 54px; }
  .welcome-content { padding: 8px; }
  .zone-half { padding: 6px 10px; }
}
