:root {
  --sheet-blue: #185abd;
  --sheet-orange: #f89a0e;
  --sheet-ink: #263746;
  --sheet-muted: #617282;
  --sheet-border: #dfe5ea;
  --sheet-bg: #f3f6f8;
  --sheet-white: #fff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--sheet-ink);
  background: var(--sheet-bg);
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 14px;
}

button,
a {
  font: inherit;
}

.match-sheet-page {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.sheet-header,
.sheet-card,
.sheet-error {
  border-radius: 10px;
  background: var(--sheet-white);
  box-shadow: 0 3px 14px rgba(26, 49, 67, .09);
  overflow: hidden;
}

.sheet-heading {
  padding: 20px 24px;
  color: var(--sheet-white);
  background: var(--sheet-blue);
  text-align: center;
}

.sheet-heading p {
  margin: 0 0 3px;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .85;
}

.sheet-heading h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  text-transform: uppercase;
}

.match-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.match-meta span {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 5px;
  font-size: .8rem;
}

.match-score {
  min-height: 148px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

.match-team {
  min-width: 0;
  text-align: center;
}

.match-team span,
.final-score span {
  display: block;
  margin-bottom: 6px;
  color: var(--sheet-muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.match-team strong {
  display: block;
  color: var(--sheet-blue);
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  overflow-wrap: anywhere;
}

.final-score {
  min-width: 132px;
  padding: 14px 20px;
  border-radius: 9px;
  color: #171717;
  background: #fff4df;
  text-align: center;
}

.final-score strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.sheet-actions {
  margin: 14px 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.sheet-actions button,
.sheet-error a {
  padding: 8px 14px;
  border: 0;
  border-radius: 6px;
  color: var(--sheet-white);
  background: var(--sheet-blue);
  cursor: pointer;
  text-decoration: none;
}

.sheet-actions button:hover,
.sheet-actions button:focus-visible,
.sheet-error a:hover,
.sheet-error a:focus-visible {
  color: #171717;
  background: var(--sheet-orange);
}

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

.sheet-card h2 {
  margin: 0;
  padding: 13px 16px;
  color: var(--sheet-white);
  background: var(--sheet-blue);
  font-size: 1rem;
}

.lineup-card h2 span {
  margin-right: 8px;
  color: #171717;
  font-size: .72rem;
  text-transform: uppercase;
  background: var(--sheet-orange);
  border-radius: 4px;
  padding: 3px 6px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border: 0;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 8px;
  border: 0;
  border-bottom: 1px solid var(--sheet-border);
  vertical-align: middle;
}

th {
  color: var(--sheet-blue);
  background: #f5f7f9;
  font-size: .74rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.lineup-table th:first-child,
.lineup-table td:first-child {
  text-align: left;
}

.lineup-table th:not(:first-child),
.lineup-table td:not(:first-child) {
  width: 58px;
  text-align: center;
}

.player-result-link {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: 3px;
}

.player-result-link:hover,
.player-result-link:focus-visible {
  color: var(--sheet-blue);
  text-decoration: underline;
}

.match-progress-card {
  margin-top: 16px;
}

.match-progress-table {
  table-layout: fixed;
}

.match-progress-table th:nth-child(1),
.match-progress-table td:nth-child(1) {
  width: 66px;
  text-align: center;
}

.match-progress-table th:nth-child(2),
.match-progress-table td:nth-child(2) {
  text-align: right;
}

.match-progress-table th:nth-child(3),
.match-progress-table td:nth-child(3) {
  width: 90px;
  text-align: center;
}

.match-progress-table th:nth-child(4),
.match-progress-table td:nth-child(4) {
  text-align: left;
}

.match-progress-table .cumulative-column {
  width: 110px;
  text-align: center;
}

.double-row td {
  background: #fff8ef;
  border-bottom-color: #f5d7a8;
}

.double-row td:first-child {
  border-left: 4px solid var(--sheet-orange);
}

.sets-score,
.cumulative-score {
  font-variant-numeric: tabular-nums;
}

.wo-label {
  color: #b54a00;
  font-size: .75rem;
}

.comment-card {
  margin-top: 16px;
}

.comment-card p {
  margin: 0;
  padding: 16px;
  line-height: 1.55;
}

.empty-message {
  padding: 22px;
  color: var(--sheet-muted);
  text-align: center !important;
}

.sheet-error {
  max-width: 620px;
  margin: 80px auto;
  padding: 28px;
  text-align: center;
}

.sheet-error h1 {
  margin-top: 0;
  color: var(--sheet-blue);
}

.sheet-error p {
  margin-bottom: 24px;
}

@media (max-width: 700px) {
  body {
    font-size: 12px;
  }

  .match-sheet-page {
    width: calc(100% - 16px);
    margin: 8px auto 24px;
  }

  .sheet-heading {
    padding: 16px 10px;
  }

  .match-score {
    min-height: 0;
    padding: 16px 10px;
    grid-template-columns: minmax(0, 1fr) 88px minmax(0, 1fr);
    gap: 8px;
  }

  .final-score {
    min-width: 0;
    padding: 11px 5px;
  }

  .final-score strong {
    font-size: 1.55rem;
  }

  .team-lineups {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sheet-actions {
    margin: 10px 0;
  }

  .sheet-actions button {
    flex: 1;
  }

  .optional-mobile {
    display: none;
  }

  th,
  td {
    padding: 7px 4px;
  }

  .lineup-table th:not(:first-child),
  .lineup-table td:not(:first-child) {
    width: 42px;
  }

  .match-progress-card {
    margin-top: 12px;
  }

  .match-progress-table th:nth-child(1),
  .match-progress-table td:nth-child(1) {
    width: 42px;
  }

  .match-progress-table th:nth-child(3),
  .match-progress-table td:nth-child(3) {
    width: 58px;
  }

  .cumulative-column {
    display: none;
  }

  .match-progress-table th:nth-child(2),
  .match-progress-table td:nth-child(2),
  .match-progress-table th:nth-child(4),
  .match-progress-table td:nth-child(4) {
    overflow-wrap: anywhere;
  }
}

@media print {
  @page {
    margin: 10mm;
  }

  body {
    color: #111;
    background: #fff;
    font-size: 10px;
  }

  .match-sheet-page {
    width: 100%;
    margin: 0;
  }

  .sheet-header,
  .sheet-card {
    box-shadow: none;
    break-inside: avoid;
  }

  .sheet-heading,
  .sheet-card h2 {
    color: #111;
    background: #e8e8e8;
  }

  .match-meta span {
    border-color: #777;
  }

  .sheet-actions {
    display: none;
  }

  .match-score {
    min-height: 0;
    padding: 12px;
  }

  .team-lineups {
    gap: 8px;
  }

  th,
  td {
    padding: 4px;
    border-color: #aaa;
  }

  .match-progress-card,
  .comment-card {
    margin-top: 8px;
  }

  a {
    color: inherit !important;
    text-decoration: none !important;
  }
}
