:root {
  --page-bg: #eef1f4;
  --surface: #ffffff;
  --text: #222222;
  --muted: #6d6d6d;
  --line: #a9a9a9;
  --line-strong: #777777;
  --brown-dark: #5b3516;
  --brown-mid: #774f1e;
  --header-gray: #eeeeee;
  --blue: #d9e2f3;
  --green: #e2f0d9;
  --yellow: #fff2cc;
  --red: #f4cccc;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--page-bg);
  font-family: Arial, "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

.page-shell {
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 8px 16px;
  border-bottom: 1px solid #d1d5d9;
  background: var(--surface);
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.project-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 4px;
  color: #ffffff;
  background: var(--brown-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

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

h1 {
  font-size: 17px;
  line-height: 1.2;
}

.title-lockup p,
.source-meta,
.page-footer,
.section-heading span {
  color: var(--muted);
  font-size: 11px;
}

.title-lockup p {
  margin-top: 2px;
}

.source-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.source-divider {
  color: #b7b7b7;
}

.page-content {
  width: 100%;
  margin: 0 auto;
  padding: 12px 12px 24px;
}

.sheet-card {
  overflow: hidden;
  border: 1px solid #c7cbd0;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(34, 34, 34, 0.08);
}

.sheet-card-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #d7dade;
}

.kicker {
  margin-bottom: 4px;
  color: var(--brown-mid);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

.sheet-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 10px;
  color: #555555;
  font-size: 10px;
  white-space: nowrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.rating-sections {
  padding: 0 12px 14px;
}

.rating-section {
  padding-top: 12px;
}

.rating-section.is-secondary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 8px solid var(--page-bg);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 6px;
}

.section-heading h3 {
  color: var(--brown-dark);
  font-size: 14px;
}

.matrix-scroller {
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.rating-matrix {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 11px;
}

.name-column {
  width: 60px;
}

.rating-column {
  width: 46px;
}

.rating-matrix th,
.rating-matrix td {
  height: 24px;
  padding: 3px 4px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
  line-height: 1.15;
  white-space: nowrap;
}

.rating-matrix tr > :nth-child(4n) {
  border-right: 2px solid var(--line-strong);
}

.rating-matrix tr > :last-child {
  border-right: 0;
}

.team-row th,
.league-row th {
  height: 23px;
  color: #ffffff;
  background: var(--brown-dark);
  font-weight: 700;
}

.role-row th {
  height: 23px;
  color: #ffffff;
  background: var(--brown-mid);
  font-weight: 700;
}

.field-row th {
  height: 23px;
  color: var(--text);
  background: var(--header-gray);
  font-weight: 400;
}

.rating-matrix tbody tr:hover td {
  outline: 1px solid rgba(91, 53, 22, 0.18);
  outline-offset: -1px;
}

.name-cell,
.rating-cell,
.average-label,
.average-value {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rating-cell,
.average-value {
  font-variant-numeric: tabular-nums;
}

.name-cell.is-gray {
  color: #808080;
}

.empty-cell {
  color: #b1b1b1;
  background: #ffffff;
}

.band-high,
.average-top {
  background: var(--blue);
}

.band-good,
.average-upper {
  background: var(--green);
}

.band-mid,
.average-lower {
  background: var(--yellow);
}

.band-low,
.average-bottom {
  background: var(--red);
}

.average-row td {
  height: 27px;
  font-weight: 700;
}

.average-label {
  font-size: 10px;
}

.average-value {
  font-size: 11px;
}

.average-empty {
  color: #6d6d6d;
  background: #ffffff;
}

.loading-state,
.error-state {
  display: grid;
  gap: 5px;
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.error-state strong {
  color: #8b2d2d;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 22px;
}

.page-footer a {
  color: var(--brown-mid);
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
  }

  .source-meta {
    padding-left: 45px;
  }

  .page-content {
    padding: 10px 8px 20px;
  }

  .sheet-card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
    padding: 12px;
  }

  .legend {
    justify-content: flex-start;
    white-space: normal;
  }

  .rating-sections {
    padding: 0 8px 10px;
  }

  .page-footer {
    display: grid;
    padding: 0 14px 18px;
  }
}
