:root {
  color-scheme: dark;
  --bg: #030303;
  --panel: #0d0d0d;
  --panel-soft: #151515;
  --line: #2a2a2a;
  --line-strong: #4a4a4a;
  --text: #f1f1f1;
  --muted: #9b9b9b;
  --accent: #1ed760;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
iframe {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  padding: 48px 0;
}

.hidden {
  display: none !important;
}

.consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  background: rgba(13, 13, 13, 0.96);
  color: var(--text);
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.consent-banner h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.consent-banner p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

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

.consent-actions button {
  min-height: 44px;
}

.consent-actions .secondary-action {
  margin-top: 0;
}

.start-view,
.battle-view,
.result-view {
  width: 100%;
}

.title-block {
  max-width: 760px;
  margin-bottom: 42px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.result-eyebrow {
  margin-bottom: 28px;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.9;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(3.1rem, 8vw, 7.3rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.playlist-form {
  width: min(820px, 100%);
}

.playlist-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  border: 1px solid var(--line);
  background: var(--panel);
}

.input-row:focus-within {
  border-color: var(--line-strong);
}

.input-row input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 18px 20px;
  outline: 0;
}

.input-row input::placeholder {
  color: #5f5f5f;
}

.input-row button,
.secondary-action,
.icon-action,
.result-actions a,
.choice-action {
  border: 1px solid var(--line-strong);
  background: #f1f1f1;
  color: #050505;
  padding: 0 20px;
  min-height: 54px;
  cursor: pointer;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.input-row button:hover,
.secondary-action:hover,
.icon-action:hover,
.result-actions a:hover,
.choice-action:hover {
  background: var(--accent);
  color: #031107;
}

.secondary-action {
  margin-top: 18px;
  background: transparent;
  color: var(--text);
}

.input-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-battles {
  margin-top: 34px;
}

.section-label {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.saved-battles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-width: 920px;
}

.saved-battle-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.saved-battle-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #111;
  border: 1px solid var(--line);
}

.saved-battle-title {
  min-height: 42px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.saved-battle-actions {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.saved-battle-actions button {
  min-height: 44px;
}

.saved-battle-actions .secondary-action {
  margin-top: 0;
}

.delete-battle {
  border: 1px solid #7f1d1d;
  background: #160909;
  color: #fca5a5;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.delete-battle:hover {
  background: #ef4444;
  color: #120202;
}

.delete-battle svg {
  width: 18px;
  height: 18px;
}

.form-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

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

.battle-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.progress-block {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.icon-action {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
}

.progress-track {
  height: 2px;
  background: var(--line);
  margin-bottom: 34px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 160ms ease;
}

.cards-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.song-card {
  width: 100%;
  min-height: 392px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 18px;
  text-align: left;
  display: grid;
  grid-template-rows: 152px minmax(132px, 1fr) 48px;
  gap: 18px;
}

.song-card:hover {
  border-color: var(--accent);
  background: var(--panel-soft);
}

.spotify-embed-shell {
  width: 100%;
  height: 152px;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
}

.spotify-embed-target,
.spotify-embed-shell iframe {
  width: 100%;
  height: 152px;
  border: 0;
  border-radius: 16px;
  display: block;
}

.spotify-embed-target {
  position: relative;
  overflow: hidden;
}

.spotify-embed-target iframe {
  inset: 0;
}

.spotify-embed-target iframe + iframe {
  position: absolute;
}

.choice-action {
  width: 100%;
  min-height: 48px;
}

.song-copy {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 132px;
  overflow: hidden;
}

.song-copy strong {
  font-size: clamp(1.35rem, 3vw, 2.4rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.song-copy span {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-copy small {
  color: #747474;
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.versus {
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.85rem;
}

.winner-layout {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 36px;
  align-items: center;
}

.winner-copy h2 {
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.winner-copy p {
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1.45;
}

.result-meta {
  margin-top: 24px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.result-actions .secondary-action {
  margin-top: 0;
}

.analytics-section {
  margin-top: 42px;
}

.analytics-section h3 {
  margin: 0 0 18px;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.ranking-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.ranking-item {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.ranking-position {
  color: var(--accent);
  font-weight: 700;
}

.ranking-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ranking-copy strong {
  overflow-wrap: anywhere;
}

.ranking-copy span,
.ranking-score {
  color: var(--muted);
  font-size: 0.92rem;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.analytics-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  min-height: 132px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.analytics-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.analytics-card strong {
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.analytics-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 560px);
    align-content: start;
    padding: 32px 0;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 5rem);
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .input-row button {
    border-width: 1px 0 0;
  }

  .battle-header {
    display: grid;
    align-items: start;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .song-card {
    min-height: 392px;
  }

  .spotify-embed-shell,
  .spotify-embed-target,
  .spotify-embed-shell iframe {
    height: 152px;
  }

  .versus {
    padding: 2px 0;
  }

  .winner-layout {
    grid-template-columns: 1fr;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .consent-banner {
    grid-template-columns: 1fr;
  }

  .consent-actions {
    justify-content: start;
  }
}
