:root {
  --ink: #214f4a;
  --muted: #6f8580;
  --paper: #fffdf7;
  --line: #ded3b5;
  --green: #4da581;
  --green-dark: #27765e;
  --yellow: #f6c95d;
  --coral: #e47765;
  --blue: #4a9aae;
  --violet: #8d72bd;
  --shadow: 0 11px 0 rgba(111, 92, 46, 0.14);
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: clip;
  scrollbar-gutter: stable;
  background: #f6f9ee;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 7%, rgba(255, 218, 136, 0.3), transparent 25rem),
    radial-gradient(circle at 90% 12%, rgba(151, 220, 211, 0.28), transparent 29rem),
    linear-gradient(135deg, #fff9ed 0%, #f2faee 100%);
}

button {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 4px solid rgba(246, 201, 93, 0.85);
  outline-offset: 4px;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 48px;
}

.loading-card {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 3px solid var(--line);
  border-radius: 34px;
  background: var(--paper);
}

.loading-card span {
  font-size: 56px;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.brand-button,
.sound-button,
.plain-button {
  border: 0;
  cursor: pointer;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  background: transparent;
  text-align: left;
}

.brand-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 3px solid #c2dfd7;
  border-radius: 18px;
  background: white;
  box-shadow: 0 5px 0 rgba(48, 104, 88, 0.12);
  font-size: 28px;
}

.brand-button > span:last-child {
  display: grid;
  gap: 2px;
}

.brand-button strong {
  font-size: 22px;
  line-height: 1;
}

.brand-button small {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sound-button {
  min-height: 48px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.92);
  font-weight: 800;
}

.hero,
.play-shell,
.result-shell,
.album-shell {
  width: 100%;
  min-width: 0;
  border: 3px solid var(--line);
  border-radius: 36px;
  background: var(--paper);
  box-shadow: 0 22px 38px rgba(42, 74, 59, 0.11);
}

.hero {
  min-height: 470px;
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(390px, 0.98fr);
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px 46px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #3d826f;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.play-heading h1,
.result-copy h1,
.album-heading h1 {
  margin-bottom: 16px;
  color: var(--ink);
  font-size: clamp(42px, 5.5vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero-copy > p {
  max-width: 560px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.5;
}

.hero-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  min-height: 50px;
  padding: 12px 22px;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 900;
}

.button-primary {
  color: white;
  background: var(--green);
  box-shadow: 0 7px 0 var(--green-dark);
}

.button-primary:hover {
  background: #58ae8b;
}

.button-primary:active {
  box-shadow: 0 3px 0 var(--green-dark);
  transform: translateY(4px);
}

.button-soft {
  border-color: #c6dfd6;
  background: #edf7ef;
}

.button-outline {
  border-color: var(--line);
  background: var(--paper);
}

.hero-stage {
  position: relative;
  min-height: 470px;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 22%, #ffe596 0 48px, transparent 50px),
    linear-gradient(#bce5e7 0 48%, #a6d090 48% 100%);
}

.hero-stage::before,
.hero-stage::after {
  content: "";
  position: absolute;
  border-radius: 999px 999px 0 0;
  background: #8abe7c;
}

.hero-stage::before {
  width: 520px;
  height: 190px;
  left: -160px;
  bottom: 0;
  transform: rotate(8deg);
}

.hero-stage::after {
  width: 470px;
  height: 170px;
  right: -170px;
  bottom: 0;
  transform: rotate(-8deg);
}

.toy-shelf {
  position: absolute;
  z-index: 2;
  inset: 50% 24px auto;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
  padding: 18px 18px 34px;
  border-bottom: 16px solid #a86f43;
}

.toy-shelf span {
  width: 31%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 5px solid rgba(255, 255, 255, 0.94);
  border-radius: 28px;
  background: rgba(255, 249, 225, 0.82);
  box-shadow: 0 11px 18px rgba(45, 75, 57, 0.14);
}

.toy-shelf img {
  width: 94%;
  height: 94%;
  object-fit: contain;
}

.pair-ribbon {
  position: absolute;
  z-index: 3;
  top: 42px;
  left: 50%;
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border: 7px solid white;
  border-radius: 50%;
  color: white;
  background: var(--coral);
  box-shadow: 0 10px 18px rgba(78, 61, 36, 0.16);
  font-size: 48px;
  font-weight: 900;
  transform: translateX(-50%);
}

.route-section {
  padding-top: 52px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -0.035em;
}

.section-heading > p {
  max-width: 370px;
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
  text-align: right;
}

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

.route-card {
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.route-preview {
  position: relative;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px;
  background: color-mix(in srgb, var(--route) 18%, #fff8e8);
}

.route-preview span {
  width: 108px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 -11px;
  border: 5px solid white;
  border-radius: 24px;
  background: #fffaf0;
  box-shadow: 0 8px 16px rgba(57, 76, 58, 0.13);
  transform: rotate(calc((var(--i) - 1) * 7deg));
}

.route-preview img {
  width: 95%;
  height: 95%;
  object-fit: contain;
}

.route-preview b {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 7px 10px;
  border-radius: 11px;
  color: white;
  background: var(--route);
  font-size: 13px;
}

.route-copy {
  padding: 24px;
}

.route-copy h3 {
  margin-bottom: 10px;
  font-size: 27px;
  line-height: 1.1;
}

.route-copy p {
  min-height: 68px;
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.route-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: #667b76;
  font-size: 14px;
  font-weight: 800;
}

.album-callout {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  margin-top: 28px;
  padding: 24px 28px;
  border: 2px solid #cbded5;
  border-radius: 28px;
  background: #f1f8ef;
}

.album-stack {
  display: flex;
  width: 150px;
}

.album-stack span {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin-right: -16px;
  border: 4px solid white;
  border-radius: 19px;
  background: #fff8dc;
}

.album-stack img {
  width: 94%;
  height: 94%;
  object-fit: contain;
}

.album-callout h2 {
  margin-bottom: 6px;
  font-size: 28px;
}

.album-callout p {
  margin-bottom: 0;
  color: var(--muted);
}

.play-shell {
  padding: 30px;
}

.play-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px;
}

.play-heading h1 {
  margin-bottom: 6px;
  font-size: clamp(38px, 5vw, 58px);
}

.progress-summary {
  min-width: 170px;
  display: grid;
  gap: 7px;
  padding-bottom: 8px;
}

.progress-summary span {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6e2d7;
}

.progress-summary i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--route);
  transition: width 0.25s ease;
}

.progress-summary b {
  text-align: right;
}

.instruction-strip {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0 22px;
  padding: 14px 18px;
  border: 2px solid #edd185;
  border-radius: 20px;
  background: #fff5d7;
  font-weight: 900;
}

.instruction-strip span:last-child {
  color: #547873;
}

.memory-board {
  --columns: 6;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 14px;
  padding: 22px;
  border: 2px solid #d4ded4;
  border-radius: 26px;
  background:
    radial-gradient(circle at 10px 10px, rgba(73, 133, 111, 0.09) 0 2px, transparent 2.5px) 0 0 / 26px 26px,
    #f2f7ed;
}

.memory-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.82;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

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

.card-inner {
  position: absolute;
  inset: 0;
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.38s ease;
}

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

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid #d6cba9;
  border-radius: 20px;
  backface-visibility: hidden;
  box-shadow: 0 7px 0 rgba(107, 94, 57, 0.14);
}

.card-back {
  align-content: center;
  gap: 8px;
  color: white;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.19) 0 4px, transparent 5px) 0 0 / 28px 28px,
    var(--route);
}

.card-back span {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.88);
  border-radius: 17px;
  font-size: 30px;
}

.card-back small {
  font-weight: 900;
  letter-spacing: 0.1em;
}

.card-front {
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 8px 8px 12px;
  background: #fffaf0;
  transform: rotateY(180deg);
}

.card-front img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.card-front strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-card.is-first .card-front {
  border-color: var(--yellow);
  box-shadow: 0 0 0 5px rgba(246, 201, 93, 0.23), 0 7px 0 rgba(107, 94, 57, 0.14);
}

.memory-card.is-matched .card-front {
  border-color: var(--green);
  background: #eaf7ed;
}

.memory-card.is-matched::after {
  content: "✓";
  position: absolute;
  z-index: 3;
  top: -8px;
  right: -8px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 4px solid white;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-weight: 900;
}

.memory-card.is-hint .card-front {
  border-color: var(--yellow);
  box-shadow: 0 0 0 7px rgba(246, 201, 93, 0.28), 0 7px 0 rgba(107, 94, 57, 0.14);
}

.feedback {
  min-height: 88px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 18px;
  border: 2px solid #d2ded5;
  border-radius: 22px;
  background: #f3f7f1;
}

.feedback > span {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: #72968e;
  font-size: 25px;
  font-weight: 900;
}

.feedback p {
  margin-bottom: 0;
  font-weight: 800;
  line-height: 1.4;
}

.feedback-success,
.feedback-complete {
  border-color: #7ab999;
  background: #e9f7ed;
}

.feedback-success > span,
.feedback-complete > span {
  background: var(--green);
}

.feedback-try {
  border-color: #e99b91;
  background: #fff0ed;
}

.feedback-try > span {
  background: var(--coral);
}

.game-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.plain-button {
  min-height: 48px;
  padding: 11px 17px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  font-weight: 900;
}

.plain-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.preview-cover {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 63, 57, 0.72);
}

.preview-card {
  max-width: 500px;
  padding: 34px;
  border: 5px solid white;
  border-radius: 30px;
  background: #fffdf7;
  box-shadow: 0 20px 50px rgba(13, 41, 35, 0.25);
  text-align: center;
}

.preview-card span {
  font-size: 50px;
}

.preview-card h2 {
  margin: 12px 0 8px;
  font-size: 34px;
}

.preview-card p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.result-shell {
  min-height: 600px;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(390px, 1.12fr);
  overflow: hidden;
}

.result-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.result-copy > p {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.5;
}

.stars {
  display: flex;
  gap: 7px;
  margin: 4px 0 24px;
  color: #dfdbce;
  font-size: 46px;
}

.stars .filled {
  color: #efb638;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.stats span {
  display: grid;
  gap: 3px;
  padding: 14px 8px;
  border: 2px solid #d4e1d7;
  border-radius: 17px;
  background: #eff7ee;
  text-align: center;
}

.stats b {
  font-size: 27px;
}

.stats small {
  color: var(--muted);
  font-weight: 800;
}

.result-display {
  position: relative;
  display: grid;
  place-items: center;
  padding: 40px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.85) 0 150px, transparent 152px),
    linear-gradient(145deg, #d9f0e6, #fff0cf);
}

.result-toys {
  display: grid;
  grid-template-columns: repeat(3, 118px);
  gap: 12px;
}

.result-toys span {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 5px solid white;
  border-radius: 25px;
  background: #fffaf0;
  box-shadow: 0 9px 16px rgba(61, 83, 62, 0.13);
}

.result-toys img {
  width: 96%;
  height: 96%;
  object-fit: contain;
}

.album-shell {
  padding: 34px;
}

.album-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.album-heading h1 {
  margin-bottom: 5px;
}

.album-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.collection-card {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 170px;
  padding: 10px;
  border: 2px solid #d4decf;
  border-radius: 20px;
  background: #fffaf0;
}

.collection-card img {
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.collection-card strong {
  overflow: hidden;
  padding: 8px 4px 4px;
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-card.is-locked {
  place-items: center;
  grid-template-rows: 1fr;
  color: #9aa39c;
  background: #f0f0e8;
}

.collection-card.is-locked span {
  font-size: 42px;
  font-weight: 900;
}

.reset-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

@media (max-width: 940px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-stage {
    min-height: 390px;
  }

  .route-grid {
    grid-template-columns: 1fr;
  }

  .route-card {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) 1fr;
  }

  .route-copy p {
    min-height: 0;
  }

  .result-shell {
    grid-template-columns: 1fr;
  }

  .result-display {
    min-height: 430px;
    order: -1;
  }

  .collection-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .sound-button {
    width: 50px;
    padding: 0;
    font-size: 0;
  }

  .sound-button span {
    font-size: 20px;
  }

  .hero-copy,
  .result-copy {
    padding: 36px 28px;
  }

  .section-heading,
  .album-heading {
    align-items: start;
    flex-direction: column;
  }

  .section-heading > p {
    text-align: left;
  }

  .route-card {
    display: block;
  }

  .album-callout {
    grid-template-columns: 1fr;
  }

  .play-shell,
  .album-shell {
    padding: 20px;
    border-radius: 28px;
  }

  .play-heading {
    grid-template-columns: 1fr;
  }

  .progress-summary {
    width: 100%;
  }

  .instruction-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .memory-board {
    --columns: 4 !important;
    gap: 10px;
    padding: 14px;
  }

  .card-front strong {
    font-size: 11px;
  }

  .feedback {
    grid-template-columns: auto 1fr;
  }

  .feedback .button {
    grid-column: 1 / -1;
  }

  .game-actions {
    flex-wrap: wrap;
  }

  .collection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .brand-button strong {
    font-size: 18px;
  }

  .brand-button small {
    font-size: 11px;
  }

  .brand-icon {
    width: 48px;
    height: 48px;
  }

  .hero h1,
  .play-heading h1,
  .result-copy h1,
  .album-heading h1 {
    font-size: 38px;
  }

  .hero-stage {
    min-height: 330px;
  }

  .toy-shelf {
    inset-inline: 10px;
  }

  .pair-ribbon {
    width: 88px;
    height: 88px;
    font-size: 38px;
  }

  .route-section {
    padding-top: 38px;
  }

  .route-preview {
    min-height: 170px;
  }

  .route-preview span {
    width: 94px;
  }

  .album-stack {
    width: 130px;
  }

  .memory-board {
    --columns: 3 !important;
    gap: 8px;
    padding: 10px;
  }

  .card-face {
    border-radius: 15px;
  }

  .card-front {
    padding: 5px 5px 8px;
  }

  .feedback {
    padding: 13px;
  }

  .feedback > span {
    width: 44px;
    height: 44px;
  }

  .result-display {
    min-height: 340px;
    padding: 24px;
  }

  .result-toys {
    grid-template-columns: repeat(3, minmax(0, 92px));
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .collection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
