/* Print-ready sheet styling for generated draws + schedule pages.
   Deliberately independent of styles.css's dark theme — these are read/printed on paper. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.5rem;
  background: #eef1f5;
  color: #111827;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.5;
}

.sheet {
  max-width: 900px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 2rem;
}

.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
  max-width: 900px;
  margin: 0 auto 0.75rem;
}

.sheet-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid #1f2937;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}

.sheet-btn:hover {
  background: #111827;
}

.sheet-btn.secondary {
  background: #fff;
  color: #1f2937;
}

.back-link {
  display: inline-block;
  margin: 0 auto 0.75rem;
  max-width: 900px;
  color: #1f2937;
  font-weight: 700;
  text-decoration: none;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #111827;
  padding-bottom: 1rem;
}

.sheet-logo {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  object-fit: contain;
  background: #fff;
}

.sheet-header .eyebrow {
  margin: 0 0 0.3rem;
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sheet-header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.sheet-meta {
  margin-top: 0.4rem;
  color: #4b5563;
  font-size: 0.85rem;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #111827;
  border-left: 5px solid #111827;
  border-radius: 4px;
  background: #f3f4f6;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.87rem;
  font-weight: 600;
  color: #1f2937;
}

.info-row .info-label {
  flex: 0 0 auto;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: #4b5563;
  min-width: 68px;
}

.info-row.report {
  color: #991b1b;
  font-weight: 800;
}

.info-row.draft {
  padding-top: 0.4rem;
  border-top: 1px dashed #d1d5db;
  color: #92400e;
  font-weight: 600;
  font-size: 0.8rem;
}

.draft-banner {
  margin-bottom: 1.25rem;
  padding: 0.6rem 0.9rem;
  border: 1px dashed #b45309;
  border-radius: 4px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.82rem;
  font-weight: 700;
}

h2.section-title {
  margin: 1.75rem 0 0.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid #d1d5db;
  font-size: 1.25rem;
}

h2.section-title:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

h3.pool-title {
  margin: 1.1rem 0 0.5rem;
  font-size: 1.02rem;
  color: #1f2937;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

th,
td {
  border: 1px solid #d1d5db;
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f4f6;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

td[contenteditable="true"] {
  background: #fffef2;
  outline: 1px dashed #d4d4a8;
}

td[contenteditable="true"]:focus {
  outline: 2px solid #2563eb;
  background: #eff6ff;
}

.bye-row td {
  color: #6b7280;
  font-style: italic;
}

.score-cell:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
  font-weight: 400;
}

.round-block {
  margin-bottom: 1.1rem;
}

.court-col,
.time-col {
  white-space: nowrap;
}

.schedule-table td,
.schedule-table th {
  font-size: 0.78rem;
}

.saved-flag {
  display: none;
  margin-left: 0.5rem;
  color: #15803d;
  font-weight: 700;
  font-size: 0.82rem;
}

/* Perks panel */

.perks-panel {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
  background: #fffbeb;
  break-inside: avoid;
  page-break-inside: avoid;
}

.perks-title {
  margin: 0 0 0.5rem;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
}

.perks-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

@media screen and (min-width: 700px) {
  .perks-list {
    grid-template-columns: 1fr 1fr;
  }
}

.perks-list li {
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.5;
}

.perks-list strong {
  color: #451a03;
}

/* Slot banner: report/start/finish/courts at a glance */

.slot-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid #111827;
  border-radius: 6px;
  background: #111827;
  color: #fff;
}

.slot-banner > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.slot-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

.slot-banner strong {
  font-size: 1.05rem;
}

/* Prize panel */

.prize-panel {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
}

.prize-panel .icon {
  font-style: normal;
  font-size: 1.3rem;
  line-height: 1;
}

.prize-panel p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.prize-panel.eligible {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.prize-panel.none {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.prize-panel.cancelled {
  background: #fef2f2;
  border-color: #dc2626;
  color: #991b1b;
}

/* Pool cards — single-column flow by default (predictable print pagination);
   widens to a grid only on screens comfortably larger than A4, never in print. */

.pool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media screen and (min-width: 900px) {
  .pool-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

.pool-card {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.9rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.pool-card table {
  margin-bottom: 0.5rem;
}

.pool-card table:last-child {
  margin-bottom: 0;
}

/* Knockout bracket — vertical round-by-round flow (Quarterfinal, then
   Semifinal, then Final), each round's matches in a single-column list by
   default so it paginates cleanly; a light 2-up grid appears only on wide
   screens, and print always forces a single column regardless of screen. */

.bracket-round {
  margin-bottom: 1.5rem;
}

.bracket-round:last-child {
  margin-bottom: 0;
}

.bracket-round-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #111827;
  margin-bottom: 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #111827;
}

.bracket-round-title .round-count {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0;
  color: #6b7280;
}

.bracket-matches {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media screen and (min-width: 900px) {
  .bracket-matches {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

.bracket-match {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  break-inside: avoid;
  page-break-inside: avoid;
  background: #fff;
}

.bracket-match-teams {
  flex: 1 1 auto;
  min-width: 0;
}

.bracket-team {
  display: block;
  padding: 0.15rem 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.bracket-vs-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 0.05rem 0;
}

.bracket-match-meta {
  flex: 0 0 auto;
  text-align: right;
  font-size: 0.7rem;
  color: #6b7280;
  white-space: nowrap;
}

.bracket-match-meta .bracket-score {
  display: inline-block;
  margin-top: 0.3rem;
  min-width: 3.5rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  color: #9ca3af;
}

.bracket-score:empty::before {
  content: attr(data-placeholder);
}

.bracket-bye {
  background: #f9fafb;
}

.bracket-bye .bracket-vs-label {
  font-style: italic;
}

/* Stat tiles */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-tile {
  text-align: center;
  padding: 0.9rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
}

.stat-tile strong {
  display: block;
  font-size: 1.6rem;
  color: #111827;
}

.stat-tile span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.stat-tile.cancelled-tile strong {
  color: #dc2626;
}

/* Cancelled treatment */

.strike,
h1.strike {
  color: #6b7280;
}

h1.strike {
  padding-left: 0.6rem;
  border-left: 4px solid #dc2626;
}

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.cancelled-banner {
  border-color: #dc2626 !important;
  color: #991b1b !important;
  background: #fef2f2 !important;
}

@page {
  size: A4;
  margin: 14mm;
}

@media print {
  body {
    background: #fff;
    padding: 0;
  }

  .sheet-toolbar,
  .back-link {
    display: none !important;
  }

  .sheet {
    max-width: none;
    border: 0;
    padding: 0;
  }

  td[contenteditable="true"] {
    outline: none;
    background: transparent;
  }

  h2.section-title {
    break-after: avoid;
    page-break-after: avoid;
  }

  h2.section-title.knockout-title {
    break-before: page;
    page-break-before: always;
  }

  .pool-grid,
  .bracket-matches,
  .perks-list {
    grid-template-columns: 1fr !important;
  }

  .stat-tiles {
    grid-template-columns: repeat(5, 1fr) !important;
  }

  .bracket-match {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .bracket-round-title {
    break-after: avoid;
    page-break-after: avoid;
  }

  .pool-card,
  .bracket-round {
    break-inside: avoid-page;
  }
}
