/* Lacrosse Whiteboard — coaching-room chrome, broadcast-turf field. */
:root {
  --bg: #0f1317;
  --panel: #171d24;
  --panel-2: #1d242d;
  --line: rgba(255, 255, 255, 0.09);
  --ink: #e9edf2;
  --muted: #93a1b0;
  --accent: #f0742a;
  --accent-soft: rgba(240, 116, 42, 0.16);
  --good: #58d68d;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --offense: #e8542f;
  --defense: #eef1f4;
  --goalie: #e8b83a;
  --ball: #ffd93b;
  --radius: 10px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
h1, h2 { margin: 0; }

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(15, 19, 23, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: #142019;
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-text h1 { font-size: 15px; line-height: 1.1; letter-spacing: 0.01em; }
.subtitle { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.top-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.icon-btn:hover { border-color: rgba(255,255,255,0.25); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.play { background: var(--accent-soft); border-color: rgba(240,116,42,0.5); color: var(--accent); }
.icon { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 12px;
  padding: 12px;
  align-items: start;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.stage { min-width: 0; position: sticky; top: 66px; }
.board {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.5);
  background: #35743f;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  max-width: 720px;
  margin: 0 auto;
}
#fieldSvg { display: block; width: 100%; height: auto; }

/* field */
.turf { fill: #35743f; }
.stripe { fill: rgba(255, 255, 255, 0.045); }
.fl { stroke: rgba(255, 255, 255, 0.88); stroke-width: 3.5; fill: none; }
.fl-mid { stroke-width: 5; }
.fl-thin { stroke: rgba(255, 255, 255, 0.55); stroke-width: 2; fill: none; }
.fl-dash { stroke: rgba(255, 255, 255, 0.75); stroke-width: 2.6; stroke-dasharray: 10 9; fill: none; }
.crease { stroke-width: 3.5; }
.goal-frame { stroke: var(--accent); stroke-width: 4.5; fill: rgba(240, 116, 42, 0.22); stroke-linejoin: round; }
.goal-net { stroke: rgba(255, 255, 255, 0.5); stroke-width: 1.4; fill: none; }
.flabel { fill: rgba(255, 255, 255, 0.55); font: 800 15px Inter, system-ui, sans-serif; text-anchor: middle; letter-spacing: 0.09em; }
.flabel-sm { font-size: 12px; }

/* pieces */
.piece { cursor: grab; }
.piece .body { stroke-width: 2.5; }
.piece.team-O .body { fill: var(--offense); stroke: #7e2413; }
.piece.team-D .body { fill: var(--defense); stroke: #5c6a78; }
.piece.role-G .body { fill: var(--goalie); stroke: #7a5c14; }
.piece .plabel { fill: #fff; font: 800 13.5px Inter, system-ui, sans-serif; text-anchor: middle; pointer-events: none; }
.piece.team-D .plabel { fill: #273240; }
.piece.role-G .plabel { fill: #33270a; }
.stick-shaft { stroke: #2c2016; stroke-width: 3.4; stroke-linecap: round; }
.team-D .stick-shaft { stroke: #3a4550; }
.stick-head { fill: rgba(255, 255, 255, 0.14); stroke: #2c2016; stroke-width: 2.2; }
.team-D .stick-head { stroke: #3a4550; }
.hand-badge circle { fill: #1d242d; stroke: rgba(255,255,255,0.5); stroke-width: 1.2; }
.hand-badge text { fill: #fff; font: 800 8px Inter, system-ui, sans-serif; text-anchor: middle; }
.piece.has-ball .body { stroke: var(--ball); stroke-width: 4; filter: drop-shadow(0 0 6px rgba(255, 217, 59, 0.65)); }
.select-ring { fill: none; stroke: rgba(255, 255, 255, 0.95); stroke-width: 2.2; stroke-dasharray: 5 5; }
.cone-body { fill: var(--accent); stroke: rgba(255,255,255,0.85); stroke-width: 2; }
.ball-body { fill: var(--ball); stroke: #8f7514; stroke-width: 2.4; }
.ball.in-flight .ball-body { filter: drop-shadow(0 0 8px rgba(255, 217, 59, 0.9)); }

/* overlays — risk is pattern + glyph + hue, never hue alone */
.lane { fill: none; opacity: 0.9; }
.lane-open { stroke: var(--good); }                                   /* solid */
.lane-contested { stroke: var(--warn); stroke-dasharray: 14 8; }      /* long dash */
.lane-covered { stroke: var(--bad); stroke-dasharray: 3 7; }          /* dotted */
.lane-time {
  font: 700 13px Inter, system-ui, sans-serif;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(10, 14, 10, 0.75);
  stroke-width: 3;
}
.lane-time.lane-open { fill: var(--good); stroke-dasharray: none; }
.lane-time.lane-contested { fill: var(--warn); stroke-dasharray: none; }
.lane-time.lane-covered { fill: var(--bad); stroke-dasharray: none; }
.pass-halo { fill: rgba(255, 255, 255, 0.08); stroke-width: 3; }
.halo-open { stroke: var(--good); }
.halo-contested { stroke: var(--warn); }
.halo-covered { stroke: var(--bad); }
.pass-halo, .halo-hint { animation: haloPulse 1.4s ease-in-out infinite; }
.halo-hint { font: 800 14px Inter, system-ui, sans-serif; text-anchor: middle; fill: rgba(255,255,255,0.85); }
@keyframes haloPulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }
.aid-mark { stroke: rgba(255, 217, 59, 0.85); stroke-width: 2.2; stroke-dasharray: 4 5; fill: none; }
.aid-ring { stroke: rgba(255, 217, 59, 0.85); stroke-width: 2.2; fill: none; }
.reticle { fill: none; stroke: rgba(255,255,255,0.85); stroke-width: 1.6; stroke-dasharray: 3 4; }

.role-badge rect { fill: rgba(13, 17, 21, 0.82); stroke: rgba(255,255,255,0.28); stroke-width: 1; }
.role-badge text { fill: #dfe6ee; font: 800 10.5px Inter, system-ui, sans-serif; text-anchor: middle; letter-spacing: 0.06em; }
.role-badge.badge-hot rect { stroke: var(--bad); }
.role-badge.badge-hot text { fill: #ff9c9c; }
.role-badge.badge-two rect { stroke: var(--warn); }
.role-badge.badge-two text { fill: var(--warn); }
.role-badge.badge-onball rect { stroke: var(--accent); }
.role-badge.badge-onball text { fill: #ffb27e; }

.bubble rect { fill: rgba(13, 17, 21, 0.92); stroke: rgba(255, 255, 255, 0.3); stroke-width: 1; }
.bubble text { fill: #eef2f6; font: 600 13px Inter, system-ui, sans-serif; }
.bubble .bubble-tail, .bubble path { fill: rgba(13, 17, 21, 0.92); stroke: none; }
.call-bubble rect { stroke: var(--accent); }
.call-bubble text { fill: #ffc59e; font-weight: 800; text-anchor: middle; }
.note-bubble rect { stroke: var(--warn); }
.note-bubble text { fill: var(--warn); font-weight: 800; text-anchor: middle; }
.lesson-ring { fill: none; stroke: var(--ball); stroke-width: 3; animation: ringPulse 1s ease-in-out infinite; }
@keyframes ringPulse { 0%,100% { stroke-opacity: 0.5; r: 22; } 50% { stroke-opacity: 1; } }

.spot-label {
  fill: rgba(255, 255, 255, 0.82);
  font: 800 10.5px Inter, system-ui, sans-serif;
  text-anchor: middle;
  letter-spacing: 0.08em;
  paint-order: stroke;
  stroke: rgba(15, 30, 18, 0.55);
  stroke-width: 2.5;
}
.spot-note { fill: rgba(255, 255, 255, 0.85); letter-spacing: 0.02em; font-weight: 600; }
.spot-dot { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.6; }
.spot-hole { fill: rgba(255, 214, 102, 0.07); stroke: rgba(255, 214, 102, 0.35); stroke-width: 1.4; stroke-dasharray: 4 6; }

.draw-object { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.draw-object.dashed { stroke-dasharray: 11 9; }

/* chips over the field */
.callchip {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(13, 17, 21, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #dfe6ee;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.ctxbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  display: flex;
  gap: 6px;
  z-index: 5;
}
.ctxbar:empty { display: none; }
.ctxbar button {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(13, 17, 21, 0.85);
  color: #eef2f6;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ctxbar button.accent { border-color: rgba(240, 116, 42, 0.7); color: #ffb27e; }
.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  bottom: 52px;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(13, 17, 21, 0.9);
  border: 1px solid rgba(255,255,255,0.22);
  color: #eef2f6;
  font-size: 12.5px;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- rail ---------- */
.rail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 90px);
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  padding: 11px 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.panel { padding: 14px; overflow-y: auto; }
.panel.hidden { display: none; }
.panel section { margin-bottom: 18px; }
.panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}
.note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 6px 0 0; }
.note-inline { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.hint-line { color: var(--muted); font-size: 12px; line-height: 1.55; border-top: 1px solid var(--line); padding-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.chip.active { border-color: rgba(240, 116, 42, 0.65); background: var(--accent-soft); color: #ffb27e; }

.field-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.field-row label { color: var(--muted); font-size: 12px; }
.field-row select, .field-row input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
}
.field-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.field-row input[type="color"] { width: 30px; height: 30px; border: none; background: none; padding: 0; cursor: pointer; }

.toggles { display: grid; gap: 8px; }
.toggle { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.toggle input { accent-color: var(--accent); margin-top: 2px; }
.toggle em { color: var(--muted); font-style: normal; font-size: 11.5px; }

.toolrow { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tool {
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.tool.active { border-color: rgba(240, 116, 42, 0.65); background: var(--accent-soft); color: #ffb27e; }

.row-buttons { display: flex; gap: 7px; flex-wrap: wrap; }
.text-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.text-btn.primary { border-color: rgba(240, 116, 42, 0.6); background: var(--accent-soft); color: #ffb27e; }
.text-btn:disabled { opacity: 0.4; cursor: default; }
.quiz-btn { width: 100%; text-align: left; }

/* lessons */
.lesson-list { display: grid; gap: 7px; }
.lesson-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: block;
  width: 100%;
}
.lesson-card b { font-size: 13.5px; display: block; }
.lesson-card span { color: var(--muted); font-size: 11.5px; }
.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.lesson-head b { font-size: 15px; }
.caption-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 58px;
}
.choice-row { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
.choice-row.hidden { display: none; }
.choice-row button {
  flex: 1;
  border: 1px solid rgba(240, 116, 42, 0.6);
  background: var(--accent-soft);
  color: #ffb27e;
  border-radius: 9px;
  padding: 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.transport { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.step-dots { display: flex; gap: 4px; margin-left: auto; }
.step-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.step-dots i.on { background: var(--accent); }
.keypoint { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(88, 214, 141, 0.08); border: 1px solid rgba(88, 214, 141, 0.25); color: #bdebd1; font-size: 12.5px; line-height: 1.5; }
.keypoint b { color: #7fe3a8; }
.quiz-result { margin-top: 10px; padding: 11px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.quiz-result.ok { background: rgba(88, 214, 141, 0.1); border: 1px solid rgba(88, 214, 141, 0.35); }
.quiz-result.no { background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.35); }
.quiz-result.hidden { display: none; }
.hidden { display: none !important; }

/* library */
.lib-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.lib-list li {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lib-list .lib-name { flex: 1; min-width: 0; font-weight: 700; font-size: 13px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-list .lib-actions { display: flex; gap: 3px; }
.lib-list .lib-actions button {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; padding: 5px; border-radius: 6px; display: grid; place-items: center;
}
.lib-list .lib-actions button:hover { color: var(--ink); background: rgba(255,255,255,0.06); }
.lib-empty { color: var(--muted); font-size: 12.5px; padding: 4px 2px; }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
  .stage { position: static; }
  .board { max-width: none; border-radius: 10px; }
  .rail { max-height: none; border-radius: 12px; }
  .panel { max-height: 46dvh; }
  .subtitle { max-width: 38vw; }
  .topbar { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
}
@media (max-width: 640px) {
  .brand-text h1 { font-size: 13px; white-space: nowrap; }
  .subtitle { font-size: 10.5px; max-width: 34vw; }
  .brand-mark { width: 30px; height: 30px; }
  .icon-btn { width: 36px; height: 36px; }
  .callchip { font-size: 10px; padding: 4px 8px; }
  .flabel { font-size: 20px; }
  .flabel-sm { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .pass-halo, .halo-hint, .lesson-ring { animation: none; }
  .toast, .icon-btn, button { transition: none; }
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (min-width: 901px) {
  .panel { flex: 1; }
}
