:root {
  color-scheme: dark;
  --bg: #070908;
  --bg-elevated: rgba(18, 21, 20, 0.92);
  --panel: rgba(19, 23, 22, 0.9);
  --panel-strong: rgba(27, 32, 31, 0.98);
  --line: rgba(152, 255, 203, 0.13);
  --line-strong: rgba(66, 255, 151, 0.35);
  --text: #f1f7f3;
  --muted: #a5b2ad;
  --soft: #77847e;
  --green: #35e07f;
  --green-dark: #15783f;
  --aqua: #5fe3df;
  --amber: #ffb545;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
label.import-button {
  min-height: 40px;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label.import-button:focus-within {
  outline: 2px solid var(--aqua);
  outline-offset: 2px;
}

.app-header,
.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 18px;
  animation: fade-in 520ms var(--ease) both;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--aqua);
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 850;
  line-height: 1.05;
}

h1 {
  font-size: 2.35rem;
}

h2 {
  font-size: 1.35rem;
}

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

.solid-button,
.ghost-button,
.import-button,
.view-tab,
.play-button,
.icon-button,
.score-chip,
.answer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 800;
  animation: control-fade 360ms var(--ease) both;
  background-size: 180% 180%;
  transition:
    transform 220ms var(--ease),
    border-color 220ms var(--ease),
    background 260ms var(--ease),
    background-position 420ms var(--ease),
    box-shadow 260ms var(--ease),
    color 220ms var(--ease),
    opacity 220ms var(--ease);
}

.solid-button {
  padding: 0 16px;
  color: #041009;
  background: linear-gradient(135deg, var(--green), var(--aqua), var(--green));
  box-shadow: 0 12px 34px rgba(53, 224, 127, 0.18);
}

.solid-button:hover,
.ghost-button:hover,
.import-button:hover,
.view-tab:hover,
.play-button:hover,
.icon-button:hover,
.score-chip:hover,
.answer-toggle:hover {
  transform: translateY(-1px);
  background-position: 100% 50%;
}

.solid-button:hover {
  box-shadow: 0 16px 38px rgba(53, 224, 127, 0.28);
}

.solid-button:active,
.ghost-button:active,
.import-button:active,
.view-tab:active,
.play-button:active,
.icon-button:active,
.score-chip:active,
.answer-toggle:active {
  transform: translateY(0);
}

.ghost-button,
.import-button {
  padding: 0 14px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 21, 20, 0.72);
  box-shadow: none;
}

.ghost-button:hover,
.import-button:hover {
  border-color: var(--line-strong);
  background: rgba(30, 38, 35, 0.9);
  box-shadow: 0 12px 28px rgba(53, 224, 127, 0.12);
}

.import-button {
  position: relative;
  cursor: pointer;
}

.import-button input {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.app-shell {
  padding-bottom: 34px;
}

.view-nav {
  width: min(1480px, calc(100% - 32px));
  display: flex;
  gap: 8px;
  margin: 0 auto 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 15, 14, 0.84);
  box-shadow: var(--shadow);
  animation: fade-in 520ms var(--ease) both;
}

.view-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.view-tab.is-active {
  color: #041009;
  border-color: rgba(95, 227, 223, 0.35);
  background: linear-gradient(135deg, var(--green), var(--aqua));
  box-shadow: 0 10px 26px rgba(53, 224, 127, 0.16);
}

.view-tab:hover:not(.is-active) {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.app-view[hidden] {
  display: none !important;
}

.app-view.is-active {
  animation: fade-up 420ms var(--ease) both;
}

.score-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(130px, 0.6fr));
  gap: 12px;
  margin: 8px 0 14px;
  animation: fade-up 560ms var(--ease) both;
}

.score-metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 13, 0.74);
  box-shadow: var(--shadow);
}

.score-metric span,
.field span,
.team-meta,
.score-breakdown,
.song-artist,
.song-subline {
  color: var(--muted);
}

.score-metric span {
  display: block;
  margin-bottom: 7px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.65rem;
  line-height: 1;
}

.leader-metric strong {
  color: var(--green);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tool-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: fade-up 620ms var(--ease) both;
}

.teams-panel {
  padding: 18px;
}

.songs-panel {
  padding: 18px;
  animation-delay: 80ms;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.song-heading {
  align-items: start;
}

.autosave-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(95, 227, 223, 0.18);
  border-radius: 999px;
  color: var(--aqua);
  background: rgba(95, 227, 223, 0.07);
  font-size: 0.78rem;
  font-weight: 800;
}

.team-form,
.song-form,
.song-toolbar {
  display: grid;
  gap: 10px;
}

.team-form {
  grid-template-columns: minmax(0, 1fr) 86px;
  margin-bottom: 16px;
}

.team-form .solid-button {
  grid-column: 1 / -1;
}

.song-form {
  grid-template-columns: minmax(160px, 1.2fr) minmax(160px, 1fr) minmax(112px, 0.65fr) minmax(112px, 0.6fr) 72px minmax(190px, 1fr) auto;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.song-toolbar {
  grid-template-columns: minmax(220px, 1fr) 150px 150px;
  align-items: end;
  margin: 14px 0;
}

.field,
.color-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.color-field span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(7, 10, 9, 0.78);
}

input,
select {
  padding: 0 11px;
}

input::placeholder {
  color: var(--soft);
}

input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

input[type="number"] {
  padding-right: 4px;
}

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

.team-card {
  --team-color: var(--green);
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left: 4px solid var(--team-color);
  border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--team-color) 13%, transparent), rgba(12, 15, 14, 0.92));
  animation: fade-up 360ms var(--ease) both;
}

.team-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px 38px;
  gap: 8px;
  align-items: end;
}

.team-name-field input {
  font-weight: 850;
}

.team-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.team-score {
  color: var(--team-color);
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.team-meta {
  font-size: 0.8rem;
  font-weight: 800;
  text-align: right;
}

.score-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 750;
}

.team-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score-chip {
  min-height: 36px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

.score-chip[data-score^="-"] {
  color: #ffd1d1;
  border-color: rgba(255, 107, 107, 0.18);
  background: rgba(255, 107, 107, 0.06);
}

.score-chip:hover {
  border-color: color-mix(in srgb, var(--team-color) 50%, transparent);
  background: color-mix(in srgb, var(--team-color) 18%, rgba(255, 255, 255, 0.03));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--team-color) 12%, transparent);
}

.icon-button {
  width: 34px;
  min-height: 40px;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.icon-button.danger:hover {
  color: #fff;
  border-color: rgba(216, 58, 58, 0.5);
  background: rgba(216, 58, 58, 0.82);
}

.link-button {
  width: 52px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 9, 8, 0.72);
}

.songs-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.songs-table th,
.songs-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  vertical-align: middle;
}

.songs-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: rgba(12, 16, 15, 0.98);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.songs-table tbody tr {
  animation: fade-in 240ms var(--ease) both;
}

.songs-table tbody tr:hover {
  background: rgba(95, 227, 223, 0.04);
}

.track-cell {
  min-width: 210px;
}

.play-cell {
  min-width: 72px;
}

.play-button {
  min-height: 34px;
  padding: 0 10px;
  color: #041009;
  border: 1px solid rgba(95, 227, 223, 0.44);
  background: linear-gradient(135deg, var(--green), var(--aqua), var(--green));
  box-shadow: 0 0 18px rgba(95, 227, 223, 0.12);
}

.play-button.needs-link {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.song-title {
  display: block;
  color: var(--text);
  font-weight: 850;
}

.song-artist {
  display: block;
  margin-top: 3px;
  font-size: 0.84rem;
}

.song-subline {
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 850;
}

.genre-pill {
  color: #d7f9ea;
  border: 1px solid rgba(53, 224, 127, 0.22);
  background: rgba(53, 224, 127, 0.08);
}

.difficulty-easy {
  color: #06120b;
  background: var(--green);
}

.difficulty-medium {
  color: #100b02;
  background: var(--amber);
}

.difficulty-hard {
  color: #e9ffff;
  background: #315d60;
}

.team-heading {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 140px;
}

.team-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 16px color-mix(in srgb, var(--dot) 70%, transparent);
}

.answer-cell {
  min-width: 68px;
}

.answer-toggle {
  width: 56px;
  min-height: 34px;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

.answer-toggle.is-correct {
  color: #031108;
  border-color: color-mix(in srgb, var(--team-color) 70%, white 10%);
  background: linear-gradient(135deg, var(--team-color), var(--aqua));
  box-shadow: 0 0 22px color-mix(in srgb, var(--team-color) 22%, transparent);
}

.row-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.tournament-panel,
.stats-panel {
  padding: 18px;
}

.stats-panel {
  padding: 22px;
}

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

.tournament-summary,
.stats-hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card,
.tournament-card,
.game-card,
.stat-card,
.team-stat-card {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  background: rgba(9, 13, 12, 0.78);
  animation: fade-up 360ms var(--ease) both;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-color: var(--line);
}

.summary-card span,
.stat-card > span,
.stats-hero-card > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-card strong,
.stat-card strong,
.stats-hero-card strong {
  overflow-wrap: anywhere;
  line-height: 1.05;
}

.summary-card strong {
  color: var(--green);
  font-size: 1.35rem;
}

.summary-card small,
.stat-card small,
.stats-hero-card small,
.mini-metrics small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.tournament-grid,
.game-grid,
.stats-grid,
.team-stats-grid {
  display: grid;
  gap: 12px;
}

.tournament-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 16px;
}

.tournament-card,
.game-card,
.team-stat-card {
  border-left: 4px solid var(--team-color);
  background: linear-gradient(120deg, color-mix(in srgb, var(--team-color) 10%, transparent), rgba(10, 14, 13, 0.9));
}

.tournament-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.rank-row,
.team-stat-header > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank-row strong,
.team-stat-header h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank {
  color: var(--aqua);
  font-size: 0.8rem;
  font-weight: 900;
}

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

.mini-metrics span {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.mini-metrics strong {
  display: block;
  min-height: 1.2em;
  overflow-wrap: anywhere;
  color: var(--team-color, var(--green));
  font-size: 1.05rem;
  line-height: 1.1;
}

.mini-metrics small {
  display: block;
  margin-top: 4px;
}

.game-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.game-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 14px;
}

.game-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.game-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.game-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid rgba(95, 227, 223, 0.18);
  border-radius: 999px;
  color: var(--aqua);
  background: rgba(95, 227, 223, 0.07);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.game-card.has-winner .game-status {
  color: #06120b;
  border-color: transparent;
  background: var(--team-color);
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.danger-text {
  color: #ffd1d1;
  border-color: rgba(255, 107, 107, 0.22);
}

.danger-text:hover {
  color: #fff;
  border-color: rgba(255, 107, 107, 0.58);
  background: rgba(255, 107, 107, 0.18);
}

.stats-hero {
  margin-bottom: 30px;
}

.podium-wrap {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 10, 9, 0.64);
}

.podium-stage {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.15fr) minmax(0, 0.92fr);
  gap: 14px;
  align-items: end;
  min-height: 310px;
}

.podium-card {
  --team-color: var(--green);
  position: relative;
  display: grid;
  align-content: end;
  gap: 10px;
  min-width: 0;
  min-height: 226px;
  padding: 18px 18px 0;
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--team-color) 42%, transparent);
  border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--team-color) 15%, transparent), rgba(9, 13, 12, 0.94));
  box-shadow: 0 22px 54px color-mix(in srgb, var(--team-color) 9%, transparent);
  animation: fade-up 420ms var(--ease) both;
}

.podium-rank-1 {
  position: relative;
  top: -26px;
  min-height: 286px;
  border-color: color-mix(in srgb, var(--team-color) 60%, var(--aqua));
  box-shadow: 0 28px 70px color-mix(in srgb, var(--team-color) 18%, transparent);
}

.podium-rank-2 {
  min-height: 238px;
}

.podium-rank-3 {
  min-height: 218px;
}

.podium-card.is-empty {
  visibility: hidden;
}

.podium-crown {
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--green);
  font-size: 3.2rem;
  line-height: 1;
  text-shadow: 0 0 28px rgba(53, 224, 127, 0.34);
}

.podium-rank-label {
  width: max-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--team-color) 40%, transparent);
  border-radius: 999px;
  color: var(--aqua);
  background: rgba(95, 227, 223, 0.06);
  font-size: 0.76rem;
  font-weight: 900;
}

.podium-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(1.35rem, 3.8vw, 2.4rem);
  line-height: 1.02;
}

.podium-score {
  color: var(--team-color);
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  font-weight: 950;
  line-height: 0.9;
}

.podium-card small {
  color: var(--muted);
  font-weight: 800;
}

.podium-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.podium-meta span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 850;
}

.podium-step {
  display: grid;
  place-items: center;
  min-height: 54px;
  margin: 8px -18px 0;
  border-radius: 0 0 var(--radius) var(--radius);
  color: #041009;
  background: linear-gradient(135deg, var(--team-color), var(--aqua));
  font-size: 1.6rem;
  font-weight: 950;
}

.podium-rank-1 .podium-step {
  min-height: 76px;
}

.podium-rank-2 .podium-step {
  min-height: 62px;
}

.podium-rest {
  display: grid;
  gap: 9px;
  padding-top: 2px;
}

.podium-rest > span {
  color: var(--aqua);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.podium-rest ol {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.podium-rest li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid var(--team-color);
  border-radius: var(--radius);
  background: linear-gradient(120deg, color-mix(in srgb, var(--team-color) 9%, transparent), rgba(9, 13, 12, 0.84));
}

.podium-rest li > span {
  color: var(--aqua);
  font-weight: 900;
}

.podium-rest strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-rest small,
.podium-rest em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 26px;
  align-items: start;
  margin-bottom: 28px;
}

.stats-section {
  display: grid;
  gap: 14px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.stats-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.stats-section-heading {
  display: grid;
  gap: 3px;
}

.stats-section-heading span {
  color: var(--aqua);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.stats-section-heading h3 {
  margin: 2px 0 0;
  font-size: 1.15rem;
  line-height: 1.1;
}

.stats-section-body {
  display: grid;
  gap: 14px;
}

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

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

.analysis-grid .wide-stat {
  grid-column: auto;
}

.song-analysis-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.song-analysis-grid .stat-card:nth-child(-n + 3) {
  grid-column: span 2;
}

.song-analysis-grid .wide-stat {
  grid-column: span 3;
}

.stat-card {
  display: grid;
  gap: 11px;
  align-self: start;
  min-height: 128px;
  padding: 18px;
}

.stat-card strong {
  color: var(--green);
  font-size: 1.35rem;
}

.wide-stat {
  grid-column: span 2;
}

.stat-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 6px 0 0;
  list-style: none;
}

.stat-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.stat-list li:first-child {
  border-top: 0;
}

.stat-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.stat-list li strong {
  color: var(--aqua);
  font-size: 0.95rem;
}

.stat-list li small {
  grid-column: 1 / -1;
}

.team-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.team-stat-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.overall-stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.team-stat-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.team-stat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.team-stat-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.team-stat-header > strong {
  color: var(--team-color);
  font-size: 2rem;
  line-height: 1;
}

.stat-lines {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stat-lines div {
  display: grid;
  grid-template-columns: minmax(120px, 0.85fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.stat-lines dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.stat-lines dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
  text-align: right;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(12, 17, 15, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes control-fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

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

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

  .song-form .solid-button {
    grid-column: 1 / -1;
  }

  .overview-grid,
  .analysis-grid,
  .overall-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .song-analysis-grid .stat-card:nth-child(-n + 3),
  .song-analysis-grid .wide-stat {
    grid-column: auto;
  }
}

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

  .header-actions {
    justify-content: flex-start;
  }

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

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

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

  .stats-hero,
  .game-form {
    grid-template-columns: 1fr;
  }

  .wide-stat {
    grid-column: auto;
  }

  .overview-grid,
  .analysis-grid,
  .song-analysis-grid,
  .team-stat-list,
  .overall-stat-grid {
    grid-template-columns: 1fr;
  }

  .podium-stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "first first"
      "second third";
    align-items: stretch;
    min-height: 0;
    padding-top: 30px;
  }

  .podium-rank-1 {
    grid-area: first;
    top: 0;
    min-height: 230px;
  }

  .podium-rank-2 {
    grid-area: second;
  }

  .podium-rank-3 {
    grid-area: third;
  }

  .podium-card.is-empty {
    display: none;
  }

  .podium-crown {
    top: -35px;
    font-size: 2.7rem;
  }
}

@media (max-width: 560px) {
  .app-header,
  .app-shell,
  .view-nav {
    width: 100%;
    max-width: 100vw;
    padding-inline: 10px;
  }

  .view-nav {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 10px;
  }

  h1 {
    font-size: 2rem;
  }

  .score-strip,
  .song-form,
  .team-form {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .header-actions > * {
    width: 100%;
    min-width: 0;
  }

  .team-topline {
    grid-template-columns: minmax(0, 1fr) 46px 38px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-panel {
    padding: 16px;
  }

  .podium-wrap {
    padding: 14px;
  }

  .podium-stage {
    gap: 10px;
  }

  .podium-card {
    min-height: 190px;
    padding: 14px 14px 0;
  }

  .podium-rank-1 {
    min-height: 218px;
  }

  .podium-score {
    font-size: 2.7rem;
  }

  .podium-step {
    margin-inline: -14px;
  }

  .podium-rest li {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .podium-rest em {
    grid-column: 2 / -1;
  }

  .stats-section-heading {
    display: grid;
    align-items: start;
  }

  .page-heading .solid-button {
    width: 100%;
  }

  .mini-metrics,
  .tournament-summary,
  .stats-hero-metrics {
    grid-template-columns: 1fr;
  }

  .game-card-top,
  .team-stat-header,
  .stat-lines div {
    grid-template-columns: 1fr;
  }

  .stat-lines dd {
    text-align: left;
  }

  .stats-hero-card strong {
    font-size: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
