/* Layout: coach's workbench — tool rail | pitch + frame timeline | squad panel */
:root {
  --bg: #e7ece7;
  --panel: #f8faf7;
  --ink: #17221c;
  --muted: #5a6960;
  --line: #cdd7cf;
  --hover: #dde5df;
  --accent: #1d5bbd;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111814; --panel: #19221d; --ink: #e4ebe6; --muted: #93a39a;
    --line: #2c3a32; --hover: #233029; --accent: #6aa5ff; --accent-ink: #0b1420;
    --danger: #ff7b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111814; --panel: #19221d; --ink: #e4ebe6; --muted: #93a39a;
  --line: #2c3a32; --hover: #233029; --accent: #6aa5ff; --accent-ink: #0b1420;
  --danger: #ff7b6b; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 14px 28px;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1480px; margin: 0 auto 14px;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 {
  font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: .02em;
  text-transform: uppercase; margin: 0; line-height: 1;
}
.brand h1 span { color: var(--accent); }
.brand p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 600;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.warn { color: var(--danger); }
.btn svg { width: 16px; height: 16px; }

.work {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) 300px; gap: 16px;
  max-width: 1480px; margin: 0 auto; align-items: start;
}

/* Tool rail */
.rail {
  display: flex; flex-direction: column; gap: 6px; padding: 7px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); position: sticky; top: 12px;
}
.tool {
  width: 44px; height: 44px; border-radius: 9px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted);
}
.tool:hover { background: var(--hover); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.tool svg { width: 22px; height: 22px; }
.rail hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; margin: 2px auto; border: 2px solid var(--line);
  padding: 0;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }

/* Stage */
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pitch-wrap {
  border-radius: 12px; overflow: hidden; background: #1f5a31;
  box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 10px 30px -14px rgba(0,0,0,.45);
}
#board { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
#board.t-move .player, #board.t-move [data-ball] { cursor: grab; }
#board.t-erase [data-did] { cursor: not-allowed; }
#board.t-draw { cursor: crosshair; }

.timeline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.play {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none;
}
.play svg { width: 18px; height: 18px; }
.frames { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 200px; min-width: 0; }
.chip {
  height: 34px; min-width: 44px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line);
  background: transparent; font-family: var(--display); font-weight: 600; font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.chip:hover { background: var(--hover); }
.chip[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tl-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tl-right select { height: 34px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); padding: 0 6px; }
.status { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex-basis: 100%; }
.status b { color: var(--ink); font-weight: 600; }
.flight { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.stack .btn { justify-content: center; }

/* Side panel */
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card h2 {
  font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; margin: 0 0 10px; color: var(--muted);
}
.team { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
.team + .team { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.team .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
label.f input[type=text], label.f input[type=number], label.f select {
  height: 34px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); padding: 0 9px; width: 100%;
  color: var(--ink); font-size: 14px;
}
input[type=color] { width: 38px; height: 34px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--bg); }
.row2 { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.empty { color: var(--muted); margin: 0; line-height: 1.45; }
.toggle { display: flex; align-items: center; gap: 9px; padding: 5px 0; cursor: pointer; }
.toggle input { width: 17px; height: 17px; accent-color: var(--accent); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 0; font-size: 13px; }
.keys dt { font-family: var(--display); font-weight: 600; }
.keys dt kbd {
  display: inline-block; min-width: 22px; text-align: center; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg); font-family: inherit;
}
.keys dd { margin: 0; color: var(--muted); }

/* Export modal */
.modal { position: fixed; inset: 0; background: rgba(5,10,7,.62); display: grid; place-items: center; z-index: 50;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal-box { background: var(--panel); border-radius: 14px; padding: 16px; max-width: 960px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.modal-box img { width: 100%; border-radius: 8px; display: block; }
.modal-box p { margin: 0; color: var(--muted); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-family: var(--display); font-size: 22px; }

@media (max-width: 1080px) {
  .work { grid-template-columns: 58px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 700px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; flex-wrap: wrap; position: static; justify-content: center; }
  .rail hr { width: 1px; height: 30px; border-top: 0; border-left: 1px solid var(--line); margin: 7px 2px; }
  .swatch { margin: 9px 2px; }
  .brand h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

body { margin: 0; } img { max-width: 100%; }
