@layer game {
  .hand-area {
    grid-area: hand;
    display: flex;
    justify-content: center;
    padding: 32px 0 16px;
    min-width: 0;
  }

  .hand-area--empty { display: none; }

  /* Each slot shrinks to the strip that stays visible while its card overflows to the right, which
     gives the overlap without measuring anything. The last card keeps its full width. */
  .hand {
    --fan-step: calc(11deg / var(--n, 13));
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: calc(var(--card-w) * 0.62 * var(--n, 13) + var(--card-w));
    padding-inline: 4px;
  }

  .hand__slot {
    --offset: calc(var(--i) - (var(--n) - 1) / 2);
    position: relative;
    flex: 0 1 var(--card-w);
    min-width: 0;
    rotate: calc(var(--offset) * var(--fan-step));
    translate: 0 calc(var(--offset) * var(--offset) * 0.35px);
    transform-origin: 50% 150%;
  }

  .hand__slot:last-child { flex-shrink: 0; }

  .hand__slot > .card,
  .hand__form,
  .hand__button { display: block; }

  .hand__form { margin: 0; }

  .hand__button {
    position: relative;
    padding: 0;
    border: 0;
    border-radius: calc(var(--card-w) * 0.11);
    background: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .hand__slot .card { transition: translate 160ms var(--ease-out), box-shadow 160ms, filter 160ms; }

  .hand__slot.is-playable .card { translate: 0 -12px; }
  .hand__slot.is-unplayable .card { translate: 0 4px; }
  .hand__slot.is-selected { z-index: 4; }
  .hand__slot.is-selected .card { translate: 0 -30px; }

  .hand__slot.is-selected .card {
    box-shadow:
      0 0 0 3px var(--messing),
      0 0 0 5px rgb(27 27 27 / 0.35),
      0 12px 24px rgb(0 0 0 / 0.4);
  }

  .hand-area--premove {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
  }

  .hand__slot.is-premove { z-index: 3; }
  .hand__slot.is-premove .card {
    translate: 0 -24px;
    box-shadow:
      0 0 0 3px var(--laken-deep),
      0 0 0 5px var(--messing-light),
      0 10px 20px rgb(0 0 0 / 0.4);
  }

  .hand__tag {
    position: absolute;
    bottom: 32px;
    z-index: 1;
    left: calc(var(--card-w) / 2);
    translate: -50% 0;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--messing-light);
    color: var(--inkt);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
  }

  .hand-area__hint,
  .premove-bar__text {
    color: var(--felt-text);
    font-size: 0.85rem;
    line-height: 1.35;
    text-align: center;
  }

  .premove-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 10px;
    max-width: 560px;
    padding-inline: 8px;
  }

  .premove-bar__text strong { color: var(--messing-light); }

  .premove-bar__clear {
    min-height: 36px;
    border-color: rgb(244 234 213 / 0.6);
    background: transparent;
    color: var(--schuim);
  }

  .premove-bar__clear:hover { background: rgb(244 234 213 / 0.12); }

  .hand__slot:has(.hand__button:focus-visible) { z-index: 5; }

  .hand__button:focus-visible { outline: none; }

  .hand__button:focus-visible .card {
    translate: 0 -30px;
    box-shadow:
      0 0 0 3px var(--laken-deep),
      0 0 0 6px var(--felt-focus),
      0 12px 24px rgb(0 0 0 / 0.4);
  }

  @media (hover: hover) {
    .hand__slot.is-playable .hand__button:hover .card { translate: 0 -20px; }
    .hand--premove .hand__slot:not(.is-premove, .is-selected) .hand__button:hover .card { translate: 0 -10px; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .hand__slot .card { transition: none; }
}
