:root {
  color-scheme: light;
  --ink: #1d1b2f;
  --muted: #68657b;
  --paper: #fffdf8;
  --panel: #ffffff;
  --line: #e5dfd6;
  --pink: #e63274;
  --teal: #0b9f9f;
  --blue: #2667d8;
  --gold: #f2b705;
  --green: #2e9f55;
  --shadow: 0 16px 42px rgba(29, 27, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(230, 50, 116, 0.14), transparent 32%),
    linear-gradient(220deg, rgba(11, 159, 159, 0.12), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 18px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.75rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.4rem, 3.5vw, 2.3rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(280px, 1.4fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.user-button,
.tab-button,
.score-button,
.primary-button,
.secondary-button,
.ghost-button,
.act-jump {
  border: 0;
  border-radius: 8px;
}

.user-button {
  min-height: 74px;
  background: var(--ink);
  color: white;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 850;
  text-transform: capitalize;
}

.user-button.active {
  background: var(--pink);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.72);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.tab-button {
  min-height: 54px;
  background: #eee8df;
  color: var(--ink);
  font-weight: 850;
}

.tab-button.active {
  background: var(--blue);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.vote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.act-panel {
  overflow: hidden;
  padding: 18px;
}

.act-topline,
.vote-actions,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 7px 12px;
  font-size: 0.88rem;
  font-weight: 850;
}

.pill.soft {
  background: #f4eee6;
  color: var(--ink);
}

.stage-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  height: clamp(80px, 15vw, 150px);
  margin: 18px -18px 20px;
  padding: 0 18px;
  background:
    linear-gradient(90deg, rgba(38, 103, 216, 0.1), rgba(242, 183, 5, 0.16), rgba(230, 50, 116, 0.12)),
    #171528;
  align-items: stretch;
}

.stage-card span {
  display: block;
  height: 100%;
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
  opacity: 0.68;
}

.stage-card span:nth-child(1) {
  background: linear-gradient(#ef476f, transparent 72%);
}

.stage-card span:nth-child(2) {
  background: linear-gradient(#f2b705, transparent 72%);
}

.stage-card span:nth-child(3) {
  background: linear-gradient(#06d6a0, transparent 72%);
}

.songline {
  margin-bottom: 6px;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  font-weight: 800;
}

.country-with-flag {
  display: inline-flex;
  min-width: 0;
  align-items: baseline;
  gap: 0.42em;
}

.flag {
  flex: 0 0 auto;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.score-button {
  min-height: 76px;
  background: #f3eee7;
  color: var(--ink);
  font-size: clamp(1.45rem, 5vw, 2.4rem);
  font-weight: 900;
}

.score-button.active {
  background: var(--gold);
  box-shadow: inset 0 0 0 4px #ffffff;
}

.score-button:hover,
.user-button:hover,
.tab-button:hover,
.act-jump:hover {
  transform: translateY(-1px);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 52px;
  padding: 0 18px;
  font-weight: 850;
}

.primary-button {
  min-width: 150px;
  background: var(--pink);
  color: white;
}

.secondary-button,
.ghost-button {
  background: #eee8df;
  color: var(--ink);
}

.running-panel {
  max-height: 660px;
  overflow: auto;
  padding: 14px;
}

.act-list {
  display: grid;
  gap: 8px;
}

.act-jump {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  background: #f5f1eb;
  color: var(--ink);
  text-align: left;
}

.act-jump.active {
  background: #dfeaff;
  box-shadow: inset 4px 0 0 var(--blue);
}

.act-jump.complete .checkmark {
  background: var(--green);
  color: white;
}

.act-number,
.checkmark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: white;
  font-weight: 900;
}

.act-name {
  display: block;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-song {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.leaderboard-grid .panel,
.table-panel {
  padding: 16px;
}

.chart-list {
  display: grid;
  gap: 10px;
}

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

.person-chart {
  min-width: 0;
  border-top: 3px solid var(--teal);
  padding-top: 10px;
}

.person-chart h4 {
  margin: 0 0 10px;
  font-size: 1rem;
  text-transform: capitalize;
}

.compact-chart {
  gap: 8px;
}

.compact-chart .bar-row {
  grid-template-columns: minmax(92px, 1fr) minmax(90px, 1fr) 44px;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) minmax(150px, 1.4fr) 54px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  min-width: 0;
}

.bar-country {
  display: block;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-meta {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: #ede6de;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--pink));
}

.bar-score {
  font-weight: 900;
  text-align: right;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border-radius: 8px;
  background: #f5f1eb;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: white;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td.score-cell,
th.score-cell {
  text-align: center;
}

.score-chip {
  display: inline-grid;
  min-width: 38px;
  min-height: 32px;
  place-items: center;
  border-radius: 999px;
  background: #eee8df;
  font-weight: 900;
}

.score-chip.has-score {
  background: #d9f2e5;
  color: #16643a;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 880px) {
  .topbar,
  .hero-panel,
  .vote-layout,
  .leaderboard-grid,
  .person-chart-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .act-topline,
  .vote-actions,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .score-grid {
    grid-template-columns: repeat(6, minmax(48px, 1fr));
  }

  .running-panel {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .app {
    padding-inline: 12px;
  }

  .tabs,
  .score-grid {
    gap: 6px;
  }

  .score-button {
    min-height: 62px;
  }

  .bar-row {
    grid-template-columns: minmax(90px, 1fr) minmax(90px, 1.1fr) 44px;
  }
}
