:root {
  color-scheme: light;
  --background: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #e9eee8;
  --ink: #171917;
  --muted: #62685f;
  --line: #d9ded7;
  --accent: #126b62;
  --accent-ink: #ffffff;
  --warning: #a35414;
  --danger: #b42318;
  --danger-soft: #ffe9e6;
  --ok-soft: #e8f4ed;
  --medium-soft: #fff2d6;
  --high-soft: #ffe0dc;
  --alpha: #126b62;
  --alpha-soft: #e8f4ed;
  --bravo: #7b4fb3;
  --bravo-soft: #f0e8fb;
  --charlie: #b05f1d;
  --charlie-soft: #fff0df;
  --shadow: 0 8px 24px rgb(28 32 28 / 10%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--background);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(18 107 98 / 35%);
  outline-offset: 2px;
}

#app {
  min-height: 100svh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgb(246 247 244 / 92%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.app-header h1,
.section-head h2,
.player-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 1.35rem;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.secondary-button,
.player-form button[type="submit"] {
  padding: 0 14px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
}

.header-actions button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--accent);
  background: var(--surface-alt);
  font-size: 0.84rem;
  font-weight: 800;
}

.secondary-button {
  color: var(--accent);
  background: var(--surface-alt);
}

main {
  display: grid;
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.lineup-band,
.bench-band {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  font-size: 1.12rem;
}

.counter {
  display: inline-grid;
  min-width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface-alt);
  font-weight: 900;
}

.line-rotation {
  display: grid;
  gap: 10px;
}

.line-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 2px solid var(--line-color, var(--line));
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.line-card[data-line-index="0"] {
  --line-color: var(--alpha);
  --line-soft: var(--alpha-soft);
}

.line-card[data-line-index="1"] {
  --line-color: var(--bravo);
  --line-soft: var(--bravo-soft);
}

.line-card[data-line-index="2"] {
  --line-color: var(--charlie);
  --line-soft: var(--charlie-soft);
}

.line-card[data-active="true"] {
  background: var(--line-soft);
}

.line-card[data-selected="true"] {
  box-shadow: 0 0 0 3px rgb(18 107 98 / 16%);
}

.line-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.line-select {
  display: grid;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.line-select span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.line-select strong {
  color: var(--line-color);
  font-size: 1.04rem;
}

.line-actions {
  display: flex;
  gap: 6px;
}

.line-actions button,
.track-badge {
  display: inline-grid;
  min-height: 36px;
  place-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface-alt);
  font-size: 0.8rem;
  font-weight: 900;
}

.track-badge {
  color: var(--accent-ink);
  background: var(--line-color, var(--accent));
}

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

.slot {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 66px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.slot[data-selected="true"] {
  border-color: var(--accent);
}

.slot[data-penalty="true"] {
  border-width: 3px;
  border-color: var(--danger);
  background: var(--danger-soft);
}

.slot[data-warning="true"] {
  border-color: var(--warning);
}

.slot-button {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.slot-code {
  display: grid;
  width: 48px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface-alt);
  font-weight: 900;
}

.slot-player {
  display: block;
  margin-top: 4px;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.15;
}

.slot-player b {
  font-weight: 950;
}

.slot-penalty-cell {
  display: grid;
  justify-items: end;
}

.slot-penalty-cell .penalty-indicator {
  min-width: 38px;
  min-height: 38px;
  margin-top: 0;
}

.penalty-indicator {
  display: inline-grid;
  min-width: 32px;
  min-height: 22px;
  place-items: center;
  margin-top: 5px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 0.74rem;
  font-weight: 900;
}

.penalty-indicator[data-warning="true"] {
  color: #ffffff;
  background: var(--danger);
  font-size: 0.82rem;
}

.assign-button small,
.suggestion small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stamina-gauge {
  display: block;
  width: min(100%, 130px);
  height: 8px;
  margin-top: 7px;
  background: #dfe4dc;
  border-radius: 999px;
  overflow: hidden;
}

.stamina-gauge span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stamina-gauge[data-fatigue="low"] span {
  width: 100%;
  background: #27845f;
}

.stamina-gauge[data-fatigue="medium"] span {
  width: 58%;
  background: #d18b16;
}

.stamina-gauge[data-fatigue="high"] span {
  width: 24%;
  background: var(--danger);
}

.icon-button {
  width: 44px;
  height: 100%;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 0;
  font-weight: 900;
}

.player-card h3 {
  font-size: 0.95rem;
}

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

.suggestion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 10px;
  color: inherit;
  background: var(--surface-alt);
  text-align: left;
}

.player-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.player-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.player-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.player-form button[type="submit"] {
  align-self: end;
  grid-column: 1 / -1;
}

.players {
  display: grid;
  gap: 10px;
}

.player-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-card[data-fatigue="low"] {
  border-color: #9ccbad;
}

.player-card[data-fatigue="medium"] {
  border-color: #e4bb62;
}

.player-card[data-fatigue="high"],
.player-card[data-penalty="true"] {
  border-color: #e07468;
}

.player-card[data-penalty="true"] {
  background: var(--danger-soft);
}

.player-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.assign-button {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.roster-number {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface-alt);
  font-weight: 900;
}

.danger-button {
  padding: 0 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-weight: 900;
}

.quick-state {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 104px;
  gap: 8px;
  align-items: center;
}

.fatigue-control {
  display: grid;
  gap: 4px;
}

.fatigue-control > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.segmented button,
.tag,
.penalty-count button {
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.penalty-count button {
  font-size: 1.35rem;
  font-weight: 900;
}

.segmented button {
  min-width: 0;
  padding: 0 6px;
  font-size: 0.78rem;
}

.segmented button[data-active="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.penalty-toggle {
  color: var(--danger);
  background: var(--danger-soft);
  font-weight: 900;
}

.penalty-toggle[data-active="true"] {
  color: #ffffff;
  background: var(--danger);
}

.penalty-count {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  height: 52px;
  background: var(--surface-alt);
  border-radius: 8px;
  overflow: hidden;
}

.penalty-count strong {
  text-align: center;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

summary {
  min-height: 36px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 900;
}

.affinity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.affinity-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 52px;
  padding: 4px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.affinity-row span {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

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

.affinity-levels button {
  min-width: 0;
  min-height: 40px;
  padding: 0 6px;
  color: var(--ink);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 900;
}

.affinity-levels button[data-active="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.compatibility-list {
  display: grid;
  gap: 8px;
}

.compatibility-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.compatibility-row > span {
  font-weight: 900;
}

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

.compatibility-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 0 6px;
  color: var(--ink);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 900;
}

.compatibility-actions button[data-active="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.compatibility-actions button[data-compatibility="avoided"][data-active="true"] {
  background: var(--danger);
}

.empty-state {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.quick-actions-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 101;
  display: grid;
  gap: 12px;
  padding: 14px 16px 18px;
  background: var(--surface);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -14px 40px rgb(28 32 28 / 28%);
}

.quick-actions-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 0;
  padding: 0;
  background: rgb(23 25 23 / 24%);
  border-radius: 0;
}

.quick-actions-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.quick-actions-head h2 {
  margin: 0;
  font-size: 1.12rem;
}

.quick-actions-head .icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 122px;
  gap: 8px;
  align-items: stretch;
}

.assignment-list {
  display: grid;
  gap: 8px;
  max-height: 44svh;
  overflow: auto;
  padding-right: 2px;
}

.assignment-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
  align-items: center;
  min-height: 54px;
  padding: 8px 10px;
  color: inherit;
  background: var(--surface-alt);
  text-align: left;
}

.suggestion > span:first-child,
.assignment-option span {
  min-width: 0;
  font-weight: 900;
}

.position-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.position-chip {
  display: inline-grid;
  min-width: 32px;
  min-height: 24px;
  place-items: center;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--accent);
  background: #dce8e3;
  font-size: 0.7rem;
  font-weight: 950;
}

.position-chip[data-level="specialist"] {
  color: #ffffff;
  background: var(--accent);
}

.suggestion .penalty-indicator,
.assignment-option .penalty-indicator {
  justify-self: end;
  margin-top: 0;
}

.suggestion .stamina-gauge,
.assignment-option .stamina-gauge {
  grid-column: 1 / -1;
  width: 100%;
}

.suggestion small,
.assignment-option small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
}

.pb-action {
  color: #ffffff;
  background: var(--danger);
  font-weight: 900;
}

.cookie-banner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 90;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(28 32 28 / 18%);
}

.cookie-banner strong {
  display: block;
  margin-bottom: 4px;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.cookie-actions {
  display: flex;
  gap: 8px;
}

.cookie-actions button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--accent);
  background: var(--surface-alt);
  font-weight: 900;
}

.cookie-actions button[data-action="accept-analytics"] {
  color: var(--accent-ink);
  background: var(--accent);
}

@media (min-width: 720px) {
  .app-header {
    padding-inline: 24px;
  }

  main {
    grid-template-columns: minmax(460px, 1.2fr) minmax(360px, 0.8fr);
    align-items: start;
    padding: 24px;
  }

  .lineup-band {
    position: sticky;
    top: 62px;
  }

  .player-form {
    grid-template-columns: minmax(0, 1fr) 110px 112px;
  }

  .player-form button[type="submit"] {
    grid-column: auto;
  }

  .suggestions,
  .affinity-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1120px) {
  main {
    grid-template-columns: 1fr;
  }

  .lineup-band {
    position: static;
  }

  .line-rotation {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .line-card {
    align-self: start;
  }

  .slots {
    grid-template-columns: 1fr;
  }

  .players {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .player-card {
    align-self: start;
  }
}

@media (max-width: 520px) {
  .app-header {
    align-items: center;
    flex-direction: row;
  }

  .header-actions {
    width: auto;
  }

  .header-actions button {
    flex: 0 0 auto;
  }

  .slots,
  .suggestions,
  .player-form,
  .quick-state,
  .affinity-grid {
    grid-template-columns: 1fr;
  }

  .quick-state {
    align-items: stretch;
  }

  .quick-actions-grid {
    grid-template-columns: minmax(0, 1fr) 122px;
  }

  .quick-actions-grid .pb-action {
    grid-column: 1 / -1;
  }

  .cookie-banner {
    grid-template-columns: 1fr;
  }

  .cookie-actions {
    justify-content: stretch;
  }

  .cookie-actions button {
    flex: 1;
  }
}
