@layer blocks {
  .tile {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    font-size: var(--step-2);
    font-weight: var(--font-weight-bold);
    line-height: 1;
    text-transform: uppercase;
    color: var(--color-text);
    background: var(--color-surface);
    border: var(--stroke) solid var(--color-edge);
    border-radius: var(--radius-s);
    box-shadow: 0 3px 0 0 var(--color-edge);
  }

  input.tile {
    inline-size: 100%;
    min-inline-size: 0;
    padding: 0;
    text-align: center;
    caret-color: transparent;

    /* A light border marks the cursor, a fill would look like a guessed tile */
    &:focus {
      outline: none;
      border-color: var(--color-text);
      translate: 0 -2px;
      box-shadow: 0 5px 0 0 var(--color-edge);
    }

    &:not(:placeholder-shown) {
      animation: tile-pop 160ms var(--ease-back);
    }
  }

  /* The newest guess flips in letter by letter */
  .tile[data-reveal] {
    animation: tile-flip 450ms var(--ease-out) both;
    animation-delay: calc(var(--index) * 90ms);
  }

  /* :where() keeps these shared colors at low specificity, so a block can override them */
  :where(.tile, .key)[data-state="right"] {
    color: var(--color-ink);
    background: var(--color-right);
  }

  :where(.tile, .key)[data-state="close"] {
    color: var(--color-ink);
    background: var(--color-close);
  }

  :where(.tile, .key)[data-state="wrong"] {
    color: var(--color-on-wrong);
    background: var(--color-wrong);
  }

  @keyframes tile-pop {
    50% {
      scale: 1.1;
    }
  }

  @keyframes tile-flip {
    from {
      rotate: x 90deg;
    }
  }
}
