:root {
  color: #191713;
  background: #f8f7f2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
}

body {
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
}

.welcome {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding:
    max(3rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(2.25rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  background: #fffefa;
  cursor: pointer;
}

.welcome-stack {
  width: min(100%, 46rem);
  display: grid;
  justify-items: center;
  gap: clamp(1.35rem, 3.8vh, 2.6rem);
}

.welcome-copy {
  width: min(100%, 28rem);
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(3.5rem, 8.6vmin, 7rem);
  line-height: 0.92;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.goal {
  margin: 0;
  color: #4b443b;
  font-size: clamp(1.1rem, 2.1vh, 1.35rem);
  line-height: 1.45;
}

.note {
  margin: 0.75rem 0 0;
  color: #80796e;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.play-button {
  width: min(100%, 34rem);
  min-height: clamp(5.5rem, 11vh, 7.5rem);
  border: 0;
  border-radius: 1.15rem;
  background: #2fa251;
  color: white;
  font-size: clamp(1.5rem, 3vh, 2rem);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow:
    inset 0 0 0 1px rgb(0 0 0 / 0.08),
    0 0.7rem 1.6rem rgb(30 25 15 / 0.12);
}

.play-button:active {
  transform: translateY(2px);
}

@media (max-width: 680px) {
  h1 {
    white-space: normal;
  }
}

.board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100svh;
  background: #fffefa;
  overflow: hidden;
  contain: strict;
}

.round-status {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
}

.round-label {
  min-height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.7rem;
  color: #6c665b;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
}

.restart-button {
  min-width: 10.75rem;
  min-height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 0.7rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #6c665b;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.restart-button.is-confirming {
  min-width: 12.5rem;
  color: #4b443b;
  background: rgb(25 23 19 / 0.06);
}

.restart-button:active {
  transform: scale(0.94);
}

.restart-icon {
  color: #9a9286;
  font-size: 1.1rem;
  font-weight: 900;
}

.card {
  --row-fit-size: calc(76svh / var(--rows));
  --card-size: clamp(2.25rem, min(13vmin, var(--row-fit-size)), 8.5rem);
  position: absolute;
  top: calc(var(--y) * 100%);
  left: calc(var(--x) * 100%);
  width: var(--card-size);
  height: var(--card-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  cursor: pointer;
  touch-action: none;
  will-change: top, left, transform, opacity;
  transition:
    top 2000ms cubic-bezier(0.2, 0.8, 0.2, 1),
    left 2000ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 150ms ease,
    opacity 420ms ease 720ms;
  box-shadow:
    inset 0 0 0 1px rgb(0 0 0 / 0.08),
    0 0.7rem 1.6rem rgb(30 25 15 / 0.12);
}

.card::after {
  content: "";
  position: absolute;
  inset: -0.65rem;
  border-radius: inherit;
}

.card.is-selected {
  transform: translate(-50%, -50%) scale(1.28);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.3),
    0 1rem 2rem rgb(30 25 15 / 0.2);
}

.card.is-selected.is-matched {
  transition:
    top 2000ms cubic-bezier(0.2, 0.8, 0.2, 1),
    left 2000ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 150ms ease,
    box-shadow 2000ms ease;
  box-shadow: none;
}

.card.is-fading {
  opacity: 0;
}

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