:root {
  --bg: #0e0b1a;
  --bg-2: #171231;
  --card: #1e1840;
  --card-2: #2a2258;
  --fg: #f4f1ff;
  --muted: #a79fd0;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(139, 92, 246, 0.25), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(236, 72, 153, 0.2), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px 16px 48px; }
.center-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px 16px;
}

.brand { font-weight: 800; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent-2); }

/* ---------- MTL brandmark (shimmering wordmark + timeline playhead) ---------- */
.brandmark { display: inline-flex; flex-direction: column; align-items: center; gap: 9px; }
.brandmark .mtl {
  font-weight: 900; letter-spacing: 0.14em; line-height: 1; font-size: 2rem;
  background: linear-gradient(100deg, #a78bfa 0%, #ec4899 25%, #22d3ee 50%, #ec4899 75%, #a78bfa 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: mtl-shimmer 6s linear infinite;
  filter: drop-shadow(0 2px 22px rgba(236, 72, 153, 0.25));
}
.brandmark.big .mtl { font-size: clamp(3rem, 10vw, 5.5rem); letter-spacing: 0.16em; }
.brandmark .tl {
  position: relative; height: 2px; width: 130px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 26px),
    rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}
.brandmark.big .tl { width: clamp(190px, 42vw, 320px); }
.brandmark .tl .play {
  position: absolute; top: 50%; left: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2);
  transform: translate(-50%, -50%); animation: mtl-playhead 4.5s ease-in-out infinite;
}
.brandmark .sub {
  font-size: 0.7rem; letter-spacing: 0.4em; text-transform: uppercase; font-weight: 800;
  color: var(--muted); padding-left: 0.4em;
}
.brandmark.big .sub { font-size: clamp(0.8rem, 2.2vw, 1.15rem); }
@keyframes mtl-shimmer { to { background-position: 300% 0; } }
@keyframes mtl-playhead { 0% { left: 0; } 50% { left: 100%; } 100% { left: 0; } }
@media (prefers-reduced-motion: reduce) {
  .brandmark .mtl { animation: none; }
  .brandmark .tl .play { animation: none; left: 50%; }
}
h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 14px 20px; border-radius: 14px; width: 100%;
  transition: transform 0.06s ease, filter 0.15s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:disabled { filter: grayscale(0.6) brightness(0.7); cursor: not-allowed; }
.btn.secondary { background: var(--card-2); border: 1px solid rgba(255,255,255,0.12); }
.btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,0.18); }
.btn.good { background: linear-gradient(135deg, #16a34a, #22c55e); }
.btn.bad  { background: linear-gradient(135deg, #dc2626, #ef4444); }
.btn.lg { padding: 20px; font-size: 1.15rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }

input[type="text"], input[type="number"], input[type="file"] {
  width: 100%; font: inherit; color: var(--fg);
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px; padding: 12px 14px;
}
input:focus { outline: 2px solid var(--accent); }
label.field { display: block; text-align: left; }
label.field span { display: block; font-size: 0.82rem; color: var(--muted); margin: 0 0 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
}
.pill.on  { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.35); }
.pill.off { background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid rgba(255,255,255,0.12); }
.dot-ind { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }

/* ---------- Desktop display ---------- */
.display-hero { width: 100%; max-width: 820px; }
.qr-box {
  background: #fff; padding: 20px; border-radius: 20px; display: inline-block;
  box-shadow: var(--shadow);
}
.qr-box canvas, .qr-box img { display: block; width: 320px; height: 320px; }
.code-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.4rem; letter-spacing: 0.3em; background: rgba(255,255,255,0.08);
  padding: 8px 18px; border-radius: 12px; display: inline-block;
}
.turn-name {
  font-size: clamp(2.2rem, 9vw, 5rem); font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c4b5fd, #f9a8d4);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 8px 0;
}
.now-playing { font-size: clamp(1.4rem, 4vw, 2.2rem); }
.eq { display: inline-flex; gap: 5px; height: 42px; align-items: flex-end; }
.eq i {
  width: 8px; background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 4px; animation: eq 0.9s ease-in-out infinite;
}
.eq i:nth-child(2){ animation-delay: .15s } .eq i:nth-child(3){ animation-delay: .3s }
.eq i:nth-child(4){ animation-delay: .45s } .eq i:nth-child(5){ animation-delay: .6s }
@keyframes eq { 0%,100%{ height: 10px } 50%{ height: 42px } }
@media (prefers-reduced-motion: reduce){ .eq i{ animation: none; height: 26px } }

.reveal-card { width: min(640px, 92vw); }
.reveal-year {
  font-size: clamp(3rem, 14vw, 7rem); font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.reveal-title { font-size: clamp(1.4rem, 5vw, 2.4rem); font-weight: 800; }
.reveal-artist { font-size: clamp(1.1rem, 3.5vw, 1.6rem); color: var(--muted); }

.players-strip { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.player-chip { padding: 8px 14px; border-radius: 12px; background: rgba(255,255,255,0.06); font-weight: 600; }
.player-chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ---------- Mobile controller ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; padding: 12px 4px; margin-bottom: 8px;
  backdrop-filter: blur(8px);
}
.player-list { display: flex; flex-direction: column; gap: 10px; }
.player-row { display: flex; gap: 10px; align-items: center; }
.player-row input { flex: 1; }
.remove-x {
  width: 46px; min-width: 46px; height: 46px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05); color: var(--muted); font-size: 1.3rem; cursor: pointer;
}
.turn-big { text-align: center; padding: 10px 0; }
.turn-big .name { font-size: 2rem; font-weight: 800; }

.scanner-overlay {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: flex; flex-direction: column;
}
#reader { flex: 1; width: 100%; }
.scanner-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: rgba(0,0,0,0.6); color: #fff; gap: 12px;
}
.scanner-hint { text-align: center; padding: 14px; color: #ddd; background: rgba(0,0,0,0.6); }
.scanner-manual { display: flex; gap: 8px; padding: 12px 16px 22px; background: rgba(0,0,0,0.6); }
.scanner-manual input { flex: 1; }

.playing-screen { text-align: center; }
.big-emoji { font-size: 4rem; }
.toggle {
  display: inline-flex; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 4px; gap: 4px;
  border: 1px solid rgba(255,255,255,0.12);
}
.toggle button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700;
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
}
.toggle button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* ---------- countdown timer ---------- */
.timer-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1em; padding: 0.08em 0.3em; border-radius: 22px;
  font-size: clamp(2.6rem, 11vw, 5rem); font-weight: 900; line-height: 1.1;
  background: rgba(255, 255, 255, 0.06); border: 3px solid var(--accent); color: #fff;
  font-variant-numeric: tabular-nums;
}
.timer-badge.low { border-color: var(--bad); color: #fecaca; animation: pulse 0.5s ease-in-out infinite alternate; }
.timer-up {
  font-size: clamp(2rem, 8vw, 3.6rem); font-weight: 900; color: #fca5a5;
  animation: pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.09); } }
@media (prefers-reduced-motion: reduce) { .timer-badge.low, .timer-up { animation: none; } }
.phone-timer { margin: 4px 0; }
.timer-set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.timer-choices button { padding: 8px 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid rgba(255,255,255,0.15);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 60;
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }
a.link { color: #c4b5fd; }
