:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f6;
  --ink: #16171d;
  --muted: #626a76;
  --border: #d9dee7;
  --accent: #05676e;
  --accent-soft: #d9f0ed;
  --hot: #d94f54;
  --hot-soft: #fde4df;
  --gold: #b78222;
  --shadow: 0 16px 40px rgba(28, 34, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(217, 240, 237, 0.6) 0, rgba(246, 247, 251, 0) 260px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.header-copy {
  min-width: 0;
}

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

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

h1 {
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 1.1rem;
  line-height: 1.15;
}

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

.button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.button:hover {
  border-color: var(--accent);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.78);
}

.button.danger {
  background: var(--hot-soft);
  border-color: #f5b6ad;
  color: #8e272a;
}

.button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 48px;
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-size: clamp(1.2rem, 4vw, 2rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px;
  gap: 10px;
  margin-bottom: 22px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.score-button:focus-visible,
.button:focus-visible {
  outline: 3px solid rgba(5, 103, 110, 0.24);
  outline-offset: 2px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.leaderboard-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.rank {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.leader-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-score {
  font-weight: 900;
  color: var(--accent);
}

.song-list {
  display: grid;
  gap: 14px;
}

.song-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.song-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.song-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.flag {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 1.65rem;
}

.song-meta {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.3;
}

.total-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 900;
  white-space: nowrap;
}

.total-pill.empty {
  background: var(--surface-strong);
  color: var(--muted);
}

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

.control-group {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.control-group legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.numeric-options {
  display: grid;
  gap: 6px;
}

.numeric-options {
  grid-template-columns: repeat(7, minmax(34px, 1fr));
}

.score-button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 850;
}

.score-button:hover {
  border-color: var(--accent);
}

.score-button.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: start;
    width: 100%;
  }

  .tools,
  .summary {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .app-header,
  .layout {
    width: min(100% - 20px, 1180px);
  }

  .button {
    flex: 1 1 92px;
  }

  .section-heading {
    align-items: center;
  }

  .section-actions {
    flex: 0 0 auto;
  }

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

  .leaderboard-list {
    grid-template-columns: 1fr;
  }

  .song-card {
    padding: 12px;
  }

  .song-topline {
    align-items: stretch;
    flex-direction: column;
  }

  .total-pill {
    align-self: start;
  }
}
