/* ===== Court SVG ===== */
.cv {
  --floor: #10223f;
  --floor-out: #0b172c;
  --paint: #173461;
  --cline: rgba(214, 228, 252, .78);
  --off: #ff7a1a;
  --off-text: #fff;
  --def: #2f7bf0;
  --def-text: #fff;
  --arw-off: #ffb37a;
  --arw-def: #8fbcff;
  --draw: #ffe14d;
}
.cv[data-theme="wood"] {
  --floor: #e2b77f;
  --floor-out: #23324d;
  --paint: #c4884d;
  --cline: rgba(255, 255, 255, .95);
  --off: #e3570b;
  --def: #173f8f;
  --arw-off: #7a2c00;
  --arw-def: #0f2d6b;
  --draw: #111;
}
.cv .c-out { fill: var(--floor-out); }
.cv .c-floor { fill: var(--floor); }
.cv .c-paint { fill: var(--paint); }
.cv .c-line { fill: none; stroke: var(--cline); stroke-width: 2.4; }
.cv .c-line.thin { stroke-width: 1.6; }
.cv .c-line.dash { stroke-dasharray: 9 8; }
.cv .c-rim { fill: none; stroke: #ff8a3d; stroke-width: 2.6; }
.cv .c-board { stroke: var(--cline); stroke-width: 4; stroke-linecap: round; }
.cv .c-logo { fill: var(--cline); opacity: .08; font: 700 54px var(--font-display); letter-spacing: .1em; }

/* zones */
.cv .zone { stroke: rgba(255, 255, 255, .18); stroke-width: 1; }
.cv .zone-label { font: 700 13px var(--font-display); fill: #fff; letter-spacing: .04em; paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 3px; pointer-events: none; }
.cv .zone-label tspan.v { font-size: 11px; opacity: .85; }

/* tokens */
.cv .tok { cursor: grab; }
.cv .tok.dragging { cursor: grabbing; }
.cv .tok .hit { fill: transparent; }
.cv .tok .body { stroke: #fff; stroke-width: 2.4; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
.cv .tok.off .body { fill: var(--off); }
.cv .tok.def .body { fill: var(--def); }
.cv .tok .lbl { font: 700 16px var(--font-display); fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.cv .tok.def .lbl { font-size: 14px; }
.cv .tok .ring { fill: none; stroke: var(--warn); stroke-width: 3; opacity: 0; }
.cv .tok.holder .ring { opacity: 1; stroke: #fff; stroke-dasharray: 4 4; }
.cv .tok.sel .ring { opacity: 1; stroke: var(--warn); stroke-dasharray: none; }
.cv .tok.dim { opacity: .45; }
.cv .ball { cursor: grab; }
.cv .ball .b { fill: #f07f1d; stroke: #2a1405; stroke-width: 1.4; }
.cv .ball .s { fill: none; stroke: #2a1405; stroke-width: 1; }
.cv.mini .tok .body { stroke-width: 3; }

/* one team only: hide the other team's players and movement (passes stay — the ball still moves) */
.cv.hide-O .tok.off, .cv.hide-X .tok.def { display: none; }
.cv.hide-O .arw.O:not(.pass), .cv.hide-X .arw.X { display: none; }
.cv.hide-O .l-lanes { display: none; }

/* arrows */
.cv .arw { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cv .arw.O { stroke: var(--arw-off); }
.cv .arw.X { stroke: var(--arw-def); }
.cv .arw.pass { stroke-dasharray: 8 7; }
.cv .arw.ghost { opacity: .35; }
.cv .ann { fill: none; stroke: var(--draw); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.cv .ann.pass { stroke-dasharray: 9 7; }
.cv .ann-hit { fill: none; stroke: transparent; stroke-width: 18; }
.cv.tool-erase .ann-g { cursor: pointer; }
.cv.tool-erase .ann-g:hover .ann { stroke: var(--danger); }
.cv.tool-draw { cursor: crosshair; }

/* passing lanes */
.cv .lane { stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; fill: none; }
.cv .lane.open { stroke: #2fd27f; }
.cv .lane.risk { stroke: #ffc23d; }
.cv .lane.denied { stroke: #ff4d5e; }
.cv .lane-dot { stroke: none; }
.cv .spacing { fill: rgba(255, 122, 26, .07); stroke: rgba(255, 122, 26, .35); stroke-width: 1.5; stroke-dasharray: 4 6; }

/* officials */
.cv .ref-zone { stroke-width: 1.5; stroke-dasharray: 6 6; }
.cv .ref .ring { stroke: #111; stroke-width: 1.5; }
.cv .ref { cursor: grab; }
.cv .ref.pinned .ring { stroke: var(--warn); stroke-width: 2.5; }
.cv .ref .disc { stroke: #fff; stroke-width: 1.5; }
.cv .ref .dir { stroke: #fff; stroke-width: 1.2; stroke-linejoin: round; }
.cv .ref .lbl { font: 700 13px var(--font-display); fill: #fff; text-anchor: middle; dominant-baseline: central; }
.cv .ref-zone-label { font: 700 12px var(--font-display); letter-spacing: .1em; fill: #fff; opacity: .8; paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 3px; }

/* ===== Modal ===== */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3, 8, 18, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(1100px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); overflow: hidden;
}
.modal.sm { width: min(560px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font: 700 26px/1 var(--font-display); letter-spacing: .03em; }
.modal-head .close { margin-left: auto; }
.modal-body { overflow-y: auto; padding: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }

/* Play detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
.detail-court { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; position: sticky; top: 0; align-self: start; z-index: 1; }
.detail-court .court-box { aspect-ratio: 560 / 530; width: 100%; }
.detail-court .court-box.full { aspect-ratio: 1000 / 560; }
.detail-court .court-box svg { width: 100%; height: 100%; display: block; }
.detail-court .playback { border-top: 1px solid var(--line); }
.detail-info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.detail-summary { color: var(--text-2); margin: 0; }
.keypoints { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.keypoints li { margin: 2px 0; }
.section-label { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 4px 0 -4px; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step {
  border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); padding: 10px 12px; cursor: pointer;
  transition: border-color .15s;
}
.step:hover { border-color: var(--line-2); }
.step.active { border-color: var(--orange); box-shadow: inset 3px 0 0 var(--orange); }
.step-h { display: flex; gap: 10px; align-items: baseline; }
.step-n { font: 700 13px var(--font-display); letter-spacing: .1em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.step-t { font: 700 17px/1.1 var(--font-display); }
.step .ss-cols { margin-top: 8px; }
.step .ss-col[contenteditable="true"] { outline: 1px dashed var(--line-2); cursor: text; }
.pos-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.pos-table td { padding: 3px 6px; border-top: 1px solid var(--line); color: var(--text-2); }
.pos-table td:first-child { width: 36px; font-weight: 800; }
.pos-table td.o { color: var(--orange-2); }
.pos-table td.x { color: var(--blue-2); }
.pos-table .moved { color: var(--warn); font-weight: 600; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.edit-field { width: 100%; }

/* Manager */
.pb-list { display: flex; flex-direction: column; gap: 8px; }
.pb-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); }
.pb-row.active { border-color: var(--orange); }
.pb-row .pb-name { font: 700 18px/1.1 var(--font-display); }
.pb-row .pb-sub { font-size: 12px; color: var(--muted); }
.pb-row .grow { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label, .form-col label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea, .form-col input, .form-col textarea, .form-col select { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 14px; color: var(--text); }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.storage-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.storage-info .ok { color: var(--ok); font-weight: 600; }
.storage-info .warn { color: var(--warn); font-weight: 600; }

.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 13.5px; color: var(--text-2); }

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .detail-court { top: -16px; }
  .form-grid { grid-template-columns: 1fr; }
}
