.builder-page .container {
  width: min(96vw, 1680px);
  max-width: min(96vw, 1680px);
}

.builder-page .page-hero {
  padding: 0.25rem 0 0.2rem;
}

.builder-page .page-hero-copy h1 {
  margin-bottom: 0.35rem;
}

.builder-page .page-hero-copy p {
  margin: 0;
}

.builder-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 330px;
  gap: 0.7rem;
  align-items: start;
}

.builder-layout.details-collapsed {
  grid-template-columns: 290px minmax(0, 1fr);
}

.builder-layout.details-collapsed .builder-settings-panel {
  display: none;
}

.builder-sidebar,
.builder-settings-panel,
.step-timeline-card,
.builder-main-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.builder-sidebar,
.builder-settings-panel {
  padding: 0.65rem;
}

.builder-sidebar {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.builder-main-panel {
  padding: 0.55rem;
  min-width: 0;
}

.builder-settings-panel {
  min-width: 0;
}

.builder-settings-panel h3,
.builder-sidebar h3,
.step-timeline-title-wrap h3 {
  margin: 0 0 0.25rem;
}

.builder-settings-panel p,
.builder-sidebar p,
.step-timeline-title-wrap p {
  margin: 0;
  color: var(--text-muted);
}

.builder-settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.4rem;
}

.builder-top-bar {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 0.45rem;
}

.builder-top-message {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  background: rgba(255, 196, 0, 0.18);
  color: #7a5200;
  border: 1px solid rgba(226, 176, 0, 0.45);
}

.builder-layout.details-collapsed .builder-top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-areas:
    "message details"
    "message save";
  gap: 0.45rem 0.55rem;
  align-items: start;
}

.builder-layout.details-collapsed .builder-top-message {
  grid-area: message;
  justify-self: center;
  max-width: none;
}

.builder-settings-grid {
  display: grid;
  gap: 0.48rem;
}

.builder-settings-grid label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.builder-settings-grid input,
.builder-settings-grid select,
.builder-settings-grid textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.62rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.builder-settings-grid textarea {
  min-height: 90px;
  resize: vertical;
}

.required-field {
  position: relative;
}

.required-field.is-missing {
  color: #c53030;
}

.required-field.is-missing input,
.required-field.is-missing select,
.required-field.is-missing textarea {
  border-color: #e53e3e;
  background: #fff5f5;
}

.builder-settings-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.builder-settings-actions-primary {
  justify-content: stretch;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 0.35rem;
}

.save-drill-btn,
.save-drill-btn:visited,
.save-drill-btn:hover,
.save-drill-btn:focus,
.save-drill-btn:active,
.save-drill-collapsed-btn,
.save-drill-collapsed-btn:visited,
.save-drill-collapsed-btn:hover,
.save-drill-collapsed-btn:focus,
.save-drill-collapsed-btn:active {
  width: 100%;
  min-height: 56px;
  font-size: 1rem;
  font-weight: 800;
  border-width: 2px;
  background: #7bd88f !important;
  color: #083b18 !important;
  border-color: #7bd88f !important;
  box-shadow: 0 10px 24px rgba(123, 216, 143, 0.28);
}

.builder-tool-message-warning {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #f5c2c7;
}

.builder-section {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.builder-section:last-child {
  margin-bottom: 0;
}

.builder-section-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.builder-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.builder-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.builder-action-grid.builder-action-grid-2x2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.builder-action-grid .clear-full-drill-btn {
  grid-column: auto;
}

.pitch-size-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.builder-tool-btn,
.pitch-size-btn,
.tool-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  transition: 0.2s ease;
}

.builder-tool-btn,
.pitch-size-btn {
  min-height: 62px;
  padding: 0.38rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.24rem;
  text-align: center;
}

.pitch-size-btn {
  min-height: 46px;
  padding: 0.22rem 0.18rem;
  gap: 0.1rem;
}

.pitch-size-btn .builder-tool-label {
  font-size: 0.7rem;
}

.builder-tool-btn:hover,
.pitch-size-btn:hover,
.tool-btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.builder-tool-btn:disabled,
.pitch-size-btn:disabled,
.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.builder-tool-btn.active-placement-tool,
.pitch-size-btn.active-tool,
.tool-btn.active-tool {
  background: rgba(19, 102, 72, 0.1);
  border-color: var(--primary);
}

.builder-tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(19, 102, 72, 0.08);
  font-size: 0.95rem;
  line-height: 1;
  flex: 0 0 auto;
}

.builder-tool-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.tool-btn {
  min-height: 40px;
  padding: 0.55rem 0.85rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.clear-full-drill-btn {
  width: 100%;
  min-height: 36px;
  margin-top: 0.45rem;
  font-size: 0.84rem;
  padding: 0.42rem 0.7rem;
}

.builder-pitch-shell {
  position: relative;
  padding-top: 0;
}

.builder-pitch {
  position: relative;
  width: 100%;
  min-height: 360px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, #3ca15d 0%, #2b8c4e 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.builder-pitch[data-pitch-preset="full"] {
  min-height: min(48vh, 500px);
}

.builder-pitch[data-pitch-preset="half"] {
  min-height: min(50vh, 520px);
}

.builder-pitch[data-pitch-preset="quarter"] {
  min-height: min(34vh, 340px);
}

.builder-pitch[data-pitch-preset="circle"] {
  min-height: min(34vh, 340px);
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="full"] {
  min-height: min(78vh, 920px);
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="half"] {
  min-height: min(78vh, 920px);
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="quarter"] {
  min-height: min(60vh, 640px);
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="circle"] {
  min-height: min(50vh, 520px);
}

.builder-pitch.builder-locked {
  opacity: 0.82;
}

#pitchRenderLayer,
#builderFieldOverlay,
#builderDynamicItems {
  position: absolute;
  inset: 0;
}

#pitchRenderLayer {
  z-index: 1;
}

#pitchRenderLayer svg {
  width: 100%;
  height: 100%;
  display: block;
}

#builderFieldOverlay {
  z-index: 5;
  pointer-events: auto;
}

#builderDynamicItems {
  z-index: 10;
  pointer-events: none;
}

#builderDynamicItems .builder-item {
  pointer-events: auto;
}

.builder-pitch[data-pitch-preset="full"] #pitchRenderLayer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88%;
  height: 100%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.builder-pitch[data-pitch-preset="half"] #pitchRenderLayer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80%;
  height: 96%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.builder-pitch[data-pitch-preset="quarter"] #pitchRenderLayer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 108%;
  height: 200%;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

.builder-pitch[data-pitch-preset="circle"] #pitchRenderLayer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96%;
  height: 178%;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="full"] #pitchRenderLayer {
  width: 90%;
  height: 100%;
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="half"] #pitchRenderLayer {
  width: 82%;
  height: 98%;
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="quarter"] #pitchRenderLayer {
  width: 110%;
  height: 198%;
}

.builder-layout.details-collapsed .builder-pitch[data-pitch-preset="circle"] #pitchRenderLayer {
  width: 106%;
  height: 188%;
}

.show-details-fab {
  width: 100%;
  min-height: 42px;
  padding: 0.42rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 12px;
  text-align: center;
  display: none;
}

.builder-layout.details-collapsed .show-details-fab {
  display: block;
  grid-area: details;
}

.save-drill-collapsed-btn {
  display: none;
}

.builder-layout.details-collapsed .save-drill-collapsed-btn {
  display: block;
  grid-area: save;
}

.builder-item {
  position: absolute;
  user-select: none;
}

.builder-item.selected {
  outline: 3px solid #ffd54a;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.22);
  z-index: 25;
}

.builder-item.blue-player,
.builder-item.red-player,
.builder-item.goalkeeper,
.builder-item.ball,
.builder-item.cone,
.builder-item.goal {
  transform: translate(-50%, -50%);
}

.builder-item.blue-player,
.builder-item.red-player,
.builder-item.goalkeeper {
  width: 25px;
  height: 25px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.02em;
}

.builder-item.blue-player.selected,
.builder-item.red-player.selected,
.builder-item.goalkeeper.selected,
.builder-item.ball.selected,
.builder-item.cone.selected,
.builder-item.goal.selected {
  transform: translate(-50%, -50%) scale(1.08);
}

.builder-item.blue-player::after,
.builder-item.red-player::after,
.builder-item.goalkeeper::after {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.builder-item.blue-player::after,
.builder-item.red-player::after,
.builder-item.goalkeeper::after {
  content: attr(data-label);
}

.builder-item.blue-player {
  background: #1e63ff;
}

.builder-item.red-player {
  background: #e43a3a;
}

.builder-item.goalkeeper {
  background: #111;
  color: #ffd54a;
}

.builder-item.goal.selected {
  outline: 3px solid #ffd54a;
  outline-offset: 4px;
}

.builder-item.ball {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.15);
}

.builder-item.cone {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 16px solid #ff9f1c;
}

.builder-item.goal {
  width: 24px;
  height: 8px;
  border: 2px solid #fff;
  border-left-width: 3px;
  border-right-width: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.builder-item.pass-arrow,
.builder-item.run-arrow,
.builder-item.shot-arrow,
.builder-arrow-preview {
  position: absolute;
  height: 0;
  transform-origin: 0 0;
}

.builder-item.pass-arrow,
.builder-arrow-preview.pass-arrow {
  border-top: 3px dashed #ffffff;
}

.builder-item.run-arrow,
.builder-arrow-preview.run-arrow {
  border-top: 3px solid #1d4ed8;
}

.builder-item.shot-arrow,
.builder-arrow-preview.shot-arrow {
  border-top: 5px solid #ef4444;
}

.builder-item.pass-arrow.selected,
.builder-item.run-arrow.selected,
.builder-item.shot-arrow.selected {
  filter: brightness(1.08);
  z-index: 26;
}

.builder-item.pass-arrow::after,
.builder-item.run-arrow::after,
.builder-item.shot-arrow::after,
.builder-arrow-preview::after {
  content: "";
  position: absolute;
  right: -1px;
  border-left: 9px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.builder-item.pass-arrow::after,
.builder-arrow-preview.pass-arrow::after {
  top: -6px;
}

.builder-item.run-arrow::after,
.builder-arrow-preview.run-arrow::after {
  top: -6px;
}

.builder-item.shot-arrow::after,
.builder-arrow-preview.shot-arrow::after {
  top: -7px;
  border-left-width: 11px;
  border-top-width: 7px;
  border-bottom-width: 7px;
}

.builder-item.pass-arrow,
.builder-item.pass-arrow::after {
  color: #ffffff;
}

.builder-item.run-arrow,
.builder-item.run-arrow::after {
  color: #1d4ed8;
}

.builder-item.shot-arrow,
.builder-item.shot-arrow::after {
  color: #ef4444;
}

.builder-arrow-preview {
  z-index: 18;
  opacity: 0.9;
  pointer-events: none;
}

.builder-ghost-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.builder-ghost-ball {
  opacity: 0.95;
}

.step-timeline-card {
  margin-top: 0.35rem;
  padding: 0.52rem 0.7rem;
}

.step-timeline-top {
  display: grid;
  gap: 0.4rem;
}

.step-timeline-actions-inline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}

.step-timeline-actions-inline .tool-btn {
  width: 100%;
  min-width: 0;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  font-size: 0.84rem;
}

.step-timeline-title-wrap p,
.sequence-status {
  display: none;
}

.sequence-status {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: #7a5200;
  background: rgba(255, 196, 0, 0.18);
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
}

.step-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.step-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.48rem 0.8rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.step-pill.active {
  border-color: var(--primary);
  background: rgba(19, 102, 72, 0.1);
}

.step-pill.active.idle-step {
  border-color: var(--border);
  background: #fff;
}

.step-note-field {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.step-note-field span {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
}

.step-note-field textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.saved-drill-preview-status {
  display: none;
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: #c53030;
  font-weight: 800;
  line-height: 1.35;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: #fff5f5;
  border: 1px solid #f5c2c7;
}

.saved-drill-preview-status:not(:empty) {
  display: block;
}

.pitch-size-warning {
  margin-top: 0.45rem;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  background: #fff5f5;
  border: 1px solid #f5c2c7;
}

.pitch-size-warning p {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #c53030;
  line-height: 1.35;
}

.pitch-size-warning-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.builder-tool-icon-svg {
  width: 30px;
  height: 30px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.original-blue-dot,
.original-red-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.original-blue-dot {
  color: #1e63ff;
}

.original-red-dot {
  color: #e43a3a;
}

.original-gk-glove {
  font-size: 1.2rem;
  background: transparent;
}

.original-cone {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 16px solid #ff9f1c;
  background: transparent;
  border-radius: 0;
}

.original-goal-net {
  font-size: 1.15rem;
  background: transparent;
}

.icon-pass-arrow {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><path d='M10 32H46' stroke='%23ffffff' stroke-width='4' stroke-linecap='round'/><path d='M38 24l10 8-10 8' fill='none' stroke='%23ffffff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

.icon-run-arrow {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><path d='M10 32H46' stroke='%231d4ed8' stroke-width='4' stroke-linecap='round'/><path d='M38 24l10 8-10 8' fill='none' stroke='%231d4ed8' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

.icon-shot-arrow {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><path d='M10 32H46' stroke='%23ef4444' stroke-width='5' stroke-linecap='round'/><path d='M38 24l10 8-10 8' fill='none' stroke='%23ef4444' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

@media (max-width: 1180px) {
  .builder-layout,
  .builder-layout.details-collapsed {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .builder-settings-panel {
    grid-column: 1 / -1;
    display: block !important;
  }

  .show-details-fab,
  .save-drill-collapsed-btn {
    display: none !important;
  }
}

@media (max-width: 1180px) {
  .builder-sidebar {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 860px) {
  .builder-layout,
  .builder-layout.details-collapsed {
    grid-template-columns: 1fr;
  }

  .builder-pitch {
    min-height: 440px;
  }

  .step-timeline-actions-inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.arrow-edit-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #136648;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  z-index: 60;
  cursor: grab;
  display: none;
  touch-action: none;
}

.arrow-edit-handle:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.arrow-edit-handle.start-handle {
  border-color: #1d4ed8;
}

.arrow-edit-handle.visible {
  display: block;
}
.arrow-edit-handle.start-handle {
  border-color: #1d4ed8;
}

.arrow-edit-handle.visible {
  display: block;
}

.builder-item.pass-arrow.selected + .arrow-edit-handle,
.builder-item.shot-arrow.selected + .arrow-edit-handle {
  box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.18), 0 2px 6px rgba(0, 0, 0, 0.2);
}