/* ============================================================
   CrewXR Playbook — "Chalk & Turf" coach's board
   Dark slate sideline, chalk linework, whistle-amber accents.
   ============================================================ */

:root {
  --board: #11181a;
  --board-2: #161f22;
  --rail: #0c1213;
  --line: #2a3639;
  --chalk: #e8e4d8;
  --chalk-dim: #9aa49b;
  --amber: #f0a92e;
  --red: #e2474b;
  --blue: #3f7fe8;
  --turf: #2e7d46;
  --font-display: "Bebas Neue", "Barlow Condensed", sans-serif;
  --font-body: "Barlow", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  display: flex;
  font-family: var(--font-body);
  color: var(--chalk);
  background:
    radial-gradient(1200px 800px at 70% -10%, #1b2629 0%, transparent 60%),
    var(--board);
  overflow: hidden;
}

/* subtle chalk-dust grain over everything */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---------------- rail ---------------- */

#rail {
  width: 232px;
  min-width: 232px;
  height: 100%;
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  z-index: 2;
}

#brand { display: flex; align-items: flex-start; gap: 10px; }

.whistle-dot {
  width: 12px; height: 12px;
  margin-top: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 14px rgba(240, 169, 46, .7);
}

#brand h1 {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: .04em;
  line-height: .9;
  color: var(--chalk);
}
#brand h1 span { color: var(--amber); }

.rail-group h2 {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .14em;
  color: var(--chalk-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rail-group h2 .accent { color: var(--amber); letter-spacing: .05em; }

/* sport selector */
#sport-list { display: flex; flex-direction: column; gap: 4px; }

.sport-btn {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: .08em;
  text-align: left;
  padding: 7px 12px;
  color: var(--chalk-dim);
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s ease;
}
.sport-btn:hover { color: var(--chalk); background: var(--board-2); }
.sport-btn.active {
  color: var(--chalk);
  background: var(--board-2);
  border-left-color: var(--amber);
}

/* legend */
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.legend-row { display: flex; align-items: center; gap: 9px; color: var(--chalk-dim); }
.legend-row .count { margin-left: auto; font-weight: 600; color: var(--chalk); }
.dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); }
.dot.red { background: var(--red); }
.dot.blue { background: var(--blue); }

/* scale slider */
input[type="range"] {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #1b1407;
  cursor: pointer;
}
/* toggle switches (XR display) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
  color: var(--chalk-dim);
  cursor: pointer;
}
.switch {
  position: relative;
  width: 40px; height: 22px;
  border-radius: 999px;
  background: var(--line);
  border: 1px solid #324043;
  cursor: pointer;
  transition: background .18s ease;
  flex: none;
}
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--chalk-dim);
  transition: transform .18s ease, background .18s ease;
}
.switch.on { background: rgba(240, 169, 46, .35); border-color: var(--amber); }
.switch.on .knob { transform: translateX(18px); background: var(--amber); }

.scale-marks {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--chalk-dim);
  margin-top: 6px;
  text-transform: uppercase; letter-spacing: .08em;
}

/* XR panel */
#xr-group { margin-top: auto; }

#xr-group input {
  width: 100%;
  margin-bottom: 7px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--chalk);
  background: var(--board-2);
  border: 1px solid var(--line);
  border-radius: 4px;
}
#xr-group input:focus { outline: none; border-color: var(--amber); }

#xr-error {
  font-size: 11.5px;
  color: #e07070;
  margin-top: 6px;
  word-break: break-word;
  max-height: 60px;
  overflow-y: auto;
}

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #555;
  transition: background .3s;
}
.status-dot.on { background: #46c46a; box-shadow: 0 0 10px rgba(70,196,106,.8); }
.status-dot.err { background: #e05555; }

/* ---------------- buttons ---------------- */

.btn {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: .1em;
  padding: 8px 16px;
  color: var(--chalk);
  background: var(--board-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: var(--chalk-dim); }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: var(--chalk-dim); }
.btn.ghost:hover { color: var(--chalk); }
.btn.accent-btn {
  background: var(--amber);
  color: #1b1407;
  border-color: var(--amber);
  font-weight: 600;
}
.btn.accent-btn:hover { filter: brightness(1.1); }
.btn.step { padding: 8px 12px; font-size: 13px; }

/* ---------------- stage ---------------- */

#stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 18, 19, .6);
}

#play-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: .05em;
  color: var(--chalk);
  background: transparent;
  border: none;
  border-bottom: 2px dashed transparent;
  padding: 2px 4px;
}
#play-name:focus { outline: none; border-bottom-color: var(--amber); }
#play-name::placeholder { color: #4a5a57; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

#play-select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  color: var(--chalk);
  background: var(--board-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  max-width: 180px;
}

/* canvas */
#canvas-wrap { flex: 1; position: relative; min-height: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; cursor: default; }
#field.dragging { cursor: grabbing; }

#sync-flash {
  position: absolute;
  top: 14px; right: 18px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: .12em;
  color: var(--amber);
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}
#sync-flash.show { opacity: 1; }

/* ---------------- bench / timeline ---------------- */

#bench {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: rgba(12, 18, 19, .6);
}

#timeline {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  flex: 1;
}

.chip {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .08em;
  min-width: 52px;
  padding: 7px 14px;
  text-align: center;
  color: var(--chalk-dim);
  background: var(--board-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.chip:hover { color: var(--chalk); }
.chip.active {
  color: #1b1407;
  background: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}

.bench-right { display: flex; gap: 8px; margin-left: 6px; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
