:root {
  color-scheme: light;
  --indigo-velvet: #5e1c99;
  --lavender-mist: #f8f1ff;
  --thistle: #decdf5;
  --dim-grey: #656176;
  --charcoal: #534d56;
  --card-radius: 14px;
  --ui-chrome-height: 280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--charcoal);
  background:
    radial-gradient(circle at top left, rgba(94, 28, 153, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(222, 205, 245, 0.9), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--lavender-mist) 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 20px auto 32px;
  display: grid;
  gap: 22px;
}

.hero,
.board-panel,
.controls,
.intake-panel {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(94, 28, 153, 0.12);
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(94, 28, 153, 0.09);
  backdrop-filter: blur(14px);
}

.hero {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(94, 28, 153, 0.18);
  color: var(--indigo-velvet);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(248, 241, 255, 0.85);
}

h1,
h2 {
  margin: 0;
  color: var(--indigo-velvet);
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
}

h1 {
  font-size: clamp(3rem, 6vw, 5rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(2.1rem, 4vw, 3.5rem);
  line-height: 1;
}

.hero-copy {
  margin: 8px 0 0;
  color: var(--dim-grey);
  font-size: 1rem;
}

.board-panel {
  padding: 26px 20px;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(var(--board-columns, 4), minmax(0, 1fr));
  gap: var(--board-gap, clamp(8px, 1.25vw, 14px));
  align-items: stretch;
  width: 100%;
  max-inline-size: min(
    100%,
    calc((100vh - var(--ui-chrome-height)) * var(--board-scale, 0.8)),
    720px
  );
  margin-inline: auto;
}

.memory-card {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  width: 100%;
  aspect-ratio: 4 / 5;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

.memory-card:disabled {
  cursor: default;
}

.memory-card:focus-visible .memory-card-inner {
  box-shadow: 0 0 0 4px rgba(94, 28, 153, 0.2);
}

.memory-card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 220ms ease;
}

.memory-card.is-flipped .memory-card-inner,
.memory-card.is-matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-face {
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid rgba(94, 28, 153, 0.12);
  box-shadow: 0 10px 22px rgba(94, 28, 153, 0.09);
  background: #ffffff;
}

.memory-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.memory-face--front {
  transform: rotateY(180deg);
}

.memory-face--back {
  transform: rotateY(0deg);
}

.memory-card.is-matched {
  opacity: 0.94;
}

.controls {
  padding: 18px 20px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.primary-button,
.secondary-link,
.size-option {
  border: 1px solid rgba(94, 28, 153, 0.18);
  background: linear-gradient(180deg, #fff 0%, rgba(248, 241, 255, 0.98) 100%);
  color: var(--indigo-velvet);
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(94, 28, 153, 0.08);
}

.primary-button,
.secondary-link {
  min-height: 48px;
  padding: 12px 18px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.primary-button:hover,
.secondary-link:hover,
.size-option:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-link:active,
.size-option:active {
  transform: translateY(0);
}

.intake-page {
  min-height: 100vh;
}

.intake-shell {
  min-height: calc(100vh - 52px);
  align-content: center;
}

.intake-hero {
  justify-content: flex-start;
}

.intake-panel {
  padding: clamp(22px, 4vw, 40px);
  display: grid;
  gap: clamp(20px, 4vw, 34px);
}

.size-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.size-option {
  min-height: 148px;
  padding: 24px;
  display: grid;
  place-items: center;
  gap: 8px;
}

.size-option span {
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
}

.size-option strong {
  color: var(--dim-grey);
  font-size: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .size-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1200px);
    margin: 12px auto 20px;
    gap: 14px;
  }

  .hero {
    padding: 18px;
  }

  h1 {
    font-size: clamp(2.35rem, 15vw, 4rem);
  }

  .board-panel {
    padding: 14px;
  }

  .game-board {
    gap: 8px;
  }

  .controls {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .primary-button,
  .secondary-link {
    justify-content: center;
    flex: 1 1 180px;
  }
}
