:root {
  color-scheme: light;
  --bg: #f0f2ec;
  --surface: #ffffff;
  --surface-2: #edf2ea;
  --text: #10221c;
  --muted: #607069;
  --line: #d2ddd4;
  --accent: #176b5b;
  --accent-dark: #0f443a;
  --blue: #166d9a;
  --warn: #9c6b21;
  --warn-bg: #fff5dc;
  --danger: #a43b3b;
  --danger-bg: #fff0ef;
  --ok-bg: #edf8f1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.55fr);
  gap: 24px;
  align-items: end;
  min-height: 430px;
  padding: 132px 34px 28px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 241, 0.9)),
    #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand-strip {
  position: absolute;
  top: 24px;
  left: 34px;
  right: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(16, 34, 28, 0.12);
}

.brand-strip img {
  display: block;
  max-width: min(44vw, 360px);
  max-height: 74px;
  object-fit: contain;
}

.hero-text h1 {
  margin: 4px 0 10px;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.92;
  letter-spacing: 0;
}

.hero-text p:last-child {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.print-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
}

.print-button:hover {
  background: var(--accent-dark);
}

.label {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.hero-card div {
  min-height: 86px;
  padding: 13px 14px;
  background: rgba(237, 242, 234, 0.94);
}

.hero-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.hero-card strong {
  display: block;
  margin-top: 5px;
  color: var(--accent-dark);
  font-size: 30px;
  line-height: 1;
}

main {
  display: grid;
  gap: 18px;
  padding: 22px 34px 34px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-title,
.rules {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
}

.section-title {
  border-bottom: 1px solid var(--line);
}

h2,
h3,
h4 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-top: 4px;
  font-size: 26px;
}

.trip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.trip article {
  padding: 18px 20px 20px;
  background: var(--surface);
}

.trip h3 {
  margin-bottom: 14px;
  font-size: 20px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.links a,
.badge,
.rule-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-2);
  font-size: 13px;
}

.notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--ok-bg);
}

.rules {
  background: #123f49;
  color: #ffffff;
}

.rules .label {
  color: #b9e4d8;
}

.rule-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rule-list span {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 800;
}

.teams {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: #f8faf6;
}

.team {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.team-head {
  display: grid;
  grid-template-columns: minmax(220px, 0.55fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #eef4ef;
}

.team-head h3 {
  font-size: 24px;
}

.team-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.team-stats div {
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.team-stats span,
.time-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.team-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.team-table-wrap {
  overflow-x: auto;
}

.team-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

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

.team-table th {
  color: #39483f;
  background: #fbfcfa;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.team-table tr:last-child td {
  border-bottom: 0;
}

.team-table td:nth-child(4),
.team-table td:nth-child(5),
.team-table td:nth-child(6),
.team-table td:nth-child(7) {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.runner {
  font-weight: 850;
}

.restart-row {
  background: #fffaf0;
}

.leg-cell span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.badge.ok {
  border-color: #bddbc7;
  background: var(--ok-bg);
}

.badge.warn {
  border-color: #ead28f;
  background: var(--warn-bg);
  color: #6b4700;
}

.badge.danger {
  border-color: #e1b0b0;
  background: var(--danger-bg);
  color: var(--danger);
}

.loading {
  padding: 28px 20px;
  color: var(--muted);
  background: var(--surface);
}

.print-note {
  display: none;
}

@media (max-width: 980px) {
  .hero,
  .trip-grid,
  .team-head {
    grid-template-columns: 1fr;
  }

  .hero {
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 241, 0.9)),
      #ffffff;
  }

  .rules {
    align-items: flex-start;
    flex-direction: column;
  }

  .rule-list {
    justify-content: flex-start;
  }

  .team-stats {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 620px) {
  .hero,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero {
    padding-top: 168px;
  }

  .brand-strip {
    left: 14px;
    right: 14px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand-strip img {
    max-width: 100%;
    max-height: 54px;
  }

  .hero-card,
  .team-stats {
    grid-template-columns: 1fr;
  }

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

  dl div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  h2 {
    font-size: 23px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    background: #ffffff;
    color: #111111;
    font-size: 9px;
    line-height: 1.25;
  }

  a {
    color: #111111;
    text-decoration: none;
  }

  .hero {
    display: block;
    min-height: 0;
    padding: 0 0 8px;
    border-bottom: 2px solid #111111;
    background: #ffffff;
  }

  .brand-strip {
    position: static;
    justify-content: flex-start;
    gap: 14px;
    padding-bottom: 6px;
    border-bottom: 0;
  }

  .brand-strip img {
    max-width: 155px;
    max-height: 38px;
  }

  .hero-text h1 {
    margin: 4px 0 2px;
    font-size: 24px;
    line-height: 1;
  }

  .hero-text p:last-child,
  .hero-actions,
  .trip,
  .rules,
  .hero-card,
  .team-head p,
  .team-table th:nth-child(5),
  .team-table td:nth-child(5),
  .team-table th:nth-child(9),
  .team-table td:nth-child(9) {
    display: none;
  }

  main {
    display: block;
    padding: 8px 0 0;
  }

  .section,
  .team,
  .team-stats div {
    border-color: #999999;
    border-radius: 0;
    background: #ffffff;
  }

  .section {
    border: 0;
    overflow: visible;
  }

  .section-title {
    display: block;
    padding: 0 0 6px;
    border-bottom: 0;
  }

  .section-title h2 {
    margin: 0;
    font-size: 15px;
  }

  .label {
    color: #333333;
    font-size: 8px;
  }

  .print-note {
    display: block;
    margin: 2px 0 0;
    color: #555555;
    font-size: 9px;
  }

  .teams {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5mm;
    padding: 0;
    background: #ffffff;
  }

  .team {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .team-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    padding: 5px 6px;
    background: #f2f2f2;
  }

  .team-head h3 {
    font-size: 14px;
  }

  .team-stats {
    grid-template-columns: repeat(3, 92px);
    gap: 4px;
  }

  .team-stats div {
    min-height: 0;
    padding: 3px 5px;
  }

  .team-stats span,
  .time-grid span {
    color: #555555;
    font-size: 7px;
  }

  .team-stats strong {
    margin-top: 1px;
    font-size: 12px;
  }

  .team-table-wrap {
    overflow: visible;
  }

  .team-table {
    min-width: 0;
    table-layout: fixed;
  }

  .team-table th,
  .team-table td {
    padding: 3px 5px;
    border-bottom-color: #cccccc;
  }

  .team-table th {
    background: #ffffff;
    color: #333333;
    font-size: 7px;
  }

  .team-table td:nth-child(1) {
    width: 7%;
  }

  .team-table td:nth-child(2) {
    width: 10%;
  }

  .team-table td:nth-child(3) {
    width: 30%;
  }

  .team-table td:nth-child(4),
  .team-table td:nth-child(6),
  .team-table td:nth-child(7) {
    width: 12%;
    font-size: 10px;
  }

  .team-table td:nth-child(8) {
    width: 13%;
  }

  .leg-cell span {
    width: 18px;
    height: 18px;
    background: #333333;
    font-size: 9px;
  }

  .badge {
    min-height: 0;
    border-radius: 0;
    padding: 1px 4px;
    background: #ffffff !important;
    color: #111111 !important;
    font-size: 8px;
  }

  .restart-row {
    background: #fff8df;
  }
}
