.popupWrapper,
.modalWrapper {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  display: grid;
  justify-content: center;
  justify-items: center;
  align-items: center;
  padding: 2rem;
  border: none;
  grid-template-columns: 100%;
  &:focus-visible {
    outline: none;
  }
  &::backdrop {
    background: transparent;
  }
  .modal {
    background: var(--bg-color);
    border-radius: var(--roundness);
    padding: 2rem;
    display: grid;
    gap: 1rem;
    width: 100%;
    max-height: 100%;
    max-width: 300px;
    color: var(--text-color);
    overflow-y: auto;
    @extend .ffscroll;
    box-shadow: 0 0 0 0.2em var(--sub-alt-color);

    & > .title {
      font-size: 1.5rem;
      color: var(--sub-color);
    }

    .inputs.withLabel {
      display: grid;
      grid-template-columns: max-content auto;
      grid-auto-flow: row;
    }

    .inputs {
      div:has(> input[type="range"]) {
        display: grid;
        grid-auto-columns: auto 3rem;
        grid-auto-flow: column;
        gap: 0.5rem;

        span {
          text-align: right;
        }
      }
    }
  }
}

body.darkMode {
  .popupWrapper,
  .modalWrapper {
    .modal .inputs {
      input[type="date"]::-webkit-calendar-picker-indicator,
      input[type="datetime-local"]::-webkit-calendar-picker-indicator {
        filter: invert(1);
      }
    }
  }
}

#miniResultChartModal {
  .modal {
    overflow: hidden;
    max-width: 70rem;
    canvas {
      max-height: 200px;
    }
  }
}

#forgotPasswordModal {
  .modal {
    max-width: 400px;
  }
}

#practiseWordsModal {
  .modal {
    max-width: 400px;

    .group {
      width: 100%;
      display: grid;
      .title {
        color: var(--sub-color);
        text-transform: lowercase;
      }
      .sub {
        color: var(--text-color);
        margin-top: 0.25rem;
        margin-bottom: 0.5rem;
      }
      .buttonGroup {
        display: flex;
        gap: 0.5rem;
        width: 100%;
        button {
          flex-grow: 1;
        }
      }
    }

    .text {
      font-size: 1rem;
      color: var(--text-color);
    }
  }
}

#simpleModal {
  .modal {
    max-width: 500px;

    form {
      display: grid;
      gap: 1rem;
    }

    .inputs {
      display: grid;
      gap: 1rem;
    }

    .text {
      font-size: 1rem;
      color: var(--text-color);
    }
  }
  & [data-popup-id="viewApeKey"] {
    textarea:disabled {
      opacity: 1;
    }
  }
  & [data-popup-id="devGenerateData"] {
    max-width: 700px;
  }
}

#googleSignUpModal {
  .modal {
    max-width: 425px;
    overflow: unset;
    .captcha {
      display: flex;
      justify-content: center;
    }
    // .inputAndIndicator {
    //   input {
    //     width: 100%;
    //   }
    //   position: relative;
    //   .checkStatus {
    //     width: 2.25rem;
    //     height: 2.25rem;
    //     position: absolute;
    //     right: 0;
    //     top: 0;
    //     /* background: red; */
    //     display: grid;
    //     grid-template-columns: 2.25rem;
    //     grid-template-rows: 2.25rem;
    //     place-items: center center;
    //     cursor: pointer;

    //     .checking,
    //     .available,
    //     .unavailable,
    //     .taken {
    //       grid-column: 1/2;
    //       grid-row: 1/2;
    //     }
    //     .checking {
    //       color: var(--sub-color);
    //     }
    //     .available {
    //       color: var(--main-color);
    //     }
    //     .unavailable,
    //     .taken {
    //       color: var(--error-color);
    //     }
    //   }
    // }
  }
}

#lastSignedOutResult {
  .modal {
    max-width: 600px;

    .buttons {
      display: flex;
      flex-direction: row-reverse;
      gap: 0.5rem;
      button {
        flex-grow: 1;
      }
    }
    .result {
      display: grid;
      gap: 0.5rem;
      grid-template-columns: 1fr 1fr;
    }
    .divider {
      background: var(--sub-alt-color);
      width: 100%;
      height: 0.25rem;
      border-radius: var(--roundness);
    }
    .group {
      .sub {
        font-size: 0.75em;
        color: var(--sub-color);
      }
      &.testType {
        grid-column: 1;
      }
      &.wpm,
      &.acc {
        font-size: 2em;
      }
    }
  }
}

#cookiesModal {
  align-items: end;
  justify-items: end;
  .extensionMessage {
    max-width: 465px;
    width: 100%;
    font-size: 0.75rem;
    color: var(--text-color);
    grid-column: 1/2;
    grid-row: 1/2;
    padding: 1rem;
  }
  .modal {
    grid-column: 1/2;
    grid-row: 1/2;
    max-width: 465px;
    z-index: 100000001;
    // outline: 0.5rem solid var(--bg-color)
    -webkit-user-select: none;
    user-select: none;
    .main {
      display: grid;
      gap: 1rem;
    }
    .buttons {
      margin-top: 0.25rem;
      display: grid;
      gap: 1rem;
    }
    .title {
      color: var(--sub-color);
    }
    .description {
      color: var(--text-color);
    }
    .settings {
      display: grid;
      gap: 1rem;
      .cookie label {
        display: grid;
        gap: 0 1rem;
        grid-template-columns: 1fr min-content;
        grid-template-areas:
          "title check"
          "description check";
        .title {
          grid-area: title;
          font-size: 1.25rem;
        }
        .description {
          grid-area: description;
        }
        input[type="checkbox"] {
          align-self: center;
          grid-area: check;
          font-size: 2em;
        }
      }
      .cookie.ads label {
        grid-template-columns: 1fr;
        grid-template-areas:
          "title"
          "description";
        a {
          margin-top: 0.25rem;
        }
        .textButton {
          padding: 0;
          padding-top: 0.25em;
          width: unset;
          text-align: unset;
        }
      }
    }
  }
}

#videoAdPopupWrapper {
  display: flex;
  padding: 2rem;
  #videoAdPopup {
    background: var(--bg-color);
    border-radius: var(--roundness);
    padding: 2rem;
    display: grid;
    gap: 1rem;
    width: 100%;
    max-width: 1000px;
    aspect-ratio: 16/9;
    display: grid;
    grid-template-areas: "middle";
    .preloader {
      grid-area: middle;
      display: grid;
      place-items: center center;
      gap: 1rem;
      font-size: 2rem;
      color: var(--main-color);
      height: max-content;
      align-self: center;
    }
    .video {
      grid-area: middle;
    }
  }
}

#pbTablesModal {
  .modal {
    max-width: 100%;
    overflow-y: scroll;
    table {
      border-spacing: 0;
      border-collapse: collapse;
      color: var(--text-color);

      tbody {
        clip-path: inset(0);
      }

      td {
        padding: 0.5rem 0.5rem;
      }

      .modesticky {
        position: sticky;
        top: calc(1rem - 2px);
        z-index: 2;
      }

      thead {
        color: var(--sub-color);
        font-size: 0.75rem;
        position: sticky;
        top: -2rem;
        background-color: var(--bg-color) !important;
        z-index: 3;
      }

      tbody tr.odd {
        background: var(--sub-alt-color);
      }

      tbody tr.even {
        background: var(--bg-color);
      }

      td.infoIcons span {
        margin: 0 0.1rem;
      }
      .miniResultChartButton {
        opacity: 0.25;
        transition: 0.25s;
        cursor: pointer;
        &:hover {
          opacity: 1;
        }
      }
      .sub {
        opacity: 0.5;
      }
      td {
        text-align: right;
      }
      td:nth-child(6),
      td:nth-child(7) {
        text-align: center;
      }
      tbody td:nth-child(1) {
        font-size: 1.5rem;
      }
    }
  }
}

#importExportSettingsModal {
  .modal {
    max-width: 900px;
  }
}

#apeKeysModal {
  .modal {
    max-width: 1000px;

    grid-template-rows: max-content auto;
    align-items: baseline;

    .top {
      display: grid;
      grid-template-columns: 1fr auto;
      .title {
        font-size: 1.5rem;
        color: var(--sub-color);
      }
      button {
        padding: 0.5em 2em;
      }
    }

    .textButton {
      justify-content: center;
    }

    .keyButtons {
      display: grid;
      grid-auto-flow: column;
      gap: 1rem;
      .button {
        width: 3rem;
      }
    }

    table {
      width: 100%;
      border-spacing: 0;
      border-collapse: collapse;

      tr td:first-child {
        text-align: center;
      }

      tr.me {
        td {
          color: var(--main-color);
          // font-weight: 900;
        }
      }

      td {
        padding: 0.5rem 0.5rem;
      }

      thead {
        color: var(--sub-color);
        font-size: 0.75rem;

        td {
          padding: 0.5rem;
          background: var(--bg-color);
          position: -webkit-sticky;
          position: sticky;
          top: 0;
          z-index: 99;
        }
      }

      tbody {
        color: var(--text-color);

        tr:nth-child(odd) td {
          background: var(--sub-alt-color);
        }
      }

      tfoot {
        td {
          padding: 1rem 0.5rem;
          position: -webkit-sticky;
          position: sticky;
          bottom: -5px;
          background: var(--bg-color);
          color: var(--main-color);
          z-index: 4;
        }
      }

      tr {
        td:first-child {
          padding-left: 1rem;
        }
        td:last-child {
          padding-right: 1rem;
        }
      }
    }
  }
}

#userReportModal {
  .modal {
    max-width: 800px;

    label {
      color: var(--sub-color);
      margin-bottom: -0.5rem;
    }

    // .text {
    //   // color: var(--sub-color);
    // }

    .user {
      font-size: 1.5rem;
    }

    textarea {
      resize: vertical;
      width: 100%;
      padding: 10px;
      line-height: 1.2rem;
      min-height: 5rem;
    }
  }
}

#editResultTagsModal {
  .modal {
    max-width: 600px;
    .buttons {
      display: grid;
      gap: 0.5rem;
      grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    }
  }
}
#shareCustomThemeModal {
  .modal {
    max-width: 400px;

    .buttons {
      display: grid;
      gap: 1rem;
      grid-template-columns: 1fr 1fr 1fr;
    }
  }
}
#shareCustomThemeUrlModal {
  .modal {
    max-width: 900px;
  }
}

#editPresetModal {
  .modal {
    max-width: 450px;
    gap: 1rem;
    .presetNameTitle {
      font-size: 0.75rem;
      color: var(--sub-color);
      text-transform: lowercase;
    }
  }

  .group {
    display: grid;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
  }

  input[type="text"] {
    width: 100%;
  }

  .inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    font-size: 0.75rem;
    .title {
      color: var(--sub-color);
      text-transform: lowercase;
    }
    .partialPresetGroups {
      .checkboxList {
        display: grid;
        gap: 1rem;
        grid-template-columns: 1fr 1fr;
        .title {
          color: var(--text-color);
          text-transform: lowercase;
        }
        .checkboxTitlePair {
          display: flex;
          gap: 0.5rem;
          button {
            flex-grow: 1;
          }
        }
      }
    }
    .presetType {
      .presetTypeButtonGroup {
        display: flex;
        width: 100%;
        gap: 0.5rem;
        button {
          flex-grow: 1;
        }
      }
    }
  }
}

#streakHourOffsetModal {
  .modal {
    max-width: 500px;
    .red {
      color: var(--error-color);
    }
    .group {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 0.5rem;
      justify-items: center;
      align-items: center;
      font-size: 2em;
      button {
        width: 100%;
      }
      input {
        text-align: center;
      }
    }
    .preview {
      & > div:first-child {
        margin-bottom: 1rem;
      }
      .row {
        display: flex;
        gap: 1rem;
      }
      div:first-child {
        flex-grow: 1;
      }
      div:last-child {
        align-self: center;
      }
    }
  }
}

#editProfileModal {
  .modal {
    max-width: 600px;
    max-height: 100%;
    label {
      color: var(--sub-color);
      margin-bottom: 0.25em;
      display: block;
    }
    input:not([type="checkbox"]) {
      width: 100%;
    }
    input[type="checkbox"] {
      vertical-align: text-bottom;
    }
    textarea {
      resize: vertical;
      width: 100%;
      padding: 10px;
      line-height: 1.2rem;
      min-height: 5rem;
      max-height: 10rem;
    }

    .socialURL {
      display: flex;
    }

    .socialURL > p {
      margin-block: 0.5rem;
      margin-inline-end: 0.5rem;
    }

    .badgeSelectionContainer {
      display: flex;
      flex-wrap: wrap;
    }

    .badgeSelectionItem {
      margin-bottom: 0.5rem;
      width: max-content;
      opacity: 25%;
      cursor: pointer;
      margin-right: 0.5rem;
      margin-bottom: 0.5rem;
      padding: 0;
      border-radius: calc(var(--roundness) / 2);
    }

    .badgeSelectionItem.selected,
    .badgeSelectionItem:hover {
      opacity: 100%;
    }

    span {
      color: var(--text-color);
    }
  }
}
