/* Settings, Agent Pool, and Team Roll modals */

.settings-modal {
  --settings-bg-lite: #171822;
  --settings-bg-dark: #05060a;
  --settings-accent: var(--bg-accent);
  position: relative;
  background:
    linear-gradient(135deg, rgba(255, 70, 85, 0.24), transparent 40%),
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.05), transparent 55%),
    linear-gradient(160deg, var(--settings-bg-lite), var(--settings-bg-dark));
  border-radius: 0;
  border: 1px solid rgba(255, 70, 85, 0.7);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  clip-path: polygon(
    18px 0,
    100% 0,
    100% calc(100% - 18px),
    calc(100% - 18px) 100%,
    0 100%,
    0 18px
  );
}

.settings-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 3px solid var(--settings-accent);
  border-left: 2px solid rgba(255, 70, 85, 0.7);
  border-radius: inherit;
  pointer-events: none;
}

.settings-modal h3 {
  margin-bottom: 16px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.9rem;
  font-family: var(--font-display);
  color: var(--txt);
}

.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100dvh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}

.settings-layout::-webkit-scrollbar {
  width: 6px;
}

.settings-layout::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

.settings-layout::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #7b8bff, var(--bg-accent));
  border-radius: 999px;
}

.settings-layout {
  scrollbar-color: var(--bg-accent) rgba(255, 255, 255, 0.05);
  scrollbar-width: thin;
}

.settings-section {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px 18px;
  text-align: left;
}

.settings-section.wide {
  padding-bottom: 8px;
}

.settings-section.wide.hidden,
.settings-section.hidden {
  display: none;
}

.settings-section h4 {
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
}

.settings-subtitle {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.toggle-label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.settings-modal input[type="text"],
.settings-modal input[type="number"],
.settings-modal select,
.settings-modal textarea {
  width: 100%;
}

.settings-modal input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.settings-modal input[type="text"]:focus,
.settings-modal select:focus,
.settings-modal textarea:focus {
  outline: none;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, white, var(--bg-accent));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--settings-bg-lite);
  border: 2px solid var(--settings-accent);
  cursor: pointer;
  clip-path: polygon(
    8px 0%,
    100% 0%,
    100% calc(100% - 8px),
    calc(100% - 8px) 100%,
    0% 100%,
    0% 8px
  );
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 0;
  background: var(--settings-bg-lite);
  border: 2px solid var(--settings-accent);
  cursor: pointer;
  clip-path: polygon(
    8px 0%,
    100% 0%,
    100% calc(100% - 8px),
    calc(100% - 8px) 100%,
    0% 100%,
    0% 8px
  );
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, white, var(--bg-accent));
  outline: none;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
}

.slider-label strong {
  display: inline-block;
  width: 40px;
  text-align: right;
}

.agent-sound-empty {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.agent-pool-clear-btn {
  margin-top: 8px;
  margin-bottom: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  align-self: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agent-pool-clear-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.6);
}

.team-roll-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  min-height: 1.2em;
}

.team-roll-hint--error {
  color: #ff9f9f;
}

/* Agent settings and availability UI */
.stacked-setting {
  margin-top: 12px;
  text-align: left;
}

.range-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

.agent-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.agent-setting-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-setting-title {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.agent-sound-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agent-preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.agent-preset-row select,
.agent-preset-row .agent-preset-name-input {
  flex: 1;
  min-width: 0;
}

.agent-preset-name-input {
  display: none;
}

.agent-preset-row .modal-button {
  white-space: nowrap;
}

.setting-row.options-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.setting-row.options-actions .modal-button {
  flex: 1;
  text-align: center;
}

.settings-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
}

.settings-status--success {
  color: #b4ffb4;
}

.settings-status--error {
  color: #ff9f9f;
}

/* Collapsible agent sound sections */
.agent-sounds-collapsible {
  width: 100%;
  margin-top: 6px;
}

.agent-sounds-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

.agent-sounds-collapsible[open] > .agent-sounds-summary {
  background: rgba(255, 255, 255, 0.08);
}

.agent-sounds-summary::after {
  content: "▸";
  transition: transform 0.15s ease;
  opacity: 0.8;
}

.agent-sounds-collapsible[open] > .agent-sounds-summary::after {
  transform: rotate(90deg);
}

.agent-sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
}

.agent-sound-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.agent-sound-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-sound-actions button {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
}

.agent-sound-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Agent availability list (exclude from wheel) */
#agentList {
  margin-top: 20px;
}

.agent-availability-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
  max-width: 920px;
  margin: 0 auto;
}

.agent-availability-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 4px 0 2px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.agent-availability-item.agent-excluded {
  opacity: 0.45;
}

.agent-availability-item.agent-excluded .agent-availability-circle {
  border-color: rgba(255, 255, 255, 0.06);
  filter: grayscale(1) brightness(0.6);
}

.agent-availability-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

.agent-availability-circle.selected {
  border-color: var(--bg-accent);
}

.agent-availability-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.agent-availability-name {
  max-width: 80px;
  font-size: 0.75rem;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

/* Density tweaks (compact spacing for settings UI) */
.settings-modal {
  padding: 12px 12px 10px;
}

.settings-modal h3 {
  margin-bottom: 10px;
}

.settings-layout {
  gap: 12px;
}

.settings-section {
  padding: 12px 14px;
}

.settings-section.wide {
  padding-bottom: 6px;
}

.settings-section h4 {
  margin: 0 0 4px;
}

.settings-subtitle {
  margin: 0 0 8px;
}

.toggle-label {
  margin-bottom: 8px;
}

.setting-row {
  gap: 6px;
}


/* Team modal layout */
.team-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.team-player-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

.team-actions {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.team-comp {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.team-comp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.team-comp-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.team-comp input[type="number"] {
  width: 64px;
  text-align: center;
}

.team-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.team-result-row {
  position: relative;
  display: grid;
  grid-template-columns: 30% 30% 30% auto;
  align-items: center;
  gap: 10px;
  --team-result-color: rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--team-result-color) 75%, transparent),
      rgba(15, 23, 42, 0.96)
    );
  border: 1px solid color-mix(in srgb, var(--team-result-color) 60%, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
  padding: 6px 12px 6px 16px;
}

.team-result-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: color-mix(in srgb, var(--team-result-color) 90%, #ffffff);
}

.team-result-row > div:first-child {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-result-row > div:nth-child(2) {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0.8;
  white-space: nowrap;
  text-align: center;
}

.team-result-row > div:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  justify-self: flex-start;
  white-space: nowrap;
}

.team-result-row img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  #teamsModal .team-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  #teamsModal .team-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "select select"
      "new save"
      "delete roll";
    row-gap: 8px;
    column-gap: 8px;
  }
  #teamsModal #savedTeamsSelect {
    grid-area: select;
    width: 100%;
  }
  #teamsModal #teamNewBtn {
    grid-area: new;
    width: 100%;
  }
  #teamsModal #teamSaveBtn {
    grid-area: save;
    width: 100%;
  }
  #teamsModal #teamDeleteBtn {
    grid-area: delete;
    width: 100%;
  }
  #teamsModal #teamRollBtn {
    grid-area: roll;
    width: 100%;
  }
}
