:root {
  --bg: #151420;
  --surface: #1F1E2E;
  --surface-raised: #262538;
  --text: #F2EFE6;
  --text-muted: #8B899E;
  --p1: #ad3939;
  --p1-dim: #742626;
  --p2: #387bd9;
  --p2-dim: #1e3958;
  --both: #F2C94C;
  --border: #34324a;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
}

*:focus-visible {
  outline: 2px solid var(--p2);
  outline-offset: 2px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 28px 20px 8px;
  text-align: center;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.4;
  max-width: 34ch;
  margin-inline: auto;
}

.app-tutorial {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 6px 0 0;
  line-height: 1.4;
  font-style: italic;
}

main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Steppers --- */

.steppers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stepper-column {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
}

.stepper-column.p1 {
  border-top: 3px solid var(--p1);
}

.stepper-column.p2 {
  border-top: 3px solid var(--p2);
}

.player-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stepper-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.step-btn {
  flex: 1;
  aspect-ratio: 1.4;
  background: var(--surface-raised);
  border: 0px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  /* touch-action: manipulation; */
  transition: background 0.12s ease, transform 0.08s ease;
}

.stepper-column.p1 .step-btn:active {
  background: var(--p1-dim);
  transform: scale(0.96);
}

.stepper-column.p2 .step-btn:active {
  background: var(--p2-dim);
  transform: scale(0.96);
}

.range-display {
  font-size: 2.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stepper-column.p1 .range-display {
  color: var(--p1);
}

.stepper-column.p2 .range-display {
  color: var(--p2);
}

.range-dash {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* --- Filter chips --- */

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.version-bulk-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.version-bulk-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.version-bulk-link:active {
  color: var(--text);
}

.version-bulk-divider {
  color: var(--border);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--surface);
  border: 0px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  /* touch-action: manipulation; */
}

.chip[aria-pressed="true"] {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--text-muted);
}

.view-toggle {
  display: flex;
  gap: 8px;
}

.view-toggle-btn {
  flex: 1;
  background: var(--surface);
  border: 0px solid var(--border);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}

.view-toggle-btn[aria-pressed="true"] {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--text-muted);
}

/* Horizontal mode: cards sit side by side, drag/scroll to see more */
.results-list.horizontal {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.results-list.horizontal .song-card {
  flex: 0 0 calc(50% - 5px);
  scroll-snap-align: start;
}

/* Optional: thin, unobtrusive scrollbar instead of the browser default */
.results-list.horizontal::-webkit-scrollbar {
  height: 4px;
}

.results-list.horizontal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* --- Results --- */

.results-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.song-card {
  background: var(--surface);
  border: 0px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.song-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.song-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.song-version {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.song-note {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85em;
}

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

.diff-row.split {
  flex-direction: column;
  gap: 6px;
}

.diff-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diff-chip {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-raised);
  border: none;
}

.diff-chip.match-p1 {
  background: var(--p1);
}

.diff-chip.match-p2 {
  background: var(--p2);
}

.diff-chip.match-both {
  background: linear-gradient(135deg, var(--p1) 50%, var(--p2) 50%);
}

.empty-state, .loading-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 32px 16px;
}

.app-footer {
  padding: 16px 20px 28px;
  text-align: center;
}

/* .app-footer p {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  margin: 0;
} */

.data-note {
  text-align: center;
}

.data-note-divider {
  width: 70%;
  border-bottom: 1px solid var(--border);
  margin: 24px auto 0;
}

.data-note p {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  margin: 0;
}


@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Version filter */

.version-dropdown {
  position: relative;
}

.version-dropdown-toggle {
  width: 100%;
  background: var(--surface);
  border: 0px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.version-dropdown-arrow {
  color: var(--text-muted);
  font-size: 0.7rem;
  transition: transform 0.12s ease;
}

.version-dropdown-toggle[aria-expanded="true"] .version-dropdown-arrow {
  transform: rotate(180deg);
}

.version-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  padding: 6px;
}

.version-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.version-option:active {
  background: var(--surface);
}

.version-option input {
  accent-color: var(--p2);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- About section --- */
.about-section {
  padding: 0 20px 0px;
}

.about-section h2 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.about-section h2:not(:first-child) {
  margin-top: 18px;
}

.about-section p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

/* --- Github Info --- */

.github-link a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: none;
}

.github-link a:hover {
  color: var(--text);
}

.github-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  fill: currentColor;
}