:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5d6673;
  --line: #d8d2c8;
  --paper: #f8f7f4;
  --panel: #ffffff;
  --court: #f2dfbd;
  --court-line: #423d36;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #3157d5;
  --orange: #d88a21;
  --green: #2ca24d;
  --red: #d43d4c;
  --purple: #a43dcc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.control-group {
  display: grid;
  gap: 10px;
}

.control-group h2 {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.transport {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
}

.icon-button,
.primary-button,
.tab-button,
.segment-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.icon-button:hover,
.primary-button:hover,
.tab-button:hover,
.segment-button:hover {
  border-color: #aeb7b5;
}

.icon-button:active,
.primary-button:active,
.tab-button:active,
.segment-button:active {
  transform: translateY(1px);
}

.tab-button:disabled,
.segment-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  font-size: 1.8rem;
  line-height: 1;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border-radius: 6px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.transport-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.transport-icon::before,
.transport-icon::after {
  content: "";
  display: block;
}

.transport-icon.play::before {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

.transport-icon.pause {
  grid-template-columns: repeat(2, 4px);
  gap: 4px;
}

.transport-icon.pause::before,
.transport-icon.pause::after {
  width: 4px;
  height: 14px;
  border-radius: 1px;
  background: currentColor;
}

.range-row {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.range-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.timeline-time {
  color: var(--ink);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.select-row {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.select-row select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 700;
}

.audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
  font-size: 0.86rem;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mode-control label {
  display: block;
  min-width: 0;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control span {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.mode-control input:checked + span {
  border-color: var(--accent);
  background: #dff3ef;
  color: #064e49;
}

.audio-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-variant-numeric: tabular-nums;
}

#modeLabel {
  color: var(--accent-dark);
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.segments {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.tab-button,
.segment-button {
  min-height: 36px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.tab-button.active,
.segment-button.active {
  border-color: var(--accent);
  background: #dff3ef;
  color: #064e49;
}

.lineup {
  display: grid;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.lineup li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 0.88rem;
  color: var(--ink);
}

.lineup li.self-role {
  font-weight: 800;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.zone-pill {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.lineup li.self-role .zone-pill {
  color: var(--accent-dark);
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 22px;
  min-width: 0;
}

.score-strip {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-strip strong {
  display: block;
  min-height: 1.4em;
  font-size: 1rem;
}

.sync-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 0;
}

.sync-workspace.video-mode {
  grid-template-columns: minmax(360px, 1.2fr) minmax(320px, 0.8fr);
}

.sync-workspace.overlay-mode {
  grid-template-columns: minmax(0, 1fr);
}

.sync-workspace.overlay-mode .court-wrap {
  display: none;
}

.court-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
}

#court {
  width: min(100%, 920px);
  max-height: calc(100vh - 210px);
  aspect-ratio: 1.44;
  display: block;
}

.video-pane {
  display: none;
  margin: 0;
  min-width: 0;
}

.sync-workspace.video-mode .video-pane {
  display: grid;
  gap: 8px;
}

.sync-workspace.overlay-mode .video-pane {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.video-frame {
  position: relative;
  width: 100%;
}

.sync-workspace.overlay-mode .video-frame {
  width: min(100%, 1100px);
}

.video-frame video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.video-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.video-overlay marker path {
  fill: rgba(15, 118, 110, 0.85);
}

.overlay-move {
  stroke: rgba(15, 118, 110, 0.76);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 8 7;
  marker-end: url("#overlayArrow");
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.8));
}

.overlay-move.self {
  stroke: #f2c94c;
  stroke-width: 4.5;
}

.overlay-role circle {
  fill: rgba(255, 255, 255, 0.08);
  stroke: var(--role-color);
  stroke-width: 4;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.overlay-role text {
  text-anchor: middle;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.72);
  stroke-width: 4px;
  font-size: 15px;
  font-weight: 900;
}

.overlay-role.self circle {
  fill: rgba(242, 201, 76, 0.18);
  stroke: #f2c94c;
  stroke-width: 5;
}

.overlay-self-marker circle,
.overlay-self-marker path {
  fill: none;
  stroke: #f2c94c;
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.video-pane figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.sync-workspace.video-mode #court {
  max-height: calc(100vh - 230px);
}

.court-floor {
  fill: var(--court);
  stroke: var(--court-line);
  stroke-width: 1.1;
}

.court-grid {
  fill: url("#floorPattern");
  stroke: none;
  opacity: 0.85;
}

.net {
  stroke: #26231f;
  stroke-width: 2;
}

.attack-line,
.center-guide {
  stroke: #6d6256;
  stroke-width: 0.8;
}

.center-guide {
  opacity: 0.22;
  stroke-dasharray: 2 2;
}

.court-label {
  text-anchor: middle;
  fill: #302b25;
  font-size: 4px;
  font-weight: 800;
}

.court-zone {
  text-anchor: middle;
  fill: #8c7c69;
  font-size: 5px;
  font-weight: 800;
  opacity: 0.52;
}

.trail {
  fill: none;
  stroke: rgba(15, 118, 110, 0.32);
  stroke-width: 1.5;
  stroke-dasharray: 2 2;
}

.player {
  transition: transform 650ms cubic-bezier(0.2, 0.9, 0.25, 1);
}

.player.dim {
  opacity: 0.42;
}

.player circle {
  stroke: #fff;
  stroke-width: 1.8;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.player.self circle {
  stroke: var(--accent-dark);
  stroke-width: 2.3;
}

.player text {
  text-anchor: middle;
  dominant-baseline: central;
  fill: #fff;
  font-size: 4.4px;
  font-weight: 900;
  pointer-events: none;
}

.bench circle {
  opacity: 0.55;
}

.bench text {
  opacity: 0.85;
}

.legend {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 850px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    padding-top: 14px;
  }

  #court {
    max-height: none;
  }

  .score-strip {
    grid-template-columns: 1fr;
  }

  .sync-workspace.video-mode {
    grid-template-columns: 1fr;
  }

  .legend {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
