:root {
  color-scheme: light;
  /* iOS-style grouped background: light, soft, low saturation */
  --bg: #eef3ec;
  --bg-grouped: #f2f5f0;
  --panel: #ffffff;
  --ink: #1b231c;
  --muted: #6b7670;
  --accent: #2f7d32;
  --accent-dark: #1f5f24;
  --line: #e2e8df;
  --separator: rgba(60, 70, 60, 0.12);
  --soft: #eef5ec;
  --danger: #d23b30;
  /* Softer, tighter iOS-style elevation */
  --shadow: 0 1px 2px rgba(20, 40, 20, 0.06), 0 8px 24px rgba(20, 40, 20, 0.06);
  /* iOS radii */
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Plus Jakarta Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

button,
input {
  font: inherit;
}

/* iOS-style controls: rounded-rect, filled, with press feedback */
button {
  -webkit-tap-highlight-color: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  padding: 0.7rem 1.05rem;
  transition: transform 0.12s var(--ease), background-color 0.15s ease,
    border-color 0.15s ease, opacity 0.15s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

/* The signature iOS tap: a subtle press-in scale */
button:active {
  transform: scale(0.97);
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  max-width: 760px;
  margin-bottom: 24px;
}

/* Tighten the gap before the player view's segmented tabs */
.hero:has(+ .form-error + .view-tabs),
.hero:has(+ .view-tabs) {
  margin-bottom: 10px;
}

/* Collapse the load-error placeholder when it has no message */
#load-error {
  margin: 0;
}

#load-error:empty {
  display: none;
}

.hero h1,
.toolbar h2,
.section-heading h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
}

.hero-copy {
  color: var(--muted);
  font-size: clamp(0.95rem, 1.35vw, 1.08rem);
  line-height: 1.6;
  margin: 16px 0 0;
  max-width: 52ch;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.panel,
.round-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.setup-panel,
.verification-panel {
  padding: 22px;
}

.section-heading,
.toolbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.section-heading p {
  color: var(--muted);
  margin: 6px 0 0;
}

.setup-panel .section-heading {
  margin-bottom: 20px;
}

#pane-settings .section-heading {
  margin-bottom: 22px;
}

/* Password fields don't need full panel width */
#password-form .field input {
  max-width: 360px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  padding-inline: 0;
}

.player-textarea {
  display: block;
  margin: 24px 0;
}

.player-textarea span {
  color: var(--muted);
  display: block;
  font-size: 0.83rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.player-textarea textarea {
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.7;
  min-height: 250px;
  padding: 1rem 1.1rem;
  resize: vertical;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.player-textarea textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 125, 50, 0.12);
  outline: none;
}

.player-textarea textarea[aria-invalid="true"] {
  border-color: var(--line);
}

.form-help,
.form-error {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-top: 8px;
}

.form-help {
  color: var(--muted);
}

.form-error {
  color: var(--danger);
  min-height: 1.2em;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 220px;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* iOS-style filled buttons dim on press rather than only scaling */
.primary-button:active {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.schedule-shell {
  margin-top: 28px;
}

.hidden {
  display: none !important;
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.round-list {
  display: grid;
  gap: 10px;
}

.print-note {
  display: none;
}

.round-card {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 86px 1fr;
  padding: 14px 24px 14px 20px;
}

.round-card h3 {
  color: var(--accent-dark);
  font-size: 1.05rem;
  margin: 0;
}

.game-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  width: 100%;
}

.game-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
}

.court-label {
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.matchup {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto 1fr;
}

.team {
  background: var(--panel);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
  min-height: 0;
  padding: 10px 12px;
  text-align: center;
}

.versus {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.verification-panel {
  margin-top: 18px;
}

.verification-panel summary {
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 900;
}

.check-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 18px 0;
}

.check {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}

.check span {
  color: var(--accent-dark);
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.check.fail span {
  color: var(--danger);
}

.check p {
  margin: 0;
}

.rotation-note {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 16px;
  padding: 12px 16px;
}

.schedule-id {
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin: 6px 0 0;
}

.court-sequence {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
}

.court-badge {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.court-1 {
  background: rgba(47, 125, 50, 0.15);
  color: var(--accent-dark);
}

.court-2 {
  background: rgba(31, 95, 36, 0.55);
  color: #ffffff;
}

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

.table-card {
  background: #fbfdf9;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
}

.table-card.wide {
  grid-column: 1 / -1;
}

.table-card h3 {
  margin: 0 0 12px;
}

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

table {
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem;
  text-align: left;
  white-space: nowrap;
}

thead th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.matrix-table th,
.matrix-table td {
  text-align: center;
}

.matrix-table tbody th {
  text-align: left;
}

/* Keep the header + trailing button on one row, button right-aligned, even on
   mobile (overrides the global toolbar column-stacking). */
.standings-toolbar,
.scores-toolbar {
  align-items: center;
  flex-direction: row;
  flex-wrap: nowrap;
}

.standings-toolbar > div,
.scores-toolbar > div {
  min-width: 0;
}

.scores-toolbar #change-player {
  flex-shrink: 0;
}

/* "Live" badge: signals standings auto-update */
.live-badge[hidden] {
  display: none;
}

.live-badge {
  align-items: center;
  background: rgba(47, 125, 50, 0.12);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 6px;
  padding: 0.35rem 0.7rem;
}

/* "Complete" badge: shown when every score is in (mirrors the Live badge) */
.complete-badge {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 5px;
  padding: 0.35rem 0.7rem;
}

.complete-badge[hidden] {
  display: none;
}

.live-badge::before {
  background: var(--accent);
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 8px;
  width: 8px;
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Standings: even out columns. Rank + numeric columns get equal fixed
   widths; Player takes the remaining space. */
.standings-table {
  table-layout: fixed;
  width: 100%;
}

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

.standings-table th:first-child,
.standings-table td:first-child {
  width: 11%;
}

/* Player column kept narrow so the three numeric columns shift left and the
   last header ("Games Completed") isn't clipped against the table edge. */
.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  width: 22%;
}

/* Points + Wins equal width (uniform spacing); Games Completed slightly wider
   so its two-line header fits without clipping. */
.standings-table th:nth-child(3),
.standings-table td:nth-child(3),
.standings-table th:nth-child(4),
.standings-table td:nth-child(4) {
  width: 20%;
}

.standings-table th:nth-child(5),
.standings-table td:nth-child(5) {
  width: 27%;
}

/* Let headers/cells wrap within their fixed width instead of clipping */
.standings-table thead th,
.standings-table td {
  white-space: normal;
}

/* Slightly smaller header text so "GAMES COMPLETED" fits on two clean lines */
.standings-table thead th {
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

/* Give the last column ("Games Completed") a hair more room on the right */
.standings-table th:last-child,
.standings-table td:last-child {
  padding-right: 0.7rem;
}

.standings-table th,
.standings-table td {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

/* ---- Admin login ---- */

.login-screen {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.login-screen.hidden {
  display: none !important;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 28px 26px;
  width: min(400px, 100%);
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}

.login-logo {
  align-items: center;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(31, 95, 36, 0.3);
  display: inline-flex;
  height: 62px;
  justify-content: center;
  margin-bottom: 16px;
  width: 62px;
}

.login-brand h1 {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin: 0;
}

.login-brand p {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  margin: 6px 0 0;
}

.login-submit {
  width: 100%;
}

.primary-button.is-loading {
  opacity: 0.8;
}

.login-foot {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 18px 0 0;
  text-align: center;
}

/* ---- Admin shell with left sidebar nav ---- */

.admin-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.admin-shell[hidden] {
  display: none;
}

.admin-nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.admin-brand {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  padding: 0 8px;
}

.admin-logo {
  border-radius: 11px;
  display: inline-block;
  height: 38px;
  width: 38px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(20, 40, 20, 0.12);
}

.admin-brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-brand-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.admin-badge {
  align-self: flex-start;
  padding: 3px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3a9a3e 0%, #2f7d32 45%, #1f5f24 100%);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(31, 95, 36, 0.35);
}

.admin-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-tab {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--ink);
  display: flex;
  font-weight: 600;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  text-align: left;
  width: 100%;
}

.admin-tab .tab-icon {
  flex-shrink: 0;
}

.admin-tab .tab-label-short {
  display: none;
}

.admin-tab:hover,
.admin-tab:focus-visible {
  background: var(--bg-grouped);
  border: 0;
}

.admin-tab.active {
  background: rgba(47, 125, 50, 0.12);
  color: var(--accent-dark);
}

.admin-signout {
  align-items: center;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  justify-content: center;
  min-width: 220px;
  padding: 0.85rem 1.1rem;
  text-align: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.admin-signout:hover,
.admin-signout:focus-visible {
  background: var(--danger);
  color: #ffffff;
}

/* Consistent vertical spacing between stacked panels in any admin pane
   (e.g. New session + Sessions, Change password + Account). */
.admin-pane .panel + .panel {
  margin-top: 20px;
}

.admin-content {
  padding: 36px 0 64px;
  width: min(900px, calc(100% - 48px));
}

.admin-pane.hidden {
  display: none;
}

@media (max-width: 760px) {
  .admin-shell {
    display: block;
  }

  .admin-nav {
    border-bottom: 1px solid var(--separator);
    border-right: 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    align-items: center;
    justify-content: center;
    padding: 22px 16px calc(12px + env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--panel);
  }

  .admin-brand {
    margin-bottom: 0;
    margin-right: 0;
    gap: 10px;
    padding: 0;
  }

  .admin-logo {
    height: 34px;
    width: 34px;
  }

  /* Title + badge sit inline for a compact, app-like header */
  .admin-brand-text {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .admin-brand-name {
    font-size: 1rem;
  }

  .admin-badge {
    padding: 2px 8px;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    box-shadow: none;
  }

  /* Menu becomes a fixed bottom tab bar with stacked icon + label */
  .admin-menu {
    background: var(--panel);
    border-top: 1px solid var(--line);
    bottom: 0;
    box-shadow: 0 -2px 12px rgba(20, 40, 20, 0.08);
    flex-direction: row;
    gap: 0;
    left: 0;
    order: 3;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    width: 100%;
    z-index: 50;
  }

  .admin-tab {
    align-items: center;
    border-radius: 12px;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    padding: 0.4rem 0.2rem;
    text-align: center;
  }

  .admin-tab .tab-label {
    font-size: 0.68rem;
    font-weight: 600;
  }

  .admin-tab[data-pane="generate"] .tab-label {
    display: none;
  }

  .admin-tab[data-pane="generate"] .tab-label-short {
    display: inline;
    font-size: 0.68rem;
    font-weight: 600;
  }

  .admin-tab.active {
    background: transparent;
    color: var(--accent-dark);
  }

  .admin-signout {
    min-width: 0;
    width: 100%;
  }

  .admin-content {
    padding: 22px 0 calc(80px + env(safe-area-inset-bottom));
    width: min(900px, calc(100% - 32px));
  }
}

/* ---- Admin + player app components ---- */

.field {
  display: block;
  margin: 0 0 18px;
}

.field span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 7px;
}

.field input {
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.88rem 1rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* iOS Safari gives date/number inputs an intrinsic width that ignores
   width:100% and overflows the card; reset the native appearance so they
   shrink to their container. */
.field input[type="date"],
.field input[type="number"] {
  -webkit-appearance: none;
  appearance: none;
}

/* After resetting -webkit-appearance, iOS collapses the date input's line
   box so it ends up shorter than the other fields; pin a matching height. */
.field input[type="date"] {
  min-height: calc(1.4em + 1.76rem + 2px);
  text-align: left;
}

/* WebKit centers the date text inside its value container by default;
   left-align it once a date is picked. */
.field input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

.field input:focus {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(47, 125, 50, 0.15);
  outline: none;
}

.share-row {
  display: flex;
  gap: 10px;
  margin: 18px 0 12px;
}

.share-row input {
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.85rem 1rem;
}

.share-actions {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
}

.qr-code canvas {
  border: 1px solid var(--line);
  border-radius: 14px;
}

/* iOS-style segmented control */
.view-tabs {
  background: rgba(60, 70, 60, 0.08);
  border-radius: var(--radius-md);
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  padding: 3px;
}

.view-tabs[hidden] {
  display: none;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 11px;
  color: var(--ink);
  flex: 1;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
}

.tab:hover,
.tab:focus-visible {
  border: 0;
}

.tab.active {
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(20, 40, 20, 0.12);
  color: var(--accent-dark);
}

.tab.active:active {
  transform: none;
}

.player-chip-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-top: 18px;
}

.player-chip {
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.95rem 1rem;
}

/* Match card stacks: a header row (R# + centered court) then the score form */
.match-card {
  display: block;
}

.match-header {
  align-items: center;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  margin-bottom: 12px;
}

.match-header h3 {
  grid-column: 1;
  justify-self: start;
  margin: 0;
}

.match-header .court-label {
  grid-column: 2;
  justify-self: center;
  margin: 0;
}

.match-header .edit-score {
  grid-column: 3;
  justify-self: end;
}

.match-card.mine-a,
.match-card.mine-b {
  border-color: var(--accent);
}

/* Edit/pencil button: small, icon-only, only shown in saved mode */
.edit-score {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  display: none;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.edit-score:hover,
.edit-score:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* --- Saved vs edit mode toggling --- */
.score-board,
.board-status {
  display: none;
}

.match-card.is-saved .match-form {
  display: none;
}

.match-card.is-saved .score-board {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
}

.match-card.is-saved .board-status {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 10px 0 0;
  text-align: center;
}

.match-card.is-saved .edit-score {
  display: inline-flex;
}

/* Scoreboard look */
.board-team {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  text-align: center;
}

.board-team.is-mine {
  background: rgba(47, 125, 50, 0.12);
  border-color: var(--accent);
}

.board-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.board-points {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.board-dash {
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 700;
}

.match-form {
  width: 100%;
}

.score-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
}

.score-team {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: block;
  padding: 10px 12px;
  text-align: center;
}

.score-team.is-mine {
  background: rgba(47, 125, 50, 0.12);
  border-color: var(--accent);
}

.score-team span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.score-team input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 3.6rem;
  font-weight: 800;
  min-height: 128px;
  padding: 0.7rem;
  text-align: center;
  width: 100%;
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.score-team input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 50, 0.15);
  outline: none;
}

/* Hide the number input up/down spinner arrows. */
.score-team input::-webkit-outer-spin-button,
.score-team input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.match-actions {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.match-actions .primary-button {
  min-width: 0;
  padding: 0.85rem 1.2rem;
  width: 100%;
}

.match-status {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}


.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.events-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.users-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.create-user-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.create-user-form .primary-button {
  justify-self: start;
}

.user-row {
  align-items: center;
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  padding: 14px 16px;
}

.user-row .delete-user {
  order: 2;
  margin-left: auto;
}

.user-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.user-meta strong {
  font-size: 1rem;
}

.user-joined {
  color: var(--muted);
  font-size: 0.8rem;
}

.event-row {
  align-items: center;
  background: var(--bg-grouped);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
  position: relative;
}

/* Trash icon button (delete) */
.icon-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--danger);
  display: inline-flex;
  justify-content: center;
  padding: 0.45rem;
  line-height: 0;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.icon-button.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Desktop: trash sits inline at the end of the row, vertically centered with
   the action buttons. */
.event-row .delete-event {
  order: 3;
  align-self: center;
}

/* Copied confirmation state on copy buttons */
.copy-event.is-copied,
#copy-link.is-copied {
  border-color: var(--accent);
  color: var(--accent);
}

.check-icon {
  margin-right: 0.35rem;
  vertical-align: -2px;
}

.event-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: auto;
}

.event-meta strong {
  font-size: 1rem;
}

.event-meta span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.event-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.event-actions button {
  padding: 0.5rem 0.9rem;
}

/* Pill action buttons for Players / Standings (replaces plain text links) */
.event-link {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 600;
  gap: 0.4rem;
  line-height: 1;
  padding: 0.5rem 0.95rem;
  text-decoration: none;
  transition: transform 0.12s var(--ease), background-color 0.15s ease,
    border-color 0.15s ease, color 0.15s ease;
}

.event-link svg {
  flex-shrink: 0;
}

.event-link:hover,
.event-link:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.event-link:active {
  transform: scale(0.97);
}

.danger-button {
  border-color: var(--danger);
  color: var(--danger);
}

.danger-button:hover,
.danger-button:focus-visible {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

/* Modal confirmation dialog (replaces window.confirm/alert) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(20, 30, 20, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}

.modal-overlay.is-open {
  opacity: 1;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.5rem 1.25rem;
  transform: translateY(8px) scale(0.97);
  opacity: 0;
  transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
}

.modal-overlay.is-open .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-message {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.modal-actions button {
  padding: 0.6rem 1.1rem;
}

@media (max-width: 460px) {
  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}

.place {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

/* Gold/silver/bronze medal badges for the top 3 placements */
.medal-badge {
  align-items: center;
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.medal-badge.medal-1 {
  background: linear-gradient(150deg, #f7d774, #d4af37);
  box-shadow: 0 2px 6px rgba(212, 175, 55, 0.45);
  color: #5c4a00;
}

.medal-badge.medal-2 {
  background: linear-gradient(150deg, #e8ebee, #b6bcc4);
  box-shadow: 0 2px 6px rgba(150, 158, 168, 0.4);
  color: #44505c;
}

.medal-badge.medal-3 {
  background: linear-gradient(150deg, #e0a479, #b06a3b);
  box-shadow: 0 2px 6px rgba(176, 106, 59, 0.4);
  color: #4a2a13;
}

tr.podium {
  background: rgba(47, 125, 50, 0.1);
}

@media (max-width: 860px) {
  .hero h1 {
    white-space: normal;
  }

  .hero-copy {
    white-space: normal;
  }

  .game-grid,
  .check-list,
  .verification-grid {
    grid-template-columns: 1fr;
  }

  .round-card {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .section-heading,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  /* Standings + scores keep their trailing button on the right, same row */
  .toolbar.standings-toolbar,
  .toolbar.scores-toolbar {
    align-items: center;
    flex-direction: row;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }
}

/* Phones */
@media (max-width: 600px) {
  .page {
    padding: 24px 0 48px;
    width: min(1120px, calc(100% - 24px));
  }

  .hero {
    margin-bottom: 18px;
  }

  .setup-panel,
  .verification-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .panel,
  .round-card {
    border-radius: 20px;
  }

  /* Full-width, thumb-friendly buttons */
  .button-row {
    flex-direction: column;
  }

  .button-row .primary-button,
  .primary-button {
    min-width: 0;
    width: 100%;
  }

  /* Bigger tap targets */
  button {
    padding: 0.85rem 1rem;
  }

  /* Share link + copy stack vertically */
  .share-row {
    flex-direction: column;
  }

  .share-row button {
    width: 100%;
  }

  .share-actions {
    flex-direction: column;
    gap: 10px;
  }

  .qr-code canvas {
    height: auto;
    max-width: 100%;
  }

  /* Events list rows stack into tidy cards */
  .event-row {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }

  /* Mobile: pin the trash icon to the top-right of the card */
  .event-row .delete-event {
    position: absolute;
    top: 14px;
    right: 14px;
    order: 0;
  }

  .event-meta {
    gap: 4px;
    padding-right: 44px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--separator);
  }

  .event-meta strong {
    font-size: 1.05rem;
  }

  /* Player / Standings share a row; Copy link expands full width below */
  .event-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .event-actions a,
  .event-actions button {
    flex: none;
    width: 100%;
    margin: 0;
    text-align: center;
    padding: 0.85rem 0.75rem;
  }

  .event-actions .event-link {
    justify-content: center;
  }

  .event-actions .copy-event {
    grid-column: 1 / -1;
  }

  /* Score entry: keep teams readable, stack the row */
  .match-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .match-card h3 {
    color: var(--accent-dark);
  }

  .score-row {
    gap: 8px;
  }

  .score-team {
    padding: 10px 8px;
  }

  .score-team span {
    font-size: 0.8rem;
  }

  .score-team input {
    font-size: 3.2rem;
    min-height: 120px;
    padding: 0.65rem 0.4rem;
  }

  /* Player picker chips: two columns on phones */
  .player-chip-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Tabs span full width and split evenly */
  .view-tabs {
    width: 100%;
  }

  .view-tabs .tab {
    flex: 1;
  }

  /* Standings table: tighten so it fits without internal scroll */
  table {
    font-size: 0.88rem;
  }

  th,
  td {
    padding: 0.55rem 0.4rem;
  }

  .table-card {
    padding: 14px;
  }

  .login-card {
    padding: 28px 22px 22px;
  }
}

/* Prevent iOS input auto-zoom: inputs must be >= 16px. The score inputs use a
   larger font already, so they're excluded here to stay big. */
@media (max-width: 600px) {
  .field input,
  .share-row input,
  .player-textarea textarea {
    font-size: 16px;
  }

  #password-form .field input {
    max-width: none;
  }
}

@media print {
  @page {
    margin: 0;
    size: letter portrait;
  }

  :root {
    --bg: #ffffff;
    --ink: #000000;
    --line: #999999;
    --soft: #ffffff;
    --shadow: none;
  }

  body {
    background: #ffffff;
    font-size: 11px;
  }

  button,
  .hero,
  .setup-panel,
  .toolbar-actions,
  .verification-panel {
    display: none !important;
  }

  .page {
    box-sizing: border-box;
    padding: 0.35in;
    width: 100%;
  }

  .schedule-shell {
    margin: 0;
  }

  .toolbar {
    display: block;
    margin-bottom: 6px;
  }

  .toolbar .eyebrow,
  .schedule-id {
    display: none;
  }

  .toolbar h2 {
    font-size: 1rem;
    margin: 0 0 4px;
  }

  .toolbar h2 {
    font-size: 0;
  }

  .toolbar h2::before {
    content: "Pickleball Round Robin Schedule";
    font-size: 1rem;
  }

  .round-list {
    gap: 2px;
  }

  .round-card {
    align-items: center;
    break-inside: avoid;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    gap: 6px;
    grid-template-columns: 58px 1fr;
    padding: 4px 0;
  }

  .round-card h3 {
    font-size: 0.82rem;
    margin: 0;
  }

  .game-grid {
    gap: 4px;
    grid-template-columns: repeat(2, 1fr);
  }

  .game-card {
    border-radius: 0;
    padding: 4px 5px;
  }

  .court-label {
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    margin-bottom: 3px;
  }

  .matchup {
    gap: 4px;
  }

  .team {
    border-radius: 0;
    font-size: 0.72rem;
    min-height: 0;
    padding: 4px 5px;
  }

  .versus {
    font-size: 0.58rem;
  }

  .game-card,
  .team {
    border-color: #cccccc;
  }

  .print-note {
    display: block;
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1.15;
    margin-top: 18px;
    text-align: center;
  }

  .print-note p {
    margin: 0 0 18px;
  }

  .print-note-finale {
    text-decoration: underline;
    text-underline-offset: 0.12em;
  }
}

/* ===================================================================
   Public sign-up landing page
   =================================================================== */
.landing-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--separator);
}

.landing-header-inner {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 auto;
  padding: 12px 16px;
  width: min(1120px, calc(100% - 16px));
}

.landing-header-inner .admin-brand {
  margin-top: 4px;
  margin-bottom: 0;
}

.landing-login {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  text-decoration: none;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease);
}

.landing-login:hover,
.landing-login:focus-visible {
  background: var(--accent-dark);
}

.landing-login:active {
  transform: scale(0.97);
}

.landing.page {
  width: min(900px, calc(100% - 32px));
  padding: 32px 0 80px;
}

.landing-intro h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.landing-intro p {
  color: var(--muted);
  margin: 0 0 24px;
}

.landing-events {
  display: grid;
  gap: 16px;
}

.landing-loading,
.landing-empty,
.landing-error {
  color: var(--muted);
  padding: 8px 0;
}

.landing-error {
  color: var(--danger);
}

/* Session cards */
.event-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.event-card-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.event-card-title {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}

.event-card-date {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}

.event-card-count {
  background: var(--soft);
  border-radius: 999px;
  color: var(--accent-dark);
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 12px;
  white-space: nowrap;
}

.event-card-status {
  border-radius: var(--radius-md);
  display: inline-block;
  font-size: 0.92rem;
  font-weight: 700;
  margin: 14px 0;
  padding: 10px 14px;
}

.event-card-status.tone-open {
  background: var(--soft);
  color: var(--accent-dark);
}

.event-card-status.tone-waitlist {
  background: #fff4e0;
  color: #9a5b00;
}

.event-card-status.tone-full {
  background: #fdecea;
  color: var(--danger);
}

.event-card-people {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 18px;
}

.people-col h3 {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.signup-names {
  display: grid;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.signup-names li {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: 0.95rem;
  font-weight: 600;
  gap: 8px;
}

.signup-pos {
  background: var(--bg-grouped);
  border-radius: 6px;
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  min-width: 20px;
  padding: 1px 0;
  text-align: center;
}

.signup-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.event-card-actions {
  align-items: center;
  border-top: 1px solid var(--separator);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 16px;
}

.event-card-actions .primary-button {
  min-width: 0;
}

.event-card-actions .primary-button:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

/* Sign-up modal */
.signup-overlay {
  align-items: center;
  background: rgba(20, 30, 22, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  padding: 16px;
  position: fixed;
  transition: opacity 0.2s var(--ease);
  z-index: 1000;
}

.signup-overlay[hidden] {
  display: none;
}

.signup-overlay.is-open {
  opacity: 1;
}

.signup-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(20, 40, 20, 0.25);
  max-width: 420px;
  padding: 24px;
  position: relative;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s var(--ease);
  width: 100%;
}

.signup-overlay.is-open .signup-card {
  transform: translateY(0) scale(1);
}

.signup-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 8px;
  position: absolute;
  right: 12px;
  top: 12px;
}

.signup-card h2 {
  margin: 0 0 2px;
}

.signup-sub {
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 18px;
}

.signup-success {
  color: var(--accent-dark);
  display: block;
  font-weight: 700;
  margin-top: 8px;
}

.signup-toggle {
  display: inline-block;
  margin-top: 10px;
}

.signup-toggle[hidden] {
  display: none;
}

/* Admin: new-session form grid + event tags */
.field-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr 1fr;
}

.field-grid .field {
  min-width: 0;
}

.event-tag {
  background: var(--bg-grouped);
  border-radius: 6px;
  color: var(--muted);
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  margin-top: 2px;
  padding: 2px 8px;
  width: fit-content;
}

.event-tag-signups {
  background: var(--soft);
  color: var(--accent-dark);
}

.signup-roster {
  margin-top: 8px;
  width: 100%;
}

.signup-roster-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.signup-roster-col {
  min-width: 0;
}

.signup-roster-empty {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  margin: 0;
}

.signup-roster-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: decimal;
  margin: 0;
  padding-left: 1.4rem;
}

.signup-roster-names li {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.signup-roster-names li {
  align-items: center;
  display: flex;
  gap: 8px;
}

.signup-roster-name {
  flex: 1;
}

.remove-signup {
  padding: 0.3rem;
}

.remove-signup svg {
  width: 15px;
  height: 15px;
}

.signup-roster-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 8px 0 3px;
  text-transform: uppercase;
}

.signup-roster-waitlist li {
  color: var(--muted);
  font-weight: 500;
}

.generate-event {
  cursor: pointer;
}

@media (max-width: 600px) {
  .event-card-people {
    grid-template-columns: 1fr 1fr;
  }

  .signup-roster-split {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .event-card-actions .primary-button,
  .event-card-actions .link-button {
    width: 100%;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}


/* Auto-dismissing toast notification */
.rr-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  z-index: 1000;
  max-width: min(92vw, 420px);
  padding: 1rem 1.4rem;
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.rr-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
