/* =========================================================
   Fantasy Team Builder — Release Candidate 1.0
   ========================================================= */

/* Skjul kun Gravity Forms' originale felter på /saet-hold/-sider. */
body.fl-team-builder-page .gform_wrapper form > .gform-body,
body.fl-team-builder-page .gform_wrapper form > .gform_body,
body.fl-team-builder-page .gform_wrapper form > .gform_footer {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Gravity Forms' standardtekst om obligatoriske felter er ikke relevant her. */
body.fl-team-builder-page .gform_required_legend {
  display: none !important;
}

#fl-team-builder,
#fl-team-builder * {
  box-sizing: border-box;
}

#fl-team-builder {
  display: grid;
  grid-template-columns: minmax(620px, 2.3fr) minmax(260px, 1fr);
  gap: 24px;
  align-items: start;
  width: 100%;
}

#fl-pitch,
#fl-squad {
  width: 100%;
  min-width: 0;
  border-radius: 16px;
  padding: 20px;
}

#fl-pitch {
  position: relative;
  overflow: hidden;
  min-height: 500px;
  background: linear-gradient(#4caf50, #2e7d32);
  color: #fff;
}

#fl-pitch h3,
#fl-squad h3 {
  margin-top: 0;
}

#fl-squad {
  background: #f3f3f3;
}

#fl-pitch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 34px;
}

#fl-round-control,
#fl-controls {
  width: 100%;
  min-width: 0;
  margin: 0;
  font-weight: 700;
}

#fl-round-control label,
#fl-controls label {
  display: block;
  margin-bottom: 8px;
}

#fl-round-control select,
#fl-controls select {
  width: 100%;
  max-width: 100%;
}

#fl-selected-players {
  position: relative;
  z-index: 2;
  min-height: 620px;
  padding: 42px 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 24px;
  overflow: hidden;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      to right,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 58px,
      rgba(0, 0, 0, 0.04) 58px,
      rgba(0, 0, 0, 0.04) 116px
    ),
    linear-gradient(#45ad45, #2f9638);
}

#fl-selected-players::before {
  content: "";
  position: absolute;
  inset: 22px 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1000 1400' style='transform:rotate(180deg);transform-origin:center' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.9)' stroke-width='8'%3E%3Crect x='20' y='20' width='960' height='1360' rx='6'/%3E%3Cline x1='20' y1='700' x2='980' y2='700'/%3E%3Ccircle cx='500' cy='700' r='120'/%3E%3Ccircle cx='500' cy='700' r='6' fill='rgba(255,255,255,0.9)'/%3E%3Crect x='260' y='20' width='480' height='170'/%3E%3Crect x='365' y='20' width='270' height='75'/%3E%3Cpath d='M420 190 A120 120 0 0 0 580 190'/%3E%3Ccircle cx='500' cy='145' r='6' fill='rgba(255,255,255,0.9)'/%3E%3Crect x='260' y='1210' width='480' height='170'/%3E%3Crect x='365' y='1305' width='270' height='75'/%3E%3Cpath d='M420 1210 A120 120 0 0 1 580 1210'/%3E%3Ccircle cx='500' cy='1255' r='6' fill='rgba(255,255,255,0.9)'/%3E%3Cpath d='M20 75 A55 55 0 0 0 75 20'/%3E%3Cpath d='M925 20 A55 55 0 0 0 980 75'/%3E%3Cpath d='M20 1325 A55 55 0 0 1 75 1380'/%3E%3Cpath d='M925 1380 A55 55 0 0 1 980 1325'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.fl-line {
  display: grid;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

.fl-line[data-count="1"] {
  grid-template-columns: 110px;
}

.fl-line[data-count="2"] {
  grid-template-columns: repeat(2, 120px);
  gap: 70px;
}

.fl-line[data-count="3"] {
  grid-template-columns: repeat(3, 120px);
  gap: 34px;
}

.fl-line[data-count="4"] {
  grid-template-columns: repeat(4, 88px);
  gap: 10px;
}

.fl-line[data-count="5"] {
  grid-template-columns: repeat(5, 76px);
  gap: 6px;
}

.fl-slot {
  min-width: 95px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  color: #111;
  font-weight: 700;
}

.fl-slot.is-filled {
  min-width: 105px;
  min-height: 95px;
  padding: 0;
  background: transparent;
}

.fl-shirt-card {
  position: relative;
  text-align: center;
  cursor: pointer;
}

.fl-shirt {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto 6px;
}

.fl-shirt svg {
  width: 100%;
  height: 100%;
  fill: #fff;
  stroke: #111;
  stroke-width: 3;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.25));
}

.fl-shirt.is-goalkeeper svg {
  fill: #27ae60;
}

.fl-shirt.is-captain svg {
  stroke: #f1c40f;
  stroke-width: 5;
}

.fl-shirt span {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  color: #111;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.fl-shirt-name {
  max-width: 95px;
  min-height: 24px;
  margin: 0 auto;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.fl-captain-btn {
  position: absolute;
  top: -8px;
  right: 20px;
  z-index: 20;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.fl-captain-btn.is-captain {
  background: transparent;
  box-shadow: none;
  font-size: 18px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#fl-status-box {
  margin-top: 22px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 700;
}

.fl-status-item {
  margin: 4px 0;
}

.fl-status-item.is-ok {
  color: #d7ffd9;
}

.fl-status-item.is-missing {
  color: #ffe0e0;
}

#fl-submit-wrapper {
  margin-top: 14px;
  text-align: center;
}

#fl-submit {
  padding: 16px 34px;
  border: 0;
  border-radius: 10px;
  background: #1f1f1f;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  transition: background 0.2s ease, transform 0.2s ease;
}

#fl-submit:hover {
  background: #333;
  transform: translateY(-1px);
}

.fl-position-group {
  margin-bottom: 20px;
}

.fl-position-group h4 {
  margin-bottom: 10px;
  color: #444;
  font-size: 14px;
  text-transform: uppercase;
}

.fl-squad-player {
  margin-bottom: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.fl-squad-player:focus-visible {
  outline: 3px solid #2e7d32;
  outline-offset: 2px;
}

.fl-squad-player.is-on {
  background: #d7ffd9;
  font-weight: 700;
}

.fl-squad-player.is-empty {
  border: 1px dashed #bbb;
  opacity: 0.65;
  font-style: italic;
}

#fl-toast {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 999;
  padding: 12px 18px;
  transform: translateX(-50%);
  border-radius: 10px;
  background: rgba(25, 25, 25, 0.9);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.25s ease;
}

#fl-toast.show {
  opacity: 1;
}

@media (max-width: 900px) {
  #fl-team-builder {
    grid-template-columns: 1fr;
  }

  #fl-pitch {
    min-width: 0;
  }
}

@media (max-width: 700px) {
  #fl-team-builder {
    grid-template-columns: 1fr;
    gap: 22px;
    max-width: 100%;
  }

  #fl-pitch,
  #fl-squad {
    width: 100%;
    min-width: 0;
  }

  #fl-pitch {
    padding: 12px 12px 18px;
    border-radius: 14px;
  }

  #fl-pitch-controls {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 34px;
  }

  #fl-round-control select,
  #fl-controls select {
    height: 48px;
    font-size: 16px;
  }

  #fl-selected-players {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  #fl-selected-players::before {
    inset: 18px 6px;
  }

  .fl-line {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: none;
    gap: 6px;
    padding: 0 4px;
    align-items: center;
    justify-items: center;
  }

  .fl-line[data-count="1"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .fl-line[data-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fl-line[data-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fl-line[data-count="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .fl-line[data-count="5"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
  }

  .fl-slot {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .fl-shirt-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .fl-shirt-name {
    width: auto;
    max-width: 82px;
    min-width: 0;
    padding: 4px 5px;
    overflow-wrap: anywhere;
    font-size: 10px;
    line-height: 1.05;
    white-space: normal;
  }

  .fl-line[data-count="4"] .fl-shirt-name {
    max-width: 72px;
    font-size: 9px;
  }

  .fl-line[data-count="5"] .fl-shirt-name {
    max-width: 60px;
    padding-left: 2px;
    padding-right: 2px;
    font-size: 8px;
  }

  .fl-captain-btn {
    left: calc(50% + 14px);
    right: auto;
  }

  #fl-status-box {
    margin-top: 14px;
    padding: 10px 12px;
  }

  .fl-status-item {
    margin: 2px 0;
    font-size: 15px;
  }

  #fl-submit {
    width: 100%;
    max-width: 100%;
    padding: 15px 12px;
    font-size: 17px;
  }

  #fl-squad {
    padding: 18px;
  }
}
