:root {
  --navy: #061f46;
  --navy-light: #0d3974;
  --gold: #d2ad4a;
  --cream: #f5f2e9;
  --white: #fff;
  --ink: #122038;
  --muted: #667085;
  --line: #d9dee7;
  --success: #157347;
  --warning: #9a6700;
  --danger: #b42318;
  --surface: #fff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family:
    Inter, ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.topbar {
  min-height: 82px;
  padding: 14px clamp(18px, 5vw, 70px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--white);
  background: var(--navy);
}

.brand img {
  display: block;
  width: 170px;
  height: auto;
}

.topbar-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.topbar-actions a {
  color: var(--white);
  font-weight: 700;
  text-decoration: none;
}

.environment {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  font-size: .75rem;
  letter-spacing: .12em;
}

main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0 80px;
}

.page-heading {
  padding: clamp(30px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 40px;
  align-items: end;
  color: var(--white);
  border-radius: 28px;
  background:
    radial-gradient(
      circle at 85% 15%,
      rgba(210,173,74,.28),
      transparent 32%
    ),
    linear-gradient(
      135deg,
      var(--navy),
      var(--navy-light)
    );
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .18em;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(3rem, 8vw, 6.2rem);
  line-height: .9;
}

h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.subtitle {
  max-width: 680px;
  margin: 0;
  color: rgba(255,255,255,.8);
  font-size: 1.05rem;
  line-height: 1.65;
}

.formula-card {
  padding: 24px;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  background: rgba(255,255,255,.08);
}

.formula-card span,
.formula-card small {
  color: rgba(255,255,255,.72);
}

.formula-card strong {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 3rem;
}

.summary {
  margin: 22px 0 58px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.summary article {
  padding: 22px;
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.summary span {
  color: var(--muted);
  font-size: .88rem;
}

.summary strong {
  color: var(--navy);
  font-size: 1.9rem;
}

.section-title,
.detail-heading {
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.refresh-button,
.detail-heading button,
.team-button {
  min-height: 44px;
  padding: 10px 17px;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 750;
}

.refresh-button {
  color: var(--white);
  border: 0;
  background: var(--navy);
}

.state-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

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

.ranking {
  display: grid;
  gap: 12px;
}

.ranking-row {
  padding: 20px;
  display: grid;
  grid-template-columns:
    72px minmax(190px, 1.5fr)
    minmax(150px, 1fr)
    90px 90px 110px 145px;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.ranking-row.podium {
  border-color: rgba(210,173,74,.7);
}

.position {
  color: var(--navy);
  font-family: Georgia, serif;
  font-size: 2.2rem;
}

.team-name {
  display: grid;
  gap: 5px;
}

.team-name strong {
  font-size: 1.08rem;
}

.team-name small,
.metric span {
  color: var(--muted);
}

.members {
  font-size: .9rem;
  line-height: 1.55;
}

.metric {
  display: grid;
  gap: 4px;
}

.metric strong {
  font-size: 1.05rem;
}

.status {
  padding: 8px 11px;
  border-radius: 999px;
  text-align: center;
  font-size: .78rem;
  font-weight: 800;
}

.status.qualified {
  color: var(--success);
  background: #e7f6ed;
}

.status.pending {
  color: var(--warning);
  background: #fff4d6;
}

.team-button {
  color: var(--navy);
  border: 1px solid var(--navy);
  background: transparent;
}

.team-detail {
  margin-top: 34px;
  padding: clamp(24px, 5vw, 44px);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 22px 60px rgba(6,31,70,.12);
}

.detail-heading button {
  color: var(--navy);
  border: 1px solid var(--line);
  background: var(--white);
}

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

.result-row {
  padding: 16px;
  display: grid;
  grid-template-columns: 110px 1fr 160px 90px 150px;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.result-row.excluded {
  opacity: .58;
}

.result-row.rejected {
  border-color: #f0b5b0;
  background: #fff4f3;
}

.result-score {
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 850;
}

.result-label {
  color: var(--muted);
  font-size: .82rem;
}

footer {
  padding: 28px clamp(20px, 5vw, 70px);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: rgba(255,255,255,.7);
  background: var(--navy);
  font-size: .78rem;
  letter-spacing: .1em;
}

@media (max-width: 1000px) {
  .ranking-row {
    grid-template-columns: 55px 1fr 1fr;
  }

  .ranking-row .team-button {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .result-row {
    grid-template-columns: 100px 1fr 80px;
  }

  .result-row > :nth-child(3),
  .result-row > :nth-child(5) {
    grid-column: 2 / -1;
  }
}

@media (max-width: 720px) {
  main {
    width: min(100% - 24px, 1180px);
    padding-top: 22px;
  }

  .topbar {
    min-height: 70px;
  }

  .brand img {
    width: 132px;
  }

  .environment {
    display: none;
  }

  .page-heading {
    padding: 28px 22px;
    grid-template-columns: 1fr;
  }

  .formula-card {
    max-width: none;
  }

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

  .ranking-row {
    padding: 18px;
    grid-template-columns: 44px 1fr;
  }

  .ranking-row > *:not(.position) {
    grid-column: 2;
  }

  .result-row {
    grid-template-columns: 1fr 72px;
  }

  .result-row > * {
    grid-column: 1 / -1;
  }

  .result-score {
    grid-column: 2;
    grid-row: 1;
  }

  .section-title,
  .detail-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  footer {
    flex-direction: column;
  }
}

/* CLASSIFICA COMPATTA V2 */

.ranking {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.ranking-head,
.ranking-row {
  display: grid;
  grid-template-columns:
    58px
    minmax(230px, 1.8fr)
    minmax(110px, .8fr)
    82px
    76px
    minmax(150px, 1fr)
    108px;
  gap: 14px;
  align-items: center;
}

.ranking-head {
  min-height: 48px;
  padding: 10px 18px;
  color: var(--muted);
  background: #f8f9fb;
  border-bottom: 1px solid var(--line);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ranking-row {
  min-height: 74px;
  padding: 11px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.ranking-row:last-child {
  border-bottom: 0;
}

.ranking-row.podium {
  border-color: var(--line);
  box-shadow: inset 4px 0 0 var(--gold);
}

.position {
  font-size: 1.55rem;
  font-weight: 600;
}

.team-name {
  min-width: 0;
  gap: 3px;
}

.team-name strong,
.team-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-name strong {
  font-size: .95rem;
}

.team-name small {
  font-size: .76rem;
}

.members {
  font-size: .82rem;
  line-height: 1.35;
}

.metric {
  display: block;
}

.ranking-row .metric span {
  display: none;
}

.metric strong {
  font-size: .96rem;
}

.status {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: .68rem;
  line-height: 1.16;
}

.team-button {
  min-height: 38px;
  padding: 7px 11px;
  font-size: .76rem;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .ranking-head,
  .ranking-row {
    grid-template-columns:
      46px
      minmax(180px, 1.7fr)
      92px
      66px
      66px
      126px
      92px;
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .team-name small {
    white-space: normal;
  }
}

@media (max-width: 760px) {
  .ranking {
    gap: 10px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .ranking-head {
    display: none;
  }

  .ranking-row {
    min-height: 0;
    padding: 15px;
    grid-template-columns: 48px 1fr 1fr;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 15px;
  }

  .ranking-row:last-child {
    border-bottom: 1px solid var(--line);
  }

  .ranking-row.podium {
    border-color: rgba(210,173,74,.7);
    box-shadow: none;
  }

  .position {
    grid-row: 1 / span 2;
  }

  .team-name {
    grid-column: 2 / -1;
  }

  .members {
    grid-column: 2 / -1;
  }

  .ranking-row .metric {
    display: grid;
    gap: 3px;
  }

  .ranking-row .metric span {
    display: block;
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .status {
    width: auto;
    min-height: 46px;
    grid-column: 2 / -1;
  }

  .team-button {
    width: 100%;
    grid-column: 2 / -1;
  }
}

/* CLASSIFICA RIGHE COMPATTE V3 */

@media (min-width: 761px) {
  .ranking-row {
    min-height: 58px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .ranking-head {
    min-height: 42px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .position {
    font-size: 1.35rem;
  }

  .team-name {
    gap: 1px;
  }

  .team-name strong {
    font-size: .88rem;
    line-height: 1.15;
  }

  .team-name small {
    font-size: .7rem;
    line-height: 1.15;
  }

  .members {
    font-size: .76rem;
    line-height: 1.2;
  }

  .metric strong {
    font-size: .9rem;
  }

  .status {
    min-height: 32px;
    padding: 5px 8px;
    font-size: .64rem;
  }

  .team-button {
    min-height: 32px;
    padding: 5px 10px;
    font-size: .7rem;
  }
}

/* CLASSIFICA RIGHE COMPATTE V3 */

@media (min-width: 761px) {
  .ranking-row {
    min-height: 58px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .ranking-head {
    min-height: 42px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .position {
    font-size: 1.35rem;
  }

  .team-name {
    gap: 1px;
  }

  .team-name strong {
    font-size: .88rem;
    line-height: 1.15;
  }

  .team-name small {
    font-size: .7rem;
    line-height: 1.15;
  }

  .members {
    font-size: .76rem;
    line-height: 1.2;
  }

  .metric strong {
    font-size: .9rem;
  }

  .status {
    min-height: 32px;
    padding: 5px 8px;
    font-size: .64rem;
  }

  .team-button {
    min-height: 32px;
    padding: 5px 10px;
    font-size: .7rem;
  }
}
