@font-face {
  font-family: 'Permanent Marker';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/PermanentMarker-Regular.ttf) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --background: #ffffff;
  --background-alt: #dddcdc;
  --foreground: #303030;
  --valid: #176B3C;
  --invalid: #8B0000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #303030;
    --background-alt: #404040;
    --foreground: #dddcdc;
    --valid: #4FD171;
    --invalid: #FF4D4D;
  }
}

html {
  height: 100%;
  font-size: 100%;
  letter-spacing: 0.125em;
  overscroll-behavior: none;
  font-family: 'Permanent Marker', cursive;
}

body {
  margin: 0;
  padding: 1rem 0.5rem;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  color: var(--foreground);
  background: var(--background);
}

*, *:before, *:after {
  box-sizing: border-box;
}

header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;

  & h1 {
    font-size: 2rem;
    letter-spacing: 0.125em;
    margin: 0;
  }

  & button {
    border: 0;
    padding: 0;
    background: var(--background);
    font-size: 1.75rem;
    border-radius: 0.125rem;
    cursor: pointer;
    color: inherit;
  }

  & span,
  & button {
    width: 2.1rem;
  }
}

.game {
  display: grid;
  grid-template-rows: repeat(9, 1fr);
  grid-template-columns: repeat(9, 1fr);
  border: 0.0625rem solid;
  width: 100%;
  max-width: 36rem;

  &.valid {
    color: var(--valid);
  }

  &.invalid {
    color: var(--invalid);
  }

  & input {
    color: inherit;
    appearance: none;
    display: flex;
    flex-shrink: 1;
    justify-content: center;
    align-items: center;
    border: 0.0625rem solid;
    padding: 0.5rem;
    aspect-ratio: 1;
    cursor: pointer;
    font-size: 1rem;
    text-align: center;
    min-width: 0;
    background: none;
    border-radius: 0;
    line-height: 1.5rem;

    &[readonly] {
      cursor: default;
      pointer-events: none;
      font-family: sans-serif;
    }

    &:not([readonly]) {
      font-family: inherit;
      font-size: 1.5rem;
      padding-top: 0;
      padding-bottom: 0.25rem;

      &:focus {
        z-index: 1;
      }
    }

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
      appearance: none;
      margin: 0;
    }

    &:nth-child(-n+3),
    &:nth-child(n+7):nth-child(-n+12),
    &:nth-child(n+16):nth-child(-n+21),
    &:nth-child(n+25):nth-child(-n+27),
    &:nth-child(n+31):nth-child(-n+33),
    &:nth-child(n+40):nth-child(-n+42),
    &:nth-child(n+49):nth-child(-n+51),
    &:nth-child(n+55):nth-child(-n+57),
    &:nth-child(n+61):nth-child(-n+66),
    &:nth-child(n+70):nth-child(-n+75),
    &:nth-child(n+79) {
      background: var(--background-alt);
    }
  }
}

footer {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;

  & p {
    margin: 0;
    text-align: center;
  }
}
