:root {
  --thc-font: var(--wp--preset--font-family--body, "Segoe UI", Tahoma, Arial, sans-serif);
  --thc-color-primary: #004c9e;
  --thc-color-primary-soft: #35689e;
  --thc-color-secondary-surface: #fff9eb;
  --thc-color-bg: #f4f7fb;
  --thc-color-surface: #ffffff;
  --thc-color-text: #17324d;
  --thc-color-text-soft: #5f7286;
  --thc-color-border: #d7e1eb;
  --thc-color-success: #00ad6e;
  --thc-color-danger: #d10000ff;
  --thc-color-backdrop: rgba(10, 24, 43, 0.62);
  --thc-radius-sm: 10px;
  --thc-radius-md: 16px;
  --thc-radius-lg: 22px;
  --thc-shadow-sm: 0 10px 30px rgba(8, 24, 48, 0.06);
}

body.thc-modal-open {
  overflow: hidden;
}

.thc-ladder-admin,
.thc-ladder-challenges,
.thc-ladder-matches,
.thc-ladder-optin,
.thc-ranking {
  font-family: var(--thc-font);
  color: var(--thc-color-text);
  font-size: 1rem;
  line-height: 1.45;
}

.thc-ladder-optin {
  display: flex;
  justify-content: flex-start;
  padding-bottom: 14px;
}

.thc-ui-panel {
  background: var(--thc-color-surface);
  border: 1px solid var(--thc-color-border);
  border-radius: var(--thc-radius-lg);
  padding: 18px;
  box-shadow: var(--thc-shadow-sm);
}

.thc-ui-hint {
  margin: 0 0 14px;
  color: var(--thc-color-text-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.thc-ui-alert {
  display: block;
  padding: 12px 14px;
  margin: 0 0 16px;
  border-radius: var(--thc-radius-sm);
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--thc-color-text);
}

.thc-ui-info-row {
  display: block;
  padding: 12px 14px;
  margin: 12px 0;
  border-radius: var(--thc-radius-sm);
  border: 1px solid var(--thc-color-border);
  background: var(--thc-color-bg);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--thc-color-text);
}

.thc-ui-info-row--limits {
  margin-bottom: 16px;
}

.thc-ui-info-row__line {
  margin: 0;
}

.thc-ui-info-row__line + .thc-ui-info-row__line {
  margin-top: 6px;
}

.thc-ui-alert--success {
  background: rgba(47, 111, 87, 0.1);
  border-color: rgba(47, 111, 87, 0.22);
}

.thc-ui-alert--error {
  background: rgba(157, 67, 67, 0.1);
  border-color: rgba(157, 67, 67, 0.22);
}

.thc-ui-alert--info {
  background: rgba(0, 76, 158, 0.08);
  border-color: rgba(0, 76, 158, 0.2);
}

.thc-ui-link {
  color: var(--thc-color-primary);
  font-weight: 700;
  text-decoration: none;
}

.thc-ui-link:hover,
.thc-ui-link:focus-visible {
  text-decoration: underline;
}

.thc-admin {
  font-size: 1rem;
}

.thc-admin__section {
  margin-top: 14px;
}

.thc-admin__section:first-of-type {
  margin-top: 0;
}

.thc-admin__section > .thc-ui-card + .thc-ui-card {
  margin-top: 12px;
}

.thc-admin__title {
  margin: 0;
}

.thc-ui-section-title {
  margin: 0 0 12px;
  font-size: 1.28rem;
  line-height: 1.25;
  font-weight: 700;
}

.thc-ui-subtitle {
  margin: 0 0 10px;
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--thc-color-text-soft);
}

.thc-admin__export-row {
  margin: 0 0 16px;
}

.thc-admin__export-link {
  font-size: 1rem;
  font-weight: 700;
}

.thc-ui-table-wrap,
.thc-admin__table-wrap {
  overflow-x: auto;
}

.thc-ui-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.thc-ui-table th,
.thc-ui-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--thc-color-border);
  text-align: left;
  vertical-align: middle;
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 400;
}

.thc-ui-table thead th {
  font-size: 0.95rem;
  color: var(--thc-color-text-soft);
  font-weight: 700;
}

.thc-ui-table__number {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.thc-admin__correction-flag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--thc-color-border);
  font-size: 0.8rem;
  font-weight: 700;
}

.thc-admin__correction-flag.is-yes {
  color: var(--thc-color-primary);
  background: rgba(0, 76, 158, 0.1);
}

.thc-admin__correction-flag.is-no {
  color: var(--thc-color-text-soft);
  background: #f3f6fa;
}

.thc-admin__open-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

.thc-admin__open-meta {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--thc-color-text-soft);
}

.thc-ui-control,
.thc-ladder-admin input,
.thc-ladder-admin select,
.thc-ladder-challenges input,
.thc-ladder-challenges select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--thc-color-border);
  border-radius: var(--thc-radius-sm);
  padding: 10px 12px;
  background: var(--thc-color-surface);
  color: var(--thc-color-text);
  box-sizing: border-box;
}

.thc-ui-control:focus,
.thc-ladder-admin input:focus,
.thc-ladder-admin select:focus,
.thc-ladder-challenges input:focus,
.thc-ladder-challenges select:focus {
  outline: 2px solid rgba(0, 76, 158, 0.22);
  outline-offset: 1px;
  border-color: var(--thc-color-primary);
}

.thc-ui-btn,
.thc-ladder-admin button,
.thc-ladder-challenges button,
.thc-ladder-optin button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--thc-font);
  min-height: 20px;
  border: 1px solid transparent;
  border-radius: var(--thc-radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
}

.thc-ui-btn:focus-visible {
  outline: 2px solid rgba(0, 76, 158, 0.24);
  outline-offset: 1px;
}

.thc-ui-btn--block {
  width: 100%;
}

.thc-ui-btn--primary {
  background: var(--thc-color-primary);
  color: #fff;
}

.thc-ui-btn--primary:hover,
.thc-ui-btn--primary:focus-visible {
  background: var(--thc-color-primary-soft);
}

.thc-ui-btn--secondary {
  background: var(--thc-color-secondary-surface);
  border-color: #eadfbd;
  color: var(--thc-color-text);
}

.thc-ui-btn--ghost {
  background: transparent;
  border-color: var(--thc-color-border);
  color: var(--thc-color-text);
}

.thc-ui-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

.thc-ui-card-list {
  display: grid;
  gap: 14px;
}

.thc-ui-card,
.thc-open-challenge-card,
.thc-ladder-admin-match-card {
  background: var(--thc-color-surface);
  border: 1px solid var(--thc-color-border);
  border-radius: var(--thc-radius-md);
  padding: 16px;
  font-size: 0.95rem;
}

.thc-ui-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.35;
}

.thc-ranking-card__title-main {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.thc-ui-card__meta {
  margin: 4px 0 0;
  color: var(--thc-color-text-soft);
  font-size: 0.95rem;
}

.thc-ranking__elo {
  margin: 12px 0 10px;
  font-size: 0.95rem;
  font-weight: 400;
}

.thc-ranking-card__elo-line {
  margin-top: 10px;
}

.thc-ui-card__actions {
  margin-top: 14px;
}

.thc-ranking__table-wrap {
  display: none;
}

.thc-ranking__cell-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.thc-ranking__position-arrow {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  flex: 0 0 auto;
}

.thc-ranking__position-arrow.is-up {
  background-image: url("../icons/arrow-up-solid-full.svg");
}

.thc-ranking__position-arrow.is-down {
  background-image: url("../icons/arrow-down-solid-full-2.svg");
}

.thc-ranking__delta-text {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--thc-color-text-soft);
}

.thc-ranking__delta-text.is-up {
  color: var(--thc-color-success);
}

.thc-ranking__delta-text.is-down {
  color: var(--thc-color-danger);
}

.thc-ranking__delta-text.is-flat {
  color: var(--thc-color-text-soft);
}

.thc-ranking__player {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thc-ranking__name {
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.35;
}

.thc-ranking__position,
.thc-ranking__elo {
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.2;
}

.thc-ranking__elo {
  margin: 0;
}

.thc-ranking__action {
  display: flex;
  justify-content: flex-start;
}

.thc-ranking__action .thc-ui-btn {
  min-height: 38px;
  min-width: 122px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 400;
}

.thc-ranking__action-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  min-width: 122px;
  padding: 0 12px;
  border-radius: var(--thc-radius-md);
  border: 1px solid var(--thc-color-border);
  background: #f1f4f7;
  color: #90a0b1;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
}

.thc-ranking-card__action .thc-ui-btn,
.thc-ranking-card__action .thc-ranking__action-state {
  width: auto;
  min-height: 34px;
  min-width: 112px;
  padding: 6px 12px;
  font-size: 0.95rem;
  border-radius: 12px;
}

.thc-ranking-card__action .thc-ranking__action-state {
  justify-content: center;
}

.thc-open-challenge-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.thc-open-challenge-card__role {
  margin: 4px 0 0;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--thc-color-text-soft);
}

.thc-ui-status-chip,
.thc-open-challenge-card__status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--thc-color-border);
  background: #f3f6fa;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--thc-color-text-soft);
  white-space: nowrap;
}

.thc-open-challenge-card__status-chip.is-pending {
  color: #8a5a00;
  background: rgba(138, 90, 0, 0.08);
}

.thc-open-challenge-card__status-chip.is-scheduled {
  color: var(--thc-color-primary);
  background: rgba(0, 76, 158, 0.1);
}

.thc-open-challenge-card__meta-row {
  margin-bottom: 12px;
}

.thc-open-challenge-card__meta {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--thc-color-text-soft);
}

.thc-open-challenge-card__hint {
  margin: 10px 0 0;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--thc-color-text-soft);
}

.thc-schedule-form__error {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--thc-color-danger);
}

.thc-schedule-form__error.is-visible {
  display: block;
}

.thc-open-challenge-card__form,
.thc-challenge-sheet__grid,
.thc-ladder-challenges form,
.thc-ladder-admin form,
.thc-ladder-inline-form {
  display: grid;
  gap: 12px;
}

.thc-open-challenge-card__form label,
.thc-challenge-sheet__grid label,
.thc-ladder-challenges label,
.thc-ladder-admin label,
.thc-ladder-inline-form label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

.thc-ladder-settings-form {
  display: grid;
  gap: 18px;
  padding-bottom: 18px;
}

.thc-ladder-settings-stack {
  display: grid;
  gap: 22px;
}

.thc-ladder-settings-block {
  display: grid;
  gap: 10px;
}

.thc-ladder-settings-form--create-season {
  gap: 12px;
  padding-bottom: 0;
}

.thc-ladder-settings-grid {
  display: grid;
  gap: 14px;
}

.thc-ladder-settings-grid label,
.thc-ladder-settings-admin-users label {
  display: grid;
  gap: 8px;
  margin: 0;
}

.thc-ladder-settings-create-season {
  display: grid;
  gap: 8px;
}

.thc-ladder-settings-inline-action {
  display: grid;
  gap: 10px;
}

.thc-ladder-settings-inline-action .thc-ui-btn {
  justify-self: flex-start;
}

.thc-ladder-settings-admin-layout {
  display: grid;
  gap: 16px;
}

.thc-ladder-settings-admin-users {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
}

.thc-ladder-settings-admin-users legend {
  margin: 0;
  font-weight: 700;
}

.thc-ladder-settings-selected-box h4 {
  margin: 0 0 8px;
}

.thc-ladder-settings-selected-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.thc-ladder-settings-form .thc-ui-btn {
  justify-self: flex-start;
}

@media (min-width: 700px) {
  .thc-ladder-settings-inline-action {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
}

.thc-open-challenge-card__actions > .thc-ui-btn {
  width: 100%;
}

.thc-match-table-wrap {
  margin-top: 6px;
}

.thc-match-table {
  table-layout: auto;
}

.thc-match-table__date {
  width: 122px;
  min-width: 122px;
  vertical-align: middle;
}

.thc-match-table__date-label {
  display: block;
  font-size: inherit;
  color: var(--thc-color-text-soft);
}

.thc-match-table__flag {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(0, 76, 158, 0.08);
  color: var(--thc-color-primary);
  font-size: 0.74rem;
  font-weight: 700;
}

.thc-match-table__player {
  min-width: 132px;
}

.thc-match-table__player-name {
  display: block;
  font-size: inherit;
  line-height: 1.3;
}

.thc-match-table__row.is-winner .thc-match-table__player-name {
  font-weight: 700;
  color: var(--thc-color-text);
}

.thc-match-table__row.is-loser .thc-match-table__player-name {
  font-weight: 400;
  color: var(--thc-color-text-soft);
}

.thc-match-table__empty {
  text-align: center;
  color: var(--thc-color-text-soft);
  font-size: 0.88rem;
}

.thc-match-table__sets {
  text-align: center;
}

.thc-match-table__sets-main {
  display: block;
  font-size: inherit;
  font-weight: 700;
  line-height: 1.3;
}

.thc-match-table__sets-extra {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1;
  color: var(--thc-color-text-soft);
}

.thc-match-table__set-col {
  display: none;
}

.thc-match-table__more {
  margin: 12px 0 0;
  text-align: center;
}

.thc-challenge-modal {
  position: fixed;
  inset: 0;
  display: none;
  background: var(--thc-color-backdrop);
  padding: max(24px, env(safe-area-inset-top, 0px) + 12px) 14px 14px;
  z-index: 9999;
}

.thc-challenge-modal.is-open {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.thc-challenge-sheet__dialog {
  width: min(100%, 640px);
  max-height: calc(100dvh - 38px);
  overflow: auto;
  background: var(--thc-color-surface);
  border-radius: 24px 24px 0 0;
  padding: 18px;
  font-size: 1rem;
  line-height: 1.45;
  box-shadow: 0 20px 60px rgba(8, 24, 48, 0.24);
}

.thc-challenge-sheet__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.thc-challenge-sheet__title {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.thc-challenge-sheet__intro,
.thc-challenge-sheet__hint {
  margin: 6px 0 0;
  color: var(--thc-color-text-soft);
}

.thc-challenge-sheet__intro {
  font-size: 1rem;
  line-height: 1.4;
}

.thc-challenge-sheet__hint {
  font-size: 0.95rem;
  line-height: 1.45;
}

.thc-challenge-sheet__header .thc-ui-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.thc-challenge-sheet__impact {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--thc-color-secondary-surface);
  border: 1px solid #eadfbd;
  border-radius: var(--thc-radius-md);
}

.thc-challenge-sheet__impact p {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.thc-challenge-sheet__impact span {
  color: var(--thc-color-text-soft);
}

.thc-challenge-sheet__impact strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--thc-color-text);
}

.thc-challenge-sheet__actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.thc-challenge-modal .thc-ui-btn {
  border-style: solid;
  border-width: 1px;
}

.thc-challenge-modal .thc-ui-btn--ghost {
  border-color: var(--thc-color-border);
}

.thc-challenge-modal .thc-ui-btn--secondary {
  border-color: #eadfbd;
}

.thc-challenge-modal .thc-ui-btn--primary {
  border-color: rgba(9, 36, 68, 0.28);
}

.thc-score-entry {
  margin-top: 12px;
}

.thc-score-entry__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.thc-score-entry__summary-label,
.thc-score-entry__subtitle,
.thc-score-entry__hint {
  color: var(--thc-color-text-soft);
}

.thc-score-entry__summary {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.thc-score-entry__summary-label,
.thc-score-entry__summary-value {
  display: block;
}

.thc-score-entry__summary-value {
  font-size: 1.35rem;
  color: var(--thc-color-primary);
}

.thc-score-entry__board {
  border: 1px solid var(--thc-color-border);
  border-radius: var(--thc-radius-md);
  overflow: hidden;
}

.thc-score-entry__head {
  display: none;
  grid-template-columns: minmax(64px, 96px) 1fr 24px 1fr 120px;
  gap: 10px;
  padding: 12px;
  background: var(--thc-color-bg);
  font-size: 0.86rem;
  font-weight: 700;
}

.thc-score-entry__rows {
  display: grid;
}

.thc-score-entry__set-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--thc-color-border);
}

.thc-score-entry__set-row:first-child {
  border-top: 0;
}

.thc-score-entry__set-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.thc-score-entry__player {
  display: grid;
  gap: 6px;
}

.thc-score-entry__mobile-name {
  color: var(--thc-color-text-soft);
  font-size: 0.85rem;
}

.thc-score-entry__separator {
  display: none;
}

.thc-ui-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--thc-color-bg);
  border: 1px solid var(--thc-color-border);
  font-size: 0.78rem;
  font-weight: 700;
}

.thc-admin-table {
  min-width: 860px;
}

.thc-ui-match-score {
  display: grid;
  gap: 8px;
}

.thc-ui-match-score__summary {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
  color: var(--thc-color-primary);
}

.thc-ui-match-score__sets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thc-ui-set-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--thc-color-border);
  background: #f3f6fa;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--thc-color-text-soft);
}

.thc-score-entry-form__current {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.thc-score-entry-form__current-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--thc-color-border);
  background: #f3f6fa;
  font-size: 0.82rem;
  font-weight: 700;
}

@media (min-width: 700px) {
  .thc-match-table__set-col {
    display: table-cell;
  }

  .thc-open-challenge-card__form,
  .thc-challenge-sheet__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .thc-challenge-sheet__grid .thc-challenge-sheet__field--full {
    grid-column: 1 / -1;
  }

  .thc-open-challenge-card__actions > .thc-ui-btn {
    width: auto;
    min-width: 160px;
  }

  .thc-challenge-sheet__actions {
    grid-template-columns: 1fr 1fr;
  }

  .thc-score-entry__head {
    display: grid;
  }

  .thc-score-entry__set-row {
    grid-template-columns: minmax(64px, 96px) 1fr 24px 1fr 120px;
    align-items: center;
  }

  .thc-score-entry__mobile-name {
    display: none;
  }

  .thc-score-entry__separator {
    display: inline;
    text-align: center;
    font-weight: 700;
  }

}

@media (min-width: 960px) {
  .thc-ranking__list {
    display: none;
  }

  .thc-ranking__table-wrap {
    display: block;
  }

  .thc-challenge-modal.is-open {
    align-items: center;
  }

  .thc-challenge-sheet__dialog {
    border-radius: 22px;
    padding: 24px;
  }
}
