:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #171717;
  --panel-2: #202020;
  --text: #f6f1e7;
  --muted: #b8b0a3;
  --line: #39342d;
  --red: #d83a34;
  --gold: #f6c542;
  --teal: #23c7b7;
  --green: #77d36b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, rgba(216, 58, 52, 0.24), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(35, 199, 183, 0.17), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0.75rem 1rem;
  touch-action: manipulation;
}

button:hover {
  filter: brightness(1.08);
}

button.secondary,
.tab {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.active,
.tab.active {
  background: var(--gold);
  color: #1b1200;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0f0f;
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 11vw, 5.4rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.5rem, 5vw, 2.4rem);
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom));
}

.intro {
  min-height: 15svh;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 0.75rem;
}

.badge-image {
  width: clamp(54px, 15vw, 180px);
  height: auto;
  image-rendering: auto;
  border-radius: 8px;
  border: 1px solid rgba(246, 197, 66, 0.35);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 0.3rem;
  color: var(--gold);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 900;
}

.panel,
.app-header,
.filters,
.band-card,
.result-card,
.team-progress-card {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.auth-grid {
  display: grid;
  gap: 1rem;
}

.auth-card {
  display: grid;
  gap: 0.85rem;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 1rem;
}

.auth-card h3 {
  margin: 0;
  font-size: 1.35rem;
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.team-code-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.7rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0.8rem;
}

.team-code-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.team-code-box strong {
  grid-row: 2;
  color: var(--gold);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0;
}

.team-code-box button {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.invite-mode .team-code-box {
  display: none;
}

.invite-mode #createTeamCard {
  display: none;
}

.link-field {
  margin-top: 0.55rem;
  max-width: min(100%, 720px);
}

.link-field span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.link-field input {
  min-width: 0;
  color: var(--gold);
}

.copy-link {
  min-width: 78px;
}

.button-row,
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.swipe-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  width: min(92vw, 390px);
}

.swipe-actions button {
  min-height: 34px;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--line);
  background: rgba(32, 32, 32, 0.76);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.swipe-bronze {
  grid-column: 2;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  padding: 0.65rem;
}

.app-header h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.tabs {
  grid-template-columns: repeat(3, 1fr);
  margin: 0 -0.75rem 0.85rem;
  overflow-x: auto;
  padding: 0.4rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(12px);
}

.tab {
  min-width: 98px;
  padding-inline: 0.7rem;
}

.view {
  display: block;
  position: relative;
}

.hidden {
  display: none !important;
}

#refreshResults {
  width: 100%;
  margin-bottom: 1rem;
  padding-block: 0.95rem;
}

.filters-panel {
  margin-bottom: 0.85rem;
}

.filters-panel summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--gold);
  cursor: pointer;
  font-weight: 900;
  list-style-position: inside;
}

.filters {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 0;
  padding: 0.85rem;
}

.check {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check input {
  width: 20px;
  min-height: 20px;
}

.count,
.hint,
.message {
  color: var(--muted);
}

.band-grid,
.results-list {
  display: grid;
  gap: 0.8rem;
}

.team-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 0.8rem;
  margin: 0.9rem 0;
}

.team-progress-card {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.75rem 0.55rem;
  text-align: center;
}

.user-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: var(--user-color);
  color: #080808;
  font-weight: 900;
  line-height: 1;
}

.team-progress-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.team-progress-card span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.band-card,
.result-card {
  display: grid;
  gap: 0.7rem;
  padding: 0.9rem;
}

.band-card.has-cover,
.result-card.has-cover {
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: stretch;
}

.band-card.has-cover .rating-control,
.result-card.has-cover .result-meta {
  grid-column: 1 / -1;
}

.band-cover,
.result-cover {
  width: 100%;
  height: 100%;
  min-height: 92px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.band-meta,
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.video-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.video-links a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(216, 58, 52, 0.65);
  border-radius: 8px;
  color: var(--text);
  background: rgba(216, 58, 52, 0.16);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.4rem 0.55rem;
  text-decoration: none;
}

.video-links a:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem;
}

.rating-control {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  gap: 0.35rem;
}

.rating-option {
  min-width: 0;
  min-height: 38px;
  padding: 0.45rem 0.5rem;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.rating-option:hover,
.rating-option.active {
  color: #1b1200;
  background: var(--gold);
  border-color: var(--gold);
}

.match-wrap {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  overflow: visible;
  position: relative;
  z-index: 5;
}

.match-exit {
  justify-self: start;
  width: auto;
}

.match-sound {
  justify-self: end;
  width: auto;
}

.match-player {
  display: none;
}

.card-stack {
  position: relative;
  width: min(92vw, 390px);
  height: clamp(320px, 54svh, 480px);
  touch-action: none;
  z-index: 10;
}

.swipe-card {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: end;
  gap: 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(216, 58, 52, 0.42), transparent 46%),
    linear-gradient(20deg, rgba(35, 199, 183, 0.28), transparent 44%),
    var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
  transform-origin: center bottom;
  transition: transform 180ms ease, opacity 180ms ease;
  user-select: none;
  overflow: hidden;
}

.swipe-card > :not(.swipe-cover) {
  position: relative;
  z-index: 2;
}

.swipe-cover {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.58;
}

.swipe-card.has-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(8, 8, 8, 0.1), rgba(8, 8, 8, 0.88)),
    linear-gradient(40deg, rgba(216, 58, 52, 0.26), rgba(35, 199, 183, 0.18));
}

.swipe-card:nth-child(1) {
  z-index: 30;
}

.swipe-card:nth-child(2) {
  z-index: 20;
  transform: translateY(12px) scale(0.96);
  opacity: 0.72;
  pointer-events: none;
}

.swipe-card:nth-child(3) {
  z-index: 10;
  transform: translateY(24px) scale(0.92);
  opacity: 0.4;
  pointer-events: none;
}

.swipe-card h3 {
  margin: 0;
  font-size: clamp(1.8rem, 9vw, 3.4rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.swipe-card .decision {
  position: absolute;
  top: 1rem;
  left: 1rem;
  border-radius: 8px;
  border: 2px solid currentColor;
  padding: 0.35rem 0.55rem;
  color: var(--gold);
  font-weight: 900;
  opacity: 0;
}

.swipe-card.dragging {
  transition: none;
}

.swipe-card.fly-right {
  transform: translateX(120vw) rotate(18deg);
  opacity: 0;
}

.swipe-card.fly-left {
  transform: translateX(-120vw) rotate(-18deg);
  opacity: 0;
}

.swipe-card.fly-up {
  transform: translateY(-120vh) scale(0.9);
  opacity: 0;
}

.swipe-card.fly-down {
  transform: translateY(120vh) scale(0.9);
  opacity: 0;
}

.top-match {
  border-color: var(--gold);
}

.conflict {
  border-color: var(--red);
}

.score {
  color: var(--gold);
  font-size: 1.35rem;
  font-weight: 900;
}

.swipe-actions {
  position: sticky;
  bottom: max(0.6rem, env(safe-area-inset-bottom));
  z-index: 45;
  padding: 0.45rem;
  border-radius: 8px;
  background: rgba(8, 8, 8, 0.82);
  backdrop-filter: blur(12px);
}

.match-active {
  overflow: hidden;
}

.match-active .intro,
.match-active .app-header,
.match-active .tabs {
  display: none;
}

.match-active .shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0;
}

.match-active #appView,
.match-active #matchView {
  min-height: 100vh;
  min-height: 100svh;
}

.match-active #matchView {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(216, 58, 52, 0.24), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(35, 199, 183, 0.18), transparent 24rem),
    var(--bg);
}

.match-active .match-wrap {
  min-height: 100vh;
  min-height: 100svh;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  align-content: stretch;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
}

.match-active .match-exit,
.match-active .match-sound {
  position: relative;
  z-index: 120;
}

.match-active .match-player.is-playing {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
  opacity: 0.3;
  overflow: hidden;
}

.match-active .match-player.is-playing::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 8, 8, 0.42), rgba(8, 8, 8, 0.78)),
    radial-gradient(circle at center, transparent 0, rgba(8, 8, 8, 0.48) 70%);
}

.match-player iframe {
  width: 100vw;
  height: 100vh;
  border: 0;
  transform: scale(1.35);
}

.match-active .card-stack {
  align-self: center;
  height: min(62svh, 520px);
}

@media (min-width: 720px) {
  .shell {
    padding: 2rem;
  }

  .intro {
    min-height: 32vh;
    padding: 2rem 0 1.5rem;
  }

  .badge-image {
    width: clamp(90px, 18vw, 180px);
  }

  .panel {
    max-width: none;
  }

  .auth-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .restore-card {
    grid-column: 1 / -1;
  }

  .app-header {
    padding: 1rem;
  }

  .app-header h2 {
    font-size: clamp(1.5rem, 5vw, 2.4rem);
  }

  .tabs {
    margin: 0 0 1rem;
    padding: 0;
    position: static;
    background: transparent;
    backdrop-filter: none;
  }

  .filters {
    grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
    align-items: end;
    padding: 1rem;
  }

  .band-grid,
  .results-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .band-card.has-cover,
  .result-card.has-cover {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .card-stack {
    height: 500px;
  }

  .swipe-actions {
    position: static;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }
}
