:root {
  --bg: #f4f7fa;
  --card: #ffffff;
  --ink: #14324a;
  --muted: #52687c;
  --line: #d8e1ea;
  --accent: #f5b700;
  --navy: #14324a;
  --floor: #e9b77a;
  --floor-line: #ffffff;
  --ok-bg: #e5f6ea; --ok-ink: #17602f;
  --bad-bg: #fde8e8; --bad-ink: #a11c1c;
  --warn-bg: #fff4d6; --warn-ink: #7a5300;
  --fault: #d42a2a;
  --close: #e6a100;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1b27; --card: #13283a; --ink: #e9f0f6; --muted: #a9bccd; --line: #24405a;
    --floor: #b9895a; --floor-line: #f4efe6;
    --ok-bg: #133b24; --ok-ink: #9fe3b4;
    --bad-bg: #4a1717; --bad-ink: #ffb3b3;
    --warn-bg: #43350f; --warn-ink: #ffdd85;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-underline-offset: 3px; }
button, select, input { font: inherit; color: inherit; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 16px; max-width: 1100px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; text-decoration: none; }
.brand svg { width: 36px; height: 36px; }
.tag { color: var(--muted); font-size: 14px; }

.app { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .app { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }

.board, .panel details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel { display: grid; gap: 12px; }
summary { font-weight: 700; cursor: pointer; padding: 2px 0; }
details[open] summary { margin-bottom: 8px; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.bar label { display: grid; gap: 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
select, input[type=text], input[type=number] {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; min-height: 40px;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 12px; min-height: 40px; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed=true] { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed=true] { background: var(--accent); color: var(--navy); } }

.rotations { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 12px; }
.rotations button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; min-height: 44px; cursor: pointer; font-weight: 700;
}
.rotations button[aria-pressed=true] { background: var(--accent); color: var(--navy); border-color: var(--accent); }
.rotinfo { margin: 8px 0 4px; color: var(--muted); font-size: 14px; min-height: 1.5em; }

.court { width: 100%; max-width: 520px; display: block; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.court .floor { fill: var(--floor); }
.court .lines { fill: none; stroke: var(--floor-line); stroke-width: 0.08; }
.court .net { stroke: var(--ink); stroke-width: 0.16; stroke-linecap: round; }
.court .zone { fill: var(--floor-line); opacity: 0.45; font-size: 0.9px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.court .label { fill: var(--muted); font-size: 0.42px; text-anchor: middle; }
.court .player { cursor: grab; }
.court .player.dragging { cursor: grabbing; }
.court .player circle { stroke: #fff; stroke-width: 0.09; }
.court .player.fault circle { stroke: var(--fault); stroke-width: 0.2; }
.court .player.close circle { stroke: var(--close); stroke-width: 0.2; }
.court .player .num { font-size: 0.52px; font-weight: 800; text-anchor: middle; dominant-baseline: central; fill: #14324a; pointer-events: none; }
.court .player .name { font-size: 0.36px; font-weight: 600; text-anchor: middle; fill: var(--ink); paint-order: stroke; stroke: var(--floor); stroke-width: 0.12; pointer-events: none; }
.court .server-zone { fill: none; stroke: var(--muted); stroke-width: 0.04; stroke-dasharray: 0.15 0.15; }

.verdict { border-radius: 10px; padding: 10px 12px; margin-top: 8px; font-size: 15px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok-ink); }
.verdict.bad { background: var(--bad-bg); color: var(--bad-ink); }
.verdict ul { margin: 6px 0 0; padding-left: 18px; }
.verdict li.close { color: var(--warn-ink); }
.verdict .notes { margin-top: 6px; color: var(--muted); font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions button, button.small {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 12px; min-height: 42px; cursor: pointer; font-weight: 600;
}
.actions button#printAll { background: var(--navy); color: #fff; border-color: var(--navy); }
.hint, .note { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.roster { display: grid; gap: 6px; }
.roster .prow { display: grid; grid-template-columns: 58px minmax(0, 1fr) 92px 36px; gap: 6px; align-items: center; }
.roster input[type=number] { width: 100%; }
.roster .remove { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); min-height: 40px; }

.lineup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.lineup label { display: grid; font-size: 12px; color: var(--muted); font-weight: 600; }
.lineup .netrow { grid-column: 1 / -1; text-align: center; font-size: 12px; color: var(--muted); border-bottom: 3px solid var(--ink); padding-bottom: 2px; }
.problems { margin: 8px 0 0; padding-left: 18px; color: var(--bad-ink); font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 15px; }

.foot { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: 13px; }

.print-area { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; }
  .top, .foot, .board, .panel, .prose, .skip, .page-head { display: none !important; }
  .app { display: block; padding: 0; }
  .card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; }
  .lineup-card { border: 1.5px solid #000; border-radius: 2mm; padding: 3mm; break-inside: avoid; font-size: 10pt; }
  .lineup-card table { width: 100%; border-collapse: collapse; margin: 2mm 0; }
  .lineup-card th, .lineup-card td { border: 1px solid #000; text-align: center; width: 16.6%; }
  .lineup-card td { height: 12mm; font-size: 18pt; font-weight: 700; }
  .lc-top, .lc-foot { white-space: pre-wrap; }
  .print-area { display: block; }
  .print-area h1 { font-size: 16pt; margin: 0 0 2mm; }
  .print-area .sub { font-size: 10pt; margin: 0 0 4mm; color: #333; }
  .print-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .print-cell { border: 1px solid #999; border-radius: 3mm; padding: 2mm; break-inside: avoid; }
  .print-cell h2 { font-size: 11pt; margin: 0 0 1mm; text-align: center; }
  .print-cell svg { width: 100%; }
  .print-area .foot-note { font-size: 8pt; color: #444; margin-top: 4mm; }
  .court .floor { fill: #fff; }
  .court .lines { stroke: #000; }
  .court .zone { fill: #000; opacity: 0.12; }
  .court .player .name { fill: #000; stroke: #fff; }
}

/* ---------- Site chrome ---------- */
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-weight: 600; font-size: 15px; }
.nav a { text-decoration: none; padding: 6px 0; color: var(--muted); }
.nav a[aria-current=page] { color: var(--ink); border-bottom: 3px solid var(--accent); }
.top { justify-content: space-between; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.teams { flex-wrap: wrap; }
.teams select { flex: 1 1 140px; }

/* ---------- Articles ---------- */
.prose-wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.prose { line-height: 1.65; }
.prose h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.15; letter-spacing: -0.02em; margin: 16px 0 12px; }
.prose h2 { font-size: 23px; margin: 32px 0 8px; line-height: 1.25; }
.prose h3 { font-size: 18px; margin: 22px 0 6px; }
.prose p, .prose li { max-width: 68ch; }
.prose .lede { font-size: 18px; color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--card); }
.prose .callout { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin: 18px 0; }
.prose .cta { display: inline-block; background: var(--navy); color: #fff; text-decoration: none; font-weight: 700; padding: 10px 16px; border-radius: 10px; margin: 6px 0; }
@media (prefers-color-scheme: dark) { .prose .cta { background: var(--accent); color: var(--navy); } }
.prose .meta { color: var(--muted); font-size: 14px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin: 16px 0; }
.cards .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-decoration: none; display: block; }
.cards .card h3 { margin: 0 0 6px; font-size: 17px; }
.cards .card p { margin: 0; color: var(--muted); font-size: 15px; }
.price { font-weight: 800; font-size: 20px; }
.price s { color: var(--muted); font-weight: 400; font-size: 15px; }
.badge { display: inline-block; background: var(--accent); color: var(--navy); font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.page-head { max-width: 1100px; margin: 0 auto; padding: 4px 16px 0; }
.page-head h1 { font-size: clamp(24px, 4.5vw, 32px); margin: 8px 0 4px; line-height: 1.2; }
.page-head p { margin: 0 0 12px; color: var(--muted); }
.explainer { grid-column: 1 / -1; }

/* ---------- Tools (calculators, planner) ---------- */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 16px 0; }
.tool h2 { margin-top: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.fields label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.fields input { width: 100%; }
.result { font-size: 30px; font-weight: 800; margin: 12px 0 2px; }
.result-note { color: var(--muted); font-size: 14px; margin: 0; }
.plan-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.plan-table th, .plan-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.plan-wrap { overflow-x: auto; }
.pt-players { display: grid; gap: 6px; }
.pt-players .prow { display: grid; grid-template-columns: 58px minmax(0, 1fr) 36px; gap: 6px; }
.page-head { grid-column: 1 / -1; padding: 0; }
.page-head { margin: 0; max-width: none; }
.fields { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.fields select { width: 100%; }
.check-label { display: flex !important; align-items: center; gap: 8px; align-self: end; min-height: 40px; color: var(--ink) !important; }
.check-label input { width: auto !important; min-height: 0; }
