:root {
  --bg: #15110e;
  --surface: #241d18;
  --sleeve: #2b231d;
  --text: #f6ecdc;
  --muted: #a99b89;
  --accent: #ff7a3d;
  --accent-2: #3fb8a5;
  --cream: #f6ecdc;
  --ink: #1b1511;
  --level: 0;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}

[hidden] { display: none !important; }

a { color: var(--accent-2); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.01em;
}
.logo svg { flex: 0 0 auto; }
.logo .pre { color: var(--cream); font-weight: 600; }
.logo .main { color: var(--accent); }

.topbar .logo { flex: 1; min-width: 0; }

/* Schakelaar voor de quizmodus, altijd zichtbaar bovenin */
.quiz-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.quiz-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.quiz-toggle .switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid #44382f;
  transition: background .2s;
}

.quiz-toggle .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: translate .2s, background .2s;
}

.quiz-toggle input:checked + .switch { background: var(--accent-2); border-color: var(--accent-2); }
.quiz-toggle input:checked + .switch::after { translate: 18px 0; background: var(--cream); }
.quiz-toggle:has(input:checked) { color: var(--accent-2); }
.quiz-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn, .text-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  font: inherit;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Podium met de actuele kaart ---------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 8px 16px 20px;
}

.card-slot {
  position: relative;
  width: min(78vw, 360px);
  aspect-ratio: 1;
  perspective: 1200px;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.card-slot > .card { position: relative; width: 100%; height: 100%; }

/* ---------- Plaat (achterkant en voorkant) ---------- */

.vinyl {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .14), transparent 40%),
    repeating-radial-gradient(circle, #111 0 2px, #1c1c1c 2px 4px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45), inset 0 0 0 2px #000;
}

.label {
  position: relative;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--accent);
  color: var(--ink);
  transition: scale .12s linear;
}

/* Achterkant: een hoes met de plaat erin */
.card-back {
  background: var(--sleeve);
  border: 1px solid rgba(246, 236, 220, .12);
  cursor: pointer;
}

.card-back .vinyl { width: 86%; }

.card-back .label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 6%;
}

.mystery {
  font-size: clamp(2.6rem, 13vw, 4rem);
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  translate: 0 -4%;
}

.back-hint {
  position: absolute;
  bottom: 3.5%;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* De plaat draait tijdens luisteren en afspelen */
.listening #idleCard .vinyl,
.spinning .card-flip .card-back .vinyl { animation: spin 2.4s linear infinite; }
.listening #idleCard .label { scale: calc(1 + var(--level) * .12); }

@keyframes spin { to { rotate: 360deg; } }

/* Voorkant: hoes in de kleur van het decennium */
.card-front {
  background: var(--era, #5a4a3f);
  color: var(--ink);
  cursor: pointer;
  justify-content: space-between;
  padding: 6% 7% 7%;
}

.card-front .vinyl { width: 68%; }

.card-front .label {
  width: 58%;
  background: var(--cream);
}

.card-front .year {
  font-weight: 900;
  font-size: clamp(1.7rem, 9vw, 2.7rem);
  letter-spacing: -.02em;
  line-height: 1;
}

.card-front .meta {
  align-self: stretch;
  text-align: left;
}

.card-front .artist {
  font-weight: 800;
  font-size: clamp(1rem, 4.6vw, 1.35rem);
  line-height: 1.2;
}

.card-front .title {
  font-size: clamp(.9rem, 4vw, 1.1rem);
  line-height: 1.25;
  opacity: .85;
}

.card-front .play-hint {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: .7rem;
  font-weight: 700;
  opacity: .55;
}

/* ---------- Omdraaien ---------- */

.card-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}

.card-flip .card-back { transform: rotateY(180deg); }
.card-flip.hidden { transform: rotateY(180deg); }
.card-flip.enter { animation: deal .6s cubic-bezier(.2, .8, .2, 1); }

/* Zonder opacity: die maakt de 3D-kaart plat, waardoor de voorkant even doorschemert */
@keyframes deal {
  from { translate: 0 60px; scale: .85; }
  to   { translate: 0 0; scale: 1; }
}

/* ---------- Status & knoppen ---------- */

.status {
  margin: 0;
  min-height: 1.3em;
  color: var(--muted);
  font-size: .95rem;
  text-align: center;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(255, 122, 61, .3);
}

.listen-btn .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}

.listen-btn.on { background: var(--surface); color: var(--text); box-shadow: none; }
.listen-btn.on .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .25; } }

.random-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border: 2px solid var(--accent-2);
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--accent-2);
  background: transparent;
  cursor: pointer;
}

.random-btn:disabled { opacity: .5; cursor: wait; }

/* ---------- Tijdlijn ---------- */

.timeline-wrap {
  padding: 0 0 16px;
  min-height: 0;
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.timeline-head h2 {
  margin: 0;
  font-size: .8rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
}

.timeline {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 16px 6px;
  scroll-snap-type: x proximity;
}

.timeline:empty::after {
  content: "Herkende nummers verschijnen hier, gesorteerd op jaar.";
  color: var(--muted);
  font-size: .85rem;
}

.mini {
  flex: 0 0 auto;
  width: 112px;
  aspect-ratio: 1;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  color: var(--ink);
  background: var(--era);
  border: 0;
  font: inherit;
  cursor: pointer;
  scroll-snap-align: start;
}

.mini .year {
  display: grid;
  place-items: center;
  width: 58px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 0 5px #151515;
  margin-top: 4px;
  font-weight: 900;
  font-size: .95rem;
}

.mini .artist, .mini .title {
  font-size: .62rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.mini .artist { font-weight: 800; }

/* ---------- Instellingen ---------- */

dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}
.settings-form h2 { margin: 0 0 4px; font-size: 1.1rem; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.settings-form label.check { flex-direction: row; align-items: center; gap: 10px; }

.settings-form input[type=text], .settings-form select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #44382f;
  background: var(--bg);
  color: var(--text);
}

.hint { margin: 0; font-size: .8rem; color: var(--muted); }

.actions { display: flex; justify-content: flex-end; gap: 8px; }

.primary {
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
}

@media (min-width: 800px) {
  .card-slot { width: 380px; }
}
