/* Spotify music quiz. Same palette as the profile page; no external resource (CSP 'self'). */
:root {
  --bg: #08060d;
  --card: rgba(24, 19, 34, 0.66);
  --card-strong: rgba(34, 27, 48, 0.85);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f0fa;
  --muted: #a59cb5;
  --accent-1: #8b5cf6;
  --accent-2: #d946ef;
  --accent-3: #22d3ee;
  --ok: #22c55e;
  --ko: #f43f5e;
  --radius: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 20% 15%, rgba(139, 92, 246, 0.40), transparent 60%),
    radial-gradient(34vmax 34vmax at 85% 25%, rgba(217, 70, 239, 0.28), transparent 60%),
    radial-gradient(40vmax 40vmax at 60% 95%, rgba(34, 211, 238, 0.16), transparent 60%);
  filter: blur(20px);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(-3vmax, 2vmax, 0) rotate(-6deg); }
}

.page {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(32px, env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: rise 0.35s ease both; }
#screen-loading.active, #screen-closed.active { display: grid; place-items: center; min-height: 80vh; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { margin: 0; line-height: 1.15; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.center { text-align: center; }
.center-text { text-align: center; margin: 4px 0 18px; }
.grad {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2) 55%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-3);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---------- buttons, inputs ---------- */

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); box-shadow: 0 8px 28px rgba(139, 92, 246, 0.35); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border); }
.btn.danger { background: rgba(244, 63, 94, 0.18); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.35); }
.btn.small { padding: 8px 14px; font-size: 0.85rem; }
.link {
  display: block;
  margin: 18px auto 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.link:hover { color: var(--text); }

input[type="text"], input[type="password"], input:not([type]) {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  min-width: 0;
  outline: none;
}
input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > input { flex: 1 1 180px; }
.center-row { justify-content: center; margin-top: 18px; }
.form-error { color: #fda4af; min-height: 1.2em; margin: 10px 0 0; font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

/* ---------- home ---------- */

.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: clamp(1.75rem, 6.5vw, 2.5rem); font-weight: 800; margin-bottom: 10px; }
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 16px;
  padding: 4px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.4);
}
.rules {
  list-style: none;
  padding: 0;
  margin: 22px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.rules li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rules b { font-size: 1.3rem; }
.rules span { font-size: 0.75rem; color: var(--muted); }
.start label { display: block; font-weight: 700; margin-bottom: 10px; }

/* ---------- question ---------- */

.q-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill, .chip {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip { color: var(--accent-3); }
.pill.score { color: #f0abfc; }
.timer {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 0 18px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  border-radius: inherit;
  transform-origin: left;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-1), var(--accent-2));
}
.timer-bar.hurry { background: linear-gradient(90deg, #fb7185, var(--ko)); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.55; } }

.q-media { display: flex; justify-content: center; }
.q-media.has-image img {
  width: min(240px, 62vw);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  margin-bottom: 18px;
}
.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 150px;
  height: 150px;
  justify-content: center;
  border-radius: 50%;
  border: 0;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent-1) 70%);
  box-shadow: 0 0 0 10px rgba(139, 92, 246, 0.15), 0 16px 50px rgba(139, 92, 246, 0.45);
  margin-bottom: 20px;
}
.play-label { font-size: 0.9rem; }

/* Equaliser bars (loading, audio question). */
.eq { display: inline-flex; align-items: flex-end; gap: 4px; height: 34px; }
.eq i { width: 6px; height: 30%; border-radius: 3px; background: currentColor; }
.eq.big { height: 60px; color: var(--accent-1); }
.eq.big i { width: 10px; }
.eq.big i, body.playing .play .eq i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s !important; }
.eq i:nth-child(3) { animation-delay: -0.6s !important; }
.eq i:nth-child(4) { animation-delay: -0.15s !important; }
.eq i:nth-child(5) { animation-delay: -0.45s !important; }
@keyframes eq { 0%, 100% { height: 20%; } 50% { height: 100%; } }

.q-text { font-size: clamp(1.3rem, 5vw, 1.7rem); font-weight: 800; text-align: center; margin: 0 0 20px; }
.choices { display: grid; gap: 12px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s, background 0.2s, opacity 0.3s;
}
.choice:hover:not(:disabled) { border-color: rgba(139, 92, 246, 0.7); transform: translateY(-1px); }
.choice:active:not(:disabled) { transform: scale(0.98); }
.choice:disabled { cursor: default; }
.choice .letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-weight: 800;
  background: rgba(139, 92, 246, 0.22);
  color: #c4b5fd;
}
.choice .label { overflow-wrap: anywhere; }
.choice.picked { border-color: var(--accent-1); }
.choice.right { background: rgba(34, 197, 94, 0.18); border-color: var(--ok); }
.choice.right .letter { background: var(--ok); color: #04210f; }
.choice.wrong { background: rgba(244, 63, 94, 0.16); border-color: var(--ko); animation: shake 0.35s; }
.choice.wrong .letter { background: var(--ko); color: #2a0610; }
.choice.dim { opacity: 0.45; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback { margin-top: 18px; text-align: center; animation: rise 0.3s ease both; }
.fb-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 6px; }
.fb-title.ok { color: var(--ok); }
.fb-title.ko { color: var(--ko); }
.fb-explain { color: var(--muted); margin: 0 0 16px; }
.feedback .btn { width: 100%; }

/* ---------- result ---------- */

.result-hero { margin-top: 10px; }
.big-score {
  font-size: clamp(3rem, 15vw, 4.6rem);
  font-weight: 900;
  margin: 0;
  line-height: 1;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2) 55%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.big-score small { font-size: 1.2rem; margin-left: 6px; }
.res-line { font-weight: 700; margin: 10px 0 0; }
.res-rank { font-size: 1.15rem; margin: 6px 0 0; }
.verdict { color: var(--muted); margin: 12px auto 0; max-width: 440px; }
.section-title { font-size: 1.45rem; font-weight: 800; margin: 34px 0 14px; text-align: center; }
.recap { display: grid; gap: 12px; }
.recap .section-title { margin-bottom: 2px; }
.recap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.recap h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-3); margin-bottom: 12px; }
.top-list { list-style: none; counter-reset: top; padding: 0; margin: 0; display: grid; gap: 10px; }
.top-list li { counter-increment: top; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-list li::before { content: counter(top); width: 1.1em; font-weight: 800; color: var(--muted); flex: none; }
.top-list img, .top-list .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: rgba(255, 255, 255, 0.08); }
.top-list .round { border-radius: 50%; }
.top-list .name { min-width: 0; display: flex; flex-direction: column; font-weight: 600; overflow-wrap: anywhere; }
.top-list .name small { color: var(--muted); font-weight: 500; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 7px 13px; border-radius: 999px; background: rgba(139, 92, 246, 0.18); border: 1px solid rgba(139, 92, 246, 0.35); font-weight: 600; font-size: 0.9rem; }
.stats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stats li { display: flex; flex-direction: column; gap: 2px; padding: 16px; }
.stats b { font-size: 1.6rem; font-weight: 900; }
.stats span { color: var(--muted); font-size: 0.85rem; }

.review { margin-top: 16px; }
.review summary { cursor: pointer; font-weight: 700; }
.review-list { padding-left: 1.3em; margin: 14px 0 0; display: grid; gap: 14px; }
.review-list p { margin: 0; }
.rv-q { font-weight: 600; }
.rv-a { font-size: 0.92rem; }
.review-list .ok .rv-a { color: #86efac; }
.review-list .ko .rv-a { color: #fda4af; }
.rv-good { color: #86efac; }
.rv-pts { color: var(--muted); }
.rv-x { color: var(--muted); font-size: 0.85rem; }

/* ---------- leaderboard ---------- */

.board { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.board li {
  display: grid;
  grid-template-columns: 2.4em 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
}
.board li.me { border-color: var(--accent-2); background: rgba(217, 70, 239, 0.14); }
.board li.gap { display: block; text-align: center; background: none; border: 0; padding: 0; color: var(--muted); }
.board .rank { font-weight: 800; text-align: center; font-size: 1.1rem; }
.board .who { font-weight: 700; overflow-wrap: anywhere; }
.board .good { color: var(--muted); font-size: 0.85rem; }
.board .pts { font-weight: 800; color: #f0abfc; }
#board-back { display: block; margin: 0 auto; }

@media (max-width: 480px) {
  .recap-grid { grid-template-columns: 1fr; }
  .rules b { font-size: 1.1rem; }
  .board li { grid-template-columns: 2em 1fr auto; }
  .board .good { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- admin ---------- */

.admin .page { width: min(980px, 100%); }
.admin h1 { font-size: 1.8rem; margin: 10px 0 18px; }
.admin .card { margin-bottom: 14px; }
.admin h2 { font-size: 1.1rem; margin-bottom: 10px; }
.admin .kv { color: var(--muted); margin: 6px 0; font-size: 0.92rem; }
.admin .kv b { color: var(--text); }
.admin .ok-text { color: #86efac; }
.admin .ko-text { color: #fda4af; }
.admin code { background: rgba(255, 255, 255, 0.08); padding: 2px 6px; border-radius: 6px; font-size: 0.85rem; overflow-wrap: anywhere; }
.admin .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.admin .notice { padding: 12px 16px; border-radius: 14px; margin-bottom: 14px; background: rgba(34, 211, 238, 0.12); border: 1px solid rgba(34, 211, 238, 0.3); }
.admin .notice.err { background: rgba(244, 63, 94, 0.14); border-color: rgba(244, 63, 94, 0.35); }
.qlist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.qlist li { display: grid; grid-template-columns: auto 56px 1fr; gap: 12px; align-items: start; padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); }
.qlist li.off { opacity: 0.5; }
.qlist input[type="checkbox"] { width: 20px; height: 20px; margin-top: 4px; accent-color: var(--accent-1); }
.qlist .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: rgba(255, 255, 255, 0.06); display: grid; place-items: center; font-size: 1.4rem; }
.qlist .qt { font-weight: 700; margin: 0 0 4px; }
.qlist .qc { margin: 0; font-size: 0.88rem; color: var(--muted); }
.qlist .qc b { color: #86efac; font-weight: 600; }
.qlist .qx { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); font-style: italic; }
.qlist .tag { font-size: 0.72rem; font-weight: 700; color: var(--accent-3); margin-right: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.qlist audio { width: 100%; height: 32px; margin-top: 6px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ptable th, .ptable td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.ptable th { color: var(--muted); font-weight: 600; }
.file-label { display: inline-flex; }
.file-label input { display: none; }
