:root {
  color-scheme: dark;
  --bg: #101113;
  --bg-soft: #15171b;
  --panel: #1c2026;
  --panel-strong: #252a32;
  --text: #f6f2e9;
  --muted: #a9adb7;
  --line: #343a45;
  --line-soft: #272c35;
  --accent: #f0b84f;
  --accent-strong: #ffd074;
  --accent-2: #50d0be;
  --danger: #e96f6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #171a1f 0%, var(--bg) 34rem);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #17120b;
  cursor: pointer;
  font-weight: 850;
  min-height: 46px;
  padding: 0 18px;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.account-bar {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.account-profile {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
  min-width: 0;
  position: relative;
}

.profile-menu-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  min-height: 0;
  padding: 0;
}

.profile-menu-button img {
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 36px;
  object-fit: cover;
  width: 36px;
}

.account-profile span {
  color: var(--text);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  display: grid;
  min-width: 170px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: 46px;
  z-index: 6;
}

.profile-menu-item {
  align-items: center;
  background: transparent;
  border-radius: 6px;
  color: var(--text);
  display: flex;
  gap: 8px;
  justify-content: start;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.profile-menu-item:hover {
  background: var(--panel-strong);
  filter: none;
}

.developer-toggle {
  cursor: pointer;
  font-weight: 850;
}

.developer-toggle input {
  accent-color: var(--accent);
  min-height: 0;
  width: auto;
}

.login-button {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #17120b;
  display: inline-flex;
  font-weight: 850;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  text-decoration: none;
  width: fit-content;
}

.header-login {
  min-height: 38px;
  padding: 0 14px;
}

.authenticated-app {
  display: grid;
  gap: 18px;
}

.statistics-page,
.database-page {
  display: grid;
  gap: 18px;
  min-height: 72vh;
  align-content: center;
}

.database-page {
  align-content: start;
}

.page-heading {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.page-heading p {
  color: var(--muted);
  margin: 8px 0 0;
}

.statistics-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.statistics-grid article {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 16px;
}

.statistics-grid span {
  color: var(--accent-strong);
  font-weight: 900;
}

.statistics-grid strong {
  color: var(--muted);
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
}

.artist-stat-sections {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.artist-stat-panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 16px;
}

.artist-stat-panel h3 {
  color: var(--accent-strong);
  margin: 0;
}

.database-filters {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  padding: 12px;
}

.database-filters label {
  display: grid;
  gap: 6px;
}

.database-filters span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.database-filters input,
.database-filters select {
  min-height: 40px;
}

.database-filters button {
  align-self: end;
  min-height: 40px;
}

.database-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.database-toolbar span {
  color: var(--muted);
  font-weight: 850;
}

.database-toolbar div {
  display: flex;
  gap: 8px;
}

.database-table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: auto;
}

.database-table {
  background: var(--panel);
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

.database-table th,
.database-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.database-table th {
  color: var(--accent-strong);
  font-size: 0.82rem;
}

.database-table td {
  color: var(--text);
}

.database-table td strong,
.database-table td span,
.database-table td a {
  display: block;
}

.database-table td span,
.muted-cell {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.database-table a {
  color: var(--accent-strong);
  text-decoration: none;
}

.empty-table {
  color: var(--muted);
  text-align: center !important;
}

.artist-stat-panel p {
  color: var(--muted);
  margin: 0;
}

.artist-stat-panel ol {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
}

.artist-stat-panel li {
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
  padding: 10px;
}

.artist-stat-panel li div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.artist-stat-panel li strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist-stat-panel li span {
  color: var(--muted);
  font-size: 0.88rem;
}

.artist-stat-panel li b {
  color: var(--accent-strong);
  font-size: 1.1rem;
}

.artist-stat-panel .empty-stat {
  color: var(--muted);
  display: block;
  grid-template-columns: 1fr;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 38px;
}

.shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.setup {
  display: grid;
  gap: 18px;
  min-height: 88vh;
  align-content: center;
}

.setup-hero {
  align-items: end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
}

.scoreboard span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 12px;
}

.help-wrap {
  display: grid;
  justify-items: end;
  position: relative;
}

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-grid;
  font-size: 1.1rem;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  padding: 0;
  width: 42px;
}

.help-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 10px;
  margin-top: 10px;
  max-width: min(520px, calc(100vw - 32px));
  min-width: min(460px, calc(100vw - 32px));
  padding: 18px;
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 3;
}

.help-panel h2 {
  font-size: 1rem;
}

.help-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(3.8rem, 12vw, 9rem);
  line-height: 0.82;
  margin-bottom: 0;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.8rem);
  line-height: 1;
  margin-bottom: 0;
}

.launch-panel {
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.import-form {
  align-items: end;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
}

.playlist-field,
.song-count {
  display: grid;
  gap: 7px;
}

.playlist-field span,
.song-count label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
select {
  min-height: 52px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0f12;
  color: var(--text);
  padding: 0 14px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.song-count {
  grid-template-columns: 118px 118px;
}

.song-count label {
  grid-column: 1 / -1;
}

.note,
.status,
.save-status {
  color: var(--muted);
  margin-bottom: 0;
  max-width: 920px;
}

.status.error {
  color: var(--danger);
}

.history {
  display: grid;
  gap: 18px;
  margin-top: 8px;
}

.history-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.history-list {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.history-section {
  display: grid;
  gap: 10px;
}

.history-section h3 {
  color: var(--accent-strong);
  font-size: 1.05rem;
  margin: 0;
}

.continue-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.history-item {
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 104px minmax(0, 1fr);
  padding: 10px;
}

.history-thumb {
  display: block;
}

.history-thumb img {
  aspect-ratio: 16 / 9;
  background: #050506;
  border-radius: 6px;
  object-fit: cover;
  width: 100%;
}

.history-summary {
  min-width: 0;
}

.history-item h3 {
  font-size: 1rem;
  line-height: 1.25;
  margin: 0 0 4px;
}

.history-item p,
.empty-history {
  color: var(--muted);
  margin: 0;
}

.battle-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.battle-stats span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 5px 8px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.history-actions .ghost-button {
  min-height: 34px;
}

.history-songs {
  border-top: 1px solid var(--line-soft);
  grid-column: 1 / -1;
  padding-top: 10px;
}

.champion-icon {
  background: var(--accent-strong);
  border-radius: 999px;
  height: 22px;
  flex: 0 0 auto;
  padding: 4px;
  width: 22px;
}

.history-songs summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.history-songs ol {
  display: grid;
  gap: 7px;
  list-style: none;
  margin-top: 10px;
  max-height: 180px;
  overflow: auto;
  padding: 0;
}

.history-songs li {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
  padding: 0 0 7px;
}

.history-songs a {
  color: var(--muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-songs a:hover {
  color: var(--accent-strong);
}

.show-results-toggle {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  margin-top: 10px;
}

.show-results-toggle input {
  accent-color: var(--accent);
  min-height: 0;
  width: auto;
}

.song-result-stats {
  align-items: center;
  display: none;
  gap: 10px;
  justify-content: end;
}

.song-pass-rate,
.song-champion-count {
  align-items: center;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 0.82rem;
  gap: 5px;
  font-weight: 850;
  white-space: nowrap;
}

.song-champion-count .champion-icon {
  height: 18px;
  padding: 3px;
  width: 18px;
}

.history-item.showing-results .song-result-stats {
  display: inline-flex;
}

.hidden {
  display: none !important;
}

.game {
  display: grid;
  gap: 18px;
  position: relative;
}

.game.is-transitioning .battle,
.game.is-transitioning .standings {
  opacity: 0.45;
  pointer-events: none;
}

.round-transition {
  align-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 8px;
  justify-items: center;
  left: 50%;
  min-width: min(520px, calc(100vw - 32px));
  padding: 28px;
  position: fixed;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  animation: stage-enter 260ms ease-out;
}

.round-transition h2 {
  font-size: clamp(2rem, 6vw, 4.5rem);
}

.round-transition p {
  color: var(--muted);
  margin-bottom: 0;
}

.round-transition.leaving {
  animation: stage-leave 260ms ease-in forwards;
}

.game-header {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--line));
  color: var(--danger);
}

.danger-solid {
  background: var(--danger);
  color: #210807;
}

.modal-backdrop {
  align-items: center;
  background: rgba(0, 0, 0, 0.58);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  display: grid;
  gap: 14px;
  max-width: 460px;
  padding: 20px;
  width: 100%;
}

.modal p {
  color: var(--muted);
  margin: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.battle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  perspective: 1200px;
}

.song-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  position: relative;
  transform: translateY(0) scale(1);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease,
    opacity 220ms ease,
    transform 220ms ease;
  will-change: transform, opacity, filter;
}

.song-card::after {
  border: 1px solid transparent;
  border-radius: 8px;
  content: "";
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 180ms ease;
}

.song-card:hover,
.song-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 66%, var(--line));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(240, 184, 79, 0.18);
  transform: translateY(-4px);
}

.song-card:hover::after,
.song-card:focus-within::after {
  opacity: 1;
  border-color: rgba(240, 184, 79, 0.25);
}

.battle.is-resolving .song-card {
  pointer-events: none;
}

.song-card.is-passed {
  animation: passed-card 720ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  border-color: var(--accent-2);
  box-shadow: 0 28px 90px rgba(80, 208, 190, 0.28), 0 0 0 1px rgba(80, 208, 190, 0.35);
  z-index: 2;
}

.song-card.is-passed::after {
  background: linear-gradient(120deg, transparent, rgba(80, 208, 190, 0.2), transparent);
  opacity: 1;
}

.song-card.is-eliminated {
  animation: eliminated-card 720ms cubic-bezier(0.55, 0, 0.4, 1) both;
  filter: grayscale(0.85) brightness(0.62);
}

.player {
  aspect-ratio: 16 / 9;
  background: #050506;
  width: 100%;
}

.song-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.song-heading {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr);
}

.side-label {
  align-items: center;
  background: var(--accent-2);
  border-radius: 999px;
  color: #071311;
  display: inline-grid;
  font-size: 0.78rem;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.song-title {
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.22;
  margin: 0;
}

.song-meta {
  color: var(--muted);
  margin: 5px 0 0;
}

.choose {
  overflow: hidden;
  position: relative;
  width: 100%;
}

.choose span {
  position: relative;
  z-index: 1;
}

.choose::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  content: "";
  height: 100%;
  left: -70%;
  position: absolute;
  top: 0;
  transform: skewX(-18deg);
  transition: left 260ms ease;
  width: 46%;
}

.song-card:hover .choose::before,
.song-card:focus-within .choose::before {
  left: 125%;
}

.bye {
  align-content: center;
  background: var(--panel-strong);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  min-height: 360px;
  padding: 22px;
  text-align: center;
}

.standings {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 210px;
  overflow: auto;
  padding-top: 14px;
}

.standings > div {
  min-width: 0;
}

ol {
  color: var(--muted);
  margin: 0;
  padding-left: 22px;
}

li + li {
  margin-top: 8px;
}

.winner {
  display: grid;
  gap: 18px;
  min-height: 74vh;
  align-content: center;
}

.winner-player {
  aspect-ratio: 16 / 9;
  background: #050506;
  width: min(980px, 100%);
}

@media (max-width: 900px) {
  .setup-hero,
  .game-header {
    align-items: start;
    flex-direction: column;
  }

  .scoreboard {
    justify-content: flex-start;
  }

  .help-wrap {
    justify-items: start;
  }

  .help-panel {
    left: 0;
    right: auto;
  }

  .import-form,
  .database-filters,
  .battle,
  .standings {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1400px);
    padding: 18px 0 30px;
  }

  .launch-panel {
    padding: 12px;
  }

  .song-count {
    grid-template-columns: 1fr;
  }

  .history-heading {
    align-items: start;
    flex-direction: column;
  }

  .account-bar,
  .page-heading {
    align-items: start;
    flex-direction: column;
  }

  .statistics-grid,
  .artist-stat-sections {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes passed-card {
    0% {
      transform: translateY(-4px) scale(1);
    }

    42% {
      transform: translateY(-12px) scale(1.035);
    }

    100% {
      opacity: 0;
      transform: translateY(-24px) scale(1.055);
    }
  }

  @keyframes eliminated-card {
    0% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    45% {
      opacity: 0.58;
      transform: translateY(8px) scale(0.975) rotateX(2deg);
    }

    100% {
      opacity: 0;
      transform: translateY(26px) scale(0.94) rotateX(4deg);
    }
  }

  @keyframes stage-enter {
    from {
      opacity: 0;
      transform: translate(-50%, -46%) scale(0.97);
    }

    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
  }

  @keyframes stage-leave {
    from {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }

    to {
      opacity: 0;
      transform: translate(-50%, -54%) scale(0.98);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .song-card,
  .choose::before {
    transition: none;
  }

  .song-card.is-passed,
  .song-card.is-eliminated {
    animation: none;
    opacity: 0.5;
  }
}
