:root {
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 28rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 0;
}

main.app-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.top {
  flex-shrink: 0;
}

.brand-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  margin: -0.35rem -0.35rem 0;
  padding: 0.35rem 0.35rem 0.15rem;
  outline-offset: 2px;
  transition: background 0.15s ease;
}

.brand-link:focus-visible {
  outline: 2px solid #16a34a;
}

.top h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.brand-link .tag {
  margin: 0 0 1rem;
}

.tag {
  margin: 0 0 1rem;
  color: #64748b;
  font-size: 0.95rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

#players-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

#players-inputs input {
  padding: 0.9rem 1rem;
}

.hidden {
  display: none !important;
}

label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select,
textarea,
button {
  width: 100%;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
}

button {
  cursor: pointer;
  margin-top: 1rem;
  background: #16a34a;
  color: #fff;
  border: none;
  font-weight: 600;
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.row {
  display: flex;
  gap: 0.5rem;
}

.row button {
  flex: 1;
}

.session-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.session-head .secondary {
  margin-top: 0;
}

#view-session .session-block {
  margin: 0;
  padding: 1.35rem 0 0;
}

#view-session .session-block + .session-block {
  margin-top: 0.35rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

#view-session .session-block--first {
  padding-top: 0.65rem;
}

.section-heading {
  margin: 0 0 0.85rem;
  padding: 0 0.05rem;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #0f172a;
  line-height: 1.3;
}

.meta {
  color: #475569;
  font-size: 0.95rem;
}

/* Shared link expired, typo, or never existed */
.not-found-card.card {
  max-width: 23rem;
  margin-inline: auto;
  padding: 1.85rem 1.35rem 1.7rem;
  text-align: center;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 36px rgb(15 23 42 / 7%);
}

.not-found-card .not-found-eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #94a3b8;
}

.not-found-title {
  margin: 0 0 1rem;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.not-found-lede {
  margin: 0 0 1rem;
  font-size: 0.94rem;
  line-height: 1.62;
  color: #475569;
}

.not-found-hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.52;
  color: #64748b;
}

.not-found-card .cta-home-primary {
  margin-top: 0.35rem;
  width: 100%;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid #e2e8f0;
}

.round-board {
  display: grid;
  gap: 0.75rem;
}

.court-card {
  padding: 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.court-card--unused {
  background: #f8fafc;
  color: #64748b;
}

.court-card-head,
.court-score-row,
.court-teams {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.court-status {
  color: #64748b;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.court-teams {
  margin: 0.85rem 0;
}

.court-teams > div {
  flex: 1;
}

.court-score-row label {
  flex: 1;
}

.court-score-row input {
  display: block;
  margin-top: 0.25rem;
}

@media (min-width: 44rem) {
  body {
    max-width: 54rem;
  }

  .round-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Suggested doubles panel: keeps loading state flush with card surface */
#suggestion.card {
  overflow: hidden;
  background-color: #fff;
}

.team-block {
  margin-bottom: 0.75rem;
}

.team-block:last-child {
  margin-bottom: 0;
}

.team-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.suggestion-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.65rem;
  min-height: 5.75rem;
  margin: -1rem;
  padding: 1.5rem 1rem;
  background-color: #fff;
}

/* Shared spinner (replaces PNG); sizes via modifiers */
.app-spinner {
  box-sizing: border-box;
  display: block;
  flex-shrink: 0;
  margin-inline: auto;
  border-radius: 50%;
  border-style: solid;
  border-color: #e8eef4;
  border-top-color: #16a34a;
  animation: spin 0.95s linear infinite;
}

.app-spinner--md {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
}

.app-spinner--lg {
  width: 4.5rem;
  height: 4.5rem;
  border-width: 5px;
}

.suggestion-loading-text {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #475569;
}

.history-side-label {
  display: block;
  width: 100%;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 0 0 0.1rem;
  text-align: center;
}

.hint {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 0.5rem;
}

.standings-hint {
  margin-top: 0.15rem;
  margin-bottom: 0.65rem;
  padding-left: 0.05rem;
}

.standings-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.25rem 0 0.45rem;
  padding: 0.25rem;
  background: #e2e8f0;
  border-radius: 12px;
}

.standings-tab {
  flex: 1;
  margin-top: 0;
  padding: 0.55rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  border: none;
  font-weight: 600;
}

.standings-tab:hover {
  background: rgb(255 255 255 / 50%);
}

.standings-tab--active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgb(15 23 42 / 10%);
}

.standings-tab:focus-visible {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
}

.standings-empty {
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
  padding: 1rem 0.5rem !important;
}

.resting-label {
  margin-top: 0.75rem;
}

.resting-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin: 0.35rem 0 0.5rem;
}

.resting-player-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  user-select: none;
}

.resting-player-option:has(input:checked) {
  border-color: #0f172a;
  background: #e2e8f0;
}

.resting-player-option input {
  margin: 0;
}

.optional-tag {
  font-weight: 400;
  color: #94a3b8;
}

.ad-container {
  margin: 1rem 0;
  min-height: 5rem;
}

.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 5rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.5rem;
  color: #94a3b8;
  font-size: 0.8125rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 1rem;
}

.history-reset-hint {
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.35;
  max-width: 22rem;
}

.history {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.history-item {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.95rem 1.05rem;
  box-shadow: 0 1px 3px rgb(15 23 42 / 8%);
}

.history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.65rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #f1f5f9;
}

.history-when {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  letter-spacing: 0.025em;
  margin: 0;
  padding: 0;
  border-bottom: none;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.history-item-edit,
.history-item-delete {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.14s ease, background 0.14s ease, color 0.14s ease,
    transform 0.12s ease;
}

.history-item-edit {
  background: rgb(241 245 249 / 0.95);
  color: #475569;
}

.history-item-edit:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.history-item-delete {
  background: rgb(254 226 226 / 0.55);
  color: #b91c1c;
}

.history-item-delete:hover {
  background: rgb(254 202 202 / 0.95);
  color: #991b1b;
}

.history-item-edit:active,
.history-item-delete:active {
  transform: scale(0.96);
}

.history-item-edit-icon,
.history-item-delete-icon {
  display: block;
  pointer-events: none;
}

.history-item-edit:focus-visible,
.history-item-delete:focus-visible {
  opacity: 1;
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

@media (hover: hover) {
  .history-item-actions .history-item-edit,
  .history-item-actions .history-item-delete {
    opacity: 0;
  }

  .history-item:hover .history-item-actions .history-item-edit,
  .history-item:hover .history-item-actions .history-item-delete,
  .history-item:focus-within .history-item-actions .history-item-edit,
  .history-item:focus-within .history-item-actions .history-item-delete {
    opacity: 1;
  }
}

@media (hover: none) {
  .history-item-actions .history-item-edit,
  .history-item-actions .history-item-delete {
    opacity: 0.72;
  }
}

.history-score-input {
  box-sizing: border-box;
  width: 3.15rem;
  max-width: 5rem;
  margin: 0;
  padding: 0.38rem 0.35rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.25;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
}

.history-edit-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid #f1f5f9;
}

.history-edit-bar button {
  width: auto;
  margin-top: 0;
  flex: 0 0 auto;
  min-height: 0;
  padding: 0.45rem 0.95rem;
  font-size: 0.875rem;
}

.history-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 0.5rem;
}

.history-side {
  flex: 1 1 38%;
  min-width: 7.5rem;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.45rem;
  text-align: center;
  padding: 0.25rem 0.35rem;
}

.history-players {
  font-weight: 600;
  font-size: 1.02rem;
  color: #0f172a;
  line-height: 1.35;
}

.history-score {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #15803d;
  white-space: nowrap;
}

.history-score--winner::after {
  content: "";
  margin-top: 0.38rem;
  height: 3px;
  width: min(2.75rem, 100%);
  min-width: 1.65em;
  background: #22c55e;
  border-radius: 999px;
  flex-shrink: 0;
}
.history-vs {
  flex: 0 0 auto;
  align-self: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  padding: 0.4rem 0.65rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
}

@media (max-width: 380px) {
  .history-row {
    flex-direction: column;
  }
  .history-vs {
    order: -1;
  }
  .history-side {
    width: 100%;
  }
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: auto;
}

th,
td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

/* Standings: rank + name left; stats centered */
.standings-table th:first-child,
.standings-table td:first-child {
  text-align: left;
  width: 2.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #475569;
}

.standings-table th:first-child {
  text-align: center;
}

.standings-table td.standings-rank-cell {
  text-align: center;
  font-variant-numeric: normal;
  font-size: 1.1rem;
  line-height: 1;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table th:nth-child(n + 3),
.standings-table td:nth-child(n + 3) {
  text-align: center;
  white-space: nowrap;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
}

.pid {
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
  word-break: break-all;
  margin-top: 0.15rem;
}

.loading-card {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgb(15 23 42 / 6%);
}

.loading-title {
  margin: 1rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.loading-hint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #64748b;
  max-width: 22rem;
  margin-inline: auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.site-footer {
  flex-shrink: 0;
  margin-top: 1.75rem;
  padding: 1.25rem 0 1.75rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  padding: 0.65rem 1rem;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgb(15 23 42 / 5%);
}

.version-pill {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #15803d;
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  border: 1px solid #a7f3d0;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
}

.footer-divider {
  width: 1px;
  height: 0.9rem;
  background: #cbd5e1;
}

.footer-tagline {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

.footer-link {
  font-size: 0.78rem;
  color: #15803d;
  font-weight: 500;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 10;
}

/* Session setup — parity multiplier + roster */
.session-setup-hint {
  margin-bottom: 0.75rem;
}

.session-setup-card {
  margin-top: 0.25rem;
}

.session-setup-card button {
  margin-top: 0.85rem;
}

.session-setup-card input[type="checkbox"] {
  width: auto;
}

.session-config-toggles {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.session-config-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  cursor: pointer;
}

.session-config-switch-text {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: #334155;
  line-height: 1.35;
}

.session-config-switch-visual {
  position: relative;
  flex-shrink: 0;
  height: 1.48rem;
  width: 2.95rem;
}

.session-config-switch-input {
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.session-config-switch-input:focus-visible ~ .session-config-switch-track {
  outline: 2px solid #16a34a;
  outline-offset: 3px;
}

.session-config-switch-track {
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  position: relative;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.session-config-switch-track::after {
  content: "";
  position: absolute;
  width: 1.06rem;
  height: 1.06rem;
  border-radius: 50%;
  background: #fff;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  box-shadow: 0 1px 3px rgb(15 23 42 / 18%);
  transition:
    transform 0.18s ease,
    left 0.18s ease;
}

.session-config-switch-visual:has(.session-config-switch-input:checked)
  .session-config-switch-track {
  background: #dcfce7;
  border-color: #86efac;
}

.session-config-switch-visual:has(.session-config-switch-input:checked)
  .session-config-switch-track::after {
  left: calc(100% - 1.06rem - 3px);
}

.session-config-switch-input:disabled {
  cursor: wait;
}

.session-config-switch-input:disabled ~ .session-config-switch-track {
  opacity: 0.55;
}

.session-setup-player-count {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
}

.session-setup-player-list {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.session-setup-player-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
}

.session-setup-player-item--inactive {
  background: #f8fafc;
}

.session-setup-player-item:last-child {
  border-bottom: none;
}

.session-setup-player-main {
  flex: 1 1 auto;
  min-width: 0;
}

.session-setup-player-name {
  font-weight: 600;
}

.session-setup-player-main .pid {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
  word-break: break-all;
  margin-top: 0.2rem;
  text-align: left;
  max-width: none;
}

.session-setup-player-action {
  flex: 0 0 auto;
  max-width: 100%;
}

.session-setup-away {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.35;
  display: block;
}

button.session-remove-player {
  margin-top: 0;
  width: auto;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}
