/* Game views share the shell palette while retaining week and team colors. */
html[data-theme="dark"] :is(.schedule-view .schedule-logo, .fo-view .fo-logo, .fo-team-option > img[src^="logos/"]) {
  background: #eeeee6;
  padding: 3px;
  border-radius: 6px;
}

.schedule-view,
.fo-view,
.th-history,
.qb-return {
  color: var(--ui-ink);
}

.schedule-view :is(a, button, summary):focus-visible,
.fo-view :is(a, button, select, summary):focus-visible,
.qb-return :is(a, summary):focus-visible,
.th-history :is(a, button):focus-visible {
  outline: var(--ui-focus-ring);
  outline-offset: 3px;
}

.schedule-view .schedule-note,
.schedule-view .schedule-sources,
.fo-view :is(.fo-explainer, .fo-meta, .fo-section-note, .fo-coverage, .fo-legend, .fo-position-details),
.th-history :is(.th-average-note, .th-ratings-note, .th-game-count),
.fo-histories > .th-ratings-note {
  font-size: var(--ui-text-small);
  line-height: 1.6;
  color: var(--ui-muted);
}

.schedule-view .schedule-toolbar {
  gap: var(--ui-space-3);
  margin: var(--ui-space-4) 0;
}

.schedule-view .schedule-toolbar h3 {
  font-family: var(--ui-font-display);
  font-size: 19px;
}

.schedule-view .schedule-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ui-tap);
  padding: 10px 16px;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-panel);
  border-color: var(--ui-edge);
  font-size: var(--ui-text-small);
  line-height: 1.5;
  text-align: center;
}

.schedule-view .schedule-button:hover {
  background: var(--ui-hover);
}

.schedule-view .schedule-list {
  gap: var(--ui-space-3);
}

.schedule-view .schedule-card {
  border-radius: var(--ui-radius-md);
  box-shadow: none;
}

.schedule-view .schedule-row {
  grid-template-columns: 120px minmax(0, 1fr);
  border-radius: var(--ui-radius-md);
}

.schedule-view .schedule-date {
  padding: 16px;
  gap: 6px;
  border-radius: 12px 0 0 12px;
}

.schedule-view .schedule-week {
  font-size: 11px;
}

.schedule-view .schedule-kickoff,
.schedule-view .schedule-timezone {
  font-size: 12px;
}

.schedule-view .schedule-matchup {
  max-width: none;
  gap: 8px 20px;
  padding: 16px 24px;
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  align-items: center;
}

.schedule-view .schedule-team {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.schedule-view .schedule-home {
  grid-column: 3;
  grid-template-columns: auto minmax(0, 1fr) 56px;
}

.schedule-view .schedule-team > * {
  grid-column: auto;
  grid-row: auto;
  justify-self: auto;
  text-align: left;
}

.schedule-view .schedule-home > * {
  text-align: right;
}

.schedule-view .schedule-logo {
  width: 56px;
  height: 56px;
  grid-column: 1;
  grid-row: 1;
}

.schedule-view .schedule-home .schedule-logo {
  grid-column: 3;
}

.schedule-view .schedule-team-name {
  font-size: 16px;
  grid-column: 2;
  grid-row: 1;
  line-height: 1.35;
}

.schedule-view .schedule-score {
  font-family: var(--ui-font-display);
  font-size: 30px;
  grid-column: 3;
  grid-row: 1;
}

.schedule-view .schedule-home .schedule-score {
  grid-column: 1;
}

.schedule-view .schedule-versus {
  grid-area: 1/2;
  font-size: 12px;
}

.schedule-view .schedule-status {
  grid-area: 2/1/3/-1;
  font-size: 12px;
  padding-top: 8px;
}

.schedule-view .schedule-load-more {
  margin-bottom: var(--ui-space-4);
}

.schedule-view .schedule-matchup-title {
  font: 600 23px/1.3 var(--ui-font-display);
  margin: 16px 0 8px;
  overflow-wrap: anywhere;
}

.schedule-view[data-schedule-key^="game/"] > .schedule-note {
  margin: 6px 0;
}

.schedule-view[data-schedule-key^="game/"] > .fo-view {
  margin-top: var(--ui-space-3);
  display: flex;
  flex-direction: column;
}

.schedule-view[data-schedule-key^="game/"] > .fo-view > .fo-explainer:first-child {
  order: 1;
  margin: 12px 0;
}

.schedule-view .schedule-sources {
  margin-top: var(--ui-space-5);
  border-top: 1px solid var(--ui-rule);
  padding-top: 8px;
  overflow-wrap: anywhere;
}

.schedule-view .schedule-sources summary {
  min-height: var(--ui-tap);
  padding: 10px 0;
  line-height: 1.6;
}

.schedule-view .schedule-source-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.schedule-view .schedule-sources a {
  padding: 10px 0;
  min-height: var(--ui-tap);
}

.fo-view .fo-mode {
  gap: 8px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}

.fo-view .fo-mode legend {
  font-size: 12px;
  margin-bottom: 8px;
}

.fo-view :is(.fo-mode-button, .fo-unit-tab, .fo-team-dialog-close) {
  min-height: var(--ui-tap);
  border-radius: var(--ui-radius-sm);
  font-size: 13px;
}

.fo-view .fo-mode-button {
  padding: 10px 20px;
}

.fo-view .fo-pickers {
  gap: var(--ui-space-4);
}

.fo-view .fo-identity {
  border: 1px solid var(--ui-rule);
  border-radius: var(--ui-radius-md);
  padding: 16px;
  background: var(--ui-panel);
}

.fo-view .fo-select-label {
  font-size: 12px;
  line-height: 1.5;
}

.fo-view .fo-select {
  margin: 8px 0 12px;
  min-height: var(--ui-tap);
  font-size: 13px;
  border-radius: var(--ui-radius-sm);
}

.fo-view .fo-identity-heading {
  min-height: 80px;
  gap: 12px;
}

.fo-view .fo-name {
  font-family: var(--ui-font-display);
  font-size: 21px;
  line-height: 1.25;
  min-height: var(--ui-tap);
}

.fo-view .fo-image {
  width: 72px;
  height: 72px;
}

.fo-view .fo-team-picker {
  border-radius: var(--ui-radius-md);
  padding: 8px;
  gap: 8px;
  background: var(--ui-rail);
}

.fo-view .fo-team-picker-hint {
  font-size: 11px;
}

.fo-view .fo-explainer {
  margin: 12px 0;
}

.fo-view > .fo-explainer:first-child {
  margin-top: 0;
  margin-bottom: 12px;
}

.fo-view .fo-stat-section {
  margin: 16px 0;
  padding: 20px 24px;
  border-radius: var(--ui-radius-md);
  background: var(--ui-panel);
}

.fo-view .fo-stat-section h3,
.fo-view .fo-availability > h3 {
  font: 600 22px/1.3 var(--ui-font-display);
}

.fo-view .fo-stat-row {
  padding: 16px 0;
}

.fo-view .fo-stat-headings {
  grid-template-columns: minmax(0, 1fr) minmax(110px, 1.5fr) minmax(0, 1fr);
  gap: 8px;
}

.fo-view .fo-stat-label {
  font-size: 13px;
  line-height: 1.5;
}

.fo-view .fo-stat-value {
  font-family: var(--ui-font-display);
  font-size: 21px;
  overflow-wrap: anywhere;
}

.fo-view .fo-value-number {
  border-radius: var(--ui-radius-pill);
  padding: 4px 8px;
}

.fo-view .fo-value-winner {
  border-color: var(--ui-accent);
  background: var(--ui-soft);
}

.fo-view .fo-winner {
  font-size: 12px;
  line-height: 1.5;
  padding-top: 8px;
}

.fo-view .fo-bars {
  height: 12px;
  border-radius: var(--ui-radius-pill);
}

.fo-view .fo-availability {
  margin-top: var(--ui-space-5);
}

.fo-view .fo-legend {
  gap: 10px 16px;
  margin: 16px 0;
}

.fo-view .fo-team-diagrams {
  gap: var(--ui-space-4);
}

.fo-view .fo-availability-card {
  padding: 20px;
  border-radius: var(--ui-radius-md);
}

.fo-view .fo-availability-card h4 {
  font: 600 19px/1.3 var(--ui-font-display);
}

.fo-view .fo-coverage {
  color: var(--ui-amber);
}

.fo-view .fo-unit-controls {
  margin-top: 16px;
}

.fo-view .fo-unit-title {
  font-size: 14px;
}

.fo-view .fo-field {
  height: 470px;
  border-radius: var(--ui-radius-sm);
  margin-top: 12px;
  overflow: visible;
}

.fo-view .fo-position {
  width: 18%;
  max-width: 82px;
  min-height: 58px;
  padding: 6px 3px;
  font-size: 11px;
  line-height: 1.3;
  border-radius: var(--ui-radius-sm);
  box-shadow: none;
  border-color: currentColor;
}

.fo-view .fo-position-line {
  width: 12.5%;
  max-width: none;
}

.fo-view .fo-position strong {
  font-size: 11px;
  white-space: normal;
  margin-bottom: 4px;
}

.fo-view .fo-position span {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  overflow-wrap: anywhere;
}

.fo-view .fo-position.fo-status-available {
  background: var(--ui-green-soft);
  color: var(--ui-green);
}

.fo-view .fo-position.fo-status-out {
  background: var(--ui-red-soft);
  color: var(--ui-red);
}

.fo-view .fo-position.fo-status-uncertain {
  background: var(--ui-amber-soft);
  color: var(--ui-amber);
}

.fo-view .fo-position.fo-status-unknown {
  background: var(--ui-unknown-soft);
  color: var(--ui-unknown);
}

.fo-view .fo-position.fo-status-unknown {
  color: var(--ui-ink);
  border-color: var(--ui-unknown);
}

.fo-view .fo-position[aria-expanded=true] {
  outline-color: var(--ui-focus);
}

.fo-view .fo-position-details {
  min-height: 88px;
  border-left-color: var(--ui-edge);
  padding: 12px;
  background: var(--ui-rail);
  border-radius: var(--ui-radius-sm);
}

.fo-view .fo-position-sources a {
  display: inline-flex;
  align-items: center;
  min-height: var(--ui-tap);
}

.fo-view .fo-team-grid {
  gap: 12px;
}

.fo-view .fo-team-option {
  font-size: 12px;
  border-radius: var(--ui-radius-md);
  padding: 12px 8px;
}

.fo-view .fo-team-dialog-heading h3 {
  font: 600 22px/1.3 var(--ui-font-display);
}

.fo-view .fo-histories {
  margin: 20px 0;
}

.fo-view .fo-histories-grid {
  gap: 12px 16px;
}

.th-history .th-average {
  border-radius: var(--ui-radius-md);
  background: var(--ui-soft);
}

.th-history .th-average-value {
  font-family: var(--ui-font-display);
  color: var(--ui-accent);
}

.th-history .th-game {
  border-radius: var(--ui-radius-md);
  gap: 12px;
  background: var(--ui-panel);
}

.th-history .th-game-context {
  font-size: 12px;
  line-height: 1.4;
}

.th-history .th-result {
  border-radius: var(--ui-radius-sm);
}

.th-history .th-result-w {
  background: var(--ui-green);
  color: var(--ui-panel);
}

.th-history .th-result-l {
  background: var(--ui-red);
  color: var(--ui-panel);
}

.th-history .th-result-t {
  background: var(--ui-amber);
  color: var(--ui-panel);
}

.th-history .th-final {
  padding-top: 10px;
  gap: 6px;
}

.th-history .th-final-score {
  font-size: 16px;
}

.th-history-compact .th-average {
  padding: 14px;
}

.th-history-compact .th-average-label,
.th-history-compact .th-average-note {
  font-size: 12px;
}

.th-history-compact .th-average-unit {
  font-size: 12px;
}

.th-history-compact .th-game {
  padding: 12px;
}

.qb-return .qb-return-label {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ui-accent);
}

.qb-return.qb-return-unavailable .qb-return-label,
.qb-return.qb-return-elapsed .qb-return-label {
  color: var(--ui-muted);
}

.qb-return .qb-return-sources {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ui-muted);
}

.qb-return .qb-return-sources summary {
  padding: 10px 0;
  min-height: var(--ui-tap);
}

.qb-return .qb-return-source-list {
  gap: 8px;
}

.qb-return .qb-return-source-list a {
  display: inline-block;
  padding: 6px 0;
}

@media (max-width: 1100px) {
  .fo-view .fo-team-diagrams {
    grid-template-columns: minmax(0, 1fr);
  }

  .fo-view .fo-field {
    height: 500px;
  }
}

@media (max-width: 800px) {
  .schedule-view .schedule-row {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .schedule-view .schedule-matchup {
    padding: 16px;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  }

  .schedule-view .schedule-team,
  .schedule-view .schedule-home {
    display: contents;
  }

  .schedule-view .schedule-team > * {
    grid-column: 1;
    justify-self: center;
    text-align: center;
  }

  .schedule-view .schedule-home > * {
    grid-column: 3;
  }

  .schedule-view .schedule-logo {
    width: 48px;
    height: 48px;
    grid-row: 1;
  }

  .schedule-view .schedule-team-name {
    font-size: 14px;
    grid-row: 2;
  }

  .schedule-view .schedule-team .schedule-score {
    grid-row: 3;
    grid-column: 1;
  }

  .schedule-view .schedule-home .schedule-score {
    grid-column: 3;
  }

  .schedule-view .schedule-status {
    grid-area: 3/1/4/-1;
  }

  .schedule-view .schedule-versus {
    align-self: start;
    margin-top: 18px;
  }
}

@media (max-width: 600px) {
  .schedule-view .schedule-row {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .schedule-view .schedule-date {
    padding: 12px 8px;
  }

  .schedule-view .schedule-matchup {
    padding: 12px 8px;
    column-gap: 5px;
    grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
  }

  .schedule-view .schedule-team-name {
    font-size: 12px;
    line-height: 1.45;
  }

  .schedule-view .schedule-logo {
    width: 42px;
    height: 42px;
  }

  .schedule-view .schedule-score {
    font-size: 26px;
  }

  .schedule-view .schedule-versus {
    font-size: 10px;
  }

  .schedule-view .schedule-week {
    font-size: 10px;
    letter-spacing: .5px;
  }

  .schedule-view .schedule-toolbar h3 {
    font-size: 18px;
  }

  .schedule-view .schedule-button {
    padding: 10px 12px;
  }

  .schedule-view .schedule-matchup-title {
    font-size: 21px;
    margin: 12px 0 6px;
  }

  .fo-view .fo-pickers {
    gap: 8px;
  }

  .fo-view .fo-identity {
    padding: 12px;
  }

  .fo-view .fo-identity-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 0;
  }

  .fo-view .fo-image {
    width: 56px;
    height: 56px;
  }

  .fo-view .fo-name {
    font-size: 17px;
  }

  .fo-view .fo-team-picker {
    padding: 6px;
  }

  .fo-view .fo-team-picker-hint {
    font-size: 10px;
  }

  .fo-view .fo-select {
    font-size: 12px;
    padding: 10px 5px;
  }

  .fo-view .fo-stat-section {
    padding: 16px 12px;
  }

  .fo-view .fo-stat-section h3,
  .fo-view .fo-availability > h3 {
    font-size: 20px;
  }

  .fo-view .fo-stat-headings {
    grid-template-columns: minmax(0, 1fr) minmax(90px, 1.4fr) minmax(0, 1fr);
    gap: 4px;
  }

  .fo-view .fo-stat-value {
    font-size: 18px;
  }

  .fo-view .fo-stat-label {
    font-size: 12px;
  }

  .fo-view .fo-value-number {
    padding: 4px;
  }

  .fo-view .fo-availability-card {
    padding: 12px;
  }

  .fo-view .fo-field {
    height: 500px;
  }

  .fo-view .fo-position {
    font-size: 10px;
    padding: 5px 2px;
    line-height: 1.3;
  }

  .fo-view .fo-position strong {
    font-size: 10px;
  }

  .fo-view .fo-histories-grid {
    column-gap: 8px;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-pickers {
    grid-template-rows: repeat(5, auto);
    row-gap: 4px;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-pickers:has(.fo-headshot) {
    grid-template-rows: repeat(7, auto);
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 5;
    row-gap: 4px;
    align-items: start;
    padding: 10px;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity:has(.fo-headshot) {
    grid-row: span 7;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity-heading,
  .schedule-view[data-schedule-key^="game/"] .fo-identity-heading > div:not(.fo-headshot) {
    display: contents;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity .fo-name {
    min-height: 0;
    padding: 4px 0;
    align-self: start;
    font-size: 16px;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity .fo-image {
    width: 44px;
    height: 44px;
  }

  .schedule-view[data-schedule-key^="game/"] .fo-identity .fo-meta {
    margin: 0;
  }

  .fo-view .th-history-compact .th-average {
    padding: 10px;
  }

  .fo-view .th-history-compact .th-average-value {
    font-size: 28px;
  }

  .fo-view .th-history-compact .th-game {
    padding: 10px;
    gap: 6px;
  }

  .fo-view .th-history-compact .th-game-context {
    font-size: 12px;
    gap: 3px 6px;
  }

  .fo-view .th-history-compact .th-opponent {
    grid-template-columns: 24px minmax(0, 1fr) 24px;
    gap: 4px;
    padding: 0;
  }

  .fo-view .th-history-compact .th-logo {
    width: 24px;
    height: 24px;
  }

  .fo-view .th-history-compact .th-result {
    width: 24px;
    font-size: 16px;
  }

  .fo-view .th-history-compact .th-final {
    flex-direction: row;
    align-items: baseline;
    padding-top: 6px;
    gap: 4px;
  }

  .fo-view .th-history-compact .th-final-score {
    font-size: 14px;
  }

  .fo-view .th-history-compact .th-average-value.th-unavailable {
    font-size: 16px;
  }
}

@media (max-width: 360px) {
  .schedule-view .schedule-row {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .schedule-view .schedule-date {
    padding: 12px 6px;
  }

  .schedule-view .schedule-matchup {
    padding: 12px 5px;
    column-gap: 3px;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  }

  .schedule-view .schedule-logo {
    width: 36px;
    height: 36px;
  }

  .fo-view .fo-identity {
    padding: 10px;
  }

  .fo-view .fo-name {
    font-size: 16px;
  }

  .fo-view .fo-position {
    font-size: 10px;
  }

  .fo-view .fo-field {
    height: 560px;
  }
}

@media (min-width: 1200px) {
  .schedule-view .schedule-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .schedule-view .schedule-card {
    display: grid;
  }

  .schedule-view .schedule-row {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .schedule-view .schedule-date {
    padding: 14px 10px;
  }

  .schedule-view .schedule-matchup {
    padding: 16px 12px;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  }

  .schedule-view .schedule-team,
  .schedule-view .schedule-home {
    display: contents;
  }

  .schedule-view .schedule-team > * {
    grid-column: 1;
    justify-self: center;
    text-align: center;
  }

  .schedule-view .schedule-home > * {
    grid-column: 3;
  }

  .schedule-view .schedule-logo {
    width: 48px;
    height: 48px;
    grid-row: 1;
  }

  .schedule-view .schedule-team-name {
    font-size: 14px;
    grid-row: 2;
  }

  .schedule-view .schedule-team .schedule-score {
    grid-row: 3;
    grid-column: 1;
  }

  .schedule-view .schedule-home .schedule-score {
    grid-column: 3;
  }

  .schedule-view .schedule-status {
    grid-area: 3/1/4/-1;
  }

  .schedule-view .schedule-versus {
    font-size: 11px;
  }
}
