:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  --ink: #244e49;
  --muted: #71827e;
  --paper: #fffdf7;
  --line: #ddd3b8;
  --green: #4d9f79;
  --green-dark: #2f7156;
  --gold: #efb63d;
  --coral: #e87963;
  --red: #d86b62;
  --blue: #5a9dbc;
  --shadow: 0 20px 46px rgba(52, 72, 66, .15);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #f4f2e7; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 10%, rgba(239, 182, 61, .17) 0 145px, transparent 148px),
    radial-gradient(circle at 94% 14%, rgba(90, 157, 188, .14) 0 190px, transparent 193px),
    linear-gradient(145deg, #f4f8ec, #fff9ed 55%, #eef5f3);
}

.page-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .2;
  background-image: radial-gradient(circle, rgba(69, 104, 91, .22) 1.2px, transparent 1.5px);
  background-size: 37px 37px;
  pointer-events: none;
}

button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid rgba(239, 182, 61, .85); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }

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

.topbar,
.brand,
.topbar-actions,
.hero-actions,
.section-heading,
.progress-heading,
.feedback-card,
.result-actions,
.collection-heading {
  display: flex;
  align-items: center;
}

.topbar {
  min-height: 68px;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  gap: 12px;
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  font-size: 28px;
  background: #fff0c9;
  border: 3px solid #dec896;
  border-radius: 19px;
  box-shadow: 0 8px 17px rgba(58, 79, 70, .13);
  rotate: -3deg;
}

.brand strong,
.brand small { display: block; }
.brand strong { font-size: 23px; font-weight: 900; }
.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.topbar-actions { gap: 9px; }
.sound-button,
.collection-button,
.back-button,
.secondary-button {
  min-height: 49px;
  color: var(--ink);
  font-weight: 900;
  background: rgba(255, 253, 247, .95);
  border: 2px solid var(--line);
  border-radius: 17px;
}

.sound-button,
.collection-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  font-size: 13px;
}

.collection-button b { color: var(--green-dark); }
.back-button { width: 49px; padding: 0; font-size: 22px; }
.secondary-button { padding: 0 18px; }
.sound-button:hover,
.collection-button:hover,
.back-button:hover,
.secondary-button:hover:not(:disabled) { border-color: #79aa91; background: #fff; }

.primary-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 22px;
  color: white;
  font-weight: 900;
  background: var(--green);
  border: 0;
  border-radius: 17px;
  box-shadow: 0 8px 0 var(--green-dark);
}

.primary-button:hover { background: #438f6c; }
.primary-button:active,
.secondary-button:active { translate: 0 2px; }
.primary-button.compact {
  min-height: 46px;
  margin-left: auto;
  padding-inline: 18px;
  box-shadow: 0 5px 0 var(--green-dark);
}

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

.hero {
  display: grid;
  min-height: 520px;
  align-items: center;
  grid-template-columns: .93fr 1.07fr;
  gap: 44px;
  padding: clamp(34px, 5vw, 62px);
  overflow: hidden;
  background: rgba(255, 253, 247, .97);
  border: 3px solid var(--line);
  border-radius: 46px;
  box-shadow: var(--shadow);
}

.hero-copy h1 {
  max-width: 590px;
  margin-bottom: 18px;
  font-size: clamp(48px, 6.2vw, 76px);
  line-height: .99;
  letter-spacing: -.045em;
}

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

.hero-actions { flex-wrap: wrap; gap: 13px; }
.hero-progress {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  padding: 0 18px;
  color: var(--ink);
  font-weight: 900;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 17px;
}

.hero-picture {
  position: relative;
  margin: 0;
}

.hero-picture img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 10px solid white;
  border-radius: 36px;
  box-shadow: 0 24px 36px rgba(45, 69, 60, .2);
}

.hero-picture::after {
  position: absolute;
  right: -16px;
  bottom: -17px;
  display: grid;
  width: 79px;
  aspect-ratio: 1;
  place-items: center;
  content: "⌨";
  color: white;
  font-size: 35px;
  background: var(--coral);
  border: 7px solid #fff7e9;
  border-radius: 50%;
  box-shadow: 0 10px 18px rgba(55, 75, 66, .2);
}

.routes-section { margin-top: 54px; }
.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(34px, 4vw, 50px);
  line-height: 1.02;
}
.section-heading > p {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.4;
  text-align: right;
}

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

.route-card {
  display: flex;
  min-height: 302px;
  flex-direction: column;
  align-items: stretch;
  padding: 25px;
  text-align: left;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 31px;
  box-shadow: 0 12px 0 rgba(205, 195, 161, .65);
}

.route-card:nth-child(1) { background: linear-gradient(145deg, #eff7ed, #fffdf7 62%); }
.route-card:nth-child(2) { background: linear-gradient(145deg, #eef6fa, #fffdf7 62%); }
.route-card:nth-child(3) { background: linear-gradient(145deg, #fff3e7, #fffdf7 62%); }
.route-card:hover { border-color: #92b8a0; }
.route-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 30px;
  place-items: center;
  color: var(--green-dark);
  font-size: 25px;
  background: white;
  border: 2px solid #dce7dc;
  border-radius: 18px;
}
.route-card small {
  color: #927148;
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.route-card h3 { margin: 8px 0 11px; font-size: 28px; line-height: 1.05; }
.route-card p { margin-bottom: 22px; color: var(--muted); font-weight: 700; line-height: 1.45; }
.route-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 17px;
  border-top: 1px dashed #d8cfb8;
}
.route-card footer b { color: var(--green-dark); }
.route-stars { color: var(--gold); letter-spacing: .08em; }

.game-shell,
.result-card,
.collection-shell {
  padding: clamp(25px, 4vw, 45px);
  background: rgba(255, 253, 247, .97);
  border: 3px solid var(--line);
  border-radius: 43px;
  box-shadow: var(--shadow);
}

.progress-heading {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 25px;
}
.progress-heading h1 { margin-bottom: 7px; font-size: clamp(34px, 4.5vw, 57px); line-height: 1.04; }
.progress-heading p:not(.eyebrow) { margin: 0; color: var(--muted); font-weight: 800; }
.progress-box {
  display: grid;
  min-width: 116px;
  min-height: 90px;
  place-items: center;
  align-content: center;
  background: #eef5ea;
  border: 3px solid #c9ddce;
  border-radius: 25px;
}
.progress-box b { font-size: 30px; }
.progress-box small { color: var(--muted); font-weight: 900; }

.play-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  align-items: stretch;
}

.mission-card {
  display: flex;
  min-height: 375px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 29px;
  text-align: center;
  background: linear-gradient(155deg, #fff1cf, #fffaf0);
  border: 3px solid #e2cf9f;
  border-radius: 32px;
}
.mission-card > span {
  display: grid;
  width: 142px;
  aspect-ratio: 1;
  margin: 8px auto 25px;
  place-items: center;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 88px;
  font-weight: 900;
  background: white;
  border: 5px solid var(--gold);
  border-radius: 35px;
  box-shadow: 0 11px 0 rgba(208, 161, 50, .28);
}
.mission-card h2 { margin-bottom: 11px; font-size: 27px; line-height: 1.15; }
.mission-card p { margin: 0; color: var(--muted); font-weight: 700; line-height: 1.45; }

.keyboard-panel {
  padding: clamp(18px, 3vw, 31px);
  background: #edf5ef;
  border: 3px solid #c8dccf;
  border-radius: 32px;
}
.keyboard-instruction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.keyboard-instruction strong { display: block; font-size: 21px; }
.keyboard-instruction small { display: block; margin-top: 5px; color: var(--muted); font-weight: 800; }
.keyboard-live {
  flex: none;
  padding: 8px 12px;
  color: #3d745e;
  font-size: 12px;
  font-weight: 900;
  background: #fff;
  border: 2px solid #c9d9ce;
  border-radius: 13px;
}

.keyboard {
  display: grid;
  gap: 9px;
  padding: 18px;
  background: #285b4b;
  border: 5px solid #204c3f;
  border-radius: 25px;
  box-shadow: inset 0 -5px 0 rgba(10, 44, 34, .25), 0 12px 20px rgba(35, 70, 57, .2);
}
.keyboard-row {
  display: grid;
  grid-template-columns: repeat(var(--keys), minmax(0, 1fr));
  gap: 7px;
}
.keyboard-row.is-single {
  width: 8%;
  min-width: 48px;
}
.key {
  display: grid;
  min-width: 0;
  min-height: 55px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  font-size: clamp(15px, 2vw, 25px);
  font-weight: 900;
  background: #fffaf0;
  border: 2px solid #d9cfae;
  border-radius: 12px;
  box-shadow: 0 5px 0 #b9aa7b;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.key:hover:not(:disabled) { background: #fff2c9; border-color: #e4b949; }
.key:active:not(:disabled) { box-shadow: 0 2px 0 #b9aa7b; translate: 0 3px; }
.key.is-target {
  color: #214a40;
  background: #ffe47f;
  border-color: #f3b928;
  box-shadow: 0 0 0 5px rgba(255, 216, 87, .42), 0 5px 0 #bf8d22;
  animation: key-glow 1.25s ease-in-out infinite alternate;
}
.key.is-wrong { color: #8b302b; background: #ffe7e2; border-color: #df756a; box-shadow: 0 5px 0 #b85a52; }
.key.is-correct { color: #215d43; background: #dff3e3; border-color: #6eaf89; box-shadow: 0 5px 0 #4f886b; }
.key:disabled { opacity: 1; }
@keyframes key-glow {
  from { background: #ffe47f; box-shadow: 0 0 0 4px rgba(255, 216, 87, .35), 0 5px 0 #bf8d22; }
  to { background: #fff0a8; box-shadow: 0 0 0 8px rgba(255, 216, 87, .2), 0 5px 0 #bf8d22; }
}
@media (prefers-reduced-motion: reduce) {
  .key.is-target { animation: none; }
}

.game-controls {
  display: flex;
  justify-content: space-between;
  gap: 13px;
  margin-top: 20px;
}

.feedback-card {
  min-height: 118px;
  gap: 18px;
  margin-top: 22px;
  padding: 20px 23px;
  background: #f3f5ef;
  border: 3px solid #d7e0d6;
  border-radius: 27px;
}
.feedback-card > span {
  display: grid;
  width: 59px;
  aspect-ratio: 1;
  flex: none;
  place-items: center;
  font-size: 28px;
  background: white;
  border-radius: 18px;
}
.feedback-card p { margin: 0; }
.feedback-card strong,
.feedback-card small { display: block; }
.feedback-card strong { margin-bottom: 6px; font-size: 20px; }
.feedback-card small { color: var(--muted); font-size: 15px; font-weight: 800; line-height: 1.42; }
.feedback-card[data-kind="success"] { background: #eaf7ed; border-color: #8fbea0; }
.feedback-card[data-kind="error"] { background: #fff0ed; border-color: #df9991; }
.feedback-card[data-kind="hint"] { background: #fff7db; border-color: #e6c66d; }

.result-card { max-width: 920px; margin: 0 auto; padding: clamp(42px, 7vw, 82px); text-align: center; }
.result-stamp {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 27px;
  padding: 15px 25px;
  color: white;
  font-weight: 900;
  letter-spacing: .12em;
  background: #2f6770;
  border-radius: 18px;
}
.result-stamp span { font-size: 30px; }
.result-card h1 { margin-bottom: 15px; font-size: clamp(44px, 6vw, 72px); line-height: 1; }
.result-card > p:not(.eyebrow) { max-width: 690px; margin: 0 auto 24px; color: var(--muted); font-size: 18px; font-weight: 800; line-height: 1.5; }
.stars { margin: 18px 0 26px; color: #d8d2c0; font-size: 49px; letter-spacing: .08em; }
.stars .earned { color: var(--gold); text-shadow: 0 5px 0 rgba(185, 127, 18, .18); }
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
  margin-bottom: 27px;
}
.result-stats span { padding: 18px; background: #eef5ea; border: 2px solid #cedece; border-radius: 21px; }
.result-stats b,
.result-stats small { display: block; }
.result-stats b { font-size: 29px; }
.result-stats small { margin-top: 3px; color: var(--muted); font-weight: 900; }
.result-actions { justify-content: center; flex-wrap: wrap; gap: 14px; }

.collection-heading {
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 27px;
}
.collection-heading h1 { margin-bottom: 6px; font-size: clamp(39px, 5vw, 60px); }
.collection-heading p { margin: 0; color: var(--muted); font-weight: 800; }
.collection-count {
  display: grid;
  min-width: 112px;
  min-height: 92px;
  place-items: center;
  align-content: center;
  background: #eef5ea;
  border: 3px solid #c9ddce;
  border-radius: 25px;
}
.collection-count b { font-size: 30px; }
.collection-count small { color: var(--muted); font-weight: 900; }
.letter-collection {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 10px;
}
.letter-card {
  display: grid;
  min-width: 0;
  aspect-ratio: .85;
  place-items: center;
  align-content: center;
  background: #fff7de;
  border: 2px solid #e2d2a5;
  border-radius: 18px;
}
.letter-card strong { font-family: Georgia, serif; font-size: clamp(23px, 3vw, 35px); }
.letter-card small { margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 900; text-align: center; }
.letter-card.is-locked { color: #a5aca7; background: #f0f1eb; border-color: #d9ddd5; }
.letter-card.is-locked strong { font-family: inherit; }
.collection-actions { display: flex; justify-content: space-between; gap: 14px; margin-top: 27px; }
.reset-button {
  min-height: 49px;
  padding: 0 18px;
  color: #92504a;
  font-weight: 900;
  background: #fff7f5;
  border: 2px solid #e5b3ad;
  border-radius: 17px;
}

.qa-report {
  max-width: 850px;
  margin: 30px auto;
  padding: 38px;
  background: var(--paper);
  border: 3px solid #8dbb9c;
  border-radius: 34px;
  box-shadow: var(--shadow);
}
.qa-report.has-failures { border-color: #db8a81; }
.qa-report h1 { font-size: 43px; }
.qa-summary { color: var(--muted); font-weight: 900; }
.qa-report ul { display: grid; gap: 9px; margin: 25px 0; padding: 0; list-style: none; }
.qa-report li { display: grid; grid-template-columns: 32px 1fr; gap: 4px 10px; padding: 13px; background: #eef7ed; border-radius: 14px; }
.qa-report li.fail { background: #fff0ed; }
.qa-report li span { grid-row: span 2; font-size: 21px; font-weight: 900; }
.qa-report li small { color: var(--muted); }
.qa-actions { display: flex; flex-wrap: wrap; gap: 12px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-picture { max-width: 650px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 225px; }
  .route-icon { margin-bottom: 18px; }
  .play-layout { grid-template-columns: 1fr; }
  .mission-card { min-height: auto; flex-direction: row; gap: 23px; text-align: left; }
  .mission-card > span { width: 105px; flex: none; margin: 0; font-size: 62px; }
  .letter-collection { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 680px) {
  .app { width: min(100% - 20px, 1120px); padding-top: 10px; }
  .topbar { align-items: flex-start; }
  .brand-mark { width: 49px; height: 49px; font-size: 23px; }
  .brand strong { max-width: 180px; font-size: 17px; }
  .brand small { font-size: 9px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .sound-button { width: 49px; padding: 0; }
  .sound-button span:last-child { display: none; }
  .collection-button { min-height: 47px; padding-inline: 12px; }
  .hero { min-height: 0; gap: 32px; padding: 29px 21px 36px; border-radius: 33px; }
  .hero-copy h1 { font-size: clamp(42px, 13vw, 60px); }
  .hero-copy > p:not(.eyebrow) { font-size: 16px; }
  .hero-picture img { border-width: 7px; border-radius: 26px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .routes-section { margin-top: 40px; }
  .game-shell,
  .result-card,
  .collection-shell { padding: 21px 15px; border-radius: 29px; }
  .progress-heading { align-items: flex-start; }
  .progress-box { min-width: 80px; min-height: 72px; }
  .progress-box b { font-size: 23px; }
  .mission-card { padding: 18px; }
  .mission-card > span { width: 82px; font-size: 48px; border-radius: 23px; }
  .mission-card h2 { font-size: 21px; }
  .keyboard-panel { padding: 13px 8px 16px; border-radius: 24px; }
  .keyboard-instruction { align-items: flex-start; flex-direction: column; gap: 9px; padding-inline: 6px; }
  .keyboard { gap: 6px; padding: 10px 7px 13px; border-width: 4px; border-radius: 18px; }
  .keyboard-row { gap: 4px; }
  .keyboard-row.is-single { min-width: 31px; }
  .key { min-height: 43px; font-size: clamp(11px, 4.3vw, 18px); border-width: 1px; border-radius: 8px; box-shadow: 0 4px 0 #b9aa7b; }
  .game-controls { flex-direction: column-reverse; }
  .game-controls button { width: 100%; }
  .feedback-card { min-height: 150px; align-items: flex-start; flex-wrap: wrap; padding: 17px; }
  .feedback-card .primary-button { width: 100%; margin-left: 0; }
  .result-stats { grid-template-columns: 1fr; }
  .collection-heading { align-items: flex-start; }
  .letter-collection { grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .collection-actions { flex-direction: column; }
  .collection-actions button { width: 100%; }
}

@media (max-width: 410px) {
  .brand small { display: none; }
  .collection-button span:first-child { display: none; }
  .hero-copy h1 { font-size: 42px; }
  .hero-actions > * { width: 100%; }
  .route-card { padding: 21px; }
  .progress-heading h1 { font-size: 31px; }
  .mission-card { align-items: center; flex-direction: column; text-align: center; }
  .keyboard-live { font-size: 10px; }
  .feedback-card > span { width: 49px; }
  .letter-collection { grid-template-columns: repeat(4, 1fr); }
}
