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

:root {
  --bg: #0a0d13;
  --glass: rgba(15, 19, 28, 0.72);
  --glass-strong: rgba(13, 17, 26, 0.9);
  --border: rgba(255, 255, 255, 0.09);
  --border-lit: rgba(255, 255, 255, 0.18);
  --text: #eef1f7;
  --muted: #98a2b6;
  --accent: #6366f1;
  --accent2: #22d3ee;
  --grad: linear-gradient(135deg, #6366f1, #22d3ee);
  --danger: #f47171;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  /* live heights of the floating top bar / timeline, kept in sync from JS so
     the side panels always dock just below the top bar and above the timeline
     no matter how the bars wrap on narrow screens */
  --topbar-h: 62px;
  --timeline-h: 68px;
}

html, body, #app { height: 100%; overflow: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; }

#canvasWrap { position: absolute; inset: 0; }
#canvasWrap canvas { display: block; touch-action: none; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

/* ================= Top bar ================= */
#topbar {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 6px;
  gap: 10px;
  padding: 8px 14px;
  z-index: 30;
  /* capped so the bar wraps into the same neat block on every screen size */
  max-width: min(640px, calc(100% - 24px));
}

.brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.9);
}
.brand-3d {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-left: 2px;
}

.sport-select {
  font-weight: 600;
  font-size: 13px;
  min-width: 160px;
}

/* segmented control */
.seg {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--grad); color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,.4); }

/* ================= Buttons & inputs ================= */
.btn {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--border-lit); }
.btn:active { transform: scale(0.97); }
.btn.slim { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: rgba(244, 113, 113, 0.3); }
.btn.danger:hover { background: rgba(244, 113, 113, 0.12); }
.btn.grow { flex: 1; }
.btn.frame-add { border-style: dashed; color: var(--muted); }
.btn.frame-add:hover { color: var(--text); }
.btn.recording {
  background: #b91c1c;
  border-color: #ef4444;
  color: #fff;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.12); }
.icon-btn.small { width: 24px; height: 24px; font-size: 11px; }
.icon-btn.danger { color: var(--danger); }

/* SVG icon system (replaces emoji) — icons inherit currentColor */
svg.ic { width: 17px; height: 17px; display: block; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-btn.small svg.ic { width: 14px; height: 14px; }
.play-btn svg.ic { width: 20px; height: 20px; stroke-width: 2.4; }
.equip-item svg.ic { width: 20px; height: 20px; }
.btn svg.ic { width: 15px; height: 15px; display: inline-block; vertical-align: -2px; margin-right: 6px; }
.btn.slim svg.ic { margin-right: 5px; }
.check svg.ic { width: 15px; height: 15px; display: inline-block; }

select, input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
  outline: none;
}
select:focus, input[type="text"]:focus { border-color: var(--accent); }
select option { background: #141924; }

input[type="color"] {
  width: 34px; height: 30px;
  border: 1px solid var(--border-lit);
  border-radius: 9px;
  background: none;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  outline: none;
  flex: 1;
  min-width: 60px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--accent); width: 14px; height: 14px; }

.val {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}

.tag {
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.25);
  padding: 3px 8px;
  border-radius: 20px;
}
.tag.off { color: var(--muted); background: rgba(255,255,255,0.05); border-color: var(--border); }

/* ================= Setup panel ================= */
#setup {
  position: absolute;
  top: calc(var(--topbar-h) + 14px); left: 14px;
  bottom: calc(var(--timeline-h) + 14px);
  width: 232px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  font-weight: 700;
  font-size: 13px;
}
#setup section {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
#setup { overflow-y: auto; }
#setup::-webkit-scrollbar { width: 8px; }
#setup::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

#setup h3 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.row { display: flex; align-items: center; gap: 8px; }
.row .lbl { color: var(--muted); font-size: 12px; min-width: 52px; }
.row select { flex: 1; min-width: 0; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slider-row label { color: var(--muted); font-size: 11px; font-weight: 600; min-width: 62px; }

#expandSetup {
  position: absolute;
  top: calc(var(--topbar-h) + 14px); left: 14px;
  z-index: 25;
  width: 34px; height: 34px;
}

/* ================= Selection card ================= */
#panel {
  position: absolute;
  top: calc(var(--topbar-h) + 14px); right: 56px;
  width: 172px;
  max-height: calc(100% - var(--topbar-h) - var(--timeline-h) - 28px);
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}
#panelTitle { font-weight: 700; font-size: 12px; }
#mainRow { gap: 6px; }
#mainRow input[type="color"] { width: 28px; height: 26px; }
#mainRow input[type="text"] { flex: 1; min-width: 0; width: 44px; text-align: center; font-weight: 700; padding: 5px 6px; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-row label { color: var(--muted); font-size: 12px; }
.panel-row input[type="text"] { width: 62px; text-align: center; font-weight: 700; }

/* ================= Timeline ================= */
#timeline {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 1500px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  z-index: 30;
}

.play-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--grad);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  transition: transform 0.1s, filter 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 2px;
}
.play-btn:hover { filter: brightness(1.15); }
.play-btn:active { transform: scale(0.94); }
.play-btn.playing { padding-left: 0; }

#scrubWrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 160px;
  display: flex;
  align-items: center;
}
#scrub { width: 100%; flex: 1; }
#scrub::-webkit-slider-thumb { border-color: var(--accent2); position: relative; z-index: 2; }
#scrubTicks {
  position: absolute;
  left: 8px; right: 8px; top: 0; bottom: 0;
  pointer-events: none;
}
.scrub-tick {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 12px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.5);
  border-radius: 1px;
}

.tl-controls { display: flex; align-items: center; gap: 8px; }
.tl-controls input[type="range"] { width: 70px; flex: none; }

.sep { width: 1px; height: 26px; background: rgba(255, 255, 255, 0.12); flex-shrink: 0; }

#frames {
  display: flex;
  gap: 5px;
  align-items: center;
  overflow-x: auto;
  max-width: 34vw;
  padding: 2px;
}
#frames::-webkit-scrollbar { height: 6px; }
#frames::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.frame-chip {
  min-width: 32px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  transition: all 0.12s;
}
.frame-chip:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.frame-chip.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}
.frame-chip.has-cam { box-shadow: inset 0 -3px 0 var(--accent2); }
.frame-chip.active.has-cam { box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4), inset 0 -3px 0 #9ff3ff; }
#camBtn.active {
  color: #22d3ee;
  border-color: var(--accent2);
  background: rgba(34, 211, 238, 0.12);
}

/* ================= Notes panel ================= */
#notesPanel {
  position: absolute;
  top: calc(var(--topbar-h) + 14px); right: 56px;
  bottom: calc(var(--timeline-h) + 14px);
  width: 258px;
  z-index: 26;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
}
#notesPanel textarea {
  flex: 1;
  margin: 8px 12px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px;
  resize: none;
  outline: none;
}
#notesPanel textarea:focus { border-color: var(--accent); }
.notes-tag {
  margin: 6px 12px 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent2);
}
body.notes-open #panel { right: 286px; }
/* active mode buttons in the top bar: blue outline */
#topbar .icon-btn.active {
  color: #a5b4fc;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.16);
  box-shadow: 0 0 0 1.5px rgba(99, 102, 241, 0.65);
}

/* ================= Equipment palette ================= */
/* Equipment palette — original dark-glass structure (matches the other panels),
   with the refined "1a" glyphs kept, in white */
#equipPanel {
  position: absolute;
  top: calc(var(--topbar-h) + 14px);
  right: 10px;
  z-index: 31;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 5px;
}
.equip-item {
  position: relative;
  width: 32px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.equip-item:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.equip-item.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.2);
  box-shadow: 0 0 0 1.5px rgba(99, 102, 241, 0.65);
  color: #a5b4fc;
}
.equip-item i {
  position: absolute;
  bottom: 0; right: 3px;
  font-style: normal;
  font-size: 8px;
  font-weight: 700;
  color: var(--muted);
}
/* the refined 1a glyph — sized & coloured to match the top-bar icon set */
.eq-ic {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
  display: block;
}
.eq-menu-ico { display: inline-flex; color: var(--muted); }
.eq-menu-ico .eq-ic { width: 16px; height: 16px; }

/* CSS-drawn palette icons */
.zone-ico {
  width: 18px; height: 13px;
  border: 1.5px dashed #22d3ee;
  border-radius: 2px;
  display: inline-block;
}
.tool-ico { display: inline-block; }
.line-ico {
  width: 18px; height: 0;
  border-top: 2.5px solid #fff;
  border-radius: 2px;
}
.circ-ico {
  width: 15px; height: 15px;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* line/circle dropdown */
.equip-wrap { position: relative; }
.equip-caret {
  position: absolute;
  top: 0; right: 2px;
  font-size: 8px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1;
}
.equip-menu {
  position: absolute;
  top: 0; right: 46px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(20, 22, 28, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
.equip-menu.hidden { display: none; }
.equip-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.equip-menu button:hover { background: rgba(255, 255, 255, 0.1); }
body.notes-open #panel { right: 286px; }

/* slim minimised bars */
#topbarMini {
  position: absolute;
  top: 0; left: 12px; right: 12px;
  height: 16px;
  border-radius: 0 0 10px 10px;
  z-index: 30;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
}
#topbarMini:hover { color: var(--text); background: rgba(99, 102, 241, 0.18); }
#expandSetup {
  top: calc(var(--topbar-h) + 14px) !important;
  bottom: calc(var(--timeline-h) + 14px);
  left: 0 !important;
  width: 16px !important;
  height: auto !important;
  border-radius: 0 10px 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
}
#expandSetup:hover { color: var(--text); background: rgba(99, 102, 241, 0.18); }

/* ================= Converge menu ================= */
#ctxMenu {
  position: fixed;
  z-index: 60;
  padding: 6px;
}

/* ================= Controls dropdown ================= */
#controlsPanel {
  position: absolute;
  top: calc(var(--topbar-h) + 8px);
  left: 50%;
  transform: translateX(calc(-50% + 180px));
  width: 280px;
  max-height: calc(100% - var(--topbar-h) - var(--timeline-h) - 24px);
  overflow-y: auto;
  z-index: 40;
  padding-bottom: 10px;
}
.ctrl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 16px 6px;
  font-size: 12px;
  color: #cdd4e1;
}
.ctrl-list b { color: #a5b4fc; font-weight: 600; }

/* ================= Rubber-band select ================= */
#rubber {
  position: fixed;
  border: 1.5px dashed var(--accent2);
  background: rgba(34, 211, 238, 0.08);
  border-radius: 4px;
  pointer-events: none;
  z-index: 50;
}

/* ================= Quiz bar ================= */
#quizBar {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  z-index: 35;
  max-width: calc(100% - 28px);
}
#quizQ {
  font-weight: 600;
  font-size: 14px;
  color: #ffe08a;
}
#quizBar .btn { background: var(--grad); border: none; font-weight: 700; }

/* ================= Help ================= */
#helpModal {
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.help-card {
  background: var(--glass-strong);
  padding: 28px 32px;
  max-width: 580px;
  max-height: 82vh;
  overflow-y: auto;
}
.help-card h2 { margin-bottom: 16px; font-size: 18px; letter-spacing: -0.3px; }
.help-card ol { padding-left: 20px; display: flex; flex-direction: column; gap: 9px; line-height: 1.5; color: #cdd4e1; }
.help-card .tip { margin: 16px 0; color: var(--muted); font-size: 12px; }
.help-card b { color: #a5b4fc; font-weight: 600; }
.help-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn.ghost { background: transparent; }

/* ================= Guided tour (onboarding) ================= */
.tour-focus {
  position: relative;
  z-index: 210 !important;
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(5, 7, 12, 0.72);
  transition: box-shadow 0.2s;
}
#tourCard {
  position: fixed;
  z-index: 220;
  width: 288px;
  max-width: calc(100vw - 24px);
  padding: 16px 18px;
  background: var(--glass-strong);
}
#tourCard h4 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
#tourCard p { font-size: 12.5px; line-height: 1.55; color: #cdd4e1; margin-bottom: 12px; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.22); }
.tour-dots span.on { background: var(--accent); }
.tour-foot .btn { padding: 6px 12px; }
#tourSkip { color: var(--muted); background: transparent; border: none; cursor: pointer; font: inherit; font-size: 12px; }
#tourSkip:hover { color: var(--text); }

/* ================= Clean top-view (nothing over the pitch) ================= */
body.top-view #panel,
body.top-view #notesPanel { display: none !important; }

/* line/circle dropdown caret — a distinct arrow beside the tool */
.equip-wrap { position: relative; }
#lineCaret {
  position: absolute;
  bottom: 0; left: 1px;
  width: 13px; height: 13px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--accent2);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  z-index: 32;
}
#lineCaret:hover { color: var(--text); transform: scale(1.25); }
#lineCaret.open { color: #fff; }

.bd-swatches { display: inline-flex; gap: 5px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
.bd-sw {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border-lit);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}
.bd-sw:hover { transform: scale(1.15); }
.bd-sw.active { box-shadow: 0 0 0 2px var(--accent); }

#equipCollapse { width: 32px; height: 16px; border-radius: 6px; margin-bottom: 1px; }
#equipCollapse svg.ic { width: 11px; height: 11px; }
#expandEquip {
  position: absolute;
  top: calc(var(--topbar-h) + 14px);
  right: 0;
  width: 16px; height: 90px;
  border-radius: 10px 0 0 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  z-index: 31;
}
#expandEquip:hover { color: var(--text); background: rgba(99, 102, 241, 0.18); }
#expandEquip svg.ic { width: 11px; height: 11px; }

.set-cat {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-top: 4px;
}
.set-cat:first-child { margin-top: 0; }

/* ================= Settings dropdown ================= */
#settingsPanel {
  position: absolute;
  top: calc(var(--topbar-h) + 8px);
  left: 50%;
  transform: translateX(calc(-50% + 120px));
  width: 288px;
  z-index: 40;
  padding-bottom: 14px;
}
.set-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 16px 0;
}
.set-lbl { color: var(--muted); font-size: 12px; }
.set-val {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* ================= Hint bar ================= */
#hintBar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--timeline-h) + 22px);
  max-width: min(720px, calc(100% - 28px));
  padding: 7px 16px;
  border-radius: 999px;
  z-index: 24;
  pointer-events: none;
  font-size: 12px;
  color: #c3cbda;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hintBar b { color: #a5b4fc; font-weight: 600; }

/* ================= Context menu (dynamic) ================= */
#ctxMenu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  min-width: 168px;
}
#ctxMenu .ctx-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 10px 2px;
}
#ctxMenu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
#ctxMenu button:hover { background: rgba(99, 102, 241, 0.22); }
#ctxMenu button.danger { color: var(--danger); }

/* ================= Overlay modals (playbook / save / roster) ================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.pb-card {
  background: var(--glass-strong);
  width: min(880px, calc(100vw - 40px));
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
}
.pb-head { display: flex; align-items: center; gap: 12px; }
.pb-head h2 { font-size: 18px; letter-spacing: -0.3px; flex: 1; }
.pb-tip { margin: 8px 0 14px; font-size: 12px; color: var(--muted); }
#pbGrid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  padding-bottom: 6px;
}
.pb-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.pb-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.pb-item img, .pb-item .pb-noimg {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #10141c;
  display: block;
}
.pb-item .pb-noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 24px; }
.pb-meta { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 7px; }
.pb-name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.pb-row { display: flex; align-items: center; gap: 6px; }
.pb-cat {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent2);
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 2px 7px;
  border-radius: 20px;
  flex: 0 0 auto;
}
.pb-sport { font-size: 10px; color: var(--muted); }
.pb-open { flex: 1; }
.pb-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px 0 20px; font-size: 13px; }

.pbs-card, .ros-card {
  background: var(--glass-strong);
  width: min(420px, calc(100vw - 40px));
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pbs-card h2, .ros-card h2 { font-size: 17px; letter-spacing: -0.2px; }
#pbsThumb { width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; }
#pbsName { flex: 1; }
.pbs-actions { margin-top: 4px; }

.ros-card { width: min(560px, calc(100vw - 40px)); }
.ros-cols { display: flex; gap: 14px; }
.ros-cols > div { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ros-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ros-title input[type="color"] { width: 24px; height: 20px; padding: 1px; border-radius: 6px; }
.ros-cols textarea {
  height: 170px;
  resize: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 9px 11px;
  outline: none;
}
.ros-cols textarea:focus { border-color: var(--accent); }

/* ================= Player view — clean watch-only mode ================= */
body.player-view #topbar, body.player-view #topbarMini, body.player-view #setup,
body.player-view #expandSetup, body.player-view #equipPanel, body.player-view #expandEquip,
body.player-view #panel, body.player-view #notesPanel, body.player-view #hintBar,
body.player-view #timeline, body.player-view #controlsPanel, body.player-view #settingsPanel,
body.player-view #quizBar { display: none !important; }
#pvExit {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top)); right: 12px;
  z-index: 45;
  color: var(--muted);
}
#pvExit:hover { color: var(--text); }
#pvBar {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  z-index: 44;
  max-width: calc(100% - 20px);
}
#pvBar .icon-btn { width: 44px; height: 44px; }
#pvBar .icon-btn svg.ic { width: 19px; height: 19px; }
#pvBar .play-btn { width: 54px; height: 54px; }
#pvSpeed { min-width: 52px; font-weight: 700; padding: 11px 10px; }
#pvChips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: min(44vw, 430px);
  padding: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.pv-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 13px;
  cursor: pointer;
  transition: all 0.12s;
}
.pv-chip::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--chip, #888); flex-shrink: 0; }
.pv-chip.active {
  border-color: #ffd54a;
  box-shadow: 0 0 0 1.5px rgba(255, 213, 74, 0.7);
  color: #ffe9a8;
  background: rgba(255, 213, 74, 0.1);
}
#pvFollowP.active, #pvFollowB.active, #pvNotesBtn.active { border-color: var(--accent); color: #a5b4fc; box-shadow: 0 0 0 1.5px rgba(99, 102, 241, 0.6); }
#pvBanner {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 45;
  padding: 9px 22px;
  font-size: 12px; font-weight: 800;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: #ffd54a;
  pointer-events: none;
}
#pvSelect {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top)); right: 96px;
  z-index: 45;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(16, 20, 28, 0.82);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  max-width: min(210px, 44vw);
  outline: none;
}
#pvSelect:focus { border-color: #ffd54a; }
#pvNotes {
  position: absolute;
  right: 12px; bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 45;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
#pvNotes textarea {
  height: 150px;
  resize: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit; font-size: 13px; line-height: 1.6;
  padding: 9px 11px;
  outline: none;
}
#pvNotes textarea:focus { border-color: #ffd54a; }
/* phones & small tablets: the bar spans the width, chips take the slack */
@media (max-width: 760px) {
  #pvBar { left: 8px; right: 8px; transform: none; }
  #pvChips { max-width: none; flex: 1; }
  #pvSelect { right: 76px; }
}

/* ================= Play browser — folders · plays · preview ================= */
.brw-card {
  background: var(--glass-strong);
  width: min(980px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 56px));
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
}
.brw-cols {
  flex: 1;
  display: grid;
  grid-template-columns: 175px minmax(160px, 235px) 1fr;
  gap: 14px;
  min-height: 0;
  margin-top: 12px;
}
.brw-col {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}
#brwFolderList { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px; min-height: 34%; }
.brw-tags-lbl { padding: 6px 12px 2px; border-top: 1px solid var(--border); }
#brwTagList { flex: 0 1 33%; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 3px; }
.brw-fdot { width: 11px; height: 11px; border-radius: 4px; display: inline-block; flex: 0 0 auto; }
.brw-mid { min-height: 0; }
#brwSearch {
  margin: 8px 8px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font: inherit; font-size: 12.5px;
  padding: 8px 10px; outline: none;
  flex: 0 0 auto;
}
#brwSearch:focus { border-color: var(--accent); }
.brw-folder {
  display: flex; align-items: center; gap: 7px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  background: none; border: none;
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.brw-folder span { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; }
.brw-folder:hover { background: rgba(255, 255, 255, 0.06); }
.brw-folder.active { background: rgba(99, 102, 241, 0.2); }
.brw-foot {
  display: flex; gap: 10px;
  padding: 9px;
  border-top: 1px solid var(--border);
  justify-content: center;
}
#brwPlayList { padding: 8px; gap: 3px; }
.brw-play {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  background: none; border: none;
  color: var(--text);
  font: inherit; font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.brw-play b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.brw-play .sub { margin-left: auto; color: var(--muted); font-size: 10px; flex: 0 0 auto; }
.brw-play em { font-style: normal; color: #ffd54a; font-size: 12px; flex: 0 0 auto; }
.brw-play svg.ic { width: 13px; height: 13px; color: #ffd54a; flex: 0 0 auto; }
.brw-play:hover { background: rgba(255, 255, 255, 0.06); }
.brw-play.active { background: rgba(99, 102, 241, 0.2); }
.brw-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 26px 12px; line-height: 1.7; }
.brw-right { padding: 12px; gap: 8px; }
#brwCanvas { width: 100%; border-radius: 10px; border: 1px solid var(--border); background: #10141c; flex: 0 0 auto; }
#brwMeta { font-size: 12px; color: var(--muted); line-height: 1.5; }
#brwMeta b { color: var(--text); }
.brw-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 3px; }
.brw-hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
#brwNotes {
  height: 104px; resize: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 12.5px; line-height: 1.55;
  padding: 8px 10px; outline: none;
}
#brwTags {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 12.5px;
  padding: 8px 10px; outline: none;
}
#brwNotes:focus, #brwTags:focus { border-color: var(--accent); }
#brwTagFilter {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 12.5px;
  padding: 6px 9px; outline: none;
}
#brwExport { margin-top: auto; }
#pbsCanvas { width: 100%; border-radius: 10px; border: 1px solid var(--border); background: #10141c; }

/* themed dialogs + export toast */
.ui-card {
  background: var(--glass-strong);
  width: min(400px, calc(100vw - 40px));
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.ui-card h2 { font-size: 16.5px; letter-spacing: -0.2px; }
.ui-card p { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0; }
#uiInput {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 13.5px;
  padding: 10px 12px; outline: none;
}
#uiInput:focus { border-color: var(--accent); }
.btn.danger { background: linear-gradient(180deg, #d54848, #b23434); border-color: transparent; color: #fff; }
#exProgress {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px; z-index: 150;
  padding: 12px 20px;
  font-size: 13px; font-weight: 600;
}
#brwMenu {
  position: fixed;
  z-index: 130;
  display: flex; flex-direction: column;
  padding: 6px;
  min-width: 190px;
}
#brwMenu button {
  display: flex; align-items: center; gap: 7px;
  background: none; border: none;
  color: var(--text);
  font: inherit; font-size: 13px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
#brwMenu button:hover { background: rgba(99, 102, 241, 0.22); }
#brwMenu button.danger { color: var(--danger); }
#brwMenu button svg.ic { width: 14px; height: 14px; }
@media (max-width: 860px) {
  .brw-cols { grid-template-columns: 150px 1fr; grid-template-rows: 1fr auto; }
  .brw-right { grid-column: 1 / -1; max-height: 42%; }
}

/* Tablets & touch screens: bigger targets */
@media (pointer: coarse) {
  .btn { padding: 11px 16px; font-size: 14px; }
  .btn.slim { padding: 9px 12px; font-size: 13px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.small { width: 32px; height: 32px; }
  .frame-chip { min-width: 42px; height: 40px; font-size: 14px; }
  .play-btn { width: 54px; height: 54px; font-size: 18px; }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; }
  input[type="color"] { width: 42px; height: 38px; }
  select, input[type="text"] { padding: 10px 12px; font-size: 15px; }
  #setup { width: 268px; }
  #panel { width: 220px; }
}

@media (max-width: 1150px) {
  body.notes-open #panel { right: 340px; }
}

/* Phone-width: narrow the side panels so the pitch stays usable */
@media (max-width: 560px) {
  #setup { width: 200px; }
  #panel { width: 168px; }
  #notesPanel { width: 210px; }
  .brand { display: none; }
  #timeline { left: 8px; right: 8px; transform: none; max-width: none; justify-content: center; }
}

/* Narrow screens: let panels shrink */
@media (max-width: 900px) {
  #setup { width: 208px; }
  #frames { max-width: 22vw; }
  .tl-controls input[type="range"] { width: 50px; }
  #scrub { flex-basis: 90px; }
}
