:root {
  /* Spotify-style: near-black and greys with a bright green. Picking a song swaps --accent and
     --accent-deep for that song's own color (main.js). */
  --accent: #1ed760;
  --accent-deep: #1db954;
  --bg: #121212;
  --panel: rgba(24, 24, 24, 0.9);
  --text: #ffffff;
  --muted: #b3b3b3;
  --line: rgba(255, 255, 255, 0.1);
  --rec: #e0533d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile first: the styles below are for phones and tablets (touch, full screen). Laptops get a
   more compact panel in the "laptop" section at the end, using the same media query as main.js. */

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#view {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: box-shadow 0.3s;
}

body.vertical #view {
  border-radius: 18px;
  box-shadow: 0 0 0 1px var(--line), 0 20px 80px rgba(0, 0, 0, 0.6);
}

body.recording #view {
  box-shadow: 0 0 0 3px var(--rec), 0 0 40px rgba(224, 83, 61, 0.4);
}

#cam {
  display: none;
}

/* ---------- controls panel ---------- */

.panel {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: calc(env(safe-area-inset-left) + 10px);
  z-index: 10;
  width: calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-width: 420px;
  max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 8px 14px 14px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 17px;
}

/* The name: Unbounded, with "Tilt" in the theme color and tipped over like a tilted hand. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: 'Unbounded', 'Outfit', system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand .tilt {
  display: inline-block;
  color: var(--accent);
  transform: rotate(-9deg) translateY(-0.04em);
  transform-origin: 0 80%;
}

.brand-mark {
  width: 1.35em;
  height: 1.35em;
  border-radius: 0.34em;
}

.card h1.brand {
  justify-content: center;
  margin: 0;
  font-size: clamp(34px, 7vw, 52px);
}

.panel.collapsed {
  width: auto;
  padding-bottom: 8px;
}

.panel.collapsed .panel-body {
  display: none;
}

.panel-body {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding-right: 6px;
}

.panel header {
  gap: 12px;
}

.panel label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* 16px text in form fields stops phones from zooming in when you tap them. */
.panel select {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel select option {
  background: #282828;
}

.panel input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  height: 32px;
  accent-color: var(--accent);
}

.value {
  color: var(--text);
}

.toggles {
  display: grid;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.panel label.check {
  display: flex;
  gap: 10px;
  min-height: 40px;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------- buttons ---------- */

button {
  font: inherit;
  cursor: pointer;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
}

.rec,
.primary,
.ghost {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
}

.rec {
  border: 0;
  background: var(--rec);
  color: #fff;
}

.rec.on {
  background: #fff;
  color: var(--rec);
}

.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #000;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.small a {
  color: var(--accent);
}

/* ---------- start screen and help ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 12px)
    calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 12px);
  background: rgba(12, 11, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.card {
  position: relative;
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 20px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.card h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
}

.tagline {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--muted);
}

.card .primary,
.card .ghost {
  padding: 14px;
  font-size: 17px;
}

.card.help {
  width: min(640px, 100%);
  text-align: left;
  gap: 4px;
}

.help h2 {
  margin: 0 0 8px;
}

.help h3 {
  margin: 14px 0 6px;
  font-size: 15px;
  color: var(--accent);
}

.help p,
.help li {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.help ul {
  margin: 0;
  padding-left: 18px;
}

.help .cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.help .close {
  position: absolute;
  top: 16px;
  right: 16px;
}

@media (max-width: 560px) {
  .help .cols {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.extras summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.extras-body {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.help .small a {
  color: var(--accent);
}

.song-select {
  width: 100%;
  padding: 7px 8px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.song-select option {
  background: #282828;
}

.song-nav {
  display: flex;
  gap: 6px;
}

.song-nav[hidden],
.song-along[hidden] {
  display: none;
}

.song-along {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.song-along .small-btn.on {
  border-color: var(--accent);
  color: var(--accent);
}

.small-btn {
  flex: 1;
  padding: 8px;
  font-size: 15px;
}

/* Top-right button for hiding the hand guides */
.guide-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 10px);
  z-index: 9; /* under the open controls panel on narrow screens */
  min-height: 58px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.guide-toggle:hover {
  border-color: var(--accent);
}

.song-search {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.song-search::placeholder {
  color: var(--muted);
}

.song-search:focus {
  outline: none;
  border-color: var(--accent);
}

#songCount:empty {
  display: none;
}

/* ---------- add a song ---------- */

.card.add-song {
  width: min(520px, 100%);
  text-align: left;
  gap: 10px;
}

.add-song h2 {
  margin: 0;
}

.add-song label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.add-song input,
.add-song select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.add-song input:focus,
.add-song select:focus {
  outline: none;
  border-color: var(--accent);
}

.add-song select option {
  background: #282828;
}

.add-preview {
  min-height: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.add-preview .problem {
  color: #f2a08a;
}

.add-preview .good {
  color: #9fd8a4;
}

.add-preview button {
  margin-left: 6px;
  min-height: 0;
  padding: 2px 10px;
  font-size: 13px;
}

.my-songs .waiting {
  color: var(--muted);
}

.my-songs .done {
  color: #9fd8a4;
}

.add-song .primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.my-songs {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.my-songs:empty {
  display: none;
}

.my-songs .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.my-songs button {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 13px;
}

/* Live search results under the search box */
.search-wrap {
  position: relative;
}

.song-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 15;
  max-height: 320px;
  overflow: auto;
  padding: 4px;
  background: #282828;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.song-results[hidden] {
  display: none;
}

.song-results .result {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.song-results .result:hover,
.song-results .result.on {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

.result-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.result-meta {
  font-size: 12px;
  color: var(--muted);
}

.result-more {
  padding: 7px 9px;
  font-size: 12px;
  color: var(--muted);
}

#recStatus .primary {
  width: 100%;
  margin-bottom: 6px;
}

/* ---------- chord pads (playing without the camera) ---------- */

.pads {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(560px, calc(100% - 24px));
  transform: translate(-50%, -50%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.pads[hidden] {
  display: none;
}

.pads button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  min-height: 84px;
  padding: 8px 4px;
  color: var(--text);
  background: rgba(30, 27, 25, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pads b {
  font-size: 22px;
}

.pads span {
  font-size: 14px;
  color: var(--muted);
}

.pads button.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #000;
}

.pads button.on span {
  color: #000;
}

.pad-minor[aria-pressed='true'] {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  border-color: var(--accent);
}

/* Sideways phones and tablets: one row of pads. */
@media (orientation: landscape) and (min-width: 640px) {
  .pads {
    grid-template-columns: repeat(8, 1fr);
    width: min(900px, calc(100% - 24px));
  }
}

.laptop-only {
  display: none !important;
}

/* ---------- laptop: mouse or trackpad and a wide window ---------- */

@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .laptop-only {
    display: flex !important;
  }

  span.laptop-only {
    display: inline !important;
  }

  .touch-only {
    display: none;
  }

  .panel,
  .panel.collapsed {
    top: 16px;
    left: 16px;
    width: 240px;
    max-height: calc(100dvh - 32px);
    padding: 12px 14px 14px;
  }

  .panel-body {
    gap: 10px;
    padding-right: 0;
  }

  .panel label {
    gap: 4px 8px;
    font-size: 13px;
  }

  .panel select,
  .song-search {
    min-height: 0;
    padding: 7px 8px;
    font-size: inherit;
  }

  .panel input[type='range'] {
    height: auto;
  }

  .panel label.check {
    gap: 8px;
    min-height: 0;
  }

  .check input {
    width: 13px;
    height: 13px;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
  }

  .rec,
  .primary,
  .ghost,
  .add-song input,
  .add-song select,
  .my-songs button {
    min-height: 0;
  }

  .small-btn {
    padding: 6px 8px;
    font-size: 13px;
  }

  .add-song input,
  .add-song select {
    font-size: inherit;
  }

  .song-results .result {
    gap: 1px;
    padding: 7px 9px;
  }

  .guide-toggle {
    top: 16px;
    right: 16px;
    z-index: 10;
    min-height: 0;
    padding: 8px 14px;
  }

  .card {
    padding: 32px 28px;
  }
}
