/*
  Football Squares. Plain CSS, not built by Tailwind. The page around the board
  follows the site's theme tokens; the board and the printed sheet are always
  ink on white, like paper, in dark mode too. Board sizes are container units
  of .fsq-boardbox and sheet sizes of .fsq-sheet, so one drawing scales from a
  phone to a landscape page.
*/

.fsq [hidden] { display: none !important; }
.fsq-alert { padding: 0.75rem 1rem; border: 1px solid var(--color-base-300); border-radius: var(--r-sm, 0.5rem); }
.fsq-loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---- Layout ---- */
.fsq-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 64rem) { .fsq-layout { grid-template-columns: minmax(0, 1fr) 23rem; } }
.fsq-main { min-width: 0; }

/* ---- Typing into a square ---- */
.fsq-editor { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.fsq-editor-label { font-size: 0.875rem; font-weight: 600; }
.fsq-editor-row { display: flex; gap: 0.5rem; align-items: center; }
.fsq-editor input { font-size: 1rem; } /* 16px keeps phones from zooming in */

.fsq-scroll {
  overflow-x: auto;
  padding: 0.5rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-md, 0.875rem);
  background: #fff;
}
/* Below this the names get too small to read, so the board scrolls sideways instead. */
.fsq-scroll .fsq-boardbox { min-width: 32rem; }

.fsq-status { margin-top: 0.6rem; font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fsq-message { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.35rem; font-size: 0.875rem; }
.fsq-message:empty { display: none; }
.fsq-message.is-warn { color: var(--color-error); }
.fsq-message .input { max-width: 100%; }

.fsq-people { margin-top: 1rem; }
.fsq-people-title { font-size: 0.875rem; font-weight: 600; }
.fsq-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.45rem 0 0; padding: 0; list-style: none; }
.fsq-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--color-base-300);
  border-radius: 999px;
  background: var(--color-base-100);
  color: var(--color-base-content);
  font-size: 0.8125rem;
  cursor: pointer;
}
.fsq-chip b { font-variant-numeric: tabular-nums; color: var(--muted); }
.fsq-chip[aria-pressed="true"] { border-color: #d9b300; background: #fff1a8; color: #1d1b22; }
.fsq-chip[aria-pressed="true"] b { color: #5c4a00; }
.fsq-chip:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ---- Settings ---- */
.fsq-panel {
  min-width: 0;
  padding: 0.5rem 1.1rem 1.1rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-md, 0.875rem);
  background: var(--color-base-100);
}
@media (min-width: 40rem) { .fsq-panel { padding: 0.75rem 1.35rem 1.35rem; } }
.fsq-section { display: flex; flex-direction: column; gap: 0.85rem; min-width: 0; margin: 0; padding: 1.1rem 0 0; border: 0; }
.fsq-section + .fsq-section { margin-top: 1.1rem; border-top: 1px solid var(--color-base-300); }
.fsq-section-title { float: left; width: 100%; padding: 0; font-size: 1rem; font-weight: 650; }
.fsq-section-title + * { clear: both; }
.fsq-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.fsq-label { font-size: 0.875rem; font-weight: 600; }
.fsq-optional { margin-left: 0.2rem; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.fsq-hint { font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.fsq-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; align-items: start; }
@media (max-width: 22rem) { .fsq-pair { grid-template-columns: minmax(0, 1fr); } }
.fsq-check { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.9rem; line-height: 1.4; cursor: pointer; }
.fsq-check input { flex: none; margin-top: 0.1rem; }
.fsq-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fsq-buttons .btn { gap: 0.35rem; }
.fsq-panel textarea { font-size: 1rem; line-height: 1.5; }

/* Segmented choice, as on the PDF tools. */
.fsq-seg {
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
  border: 1px solid var(--color-base-300);
  border-radius: 0.625rem;
  background: var(--color-base-100);
}
.fsq-seg label { position: relative; flex: 1 1 auto; cursor: pointer; }
.fsq-seg input { position: absolute; opacity: 0; pointer-events: none; }
.fsq-seg span { display: block; height: 100%; padding: 0.45rem 0.6rem; font-size: 0.8125rem; line-height: 1.3; text-align: center; }
.fsq-seg label + label span { border-left: 1px solid var(--color-base-300); }
.fsq-seg input:checked + span { background: var(--color-base-content); color: var(--color-base-100); font-weight: 600; }
.fsq-seg input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.fsq-seg-wrap label { flex-basis: 40%; }
.fsq-seg-wrap label:nth-child(3) span { border-left: 0; }
.fsq-seg-wrap label:nth-child(n + 3) span { border-top: 1px solid var(--color-base-300); }

.fsq-scores { width: 100%; border-collapse: collapse; font-size: 0.875rem; table-layout: fixed; }
.fsq-scores th { padding: 0.25rem 0.35rem; font-weight: 600; text-align: left; }
.fsq-scores thead th { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.fsq-scores thead th:first-child, .fsq-scores tbody th { width: 3.5rem; }
.fsq-scores td { padding: 0.2rem 0.3rem; }
.fsq-score { width: 100%; font-variant-numeric: tabular-nums; }
.fsq-winner-row td { padding: 0 0.35rem 0.5rem; font-size: 0.8125rem; line-height: 1.4; }

.fsq-custom { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.fsq-prizes { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.875rem; }
.fsq-prizes:empty { display: none; }
.fsq-prizes .is-warn { color: var(--color-error); }
.fsq-prize-list { display: grid; gap: 0.2rem; margin: 0; padding: 0; list-style: none; }
.fsq-prize-list li { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }

.fsq-preview {
  padding: 3.6%;
  border: 1px solid var(--color-base-300);
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

.fsq-list { list-style: disc; }
.fsq-list li::marker { color: var(--muted); }

/* ---- Inks ---- */
.ink-green { --ink: #1d7a46; --ink-soft: #e2f3e8; --ink-deep: #0e5330; }
.ink-blue { --ink: #2a5fc4; --ink-soft: #e2ebfb; --ink-deep: #183f8c; }
.ink-red { --ink: #c8382c; --ink-soft: #fde7e3; --ink-deep: #8f1f1a; }
.ink-black { --ink: #26262b; --ink-soft: #ececec; --ink-deep: #000; }

/* ---- The board ---- */
.fsq-boardbox { container-type: inline-size; width: 100%; }
.fsq-board {
  --label: 5.5cqw;
  --head: 6.5cqw;
  --headrow: var(--head);
  --line: color-mix(in srgb, var(--ink) 45%, #fff);
  --cell: calc((100cqw - var(--label) - var(--head)) / var(--n));
  display: grid;
  grid-template-columns: var(--label) var(--head) repeat(var(--n), var(--cell));
  grid-template-rows: var(--label) var(--headrow) repeat(var(--n), var(--cell));
  background: #fff;
  color: #1d1b22;
  font-family: var(--font-sans, system-ui, sans-serif);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.fsq-board.is-sets { --headrow: 9.5cqw; }

.fsq-team {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  font-size: 2.9cqw;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fsq-team span { overflow: hidden; text-overflow: ellipsis; }
.fsq-team-top { border-radius: 1.2cqw 1.2cqw 0 0; }
.fsq-team-side { border-radius: 1.2cqw 0 0 1.2cqw; }
.fsq-team-side span { writing-mode: vertical-rl; transform: rotate(180deg); }

.fsq-corner, .fsq-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
  border-right: 0.18cqw solid var(--line);
  border-bottom: 0.18cqw solid var(--line);
  background: var(--ink-soft);
  color: var(--ink-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.fsq-corner { background: #fff; border-right: 0.45cqw solid var(--ink); border-bottom: 0.45cqw solid var(--ink); }
.fsq-head-top { border-bottom: 0.45cqw solid var(--ink); font-size: 4.3cqw; }
.fsq-head-side { border-right: 0.45cqw solid var(--ink); font-size: 4.3cqw; }
.fsq-line { display: flex; justify-content: center; gap: 0.7em; font-weight: 800; }
.fsq-board.is-small .fsq-head { font-size: 5cqw; }

/* New numbers each quarter: four lines per header, labelled Q1 to Q4 in the corner. */
.fsq-board.is-sets .fsq-head,
.fsq-board.is-sets .fsq-corner { justify-content: space-evenly; font-size: 1.75cqw; }
.fsq-board.is-sets .fsq-corner { color: var(--ink); font-size: 1.45cqw; font-weight: 700; }
.fsq-board.is-sets .fsq-corner .fsq-line { font-weight: 700; }
/* 25 squares: two digits a line, so the side column is wider and the top lines smaller. */
.fsq-board.is-sets.is-small { --head: 8.5cqw; --headrow: 10cqw; }
.fsq-board.is-sets.is-small .fsq-head { font-size: 2.1cqw; }
.fsq-board.is-sets.is-small .fsq-head-side { font-size: 2.8cqw; }
.fsq-board.is-sets.is-small .fsq-line { gap: 0.5em; }

.fsq-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 0.5cqw;
  overflow: hidden;
  box-sizing: border-box;
  border: 0;
  border-right: 0.18cqw solid var(--line);
  border-bottom: 0.18cqw solid var(--line);
  border-radius: 0;
  background: #fff;
  color: #1d1b22;
  font: inherit;
  text-align: center;
}
button.fsq-sq { cursor: pointer; appearance: none; }
@media (hover: hover) { button.fsq-sq:hover { background: color-mix(in srgb, var(--ink-soft) 55%, #fff); } }
button.fsq-sq:focus-visible { z-index: 1; outline: 0.5cqw solid #1d4ed8; outline-offset: -0.5cqw; }
.fsq-sq.is-selected { z-index: 1; outline: 0.55cqw solid var(--ink-deep); outline-offset: -0.55cqw; }
.fsq-sq.is-mine { background: #fff1a8; }
.fsq-sq.is-win { background: var(--ink-soft); outline: 0.45cqw solid var(--ink); outline-offset: -0.45cqw; }
.fsq-sq.is-win.is-mine { background: #ffe066; }

.fsq-num {
  position: absolute;
  top: calc(var(--cell) * 0.05);
  left: calc(var(--cell) * 0.07);
  color: color-mix(in srgb, var(--ink) 55%, #fff);
  font-size: calc(var(--cell) * 0.14);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.fsq-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.05;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.fsq-sq.is-win .fsq-name { margin-bottom: calc(var(--cell) * 0.12); }
.fsq-badges {
  position: absolute;
  right: 0;
  bottom: calc(var(--cell) * 0.07);
  left: 0;
  display: flex;
  justify-content: center;
  gap: calc(var(--cell) * 0.04);
}
.fsq-badges span {
  padding: calc(var(--cell) * 0.015) calc(var(--cell) * 0.06);
  border-radius: calc(var(--cell) * 0.08);
  background: var(--ink);
  color: #fff;
  font-size: calc(var(--cell) * 0.13);
  font-weight: 700;
  line-height: 1.15;
}

/* ---- The printed sheet ---- */
.fsq-sheet {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 1.4cqw;
  box-sizing: border-box;
  overflow: hidden;
  background: #fff;
  color: #1d1b22;
  font-family: var(--font-sans, system-ui, sans-serif);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.fsq-preview .fsq-sheet { width: 100%; aspect-ratio: var(--ratio); }
.fsq-sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2cqw;
  padding-bottom: 0.9cqw;
  border-bottom: 0.3cqw solid var(--ink);
}
.fsq-sheet-title { min-width: 0; overflow: hidden; color: var(--ink-deep); font-size: 3.2cqw; font-weight: 800; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.fsq-sheet-title.is-long { font-size: 2.3cqw; }
.fsq-sheet-teams { flex: none; max-width: 40%; overflow: hidden; color: #4b4b55; font-size: 1.6cqw; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.fsq-sheet-body { display: flex; gap: 2.2cqw; min-height: 0; }
.fsq-sheet-board { flex: none; width: 64cqw; }
.paper-a4 .fsq-sheet-board { width: 58cqw; }
.fsq-sheet-side { display: flex; flex: 1; flex-direction: column; gap: 1.1cqw; min-width: 0; font-size: 1.3cqw; line-height: 1.4; }
.fsq-sheet-h { color: var(--ink-deep); font-size: 1.6cqw; font-weight: 700; }
.fsq-sheet-rules { color: #33333b; }
.fsq-sheet-table { width: 100%; border-collapse: collapse; font-size: 1.2cqw; table-layout: fixed; }
.fsq-sheet-table th, .fsq-sheet-table td { padding: 1cqw 0.4cqw; border-bottom: 0.12cqw solid #b9b9c2; overflow-wrap: anywhere; text-align: left; vertical-align: bottom; }
.fsq-sheet-table thead th { color: var(--ink-deep); font-size: 1.1cqw; font-weight: 700; padding-top: 0; }
.fsq-sheet-table tbody th { width: 21%; font-weight: 600; }
.fsq-sheet-table thead th:nth-child(2), .fsq-sheet-table thead th:nth-child(3),
.fsq-sheet-table .is-score { width: 17%; text-align: center; }
.fsq-sheet-table .is-prize { width: 16%; text-align: right; font-variant-numeric: tabular-nums; }
.fsq-sheet-table thead th:nth-child(5) { text-align: right; }
.fsq-sheet-pot { color: #33333b; }
.fsq-sheet-foot { margin-top: auto; color: #8a8a94; font-size: 1cqw; }

/* ---- Printing: only the sheet ---- */
.fsq-print { display: none; }
@media print {
  body > *:not(.fsq-print) { display: none !important; }
  html, body { background: #fff !important; }
  .fsq-print { display: block; }
  .fsq-print .fsq-sheet { width: var(--sheet-w); height: var(--sheet-h); }
}
