:root {
  --navy: #1a2744;
  --rail: #141e36;
  --chalk: #f3efe2;
  --chalk-dim: #c9c0ae;
  --amber: #e0a106;
  --ink: #142033;
  --turf-a: #237844;
  --turf-b: #1c693b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--navy);
  color: var(--chalk);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

button {
  background: transparent;
  border: 1px solid rgba(243, 239, 226, 0.35);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--chalk); }

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--rail);
  border-right: 1px solid rgba(243, 239, 226, 0.12);
  padding: 18px 14px 14px;
}

.brand {
  margin: 0 0 14px;
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}

.team-label {
  display: block;
  margin: 0 0 6px;
  color: var(--chalk-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#team-select {
  width: 100%;
  margin-bottom: 12px;
  background: var(--navy);
  border: 1px solid rgba(243, 239, 226, 0.35);
  border-radius: 2px;
  padding: 8px;
}

.new-team {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.new-team[hidden] { display: none; }

.new-team input {
  flex: 1;
  min-width: 0;
  background: var(--navy);
  border: 1px solid rgba(243, 239, 226, 0.35);
  border-radius: 2px;
  padding: 8px;
}

#new-team, #new-play { width: 100%; }

#new-team { margin-bottom: 8px; }

.play-list {
  overflow: auto;
  flex: 1;
  margin-top: 14px;
  min-height: 0;
}

.play-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-top: 1px solid rgba(243, 239, 226, 0.12);
}

.play-row.is-active { box-shadow: inset 3px 0 0 var(--amber); }

.play-open, .play-delete {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.play-open {
  text-align: left;
  padding: 10px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-num {
  display: inline-block;
  min-width: 1.5em;
  margin-right: 4px;
  color: var(--amber);
  font-weight: 700;
}

.play-row.is-active .play-open { font-weight: 700; }

.play-delete {
  width: 32px;
  height: 36px;
  color: var(--chalk-dim);
  font-size: 18px;
  line-height: 1;
}

.play-delete:hover { color: var(--chalk); }

.save-note {
  margin: 4px 18px 0;
  color: var(--chalk-dim);
  font-size: 13px;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stage-head { flex: none; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 14px 18px 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 0 100%;
  min-width: 0;
}

#play-number {
  width: 64px;
  flex: none;
  border: 0;
  border-bottom: 2px solid rgba(243, 239, 226, 0.45);
  background: transparent;
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 0 0 2px;
}

#play-name {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

#play-name::placeholder { color: rgba(243, 239, 226, 0.35); }

.tools, .file-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.print-go {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
  font-weight: 700;
}

.print-setup {
  margin: 10px 18px 0;
  padding: 12px;
  border: 1px solid rgba(243, 239, 226, 0.35);
}

.print-setup[hidden] { display: none; }

.print-title {
  margin: 0;
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.print-label {
  margin: 10px 0 6px;
  color: var(--chalk-dim);
  font-size: 14px;
}

.print-note {
  margin: 10px 0;
  font-size: 14px;
}

.letter-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--chalk-dim);
  font-size: 14px;
  flex: none;
}

.letter-field input {
  width: 52px;
  background: var(--navy);
  border: 1px solid rgba(243, 239, 226, 0.35);
  border-radius: 2px;
  padding: 8px;
  text-align: center;
  font-weight: 700;
}

.letter-field input:disabled { opacity: 0.4; }

.tools button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
  font-weight: 700;
}

.hint {
  margin: 8px 18px 0;
  color: var(--chalk-dim);
  font-size: 14px;
}

.finish-key {
  margin: 4px 18px 0;
  color: var(--chalk);
  font-size: 14px;
}

.banner {
  margin: 10px 18px 0;
  padding: 8px 10px;
  border: 1px solid rgba(243, 239, 226, 0.35);
  font-size: 14px;
}

.banner[data-kind="error"] {
  border-color: #e07a7a;
  color: #ffd2d2;
}

.field-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px 18px;
}

#field {
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  display: block;
  background: transparent;
  touch-action: none;
  user-select: none;
}

#field .player { cursor: grab; }
#field.is-dragging .player { cursor: grabbing; }
#field.is-drawing { cursor: crosshair; }

.yard-label {
  fill: rgba(243, 239, 226, 0.72);
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-weight: 600;
}

.los-label { fill: var(--chalk); }

.route {
  fill: none;
  stroke: var(--chalk);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-x { stroke: #f2c14e; }
.route-y { stroke: #3b82f6; }
.route-c { stroke: #ef4444; }
.route-z { stroke: #fb923c; }
.route-q { stroke: #141414; }
.route-s { stroke: #141414; }
.route-a { stroke: #a78bfa; }
.route-b { stroke: #2dd4bf; }
.route-f { stroke: #f472b6; }
.route-w { stroke: #a3e635; }
.route-t { stroke: #38bdf8; }
.route-halo { stroke: #f3efe2; }
.route.is-selected { stroke: var(--amber); }

.route-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 1.3;
  pointer-events: stroke;
}

.handle {
  fill: var(--chalk);
  stroke: var(--ink);
  stroke-width: 0.1;
  cursor: grab;
}

.handle.is-hot { fill: var(--amber); }

.player.offense circle {
  fill: #17315f;
  stroke: #091426;
}

.player.offense.id-X circle { fill: #f2c14e; stroke: #7a5b10; }
.player.offense.id-X text { fill: #1a1404; }
.player.offense.id-SL circle { fill: #2563eb; stroke: #0f2f86; }
.player.offense.id-SL text { fill: #f7f4ea; }
.player.offense.id-C circle { fill: #dc2626; stroke: #7f1d1d; }
.player.offense.id-C text { fill: #f7f4ea; }
.player.offense.id-Z circle { fill: #f97316; stroke: #9a3412; }
.player.offense.id-Z text { fill: #1a1404; }
.player.offense.id-QB circle { fill: #171717; stroke: #000; }
.player.offense.id-QB text { fill: #f7f4ea; }
.player.offense.id-SR circle { fill: #171717; stroke: #000; }
.player.offense.id-SR text { fill: #f7f4ea; }
.player.offense.id-A circle { fill: #7c3aed; stroke: #3b0764; }
.player.offense.id-A text { fill: #f7f4ea; }
.player.offense.id-B circle { fill: #0f766e; stroke: #042f2e; }
.player.offense.id-B text { fill: #f7f4ea; }
.player.offense.id-F circle { fill: #f472b6; stroke: #9d174d; }
.player.offense.id-F text { fill: #1a1404; }
.player.offense.id-W circle { fill: #84cc16; stroke: #3f6212; }
.player.offense.id-W text { fill: #1a1404; }
.player.offense.id-T circle { fill: #0284c7; stroke: #0c4a6e; }
.player.offense.id-T text { fill: #f7f4ea; }
.player.is-spare { display: none; }

.player.defense circle {
  fill: #f7f4ea;
  stroke: #17315f;
}

.player text {
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.player.offense text { fill: #f7f4ea; }
.player.defense text { fill: #17315f; }

.player.is-hot circle {
  stroke: var(--amber);
}

.ball {
  fill: #c4a574;
  stroke: #6b4a2a;
  stroke-width: 0.06;
}

#print-root { display: none; }

.print-page {
  page-break-after: always;
  break-after: page;
}

.print-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

.print-team {
  margin: 0 0 6px;
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 11pt;
  font-weight: 700;
  color: #142033;
}

.print-band {
  width: var(--band-w);
  height: var(--band-h);
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  background: white;
}

.print-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #142033;
  padding: 1px 2px 0;
  color: #142033;
}

.print-card.is-empty { border: 0; }

.print-card-head {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  line-height: 1.05;
}

.print-card-num,
.print-card-name {
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-weight: 700;
}

.print-card-num { font-size: 13pt; flex: none; }

.print-card-name {
  font-size: 8pt;
  white-space: normal;
}

#print-root[data-count="12"] .print-card-num { font-size: 9pt; }
#print-root[data-count="12"] .print-card-name { font-size: 6.5pt; }

.print-field {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
}

@page { size: letter; margin: 0.4in; }

@media print {
  body { background: white; }
  .app { display: none !important; }
  #print-root { display: block; }
}

@media (max-width: 800px) {
  html, body { height: auto; min-height: 100%; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100%; }
  .stage { order: -1; display: block; }
  .sidebar { order: 1; border-right: 0; border-top: 1px solid rgba(243, 239, 226, 0.12); }
  .brand { font-size: 22px; margin-bottom: 8px; }
  .play-list { max-height: 188px; }
  #play-number, #play-name { font-size: 28px; }
  #play-number { width: 48px; }
  .field-wrap { display: block; padding: 8px 12px 20px; }
  #field { width: 100%; height: auto; }
}
