/* ---------- tokens ---------- */
:root {
  --ink: #0B0B0D;
  --ink-raised: #16151A;
  --paper: #F4F0E8;
  --paper-dim: #C9C4B6;
  --brick: #C8443D;
  --brick-dim: #8A2E2A;
  --sage: #8A9A7E;
  --line: #3A3A38;

  --font-display: 'Big Shoulders Condensed', sans-serif;
  --font-body: 'Archivo', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 3px;
  --radius-md: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  position: relative;
  overflow-x: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* subtle grain so the near-black background doesn't feel flat/default */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }

/* ---------- header ---------- */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem clamp(1.5rem, 5vw, 4rem) 0;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.account-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--paper-dim);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.account-btn:hover { border-color: var(--paper-dim); color: var(--paper); }

/* ---------- shared layout ---------- */
.view {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 clamp(1.5rem, 5vw, 4rem) 5rem;
}

.btn-primary {
  background: var(--brick);
  color: var(--paper);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.8rem 1.6rem;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), background 180ms ease;
}
.btn-primary:hover { background: #D95850; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.link-plain {
  color: var(--paper-dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.link-plain:hover { color: var(--paper); text-decoration-color: var(--paper-dim); }
.link-plain:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

/* ---------- setup view ---------- */
.view-setup {
  position: relative;
  padding-top: clamp(3rem, 12vh, 7rem);
}

/* A record label graphic bleeding off the left edge, sitting behind the
   copy - a signature illustration tied to the concept, not a stock blob. */
.vinyl-decor {
  position: absolute;
  top: -70px;
  left: -210px;
  width: 480px;
  height: 480px;
  transform: rotate(-11deg);
  z-index: 0;
  pointer-events: none;
}
.decor-groove-outer,
.decor-groove {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.decor-label {
  fill: var(--brick-dim);
  stroke: var(--brick);
  stroke-width: 2;
  opacity: 0.55;
}
.decor-label-text {
  fill: var(--paper);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.3em;
  opacity: 0.7;
}
.decor-spindle {
  fill: var(--ink);
  stroke: var(--paper-dim);
  stroke-width: 1;
}

@media (max-width: 760px) {
  .vinyl-decor { display: none; }
}

.setup-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.setup-copy h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 5.2vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 1.1rem;
}

.lede {
  color: var(--paper-dim);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 34ch;
}

/* An "insert card" tucked into the sleeve: a second sheet peeks out from
   behind at a slightly different angle, and the top-right corner is cut
   on the diagonal like a torn ticket stub. */
.insert-card {
  position: relative;
  z-index: 1;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  padding: 1.9rem 1.9rem 1.75rem;
  transform: rotate(-0.7deg);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%);
  align-self: start;
}

.insert-card::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 16px;
  right: -10px;
  bottom: -10px;
  background: var(--ink);
  border: 1px solid var(--line);
  z-index: -1;
  transform: rotate(1.5deg);
}

.field-group { margin: 0 0 1.5rem; }

.field-group label,
.tracklist-legend {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 0.6rem;
  padding: 0;
}

.field-group input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: 0.5rem 0.05rem;
}
.field-group input[type="text"]::placeholder { color: #6b6a66; }
.field-group input[type="text"]:focus-visible {
  outline: none;
  border-bottom-color: var(--brick);
  border-bottom-width: 3px;
}

.recent-playlists { margin: 0 0 1.75rem; }

.recent-playlists-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin: 0 0 0.6rem;
}

.recent-playlists-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.recent-playlist-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.recent-playlist-row:hover { border-color: var(--paper-dim); }

.recent-playlist-cover {
  width: 36px;
  height: 36px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--ink);
  flex-shrink: 0;
}

.recent-playlist-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.recent-playlist-name {
  font-size: 0.88rem;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-playlist-owner {
  font-size: 0.75rem;
  color: var(--paper-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-playlist-remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--paper-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.recent-playlist-remove:hover { color: var(--brick); background: rgba(200, 68, 61, 0.12); }

/* Mode picker styled as a record's tracklist, not a settings form -
   track numbers instead of radio dots, a left rule marks the pick. */
.tracklist {
  border: none;
  padding: 0;
  margin: 0 0 1.75rem;
}

.track-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: baseline;
  column-gap: 0.9rem;
  padding: 0.65rem 0 0.65rem 0.7rem;
  margin-left: -0.7rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.track-row:first-of-type { border-top: 1px solid var(--line); }

.track-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.track-row:has(input:checked) { border-left-color: var(--brick); }

.track-index {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--paper-dim);
}
.track-row:has(input:checked) .track-index { color: var(--paper); }

.track-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.track-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--paper-dim);
  transition: color 160ms ease;
}
.track-row:hover .track-title { color: var(--paper); }
.track-row:has(input:checked) .track-title { color: var(--brick); }

.track-sub {
  font-size: 0.8rem;
  color: var(--paper-dim);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  flex-wrap: wrap;
}

.setup-error {
  margin: 1rem 0 0;
  color: var(--brick);
  font-size: 0.88rem;
  line-height: 1.5;
}

.setup-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--paper-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.mini-groove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brick);
  animation: spin 900ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .setup-panel { grid-template-columns: 1fr; }
  .insert-card { transform: none; }
  .insert-card::before { display: none; }
}

/* ---------- game view ---------- */
.view-game { padding-top: 2.5rem; }

.playlist-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 760px;
  margin: 0 auto 2.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.5rem;
}

.playlist-cover {
  width: 52px;
  height: 52px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--ink-raised);
  flex-shrink: 0;
}

.playlist-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0;
}

.playlist-owner {
  font-size: 0.82rem;
  color: var(--paper-dim);
  margin: 0.15rem 0 0;
}

.mode-badge {
  margin-left: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sage);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
}

.score-block {
  margin-left: auto;
  text-align: right;
  font-family: var(--font-mono);
}

#score-value {
  font-size: 1.6rem;
  color: var(--sage);
  display: block;
  line-height: 1;
}

.score-label {
  font-size: 0.68rem;
  color: var(--paper-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.game-panel {
  display: grid;
  grid-template-columns: 280px 380px;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  justify-content: center;
  max-width: 760px;
  margin: 0 auto;
}

.groove-wrap {
  width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.groove-inner {
  position: relative;
  width: 240px;
  height: 240px;
}

.groove { width: 240px; height: 240px; display: block; }

.groove-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
}

.groove-progress {
  fill: none;
  stroke: var(--brick);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 678.6;
  stroke-dashoffset: 678.6;
  transform: rotate(-90deg);
  transform-origin: 120px 120px;
  transition: stroke-dashoffset 120ms linear;
}

.groove-label {
  fill: var(--ink-raised);
  stroke: var(--line);
  stroke-width: 1;
}

.play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brick);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.play-btn:hover { transform: translate(-50%, -50%) scale(1.05); }
.play-btn:active { transform: translate(-50%, -50%) scale(0.95); }
.play-btn:focus-visible { outline: 2px solid var(--sage); outline-offset: 3px; }

.play-btn.is-loading {
  background: var(--ink-raised);
  border: 2px solid var(--line);
  cursor: default;
}
.play-btn.is-loading .icon-play,
.play-btn.is-loading .icon-pause { visibility: hidden; }
.play-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brick);
  animation: spin 800ms linear infinite;
}

.icon-play, .icon-pause { width: 22px; height: 22px; fill: var(--paper); }

.clip-length {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--paper-dim);
}

.attempts-side {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.mashup-progress {
  display: flex;
  gap: 0.6rem;
}

.mashup-progress .slot {
  flex: 1;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  color: #6b6a66;
  font-family: var(--font-mono);
}

.mashup-progress .slot.found {
  border-style: solid;
  border-color: var(--sage);
  color: var(--sage);
}

.attempts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attempts-list li {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-raised);
  font-size: 0.92rem;
}

.attempts-list li .track-no {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--paper-dim);
  width: 1.4rem;
  flex-shrink: 0;
}

.attempts-list li.empty {
  border-style: dashed;
  color: #6b6a66;
}

.attempts-list li.wrong { border-color: var(--brick-dim); }
.attempts-list li.correct { border-color: var(--sage); color: var(--sage); }

.guess-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.guess-input-wrap {
  position: relative;
  flex: 1;
}

.guess-form input {
  width: 100%;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
}
.guess-form input::placeholder { color: #6b6a66; }
.guess-form input:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 1px;
  border-color: var(--sage);
}
.guess-form input:disabled { opacity: 0.5; }

.guess-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
}

.guess-suggestions li {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}
.guess-suggestions li:hover,
.guess-suggestions li.is-active {
  background: rgba(200, 68, 61, 0.14);
}
.guess-suggestions .suggestion-title { color: var(--paper); }
.guess-suggestions .suggestion-artist {
  color: var(--paper-dim);
  font-size: 0.8rem;
  margin-left: 0.4rem;
}

.skip-btn { align-self: flex-start; }

@media (max-width: 700px) {
  .game-panel { grid-template-columns: 1fr; }
  .groove-wrap { margin: 0 auto; }
}

/* ---------- reveal ---------- */
.reveal-panel {
  margin: 2.5rem auto 0;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--ink-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.75rem;
}

.reveal-tracks {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.reveal-track-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.reveal-art {
  width: 96px;
  height: 96px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ink);
}

.reveal-verdict {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}

.reveal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
}

.reveal-artist {
  color: var(--paper-dim);
  margin: 0.2rem 0 0;
}

#next-btn { align-self: flex-start; }

.progress-note {
  max-width: 760px;
  margin: 2rem auto 0;
  color: #6b6a66;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* ---------- done view ---------- */
.view-done {
  padding-top: clamp(4rem, 16vh, 9rem);
  text-align: left;
}

.done-panel h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 1rem;
}

.done-score {
  color: var(--paper-dim);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* ---------- motion & accessibility floor ---------- */
@media (prefers-reduced-motion: reduce) {
  .mini-groove { animation: none; border-top-color: var(--line); }
  .btn-primary, .play-btn { transition: none; }
}
