@keyframes shake {
 0% { transform: translateX(0) }
 25% { transform: translateX(5px) }
 50% { transform: translateX(-5px) }
 75% { transform: translateX(5px) }
 100% { transform: translateX(0) }
}
@keyframes pulse {
 0% { background-color: hsl(0, 20%, 30%); }
 50% { background-color: hsl(0, 100%, 30%); }
 100% { background-color: hsl(0, 20%, 30%); }
}
@keyframes slide-down {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.shake {
  animation: shake 0.35s infinite;
}
.glow {
  animation: pulse 1s ease-in-out infinite;
}
.locked {
  background-color: #a00 !important;
}
.hooked {
  background-color: #606 !important;
}

body {
  background-color: black;
  font-family: Arial, sans-serif;
  color: white;
}
main {
  margin: 0 auto;
  max-width: 24rem;
  width: 100%;

  details#rules {
    summary {

      font-size: 1.5rem;
    }
  }

  #new-game {
    font-size: 1.5rem;
    background-color: black;
    color: white;
    border: 1px solid white;
    margin-top: 1rem;
  }

  #status-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem 0.5rem;
  }
  #score-display {
    color: white;
    font-size: 1.4rem;
    align-self: center;
    text-align: right;

  }
  #message {
    color: #f88;
    font-size: 1.2rem;
    text-align: right;
    
    min-height: 1.8rem;
    padding: 0.25rem 0;
  }

  [data-controller="guesses"] {
    display: flex;
    flex-direction: column;
    list-style: none;
    color: white;
    gap: 0.5rem;
    align-items: center;
    align-self: center;
    margin: 0;
    padding: 4rem 0;
    li {
      font-size: 4rem;
      display: flex;
      flex-direction: row;
      align-items: center;
      flex-wrap: nowrap;

      &.slide-in {
        animation: slide-down 300ms ease-out forwards;
      }

      ul {
        list-style: none;
        display: flex;
        flex-direction: row;

        li {
          width: 4rem;
          height: 4rem;
          border: 1px solid #333;
          text-align: center;
          justify-content: center;
          vertical-align: middle;

          &:empty {
            background-color: black;
          }

          &:not(:empty) {
            background-color: #34c;
          }
        }
      }
      .guess-score {
        font-size: 1rem;
        font-weight: bold;
        font-style: italic;
        color: #888;
        margin-left: 0.5rem;
        vertical-align: middle;
        display: inline-block;
        white-space: nowrap;
        min-width: 3rem;
      }
      &.error {
        background-color: #800;
        border-radius: 8px;
        ul li {
          border-color: #800;
        }
      }
      &.guessed {
        border-radius: 8px;
        li {
          border: 0;
          background-color: transparent !important;
        }
      }
      &:last-of-type {
        ul li {
          &.locked {
            background-color: #d00;
          }
          &.hooked {
            background-color: #96c;
          }
        }
      }
    }
  }
  section:has([data-controller="input"]) {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;

    div {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      gap: 0.2rem;

      button {
        width: 3rem;
        height: 3rem;
        font-size: 1.5rem;
        background-color: #333;
        color: white;

        &.required {
          background-color: red;
        }
      }
      &:last-of-type {
        margin-top: 1rem;
        button {
          width: 10rem;
        }
      }
    }
  }

  #mobile-input {
    position: absolute;
    opacity: 0;
    height: 0;
    width: 0;
    padding: 0;
    border: 0;
    cursor: none;
    left: -9999em; /* On some devices it was showing a blinking cursor */
  }

  #form-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
  }

  #show-keyboard {
    display: none;
  }

  fieldset#wordlength {
    display: flex;
    border: 0;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0;

    legend {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
    }

    input[type="radio"] {
      appearance: none;
      position: absolute;
      opacity: 0;
      width: 0;
      height: 0;
    }

    label {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 2.5rem;
      height: 2.5rem;
      border: 2px solid #666;
      color: #ccc;
      font-size: 1.2rem;
      cursor: pointer;

      &:has(:checked) {
        background-color: white;
        color: black;
        border-color: white;
      }
    }
  }
}

@media (max-width: 600px) {
  main {
    section:has([data-controller="input"]) {
      display: none;
    }

    &.show-keyboard section:has([data-controller="input"]) {
      display: flex;
    }

    #show-keyboard {
      display: block;
    }

    #mobile-input {
      position: absolute;
      opacity: 0;
      height: 1px;
      width: 1px;
      pointer-events: auto;
      cursor: none;
    }

    [data-controller="guesses"] {
      li {
        font-size: 2.5rem;
        ul li {
          width: 2.5rem;
          height: 2.5rem;
        }
      }
    }
  }
}
