:root {
  --desk: #e9e6e1;
  --bar: #1c1f24;
  --bar-2: #2a2e35;
  --bar-text: #f3f1ee;
  --muted: #9aa0a8;
  --accent: #e8692c;
  --ink: #111;
  --line: #6b6b6b;
  --paper: #fff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button, select, input, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Top bar ---- */
.bar { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-text); padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); box-shadow: 0 2px 10px rgb(0 0 0 / .2); }
.bar-row { display: flex; align-items: center; gap: 8px; max-width: 1100px; margin: 0 auto; }
.bar-row + .bar-row { margin-top: 8px; }
.brand { font-weight: 800; letter-spacing: .02em; font-size: 18px; margin-right: 4px; }
.brand::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
.grow { flex: 1; }
.btn { background: var(--bar-2); border: 1px solid #3a3f47; border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #59606b; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.plays select { background: var(--bar-2); border: 1px solid #3a3f47; border-radius: 8px; padding: 6px 8px; max-width: 220px; }

.tools { gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tools::-webkit-scrollbar { display: none; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 58px; padding: 5px 6px 4px; border-radius: 8px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--bar-text); }
.tool svg { width: 28px; height: 22px; }
.tool span { font-size: 11px; color: var(--muted); }
.tool:hover { background: var(--bar-2); }
.tool[aria-pressed="true"] { background: var(--bar-2); border-color: var(--accent); }
.tool[aria-pressed="true"] span { color: var(--bar-text); }
.tool:disabled { opacity: .35; cursor: default; }
.tool-sep { width: 1px; align-self: stretch; background: #3a3f47; margin: 4px 6px; flex: none; }

/* ---- Paper ---- */
.desk { padding: 20px 16px 40px; }
.page { background: var(--paper); max-width: 860px; margin: 0 auto; padding: 18px 22px 22px; border-radius: 4px; box-shadow: 0 1px 3px rgb(0 0 0 / .12), 0 8px 30px rgb(0 0 0 / .08); }
.title { display: block; width: 100%; border: 0; border-bottom: 1px dashed transparent; text-align: center; font-weight: 800; font-size: 26px; letter-spacing: .03em; text-transform: uppercase; padding: 2px 0 8px; background: none; outline: none; }
.title:hover, .title:focus { border-bottom-color: #ccc; }
.title::placeholder { color: #bbb; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.court-wrap { position: relative; }
.court { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.court .floor { stroke: var(--line); stroke-width: 2; fill: none; }
.court .floor .bold { stroke: #333; stroke-width: 3; }
.court .floor .dash { stroke-dasharray: 8 7; }
.court .floor .fill { fill: var(--line); }
.court.active-target { cursor: crosshair; }
.court.erase { cursor: not-allowed; }
.court.move .item { cursor: grab; }

.court-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: .0; transition: opacity .15s; }
.court-wrap:hover .court-tools, .court-wrap:focus-within .court-tools { opacity: 1; }
@media (hover: none) { .court-tools { opacity: 1; } }
.court-tools button { font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid #ddd; background: rgb(255 255 255 / .92); cursor: pointer; color: #333; }
.court-tools button:hover { border-color: var(--accent); color: var(--accent); }
.frame-no { position: absolute; top: 8px; left: 10px; font-size: 13px; font-weight: 700; color: #aaa; pointer-events: none; }

.notes { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 18px; }
.notes span { font-size: 13px; font-weight: 600; padding-top: 3px; color: #444; }
.notes .lines { flex: 1; position: relative; }
.notes .lines i { position: absolute; left: 0; right: 0; height: 0; border-bottom: 1px solid #cfcfcf; pointer-events: none; }
.notes .lines i:nth-child(1) { top: 25px; } .notes .lines i:nth-child(2) { top: 51px; } .notes .lines i:nth-child(3) { top: 77px; }
.notes textarea { display: block; width: 100%; border: 0; resize: none; outline: none; background: transparent; line-height: 26px; font-size: 15px; padding: 0 2px; height: 78px; overflow: hidden; }
.notes-print { display: none; }

.hint { max-width: 860px; margin: 12px auto 0; text-align: center; color: #6c6a66; font-size: 14px; }

@media (max-width: 720px) {
  .hide-sm { display: none; }
  .row { grid-template-columns: 1fr; gap: 18px; }
  .page { padding: 14px 12px; }
  .title { font-size: 21px; }
  .plays select { max-width: 140px; }
}

/* ---- Print: exactly the sheet, two courts per row, letter portrait ---- */
@page { size: letter portrait; margin: 0.4in; }
@media print {
  body { background: #fff; }
  .bar, .hint, .court-tools, .frame-no { display: none !important; }
  .desk { padding: 0; }
  .page { box-shadow: none; padding: 0; max-width: none; width: 7.7in; margin: 0; }
  .title { font-size: 18pt; padding: 0 0 .1in; height: .42in; }
  .title:placeholder-shown { visibility: hidden; }
  .row { grid-template-columns: 1fr 1fr; gap: .2in; break-inside: avoid; }
  .notes { margin: .08in 0 .16in; }
  .notes:last-of-type { margin-bottom: 0; }
  .notes textarea { display: none; }
  .notes .lines { height: .76in; overflow: hidden; }
  .notes .lines i { border-bottom-color: #999; }
  .notes .lines i:nth-child(1) { top: .24in; } .notes .lines i:nth-child(2) { top: .49in; } .notes .lines i:nth-child(3) { top: .74in; }
  .notes-print { display: block; white-space: pre-wrap; font-size: 11pt; line-height: .25in; padding: 0 2px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
