*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #070a12;
  --card: rgba(15, 23, 42, 0.88);
  --border: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --amber: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top center, #111b33 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100dvh;
}

.qz-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

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

.qz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #f59e0b);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}

.qz-brand h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.qz-top-stats,
.qz-top-actions,
.qz-player-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.qz-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  font-variant-numeric: tabular-nums;
}

.qz-player-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.qz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.88);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.qz-btn-sm {
  font-size: 0.76rem;
  padding: 5px 10px;
}

.qz-btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: rgba(56, 189, 248, 0.6);
  color: #ffffff;
}

.qz-btn-subtle {
  color: #cbd5e1;
}

.qz-btn[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent);
  color: #e0f2fe;
}

.qz-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}

.qz-settings-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.qz-setting {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.qz-setting select {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: var(--text);
}

.qz-start-btn {
  margin-left: auto;
}

.qz-start-screen {
  max-width: 720px;
  margin: 4px auto 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qz-start-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 1376 / 768;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #05070d;
}

.qz-start-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.58;
}

.qz-start-hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 10, 18, 0.25) 0%, rgba(7, 10, 18, 0.88) 100%);
}

.qz-start-hero-copy {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
  gap: 6px;
}

.qz-start-hero-copy h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3.6vw, 1.65rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.qz-start-hero-copy p {
  margin: 0;
  font-size: clamp(0.84rem, 2.2vw, 0.96rem);
  color: #e2e8f0;
  line-height: 1.4;
}

.qz-hero-start-btn {
  width: 100%;
  min-height: 50px;
  font-size: 1.02rem;
  border-radius: 12px;
}

.qz-picker-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .qz-shell {
    padding: 8px 10px 20px;
    gap: 10px;
  }
  .qz-topbar {
    padding: 8px 10px;
  }
  .qz-card {
    padding: 12px;
  }
  .qz-picker-row {
    grid-template-columns: 1fr;
  }
  .qz-choice-btn {
    min-height: 58px;
  }
}

.qz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.95fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 960px) {
  .qz-grid {
    grid-template-columns: 1fr;
  }
}

.qz-kit-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qz-kit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.qz-round-meta,
.qz-kit-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qz-round-label {
  font-weight: 800;
  font-size: 0.95rem;
}

.qz-audio-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
}

.qz-kit-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1376 / 768;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #05070d;
}

.qz-kit-stage img,
.qz-kit-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.qz-kit-stage img {
  object-fit: fill;
  user-select: none;
}

.qz-kit-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 16, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
}

.qz-kit-overlay[hidden] {
  display: none;
}

.qz-kit-overlay p {
  margin: 0;
  max-width: 44ch;
  font-size: 0.98rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.qz-timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qz-timer-wrap progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.qz-timer-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#qzPotentialPts {
  color: #fbbf24;
}

.qz-idle-pane h2 {
  margin: 0 0 8px;
  font-size: 1.02rem;
}

.qz-idle-pane ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.45;
}

.qz-clip-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.qz-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.qz-choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.85);
  color: var(--text);
  cursor: pointer;
}

@media (hover: hover) {
  .qz-choice-btn:not([disabled]):hover {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.14);
  }
}

.qz-choice-btn.is-correct {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.22);
}

.qz-choice-btn.is-wrong {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.22);
}

.qz-choice-art {
  width: 48px;
  height: 48px;
  border-radius: 7px;
  object-fit: cover;
  background: #0b0f18;
  flex-shrink: 0;
}

.qz-choice-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.qz-choice-song {
  font-weight: 700;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qz-choice-album {
  font-size: 0.74rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qz-choice-key {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: var(--muted);
}

.qz-type-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qz-type-row {
  display: flex;
  gap: 8px;
}

.qz-type-row input {
  flex: 1 1 auto;
  font: inherit;
  font-size: max(1rem, 1em);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: var(--text);
}

.qz-reveal {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.qz-reveal[hidden] {
  display: none;
}

.qz-reveal img {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  object-fit: cover;
  background: #0b0f18;
  flex-shrink: 0;
}

.qz-reveal-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.qz-reveal-outcome {
  font-weight: 800;
  font-size: 0.96rem;
}

.qz-reveal-song {
  font-weight: 700;
  font-size: 1.05rem;
}

.qz-reveal-album {
  font-size: 0.8rem;
  color: var(--muted);
}

.qz-reveal-actions,
.qz-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.qz-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qz-summary h2 {
  margin: 0;
}

.qz-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  font-size: 0.86rem;
  color: #cbd5e1;
}

.qz-volunteer-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.32);
}

.qz-volunteer-form h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #fde68a;
}

.qz-vol-sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.qz-vol-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 560px) {
  .qz-vol-grid {
    grid-template-columns: 1fr;
  }
}

.qz-auth-gate {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qz-auth-intro h2 {
  margin: 0 0 6px;
}

.qz-auth-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.qz-auth-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 680px) {
  .qz-auth-forms {
    grid-template-columns: 1fr;
  }
}

.qz-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.qz-form h3 {
  margin: 0;
  font-size: 0.95rem;
}

.qz-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qz-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
}

.qz-field input,
.qz-field select,
.qz-field textarea {
  font: inherit;
  font-size: max(1rem, 0.92em);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b101c;
  color: var(--text);
}

.qz-pw-wrap {
  display: flex;
  gap: 6px;
}

.qz-pw-wrap input {
  flex: 1 1 auto;
  min-width: 0;
}

.qz-pw-toggle {
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
}

.qz-form-err {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.78rem;
  color: #fca5a5;
}

.qz-live-status {
  margin: 8px 0 0;
  min-height: 1.1em;
  font-size: 0.8rem;
  color: #7dd3fc;
}

/* Native modal dialogs */
dialog.qz-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(90dvh, 840px);
  margin: auto;
  padding: 0;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 16px;
  background: rgba(11, 16, 28, 0.98);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
  overflow-y: auto;
}

dialog.qz-dialog.qz-dialog-sm {
  width: min(500px, calc(100vw - 24px));
}

dialog.qz-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.qz-dialog:modal {
  overscroll-behavior: contain;
}

dialog.qz-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(2, 6, 23, 0.80);
  backdrop-filter: blur(6px);
}

.qz-dialog-shell {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qz-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qz-dialog-head h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

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

/* Responsive leaderboard table */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(460px, 65vh);
  container-type: inline-size;
}

.qz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}

.qz-table caption {
  text-align: left;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.qz-table th,
.qz-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  text-align: left;
  white-space: nowrap;
}

.qz-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #0f172a;
}

.qz-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: #0b101c;
  font-weight: 700;
}

@container (width < 560px) {
  .qz-table, .qz-table thead, .qz-table tbody, .qz-table tr, .qz-table th, .qz-table td {
    display: block;
  }
  .qz-table thead {
    display: none;
  }
  .qz-table tr {
    margin-block-end: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    padding: 6px 8px;
  }
  .qz-table tbody th {
    position: sticky;
    inset-block-start: 0;
    background: #131c31;
    border-radius: 6px;
  }
  .qz-table td:nth-child(2)::before { content: "Player: "; color: var(--muted); font-weight: 600; }
  .qz-table td:nth-child(3)::before { content: "Score: "; color: var(--muted); font-weight: 600; }
  .qz-table td:nth-child(4)::before { content: "Accuracy: "; color: var(--muted); font-weight: 600; }
  .qz-table td:nth-child(5)::before { content: "Streak: "; color: var(--muted); font-weight: 600; }
  .qz-table td:nth-child(6)::before { content: "Mode: "; color: var(--muted); font-weight: 600; }
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.qz-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  color: var(--muted);
  font-size: 0.78rem;
}

.qz-postgame-signup {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.qz-postgame-signup h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #bae6fd;
}

.qz-vol-locked {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.55);
  border: 1px dashed rgba(148, 163, 184, 0.25);
  font-size: 0.8rem;
  color: var(--muted);
}
