:root {
  --ink: #174e47;
  --muted: #6f8580;
  --paper: #fffdf7;
  --cream: #fff8e9;
  --line: #ded4b5;
  --green: #49a17d;
  --green-dark: #21725c;
  --coral: #e67262;
  --yellow: #f4c75a;
  --shadow: 0 12px 0 rgba(109, 91, 47, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 214, 116, 0.22), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(119, 200, 177, 0.19), transparent 30%),
    #f5f7eb;
  font-family: "Trebuchet MS", Arial, sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 4px solid rgba(62, 143, 116, 0.34);
  outline-offset: 3px;
}

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

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

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

.loading-card span {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: white;
  background: var(--green);
  font-size: 48px;
  font-weight: 900;
}

.loading-card p {
  font-weight: 900;
}

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

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

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

.brand-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 4px solid white;
  border-radius: 19px;
  color: white;
  background: var(--green);
  box-shadow: 0 5px 0 rgba(56, 92, 64, 0.16);
  font-size: 28px;
  font-weight: 900;
}

.brand-button strong,
.brand-button small {
  display: block;
}

.brand-button strong {
  font-size: 23px;
}

.brand-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sound-button,
.plain-button {
  min-height: 48px;
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 247, 0.8);
  font-weight: 900;
}

.sound-button span {
  margin-right: 7px;
}

.hero,
.play-shell,
.result-shell,
.album-shell {
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 36px;
  background: var(--paper);
  box-shadow: 0 22px 44px rgba(67, 82, 55, 0.13);
}

.hero {
  min-height: 540px;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(380px, 0.96fr);
}

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

.eyebrow {
  margin: 0 0 12px;
  color: #397e6b;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  color: var(--ink);
}

.hero h1 {
  max-width: 650px;
  margin-bottom: 22px;
  font-size: clamp(44px, 5vw, 62px);
  line-height: 0.99;
  letter-spacing: -0.045em;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 630px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.55;
}

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

.button {
  min-height: 54px;
  padding: 13px 21px;
  border: 2px solid transparent;
  border-radius: 17px;
  cursor: pointer;
  font-weight: 900;
}

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

.button-primary:hover {
  background: #55ad88;
}

.button-outline,
.button-soft {
  border-color: var(--line);
  background: #fffdf7;
}

.button-soft {
  background: #e9f5eb;
}

.hero-stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 48px 34px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.9) 0 145px, transparent 147px),
    linear-gradient(145deg, #d7f0e5, #fff0cb);
}

.hero-letter,
.hero-picture {
  aspect-ratio: 0.82;
  display: grid;
  place-items: center;
  border: 6px solid white;
  border-radius: 28px;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.hero-letter {
  position: relative;
  color: white;
  background: #e66862;
  font-family: Georgia, serif;
  font-size: 96px;
  font-weight: 900;
}

.hero-letter span {
  position: absolute;
  right: 18px;
  bottom: 14px;
  font-size: 38px;
}

.hero-picture {
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 12px;
}

.hero-picture img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hero-picture strong {
  padding: 8px;
  font-size: 20px;
}

.hero-link {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 34px;
  font-weight: 900;
}

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

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

.section-heading h2,
.album-heading h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 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;
  padding: 30px 16px 18px;
  background: color-mix(in srgb, var(--route) 18%, #fff8e8);
}

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

.route-preview .sample-letter {
  color: white;
  background: var(--route);
  font-family: Georgia, serif;
  font-size: 54px;
  font-weight: 900;
}

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

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

.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;
}

.route-meta .filled,
.stars .filled {
  color: #efb638;
}

.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-letters {
  display: flex;
  width: 155px;
}

.album-letters span {
  width: 66px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-right: -13px;
  border: 4px solid white;
  border-radius: 18px;
  color: white;
  background: var(--green);
  box-shadow: 0 6px 12px rgba(50, 84, 61, 0.14);
  font-family: Georgia, serif;
  font-size: 30px;
  font-weight: 900;
}

.album-letters span:nth-child(2) {
  background: #e88462;
  transform: rotate(4deg);
}

.album-letters span:nth-child(3) {
  background: #8a72ba;
  transform: rotate(-3deg);
}

.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: 180px;
  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: 13px;
  padding: 20px;
  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.83;
  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.35s 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: 7px;
  color: white;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.2) 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-family: Georgia, serif;
  font-size: 31px;
  font-weight: 900;
}

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

.card-front {
  background: #fffaf0;
  transform: rotateY(180deg);
}

.letter-face {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--pair);
  font-family: Georgia, serif;
}

.letter-face b {
  font-size: clamp(48px, 6vw, 76px);
}

.letter-face small {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 27px;
  font-weight: 900;
}

.picture-face {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 6px 6px 10px;
}

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

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

.picture-face mark {
  color: var(--coral);
  background: transparent;
}

.memory-card.is-first .card-front {
  border-color: var(--yellow);
  box-shadow: 0 0 0 5px rgba(246, 201, 93, 0.25), 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-family: Georgia, serif;
  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 {
  cursor: pointer;
}

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

.result-shell {
  min-height: 600px;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(410px, 1.08fr);
}

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

.result-copy h1 {
  margin-bottom: 18px;
  font-size: clamp(43px, 5vw, 64px);
  line-height: 1;
}

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

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

.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 {
  display: grid;
  place-items: center;
  padding: 34px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.8) 0 155px, transparent 157px),
    linear-gradient(145deg, #d9f0e6, #fff0cf);
}

.result-pairs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 120px));
  gap: 12px;
}

.result-pairs span {
  min-width: 0;
  aspect-ratio: 0.9;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 5px solid white;
  border-radius: 23px;
  background: #fffaf0;
  box-shadow: 0 9px 16px rgba(61, 83, 62, 0.13);
}

.result-pairs b {
  align-self: stretch;
  display: grid;
  place-items: center;
  color: white;
  background: var(--pair);
  font-family: Georgia, serif;
  font-size: 25px;
}

.result-pairs img {
  width: 100%;
  height: 84px;
  object-fit: contain;
}

.result-pairs small {
  grid-column: 1 / -1;
  overflow: hidden;
  padding: 6px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-shell {
  padding: 34px;
}

.album-heading p:last-child {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 900;
}

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

.collection-card {
  min-width: 0;
  min-height: 170px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 2px solid #d4decf;
  border-radius: 19px;
  background: #fffaf0;
}

.collection-card > b {
  position: relative;
  display: grid;
  place-items: center;
  color: white;
  background: var(--pair);
  font-family: Georgia, serif;
  font-size: 26px;
}

.collection-card > b small {
  position: absolute;
  right: 4px;
  bottom: 5px;
  font-size: 12px;
}

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

.collection-card strong {
  grid-column: 1 / -1;
  overflow: hidden;
  padding: 8px 5px;
  font-size: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.album-actions {
  align-items: center;
  justify-content: space-between;
  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(290px, 0.82fr) 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(5, minmax(0, 1fr));
  }
}

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

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

  .sound-button span {
    margin: 0;
    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: 9px;
    padding: 13px;
  }

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

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

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

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

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

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

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

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

  .hero-stage {
    min-height: 340px;
    gap: 8px;
    padding: 34px 14px;
  }

  .hero-letter {
    font-size: 70px;
  }

  .hero-letter span {
    font-size: 28px;
  }

  .hero-link {
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

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

  .album-letters {
    width: 140px;
  }

  .memory-board {
    --columns: 2 !important;
    gap: 11px;
    padding: 11px;
  }

  .memory-card {
    aspect-ratio: 0.9;
  }

  .letter-face b {
    font-size: 66px;
  }

  .picture-face strong {
    font-size: 13px;
  }

  .feedback {
    padding: 13px;
  }

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

  .result-display {
    min-height: 350px;
    padding: 22px;
  }

  .result-pairs {
    grid-template-columns: repeat(3, minmax(0, 90px));
    gap: 8px;
  }

  .result-pairs span {
    grid-template-columns: 28px 1fr;
    border-width: 3px;
    border-radius: 17px;
  }

  .result-pairs img {
    height: 62px;
  }

  .result-pairs small {
    font-size: 9px;
  }

  .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;
  }
}
