/* Cards, controls, dropdown, popovers, roster rows, board, toasts. */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-700), var(--bg-800) 55%);
  box-shadow: var(--shadow);
  padding: 12px;
}

.card-ok {
  border-color: color-mix(in srgb, var(--ok-500) 40%, var(--line));
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head-title,
.card-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.card-head h2 {
  position: relative;
  padding-left: 10px;
}

/* Small amber tick before each section title. */
.card-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 14px;
  margin-top: -7px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--amber-300), var(--amber-500));
}

.sub-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 14px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.board-title {
  margin: 14px 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.board-title:first-of-type {
  margin-top: 4px;
}

.pill {
  flex: none;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-600);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pill.is-ok {
  border-color: color-mix(in srgb, var(--ok-500) 45%, var(--line));
  color: #a9d6b5;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--bg-600), var(--bg-700));
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s,
    background 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--amber-500) 55%, var(--line));
  color: var(--sand-100);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--amber-500);
  background: linear-gradient(180deg, var(--amber-300), var(--amber-500));
  color: #1b1305;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  color: #1b1305;
  filter: brightness(1.06);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--blood-500) 55%, var(--line));
  color: #e3a49d;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

/* Filled destructive button, for the confirm action inside a dialog. */
.btn-danger-solid {
  border-color: var(--blood-500);
  background: linear-gradient(180deg, #c04437, var(--blood-500));
  color: #fff2f0;
  font-weight: 600;
}

.btn-danger-solid:hover:not(:disabled) {
  color: #fff2f0;
  filter: brightness(1.08);
}

.btn-icon {
  gap: 7px;
}

.btn-icon > svg {
  flex: none;
  opacity: 0.85;
}

.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

/* force switch, time slots and tabs share one segmented look */

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-900);
  min-width: 0;
}

/* Let the slot group take the width its times need, not a squeezed share. */
.control-grow .segmented {
  flex: 0 1 auto;
}

.seg-btn {
  min-height: 34px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}

.seg-btn-force {
  min-width: 34px;
  font-size: 0.92rem;
  font-weight: 600;
}

.seg-btn-slot {
  flex: 1 1 auto;
  min-width: 0;
  padding-inline: 8px;
  white-space: nowrap;
}

.seg-btn:hover:not(.is-active) {
  color: var(--sand-300);
}

.seg-btn.is-active {
  border-color: color-mix(in srgb, var(--amber-500) 45%, transparent);
  background: linear-gradient(
    180deg,
    rgb(233 161 60 / 20%),
    rgb(233 161 60 / 6%)
  );
  color: var(--sand-100);
  font-weight: 600;
}

.tab {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}

.tab:hover:not(.is-active) {
  color: var(--sand-300);
}

.tab.is-active {
  border-color: color-mix(in srgb, var(--amber-500) 40%, transparent);
  background: linear-gradient(
    180deg,
    rgb(233 161 60 / 18%),
    rgb(233 161 60 / 5%)
  );
  color: var(--sand-100);
  font-weight: 600;
}

/* ----------------------------------------------------------------- inputs */

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-900);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s;
}

.input::placeholder {
  color: #5b6674;
}

.input:hover {
  border-color: var(--bg-500);
}

.input:focus {
  outline: none;
  border-color: var(--amber-500);
  box-shadow: 0 0 0 2px rgb(233 161 60 / 15%);
}

.btn:focus-visible,
.tab:focus-visible,
.seg-btn:focus-visible,
.dd-toggle:focus-visible,
.dd-option:focus-visible,
.info-btn:focus-visible,
.details-summary:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 1px;
}

.input-textarea {
  min-height: 96px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  resize: vertical;
}

.input-number {
  text-align: center;
  font-variant-numeric: tabular-nums;
  /* The spinners crowd these narrow fields; the value is typed, not stepped. */
  -moz-appearance: textfield;
  appearance: textfield;
}

.input-number::-webkit-outer-spin-button,
.input-number::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

/* A field standing alone in a card needs air above it. */
.card > .field {
  margin-top: 14px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--text-dim);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  color: var(--text-dim);
  font-size: 0.86rem;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--amber-500);
}

/* -------------------------------------------------------------- dropdown */

.dd {
  position: relative;
  min-width: 0;
}

.dd-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-height: var(--tap);
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-900);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}

.dd-compact .dd-toggle {
  min-height: 36px;
  font-size: 0.84rem;
}

.dd-toggle:hover {
  border-color: var(--bg-500);
}

.dd.is-open .dd-toggle {
  border-color: var(--amber-500);
}

.dd-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-chevron {
  flex: none;
  display: block;
  color: var(--amber-400);
  transition: transform 0.18s;
}

.dd.is-open .dd-chevron {
  transform: rotate(180deg);
}

.dd-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-700);
  box-shadow: var(--shadow-pop);
}

.dd.is-open .dd-panel {
  display: flex;
  animation: dd-in 0.13s ease-out;
}

.dd.is-up .dd-panel {
  top: auto;
  bottom: calc(100% + 4px);
}

.dd-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.dd-option:hover,
.dd-option:focus-visible {
  background: var(--bg-500);
}

.dd-option.is-selected {
  color: var(--amber-300);
  background: rgb(233 161 60 / 10%);
}

.dd-option-hint {
  flex: none;
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.dd-option-check {
  flex: none;
  margin-left: auto;
  color: var(--amber-300);
}

.dd-option-hint + .dd-option-check {
  margin-left: 0;
}

@keyframes dd-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ---------------------------------------------------- info button/popover */

.info-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--amber-400);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.info-btn > svg {
  display: block;
}

.info-btn:hover,
.info-btn[aria-expanded="true"] {
  background: rgb(233 161 60 / 16%);
  color: var(--amber-300);
}

.control .info-btn {
  width: 28px;
  height: 28px;
}

.popover {
  position: fixed;
  z-index: 60;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--amber-500) 30%, var(--line));
  border-radius: var(--radius);
  background: var(--bg-700);
  box-shadow: var(--shadow-pop);
  animation: dd-in 0.13s ease-out;
}

.popover-text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text);
}

.popover-title {
  margin: 0 0 6px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.popover-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--line-soft);
}

.popover-row:last-child {
  border-bottom: 0;
}

.popover-row.is-headline {
  color: var(--amber-300);
}

.popover-value {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.popover-note {
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ roster */

.roster-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.roster-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 72px;
  grid-template-areas: "rank name power" "rank lock lock";
  gap: 5px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 2%);
}

.roster-row:focus-within {
  border-color: color-mix(in srgb, var(--amber-500) 35%, var(--line));
}

.roster-row > .rank-badge {
  grid-area: rank;
}

.roster-row > .input-name {
  grid-area: name;
}

.roster-row > .input-power {
  grid-area: power;
}

.roster-row > .dd {
  grid-area: lock;
}

.roster-row-sub {
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-areas: "rank name";
}

.rank-badge {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-800);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.rank-badge.is-top {
  color: var(--amber-300);
  background: rgb(233 161 60 / 12%);
  font-weight: 600;
}

.rank-badge.is-missing {
  color: var(--err-500);
  background: rgb(201 88 74 / 14%);
}

.rank-badge-sub {
  font-size: 0.74rem;
}

.roster-row .input,
.roster-row .dd-toggle {
  min-height: 36px;
}

@media (min-width: 620px) {
  .roster-row {
    grid-template-columns: 34px minmax(0, 1fr) 84px 168px;
    grid-template-areas: "rank name power lock";
  }

  .roster-row-sub {
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-areas: "rank name";
  }
}

/* -------------------------------------------------------------- disclosure */

.details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 2%);
}

.details-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--sand-300);
  font-size: 0.88rem;
  cursor: pointer;
  list-style: none;
}

.details-summary::-webkit-details-marker {
  display: none;
}

.details-summary:hover {
  color: var(--sand-100);
}

.details-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid color-mix(in srgb, var(--amber-500) 45%, var(--line));
  border-radius: 50%;
  color: var(--amber-400);
  transition: transform 0.18s;
}

.details[open] .details-icon {
  transform: rotate(45deg);
}

.details-body {
  padding: 0 12px 12px;
}

/* ------------------------------------------------------------ slot config */

.budget {
  margin-bottom: 10px;
}

.budget-total {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-600);
  font-size: 0.85rem;
}

.budget-total.is-ok {
  border-left-color: var(--ok-500);
}

.budget-total.is-bad {
  border-left-color: var(--err-500);
}

.building-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.building-row {
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 2%);
}

.building-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.building-row-head strong {
  color: var(--sand-100);
}

.building-row-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px 12px;
  align-items: end;
}

.building-row-controls .field {
  margin-bottom: 0;
}

@media (min-width: 620px) {
  .building-row-controls {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}

/* --------------------------------------------------------------- the board */

.board-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-700);
  overflow: hidden;
}

.board-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  background: linear-gradient(180deg, var(--bg-500), var(--bg-600));
  border-bottom: 1px solid var(--line);
}

.board-card-midgame .board-card-head {
  background: linear-gradient(180deg, #2f2718, var(--bg-600));
}

.board-card-dynamic .board-card-head {
  background: linear-gradient(180deg, #2b2033, var(--bg-600));
}

.board-card-note {
  padding: 6px 10px 0;
  margin: 0;
}

.board-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding: 7px 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
}

.player-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.88rem;
}

.player-line:last-child {
  border-bottom: 0;
}

.player-line.is-transfer {
  color: var(--sand-100);
}

.player-index {
  min-width: 22px;
  color: var(--amber-400);
  font-size: 0.74rem;
  font-weight: 600;
}

.player-power {
  margin-left: auto;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.tag {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-800);
  color: var(--text-dim);
  font-size: 0.7rem;
  white-space: nowrap;
}

.tag-move {
  border-color: color-mix(in srgb, var(--amber-500) 40%, var(--line));
  color: var(--amber-300);
}

/* ------------------------------------------------------------------- misc */

.issue {
  margin: 0 0 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-600);
  font-size: 0.85rem;
}

.issue:last-child {
  margin-bottom: 0;
}

.issue-error {
  border-left-color: var(--err-500);
  color: #eab6ae;
}

.issue-warning {
  border-left-color: var(--warn-500);
  color: #e8cf9b;
}

.issue-ok {
  border-left-color: var(--ok-500);
  color: #aad4b6;
}

.email-output {
  margin: 0;
  padding: 11px 12px;
  max-height: 55vh;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-900);
  color: var(--sand-100);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  -webkit-user-select: all;
  user-select: all;
}

.email-subject {
  max-height: none;
  font-size: 0.84rem;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(92vw, 380px);
}

.toast {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-700);
  box-shadow: var(--shadow-pop);
  font-size: 0.86rem;
  animation: dd-in 0.16s ease-out;
}

.toast-success {
  border-left-color: var(--ok-500);
}

.toast-error {
  border-left-color: var(--err-500);
}

.toast-info {
  border-left-color: var(--amber-500);
}

.toast-out {
  opacity: 0;
  transition: opacity 0.4s;
}

/* ----------------------------------------------------------------- dialog */

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(4 6 9 / 66%);
  animation: dialog-fade 0.14s ease-out;
}

.dialog {
  width: min(100%, 380px);
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--amber-500) 26%, var(--line));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-700), var(--bg-800) 60%);
  box-shadow: var(--shadow-pop);
  animation: dialog-in 0.16s ease-out;
}

.dialog-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.dialog-text {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions .btn {
  flex: 1 1 auto;
}

@media (min-width: 460px) {
  .dialog-actions .btn {
    flex: 0 0 auto;
    min-width: 104px;
  }
}

@keyframes dialog-fade {
  from {
    opacity: 0;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}
