:root {
  --text-color: light-dark(#000, #ddd);
  --text-color-negative: light-dark(#ddd, #000);

  --background-primary: light-dark(#fff, #222);

  --background-caught: light-dark(#bda, #251);
  --background-evo: light-dark(#bae, #428);
  --background-other-game: light-dark(#ed9, #651);
  --background-wrong: light-dark(#eaa, #611);

  font-size: 16px;
  font-family: system-ui;
  color: var(--text-color);
  background-color: var(--background-primary);

  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  justify-content: center;
}

header {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  max-width: 200px;
  background-color: var(--background-primary);
  menu {
    margin: 0;
    padding: 1rem 0;
    list-style-type: none;
    li {
      a {
        display: inline-block;
        width: 100%;
        padding: 0.5em 1em;
        color: inherit;
        white-space: nowrap;
        font-weight: bold;
        text-decoration: none;
        &.active,
        &:hover {
          color: var(--text-color-negative);
          background-color: var(--text-color);
        }
        small {
          font-size: 0.8em;
        }
      }
    }
  }
}

main {
  --box-columns: 6;
  flex-grow: 1;
  margin: 1rem 0;
  max-width: 1200px;
  border-top: 4px solid;
  &[data-box-size="20"] {
    --box-columns: 5;
  }
  .box {
    display: flex;
    justify-content: safe center;
    overflow-x: auto;
    .box-label {
      flex-basis: 4ch;
      flex-shrink: 0;
      background-color: var(--background-primary);
      border: 4px solid;
      border-top-width: 0;
      font-size: 3em;
      text-align: center;
      align-content: center;
      &:not(
          :has(
              ~ .box-content
                > div:not(:is([data-slot-status="caught"], [data-slot-status="filler"]))
            )
        ) {
        background-color: var(--background-caught);
      }
      &:has(~ .box-content > div[data-slot-status="evo"]) {
        background-color: var(--background-evo);
      }
      &:has(~ .box-content > div[data-slot-status="other-game"]) {
        background-color: var(--background-other-game);
      }
      &:has(~ .box-content > div[data-slot-status="wrong"]) {
        background-color: var(--background-wrong);
      }
      &:where(
          &:has(~ .box-content > div[data-slot-status="evo"]):has(
              ~ .box-content > div[data-slot-status="other-game"]
            )
        ) {
        background-image: linear-gradient(
          to right bottom,
          var(--background-evo) calc(50% - 1px),
          var(--background-other-game) calc(50% + 1px)
        );
      }
      &:where(
          &:has(~ .box-content > div[data-slot-status="evo"]):has(
              ~ .box-content > div[data-slot-status="wrong"]
            )
        ) {
        background-image: linear-gradient(
          to right bottom,
          var(--background-evo) calc(50% - 1px),
          var(--background-wrong) calc(50% + 1px)
        );
      }
      &:where(
          &:has(~ .box-content > div[data-slot-status="wrong-and-other-game"]),
          &:has(~ .box-content > div[data-slot-status="other-game"]):has(
              ~ .box-content > div[data-slot-status="wrong"]
            )
        ) {
        background-image: linear-gradient(
          to right bottom,
          var(--background-other-game) calc(50% - 1px),
          var(--background-wrong) calc(50% + 1px)
        );
      }
      &:where(
          &:has(~ .box-content > div[data-slot-status="evo"]):where(
              &:has(~ .box-content > div[data-slot-status="wrong-and-other-game"]),
              &:has(~ .box-content > div[data-slot-status="other-game"]):has(
                  ~ .box-content > div[data-slot-status="wrong"]
                )
            )
        ) {
        background-image: linear-gradient(
          to right bottom,
          var(--background-evo) calc(100% / 3 - 1px),
          var(--background-other-game) calc(100% / 3 - 1px),
          var(--background-other-game) calc(100% / 3 * 2 - 1px),
          var(--background-wrong) calc(100% / 3 * 2 + 1px)
        );
      }
    }
    .box-content {
      display: grid;
      grid-template-columns: repeat(var(--box-columns), minmax(15ch, 1fr));
      gap: 1px;
      flex-grow: 1;
      background-color: var(--text-color);
      border: solid;
      border-width: 0 4px 4px 0;
      > div {
        display: flex;
        flex-direction: column;
        gap: 0.15em;
        padding: 0 5px;
        height: 3em;
        text-align: center;
        justify-content: center;
        background-color: var(--background-primary);
        line-height: 1;
        text-wrap: balance;
        &[data-slot-status="caught"] {
          background-color: var(--background-caught);
        }
        &[data-slot-status="evo"] {
          background-color: var(--background-evo);
        }
        &[data-slot-status="other-game"] {
          background-color: var(--background-other-game);
        }
        &[data-slot-status="wrong"] {
          background-color: var(--background-wrong);
        }
        &[data-slot-status="wrong-and-other-game"] {
          background-image: linear-gradient(
            to right bottom,
            var(--background-other-game) calc(50% - 1px),
            var(--background-wrong) calc(50% + 1px)
          );
        }
        &[data-small-text]::after {
          content: attr(data-small-text);
          font-size: 0.8em;
        }
      }
    }
  }
}

@media (width <= 1199px) {
  body {
    flex-direction: column-reverse;
  }
  header {
    top: initial;
    bottom: 0;
    z-index: 1;
    max-width: initial;
    margin-top: -4px;
    menu {
      display: flex;
      justify-content: safe center;
      overflow-x: auto;
      padding: 0;
      border-top: 4px solid;
    }
  }
  main {
    margin: 0;
  }
}

@media (width <= 979px) {
  body {
    font-size: 0.8em;
  }
  main {
    border-top-width: 0;
    margin-bottom: 0;
    .box {
      flex-direction: column;
      overflow-x: initial;
      .box-label {
        position: sticky;
        top: 0;
        flex-basis: 0;
        border-width: 0 0 4px;
      }
      .box-content {
        overflow-x: auto;
        border-width: 0 0 4px;
      }
    }
  }
}
