:root {
  color-scheme: dark;
  --bg: #101617;
  --panel: #192223;
  --line: #334041;
  --text: #eff4e9;
  --muted: #a4b4ad;
  --accent: #e9d474;
  --up: #8be5ab;
  --down: #ff9b8c
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'Segoe UI', Arial, sans-serif
}

button, input, select {
  font: inherit
}

button, a, select {
  touch-action: manipulation
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #202b2b;
  color: var(--text);
  padding: 10px 16px
}

button:hover {
  border-color: var(--accent)
}

button:disabled {
  opacity: .4;
  cursor: default
}

a {
  color: var(--accent)
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px
}

header {
  max-width: 1480px;
  margin: auto;
  padding: 25px 48px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line)
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--accent);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -2px
}

.brand span {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text)
}

.brand small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1.5px
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center
}

.actions button {
  font-size: 12px
}

#present {
  background: var(--accent);
  color: #172115;
  border: 0;
  font-weight: 700
}

main {
  max-width: 1480px;
  margin: auto;
  padding: 40px 48px
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
  font-weight: 700
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  margin: 14px 0 35px
}

h1 {
  font-size: clamp(42px, 5vw, 76px);
  line-height: 1.02;
  letter-spacing: -4px;
  margin: 0;
  font-weight: 750
}

h1 em {
  color: var(--accent);
  font-style: normal
}

.heading p {
  max-width: 470px;
  color: var(--muted);
  margin-bottom: 0
}

.patch {
  border-left: 1px solid var(--line);
  padding: 15px 35px;
  min-width: 260px
}

.patch span, .patch small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px
}

.patch strong {
  display: block;
  font-size: 32px;
  margin: 8px 0
}

.patch small {
  letter-spacing: 0
}

nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  gap: 28px
}

nav button {
  border: 0;
  border-radius: 0;
  background: none;
  padding: 15px 0;
  color: var(--muted);
  font-weight: 600
}

nav button.active {
  border-bottom: 3px solid var(--accent);
  color: var(--accent)
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line)
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .5px
}

input, select {
  border: 1px solid var(--line);
  color: var(--text);
  background: #192223;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 14px;
  min-width: 165px
}

label[hidden] {
  display: none
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 27px 0 20px
}

h2 {
  font-size: 25px;
  letter-spacing: -.5px;
  margin: 0
}

.section-head p {
  color: var(--muted);
  font-size: 12px;
  margin: 7px 0
}

#status {
  font-size: 11px;
  color: var(--muted);
  max-width: 320px;
  text-align: right
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 25px
}

.stat {
  border-top: 1px solid var(--line);
  padding: 15px 0
}

.stat small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.8px
}

.stat strong {
  font-size: 22px;
  display: block;
  margin: 6px 0
}

.stat span {
  font-size: 12px;
  color: var(--muted)
}

.bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 28px
}

.barrow {
  display: grid;
  grid-template-columns: 38px 1fr 85px;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid #253132;
  text-align: left;
  background: transparent;
  border-radius: 0;
  border-top: 0;
  border-left: 0;
  border-right: 0
}

.rank {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums
}

.barname {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  gap: 8px
}

.barname strong {
  font-weight: 600
}

.tracks {
  height: 19px;
  position: relative;
  margin-top: 9px
}

.track {
  height: 6px;
  border-radius: 2px;
  position: absolute;
  left: 0;
  max-width: 100%
}

.track.old {
  top: 0;
  background: #63706c
}

.track.current {
  top: 10px;
  background: var(--accent)
}

.delta {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums
}

.up {
  color: var(--up)
}

.down {
  color: var(--down)
}

.delta small {
  display: block;
  color: var(--muted);
  font-size: 10px
}

.legend {
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px
}

.legend i {
  display: inline-block;
  width: 16px;
  height: 5px;
  background: var(--accent);
  margin-right: 7px;
  vertical-align: middle
}

.legend .old {
  background: #63706c
}

.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 15px
}

.card {
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  text-align: left;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px
}

.card:hover {
  transform: translateY(-3px)
}

.art {
  height: 155px;
  background: radial-gradient(ellipse at center, #364547, #192223);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden
}

.art img {
  width: 100%;
  height: 100%;
  object-fit: contain
}

.card-info {
  padding: 13px
}

.card-info strong {
  font-size: 13px;
  display: block;
  min-height: 38px;
  line-height: 1.4
}

.card-info small {
  color: var(--muted);
  font-size: 11px
}

.card-rank {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #0c1415e8;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700
}

.movement {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px
}

.empty {
  padding: 45px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center
}

.deck {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px
}

.deck h3 {
  margin: 0 0 15px;
  display: flex;
  justify-content: space-between
}

.deckgrid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 9px
}

.deckcard {
  text-align: center;
  font-size: 10px;
  line-height: 1.3
}

.deckcard img {
  width: 100%;
  height: 105px;
  object-fit: contain
}

.deckcard b {
  display: block;
  color: var(--accent);
  margin-top: 4px
}

#paging {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 30px 0;
  font-size: 12px
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 24px;
  margin-top: 45px;
  font-size: 10px;
  letter-spacing: .7px
}

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  max-width: 650px;
  width: 90%;
  max-height: 90vh
}

dialog::backdrop {
  background: #000b
}

.close {
  float: right;
  font-size: 22px;
  padding: 0 10px
}

.muted {
  color: var(--muted);
  font-size: 12px
}

#configForm {
  display: grid;
  gap: 14px;
  margin: 25px 0
}

#detailBody img {
  display: block;
  height: 200px;
  max-width: 100%;
  object-fit: contain;
  margin: auto
}

#detailBody h2 {
  margin: 22px 0
}

#detailBody dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 700
}

dt {
  color: var(--muted)
}

body.present .heading, body.present .eyebrow, body.present footer, body.present #settingsButton {
  display: none
}

body.present main {
  padding-top: 12px
}

body.present .cards {
  grid-template-columns: repeat(6, 1fr)
}

body.present .art {
  height: 190px
}

body.present .barname {
  font-size: 18px
}

body.present .barrow {
  padding: 17px 0
}

body.present header {
  padding: 12px 48px
}

body.present .filters {
  padding: 12px 0
}

body.present .summary {
  display: none
}

@media(max-width:1000px) {
  .cards {
    grid-template-columns: repeat(4, 1fr)
  }

  .deckgrid {
    grid-template-columns: repeat(5, 1fr)
  }

  .patch {
    min-width: 210px;
    padding: 15px 20px
  }

  header, main {
    padding-left: 25px;
    padding-right: 25px
  }

}

@media(max-width:650px) {
  header {
    flex-wrap: wrap
  }

  .actions {
    flex-wrap: wrap
  }

  .heading {
    display: block
  }

  .patch {
    border-left: 0;
    border-top: 1px solid var(--line);
    margin-top: 25px;
    padding: 18px 0
  }

  .patch strong {
    font-size: 24px
  }

  h1 {
    letter-spacing: -2px
  }

  nav {
    gap: 18px;
    overflow: auto;
    white-space: nowrap
  }

  nav button {
    font-size: 13px
  }

  .filters {
    gap: 12px
  }

  .filters label {
    flex: 1;
    min-width: 140px
  }

  input, select {
    width: 100%;
    min-width: 0
  }

  .bars {
    grid-template-columns: 1fr
  }

  .cards, body.present .cards {
    grid-template-columns: repeat(2, 1fr)
  }

  .summary {
    grid-template-columns: 1fr
  }

  .stat {
    padding: 10px 0
  }

  .section-head {
    display: block
  }

  #status {
    display: block;
    text-align: left
  }

  .deckgrid {
    grid-template-columns: repeat(2, 1fr)
  }

  footer {
    flex-direction: column
  }

  .barrow {
    grid-template-columns: 24px 1fr 74px
  }

  .heading p {
    font-size: 14px
  }

  body.present header {
    padding: 15px 25px
  }

}

[hidden] {
  display: none!important
}

.tracks {
  display: block
}

body.present .art {
  height: 140px
}

@media(min-width:651px) and (max-width:1000px) {
  body.present .cards {
    grid-template-columns: repeat(4, 1fr)
  }

}

/* Master popularity: paired vertical bars on one shared percentage axis. */
.master-chart-scroll {
  overflow-x: auto;
  padding: 20px 3px 12px;
  scrollbar-color: var(--line) var(--bg)
}

.master-chart {
  --plot-height: 300px;
  position: relative;
  padding-left: 54px;
  min-width: 1080px
}

.master-axis {
  position: absolute;
  left: 0;
  top: 0;
  width: 45px;
  height: var(--plot-height);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums
}

.master-axis span {
  position: absolute;
  right: 3px;
  transform: translateY(50%)
}

.master-columns {
  display: grid;
  grid-template-columns: repeat(var(--master-count), minmax(0, 1fr));
  gap: 10px;
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #334041 25%);
  background-size: 100% var(--plot-height);
  background-repeat: no-repeat
}

.master-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 0 3px 8px;
  text-align: center
}

.master-column:hover {
  background: #ffffff08
}

.master-plot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: var(--plot-height);
  border-bottom: 1px solid var(--line)
}

.master-bar {
  display: block;
  position: relative;
  width: 35%;
  max-width: 26px;
  min-height: 0;
  border-radius: 3px 3px 0 0
}

.master-bar.previous {
  background: #63706c
}

.master-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: 6px;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  font-weight: 700;
  font-variant-numeric: tabular-nums
}

.master-portrait {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 64px;
  height: 70px;
  margin: 13px 0 5px
}

.master-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain
}

.master-portrait .muted {
  font-size: 9px;
  line-height: 1.2
}

.master-name {
  font-size: 11px;
  min-height: 32px;
  line-height: 1.3;
  display: block
}

.master-change {
  font-size: 10px;
  white-space: nowrap
}

body.present .master-chart {
  --plot-height: 290px
}

.deck-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px
}

.deck-heading h3 {
  margin: 0;
  font-size: 21px
}

.deck-master-art {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  background: #101617;
  border: 1px solid var(--line)
}

.deck-master-art img {
  width: 100%;
  height: 100%;
  object-fit: contain
}

.deck-master-art .muted {
  font-size: 10px;
  text-align: center;
  padding: 5px
}

.deckgrid {
  grid-template-columns: repeat(11, minmax(0, 1fr))
}

.deckmaster {
  border-right: 1px solid var(--line);
  padding-right: 9px
}

@media(max-width:1000px) {
  .deckgrid {
    grid-template-columns: repeat(6, minmax(0, 1fr))
  }

}

@media(max-width:650px) {
  .deckgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr))
  }

}

/* Deck ranking inputs and score, taken from the selected patch's spreadsheet. */
.deck-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.deck-metrics dt {
  font-size: 11px;
  color: var(--muted);
}

.deck-metrics dd {
  margin: 4px 0 0;
  text-align: left;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

/* Optional patch video: collapsed until the visitor opens it. */
.patch-video {
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.patch-video summary {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
}

.patch-video-body {
  max-width: 760px;
  padding: 0 16px 16px;
}

.patch-video-player {
  aspect-ratio: 16 / 9;
  margin-bottom: 10px;
  background: #000;
}

.patch-video-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.patch-video-body a {
  font-size: 12px;
}

body.present .patch-video {
  display: none;
}

/* Official game logo, stored locally with the website. */
.brand-logo {
  display: block;
  width: 110px;
  height: auto;
  flex-shrink: 0;
}

@media (max-width: 650px) {
  .brand-logo {
    width: 85px;
  }
}

/* Centre card details in the visible portion of an embedded dashboard. */
#detail {
  position: fixed;
  bottom: auto;
  margin: 0 auto;
  transform: translateY(-50%);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#detail .close {
  position: sticky;
  top: 0;
  z-index: 1;
}
