:root {
  /* Room palette — warm, sunlit, mid-century */
  --wall: #e8e0d2;
  --wall-2: #ddd2c0;
  --ink: #2b2620;
  --ink-soft: #6f6657;
  --ink-faint: #9a8f7d;
  --wood: #9c6a43;
  --wood-dark: #7c4f30;
  --wood-light: #b98455;
  --accent: #c2552f;
  --accent-2: #e0a04a;
  --paper: #f3ede1;
  --line: rgba(60, 48, 32, 0.14);
  --console-h: 168px;
  --maxw: 1180px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--console-h) + 40px);
}

a {
  color: inherit;
}

/* The wall / room backdrop */
.room {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 252, 244, 0.7), transparent 55%),
    radial-gradient(90% 70% at 85% 0%, rgba(224, 160, 74, 0.18), transparent 55%),
    linear-gradient(180deg, var(--wall) 0%, var(--wall-2) 78%, #cdbfa9 100%);
}
.room::after {
  /* soft baseboard shadow where wall meets the floor area */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 200px;
  background: linear-gradient(180deg, transparent, rgba(60, 44, 28, 0.12));
}

/* ---------------------------------------------------------------- Masthead */
/* Scrolls away with the page (not sticky) */
.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 40px) clamp(18px, 4vw, 44px) 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px 24px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
  background:
    radial-gradient(circle at 50% 50%, var(--wall) 0 16%, transparent 17%),
    repeating-radial-gradient(circle at 50% 50%, #1a1a1a 0 1px, #2a2a2a 1px 3px),
    radial-gradient(circle at 38% 32%, #444, #111 70%);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 16px;
  letter-spacing: 0.2px;
}

.brand-text a {
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
}
.brand-text a:hover {
  color: var(--accent);
}

.masthead-meta {
  grid-column: 1 / -1;
  order: 3;
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.masthead-meta b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.periods {
  justify-self: end;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(60, 44, 28, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.periods::-webkit-scrollbar {
  display: none;
}

.period-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}
.period-btn:hover {
  color: var(--ink);
}
.period-btn.active {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  font-weight: 600;
  box-shadow: 0 4px 12px -4px var(--accent);
}

/* ---------------------------------------------------------------- Content */
.content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px clamp(18px, 4vw, 44px) 40px;
}

.section-title {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 28px 0 20px;
}

.wall-section .section-title {
  margin-top: 6px;
}

/* The record wall — covers hung in a grid */
.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: clamp(18px, 2.6vw, 34px);
  /* nail-holes / mounting feel via row rhythm */
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.sleeve {
  position: relative;
  aspect-ratio: 1;
}

/* the black vinyl peeking out of the sleeve */
.sleeve-vinyl {
  position: absolute;
  inset: 6% 0 6% 0;
  left: 8%;
  border-radius: 50%;
  aspect-ratio: 1;
  height: 88%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 38% 34%, #3a3a3a, #0b0b0b 72%);
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.6);
  transform: translateX(8%);
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s;
}
.sleeve-vinyl::after {
  content: "";
  position: absolute;
  inset: 42%;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.cover {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #cabfaf;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 14px 26px -14px rgba(40, 28, 16, 0.7),
    0 4px 8px -4px rgba(40, 28, 16, 0.4);
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* hover: pull the vinyl out a touch to telegraph the click */
.tile:hover .sleeve-vinyl {
  transform: translateX(34%) rotate(8deg);
}
.tile:hover .cover {
  transform: translateY(-3px);
}

/* while this record is on the turntable, its vinyl is gone from the sleeve */
.tile.is-out .sleeve-vinyl {
  opacity: 0;
}
.tile.is-out .cover {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rank {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  backdrop-filter: blur(3px);
}

.tile-meta strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-meta span {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-meta em {
  font-style: normal;
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------- Chart */
.chart-section {
  margin-top: 14px;
}

.artists {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px 18px;
}

.artist {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--line);
}
.artist::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--bar, 0%);
  background: linear-gradient(90deg, rgba(194, 85, 47, 0.18), rgba(224, 160, 74, 0.06));
  z-index: 0;
}
.artist > * {
  position: relative;
  z-index: 1;
}
.artist .a-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.artist:nth-child(1) .a-rank {
  color: var(--accent);
}
.artist .a-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artist .a-count {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.artist .a-count b {
  color: var(--ink);
  font-weight: 700;
}

/* ---------------------------------------------------------------- Console */
.console {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--console-h);
  display: flex;
  justify-content: center;
}

.tabletop {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: 0 clamp(18px, 3vw, 36px);
  border-radius: 14px 14px 6px 6px;
  background:
    linear-gradient(180deg, var(--wood-light), var(--wood) 22%, var(--wood-dark) 100%);
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.18) inset,
    0 26px 50px -24px rgba(40, 24, 12, 0.7),
    0 -10px 30px -20px rgba(40, 24, 12, 0.5);
  /* wood grain */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 0 2px,
      rgba(0, 0, 0, 0.04) 2px 5px,
      transparent 5px 14px
    ),
    linear-gradient(180deg, var(--wood-light), var(--wood) 22%, var(--wood-dark) 100%);
}

.table-legs {
  position: absolute;
  bottom: -18px;
  left: 0;
  right: 0;
  height: 20px;
  z-index: -1;
}

/* Turntable */
.turntable {
  position: relative;
  width: 138px;
  height: 124px;
  border-radius: 10px;
  background: linear-gradient(160deg, #2a2c30, #15161a);
  box-shadow:
    0 10px 22px -10px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 10px;
  flex: none;
}

.platter {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, #1b1b1b 0 2px, #242424 2px 4px),
    radial-gradient(circle, #2b2b2b, #161616);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 4px 10px rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
}

.spindle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #cfcfcf;
  z-index: 3;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* The record on the platter (hidden until a record is loaded) */
.vinyl {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 36% 32%, #3c3c3c, #090909 72%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 4px 10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.turntable.loaded .vinyl {
  opacity: 1;
  transform: scale(1);
}
.turntable.playing .vinyl {
  animation: spin 1.7s linear infinite;
}
.vinyl .label {
  position: absolute;
  inset: 33%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
}
.vinyl .label::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14%;
  height: 14%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #15161a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

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

/* Tonearm */
.tonearm {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 60px;
  height: 86px;
  transform-origin: 88% 12%;
  transform: rotate(-26deg);
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 4;
  pointer-events: none;
}
.turntable.playing .tonearm {
  transform: rotate(6deg);
}
.arm-pivot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(160deg, #d8d8d8, #8a8a8a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.arm {
  position: absolute;
  right: 11px;
  top: 12px;
  width: 4px;
  height: 74px;
  background: linear-gradient(180deg, #cfcfcf, #9a9a9a);
  transform-origin: top center;
  transform: rotate(28deg);
  border-radius: 3px;
}
.arm-head {
  position: absolute;
  left: 6px;
  bottom: 2px;
  width: 12px;
  height: 16px;
  background: linear-gradient(160deg, #2a2a2a, #111);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.speed-dot {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a4d52;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}
.turntable.playing .speed-dot {
  background: #5fd07a;
  box-shadow: 0 0 8px #5fd07a, 0 0 0 2px rgba(0, 0, 0, 0.4);
}

/* Now playing text on the wood */
.now {
  min-width: 0;
  color: #fff5e9;
}
.now-status {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 240, 222, 0.65);
}
.now-title {
  display: block;
  font-size: clamp(15px, 2vw, 19px);
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.now-artist {
  display: block;
  font-size: 13px;
  color: rgba(255, 240, 222, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.now-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  max-width: 460px;
}
.now-progress span {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 240, 222, 0.75);
  width: 32px;
  flex: none;
}
.now-progress span:last-child {
  text-align: right;
}
.seek {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  position: relative;
}
.seek-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), #fff2dd);
  position: relative;
}
.seek-fill::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s;
}
.seek:hover .seek-fill::after {
  opacity: 1;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.ctl {
  appearance: none;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  cursor: pointer;
  color: #2a2118;
  background: linear-gradient(160deg, #f3e6d2, #d8c2a4);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.14s, filter 0.14s, opacity 0.14s;
}
.ctl:hover:not(:disabled) {
  filter: brightness(1.06);
}
.ctl:active:not(:disabled) {
  transform: scale(0.92);
}
.ctl:disabled {
  opacity: 0.4;
  cursor: default;
}
.ctl.play {
  width: 48px;
  height: 48px;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 14px -4px var(--accent), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  padding-left: 2px;
}

/* The flying record (created in JS) */
.flying {
  position: fixed;
  z-index: 60;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 36% 32%, #3c3c3c, #090909 72%);
  box-shadow: 0 18px 32px -10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  will-change: transform;
}
.flying .label {
  position: absolute;
  inset: 33%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
}

.yt-host {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: -9999px;
  pointer-events: none;
}

.empty {
  grid-column: 1 / -1;
  padding: 36px 0;
  text-align: center;
  color: var(--ink-soft);
}

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 760px) {
  .masthead {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .periods {
    justify-self: start;
  }
}

@media (max-width: 680px) {
  :root {
    --console-h: 150px;
  }
  .tabletop {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "turntable now"
      "controls controls";
    gap: 10px 16px;
    padding: 12px 16px;
    align-items: center;
  }
  .turntable {
    grid-area: turntable;
    width: 104px;
    height: 100px;
  }
  .platter {
    width: 78px;
    height: 78px;
    left: 11px;
    top: 11px;
  }
  .vinyl {
    width: 74px;
    height: 74px;
  }
  .now {
    grid-area: now;
  }
  .now-progress {
    display: none;
  }
  .controls {
    grid-area: controls;
    justify-content: center;
  }
  .wall {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  .vinyl,
  .tonearm,
  .sleeve-vinyl,
  .cover {
    animation: none !important;
    transition: none !important;
  }
}
