.tile-dialog {
  --tile-width: 2.3rem;
  padding: 0;

  background-color: var(--bg-color);
  color: var(--text-color);
  border-color: var(--text-color);
  border: 1px solid;
  border-radius: 0.5rem;
  outline: none;
  scrollbar-color: var(--text-color) transparent;

  &-content {
    height: min-content;
    width: min-content;
    padding: .5rem;
    box-sizing: border-box;
  }

  &--img {
    width: calc(var(--tile-width) * 16);
    display: block;
    border: 1px solid;

    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
  }

  &--no-img {
    width: calc(var(--tile-width) * 16);
    display: grid;
    place-items: center;
  }

  &--item-img {
    --tile-top: 0;
    --tile-left: 0;
    position: absolute;
    width: calc(var(--tile-width) + 2px);
    background-color: #99d9ea;
    opacity: 1;
    border: 0.2rem solid red;
    border-radius: 10%;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;

    top: calc(var(--tile-top) * var(--tile-width));
    left: calc(var(--tile-left) * var(--tile-width));

    animation: item-animation 3s infinite ease-in-out;

    @keyframes item-animation {
      0% {
        opacity: 1;
      }
      50% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }
    }
  }

  &--header {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: .5rem;

    > button {
      color: var(--text-color);
      border: 0;
      background: none;
      font-size: 1.25rem;
      line-height: 1.25rem;
      padding: 0;
      cursor: pointer;
    }
  }

  &--tilenumber {
    border: 1px solid;
    padding: 0.2rem;
    border-radius: 25%;
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
  }

  &--challenge {
    flex-grow: 1;
    display: grid;
    place-items: center;

    &:focus {
      outline: none;
    }
  }

  &--subheader {
    border: 1px solid;
    border-radius: 0.5rem;
    text-align: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  &--footer {
    display: grid;
    grid-template-areas:
      "search search"
      "requirements rewards"
      "treasure treasure";
    grid-template-columns: auto;
    column-gap: 0.5rem;

    > div {
      border: 1px solid;
      border-radius: 0.5rem;
    }

    ul, ol {
      margin-top: 0;
      margin-bottom: 0.5rem;
      padding-left: 0.5rem;
      padding-right: 0.5rem;
      display: flex;
      flex-direction: column;

      > li > ul {
        padding-left: 1rem;
      }
    }

    ul {
      list-style-type: none;
    }

    ol {
      padding-left: 1.5rem;
    }
  }

  &--search {
    grid-area: search;
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;

    > img {
      width: 3rem;
    }

    > div {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex-grow: 1;
    }

    &--fulltile-img {
      margin-right: 0.5rem;
      width: 2.5rem!important;
    }
  }

  &--requirements {
    grid-area: requirements;
    margin-top: 0.5rem;
  }

  &--rewards {
    grid-area: rewards;
    margin-top: 0.5rem;
  }

  &--treasure {
    margin-top: 0.5rem;
    grid-area: treasure;
    transition: height 1s ease-in-out;

    .skulltula-button {
      margin-left: auto;
      margin-right: 0.5rem;
    }
  }
}

.image-wrapper {
  display: grid;
  place-items: center;
}

.image-container {
  position: relative;
}

.labeled-image {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  img {
    width: 2.5rem;
    margin: 0.25rem;
  }
}

.tile-dialog--legend-mode-container {
  width: 60ch;

  .skulltulas {
    margin-top: 1rem;
  }

  .list {
    margin: .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
  }
}

.nav-button {
  position: absolute;
  opacity: 0;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--bg-color);
  color: var(--text-color);
  border: var(--text-color) 1px solid;
  font-size: 1rem;
  user-select: none;
  transition: opacity 0.3s ease-in-out;
  cursor: pointer;

  &.up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-top: none;
    border-bottom-right-radius: 25%;
    border-bottom-left-radius: 25%;
  }

  &.down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-bottom: none;
    border-top-right-radius: 25%;
    border-top-left-radius: 25%;
  }

  &.left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    border-left: none;
    border-top-right-radius: 25%;
    border-bottom-right-radius: 25%;
  }

  &.right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border-right: none;
    border-top-left-radius: 25%;
    border-bottom-left-radius: 25%;
  }
}

.image-container:hover .nav-button {
  opacity: 1;
}

@media (max-width: 800px) {
  .tile-dialog {
    --tile-width: calc((100vw - 5rem) / 16);
    left: 0!important;
    min-width: 95vw;

    &-content {
      width: 100%;
    }

    &--item-img {
      border-width: 1px;
    }

    &--footer {
      grid-template-areas:
        "search"
        "requirements"
        "rewards"
        "treasure";
    }
  }
}
