:root {
  --bg: #0a0a0a;
  --ink: #f5f2ea;
  --muted: #8d8a84;
  --line: #262626;
  --panel: #121212;
  --accent: #ffd400;
  --accent-ink: #0a0a0a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(255,212,0,.08), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(255,255,255,.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative; z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
header img { height: 44px; width: auto; display: block; }
.tag {
  font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.icon-btn {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--muted); background: #161616; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- hero ---------- */
.hero { padding: 28px 0 4px; }
.hero h1 {
  font-family: "Archivo Black", "Archivo", sans-serif;
  font-size: clamp(38px, 4.8vw, 60px);
  line-height: .9;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.hero h1 em { font-style: normal; color: var(--accent); }
@media (min-width: 901px) { .hero h1 br { display: none; } }
.hero p { margin-top: 14px; color: var(--muted); font-size: 17px; max-width: 540px; }

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 48px;
  align-items: start;
  margin-top: 28px;
}

/* ---------- wheel ---------- */
.stage { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.wheel-box {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1;
  overflow-x: clip; /* la rueda girada no debe ensanchar la página */
}
.wheel-box::after {
  content: ""; position: absolute; inset: -4%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,212,0,.14) 40%, transparent 70%);
  z-index: -1;
  opacity: 0; transition: opacity .6s;
}
.wheel-box.spinning::after { opacity: 1; }

#wheel { width: 100%; height: 100%; display: block; will-change: transform; }
#wheel text { font-family: "Archivo", sans-serif; }
#wheel .slice { fill: transparent; transition: fill .3s; }
#wheel .slice.done { fill: rgba(10,10,10,.55); }
#wheel .slice.win { fill: var(--accent); }
#wheel .lbl.done { opacity: .35; }
#wheel .lbl.win, #wheel .lbl.win text { fill: var(--accent-ink) !important; opacity: 1; }

.pointer {
  position: absolute; left: 50%; top: -16px;
  width: 40px; height: 62px;
  transform: translateX(-50%);
  transform-origin: 50% 20%;
  z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.6));
}
.pointer.tick { animation: flick .1s ease-out; }
@keyframes flick {
  0% { transform: translateX(-50%) rotate(0); }
  40% { transform: translateX(-50%) rotate(-14deg); }
  100% { transform: translateX(-50%) rotate(0); }
}

.hub {
  position: absolute; left: 50%; top: 50%;
  width: 24%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 6px var(--bg), 0 10px 30px rgba(0,0,0,.6);
  z-index: 2;
  background: #000;
}
.hub img { width: 100%; height: 100%; object-fit: contain; padding: 16%; display: block; }

/* visor en vivo */
.readout {
  width: min(100%, 520px);
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 18px;
  transition: border-color .3s;
}
.readout.live { border-color: #3a3a3a; }
.readout .ro-n {
  font-family: "Archivo Black", sans-serif;
  font-size: 34px; line-height: 1; color: var(--accent);
  min-width: 2.2ch; text-align: center;
  font-variant-numeric: tabular-nums;
}
.readout .ro-t { font-weight: 800; font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout .ro-a { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout .ro-body { min-width: 0; }

.controls { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(100%, 520px); }
.spin-btn {
  font-family: "Archivo Black", sans-serif;
  font-size: 22px; letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 999px;
  padding: 20px 56px;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(255,212,0,.5), 0 12px 30px rgba(255,212,0,.25);
  transition: transform .15s ease, box-shadow .3s ease, opacity .2s;
  animation: pulse 2.4s infinite;
}
.spin-btn:hover { transform: translateY(-2px) scale(1.02); }
.spin-btn:active { transform: translateY(1px) scale(.98); }
.spin-btn:disabled { opacity: .45; cursor: not-allowed; animation: none; transform: none; }
.spin-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,212,0,.45), 0 12px 30px rgba(255,212,0,.25); }
  70% { box-shadow: 0 0 0 18px rgba(255,212,0,0), 0 12px 30px rgba(255,212,0,.25); }
  100% { box-shadow: 0 0 0 0 rgba(255,212,0,0), 0 12px 30px rgba(255,212,0,.25); }
}

.options { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.options kbd {
  font-family: inherit; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); border-bottom-width: 2px;
  padding: 2px 6px; border-radius: 4px; color: var(--ink);
}
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 34px; height: 20px; border-radius: 999px; background: #2a2a2a; position: relative; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); transition: transform .2s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }
.link-btn {
  background: none; border: none; color: var(--muted); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

/* ---------- panel ---------- */
aside { display: flex; flex-direction: column; gap: 22px; }

.result {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
  min-height: 190px;
  overflow: hidden;
}
.result .label { font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.result .rank {
  position: absolute; right: 18px; bottom: -28px;
  font-family: "Archivo Black", sans-serif;
  font-size: 150px; line-height: 1;
  color: transparent; -webkit-text-stroke: 2px #2a2a2a;
  pointer-events: none; user-select: none;
}
.result .song {
  position: relative;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.02;
  margin-top: 14px;
  text-transform: uppercase;
  padding-right: 20px;
}
.result .artist { position: relative; margin-top: 8px; font-size: 18px; font-weight: 600; color: var(--accent); }
.result .empty { margin-top: 14px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.result.reveal { border-color: var(--accent); animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { 0% { transform: scale(.96); } 100% { transform: scale(1); } }
.listen {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 18px;
  font-size: 14px; font-weight: 700; color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px;
  transition: border-color .2s, background .2s;
}
.listen:hover { border-color: var(--ink); background: #1b1b1b; }

.player {
  position: relative;
  margin-top: 18px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.card-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 10px;
}
.card-title b { color: var(--ink); font-weight: 800; }

.search {
  width: 100%;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px 12px 40px;
  font: 500 15px "Archivo", sans-serif;
  margin-bottom: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238d8a84' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px 50%;
}
.search:focus { outline: none; border-color: var(--muted); }
.search::placeholder { color: var(--muted); }

.list-wrap {
  position: relative;
  max-height: 470px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.list-wrap.short { max-height: none !important; overflow: visible; }
.list-wrap::-webkit-scrollbar { width: 8px; }
.list-wrap::-webkit-scrollbar-thumb { background: #333; border-radius: 8px; }
.list { list-style: none; }
.list li {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 8px 9px 4px;
  border-bottom: 1px solid var(--line);
  transition: background .3s, opacity .3s;
}
.list .n { font-family: "Archivo Black", sans-serif; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list .t { font-weight: 700; font-size: 14px; line-height: 1.2; }
.list .a { font-size: 12px; color: var(--muted); }
.list .c { font-size: 12px; font-weight: 700; color: var(--muted); min-width: 22px; text-align: right; }
.list li.done { opacity: .45; }
.list li.active { background: var(--accent); color: var(--accent-ink); border-radius: 8px; border-bottom-color: transparent; opacity: 1; }
.list li.active .n, .list li.active .a, .list li.active .c { color: var(--accent-ink); }
.list .none { display: block; padding: 18px 4px; color: var(--muted); font-size: 14px; }

.history { display: flex; flex-wrap: wrap; gap: 8px; }
.history span {
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  color: var(--muted);
}
.history span b { color: var(--accent); font-weight: 800; margin-right: 4px; }
.history span:first-child { color: var(--ink); border-color: var(--muted); }
.history .none { border: none; padding: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--accent-ink);
  font-weight: 700; font-size: 14px;
  padding: 12px 18px; border-radius: 999px;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 60;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; gap: 36px; }
  .hero { text-align: center; }
  .hero p { margin-left: auto; margin-right: auto; }
}
@media (max-width: 520px) {
  .wrap { padding: 20px 16px 36px; }
  header img { height: 32px; }
  .tag { display: none; }
  .spin-btn { width: 100%; padding: 18px 24px; }
  .kbd-hint { display: none; }
  .list-wrap { max-height: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  .spin-btn { animation: none; }
}

/* ---------- popup de la canción ganadora (sobre la ruleta) ---------- */
.win-popup {
  position: absolute; left: 50%; top: 50%;
  width: min(78%, 360px);
  transform: translate(-50%, -50%) scale(.6);
  opacity: 0; visibility: hidden;
  z-index: 4;
  background: var(--accent); color: var(--accent-ink);
  border: 4px solid var(--accent-ink);
  border-radius: 24px;
  padding: 22px 22px 24px;
  text-align: center;
  box-shadow: 0 0 0 6px var(--accent), 0 24px 60px rgba(0,0,0,.7);
  cursor: pointer;
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.win-popup.show {
  opacity: 1; visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity .2s ease, transform .45s cubic-bezier(.2,1.5,.4,1), visibility 0s;
}
.win-popup .wp-kicker { font-size: 12px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.win-popup .wp-n {
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(40px, 11vw, 64px); line-height: 1; margin-top: 6px;
}
.win-popup .wp-t {
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(18px, 4.6vw, 26px); line-height: 1.05; text-transform: uppercase;
  margin-top: 8px; overflow-wrap: anywhere;
}
.win-popup .wp-a { font-size: clamp(13px, 3.4vw, 15px); font-weight: 600; margin-top: 6px; opacity: .8; }
@media (prefers-reduced-motion: reduce) {
  .win-popup, .win-popup.show { transform: translate(-50%, -50%); }
}
