:root {
  color-scheme: light;
  --ink: #112f31;
  --deep: #19432e;
  --paper: #fffdf5;
  --line: #d7d3ba;
  --gold: #f8cb55;
  --accent: #155b42;
  --shadow: 0 8px 24px #132f2c14;
  font-family: "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #fff8e8; line-height: 1.55; }
a { color: #13593c; text-underline-offset: .23em; }
button, select, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #00748d; outline-offset: 4px; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: absolute; top: .5rem; left: .5rem; z-index: 10; padding: .75rem; background: white; }
.wrap { width: min(100% - 2rem, 77rem); margin-inline: auto; }
.adventure-nav { background: var(--deep); color: white; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.5rem; padding-block: .75rem; flex-wrap: wrap; }
.nav-inner a { color: inherit; text-decoration: none; font-weight: 700; }
.brand, .nav-links { display: flex; gap: .65rem; align-items: center; }
.nav-links { gap: clamp(.6rem, 2vw, 1.65rem); flex-wrap: wrap; }
.nav-links a[aria-current], .nav-links a:hover { color: #ffdd78; }
.wallet { border-radius: 2rem; padding: .25rem .55rem; background: #fadb73; color: #261c0c; white-space: nowrap; }
.wallet [aria-hidden] { color: #9a5500; }
#adventure-main { min-height: 80vh; padding-block: clamp(1rem, 3vw, 2.5rem) 3.5rem; }
h1,h2,h3,p { margin: 0 0 .65em; }
h1,h2,h3 { line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5vw, 4.6rem); letter-spacing: -.045em; }
h2 { font-size: clamp(1.45rem, 3vw, 2.2rem); }
h3 { font-size: 1.23rem; }
.eyebrow { color: var(--accent); font-weight: 900; letter-spacing: .09em; font-size: .86rem; text-transform: uppercase; }
.hero-portrait { margin: 0; display: grid; place-items: center; }
.hero-portrait img { width: min(100%, 19rem); height: auto; max-height: 23rem; object-fit: contain; filter: drop-shadow(0 10px 12px #234e3029); }
.hero-portrait.equipped img { border: 5px solid var(--accent); border-radius: 32% 32% 42% 42%; padding: .5rem; background: #fff9df38; }
.hero-portrait figcaption { color: white; background: #0a282d; border-radius: 1rem; padding: .2rem .7rem; font-size: .88rem; margin-top: .4rem; }
.pill { display: inline-block; border-radius: 99px; padding: .28rem .75rem; background: #f1eddb; color: #1a3734; font-weight: 750; font-size: .875rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.action, .dialog-actions button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: 2px solid #e8bf51; border-radius: .85rem; min-height: 2.85rem; padding: .48rem .9rem; background: #ffda73; color: #2b240d; font-weight: 850; }
.action:hover, .dialog-actions button:hover { background: #ffe69d; }
.action.secondary { background: var(--paper); border-color: #809d86; color: #143c32; }
.action:disabled { opacity: .58; cursor: default; }
.section-intro { margin-block: 1.7rem .85rem; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,15rem),1fr)); gap: 1rem; padding: 0; list-style: none; }
.field { --accent: #14583d; --tint: #edf4dd; }
.coral { --accent: #922d38; --tint: #fff0e8; }
.plum { --accent: #5a3981; --tint: #f3eaf8; }
.sun { --accent: #845000; --tint: #fff0c7; }
.world-link, .shop-item, .panel, .mission { background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.world-link { display: flex; flex-direction: column; height: 100%; overflow: hidden; text-decoration: none; color: var(--ink); border-bottom: 5px solid var(--accent); }
.world-link:hover { background: var(--tint); }
.world-link img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.world-copy, .shop-copy { padding: 1rem; }
.world-copy p:last-child, .shop-copy p:last-child { margin: 0; }
.story { display: grid; grid-template-columns: .85fr 1fr; gap: clamp(1rem, 3vw, 2.5rem); background: var(--tint); border: 1px solid var(--line); border-radius: 1.5rem; margin-block: .9rem 1.4rem; overflow: hidden; align-items: center; }
.story img { display: block; width: 100%; max-height: 29rem; aspect-ratio: 4 / 3; object-fit: cover; }
.story-text { padding: clamp(1rem, 3vw, 2rem); }
.notice { border-inline-start: 4px solid var(--accent); padding: .7rem .9rem; background: #ffffffa6; }
.mission, .panel { padding: clamp(1rem, 4vw, 2rem); }
.mission ol { padding-inline-start: 1.4rem; }
.mission li + li { margin-top: .55rem; }
.mission h3 { margin-top: 1rem; }
.mission details { margin-block: 1rem; }
.mission label { display: block; }
.mission fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .75rem; padding: .7rem; margin: .7rem 0; }
.mission legend { font-weight: 800; }
.mission fieldset p { margin: .4rem 0 0; }
.choice, .habit-button { min-height: 2.5rem; border: 1px solid #809d86; border-radius: .6rem; padding: .35rem .6rem; background: white; color: var(--ink); margin: .2rem; text-align: left; }
.choice:hover, .habit-button:hover { background: var(--tint,#e7f3e7); }
.choice[aria-pressed=true], .habit-button:disabled { color: #16492f; background: #e1f0d7; font-weight: 800; }
.mission-input { display: block; max-width: 100%; padding: .4rem; margin: .35rem 0 .8rem; border: 1px solid #879c8c; border-radius: .4rem; }
.tracker { display: grid; grid-template-columns: repeat(auto-fit,minmax(9rem,1fr)); gap: .5rem; }
.tracker-day { display: grid; border: 1px solid var(--line); padding: .5rem; border-radius: .6rem; }
.shop-item { overflow: hidden; }
.item-art { background: var(--tint); display: grid; place-items: center; height: 9.5rem; }
.item-art img { width: 100%; height: 9.5rem; object-fit: contain; padding: .6rem; }
.shop-copy .action { margin-top: .5rem; }
.panel + .panel { margin-top: 1rem; }
.review-entry { border-top: 1px solid var(--line); padding: .65rem 0; }
.toast:not(:empty) { position: fixed; z-index: 2; bottom: .7rem; right: .7rem; max-width: min(30rem,calc(100vw - 1.4rem)); border-radius: .75rem; padding: .75rem 1rem; margin: 0; background: #102f30; color: white; box-shadow: var(--shadow); }
dialog { width: min(39rem,calc(100% - 2rem)); max-height: 90vh; border: 2px solid #b0a779; color: var(--ink); background: var(--paper); border-radius: 1rem; padding: 1.4rem; }
dialog::backdrop { background: #0c2229af; }
.dialog-actions { display: flex; gap: .7rem; margin-top: 1.1rem; }
#print-sheet article { border: 1px solid var(--line); padding: .75rem; margin: .5rem 0; break-inside: avoid; }
@media (max-width: 720px) {
  .story { grid-template-columns: minmax(0, 1fr); }
  .story img { max-height: 19rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .brand img { animation: spin 12s linear infinite; }
  .hero-portrait img { animation: arrive .7s ease-out both; }
  @keyframes spin { to { transform: rotate(1turn); } }
  @keyframes arrive { from { transform: translateY(1.2rem) scale(.92); opacity: 0; } }
}
@media print {
  body:has(dialog[open]) > :not(dialog) { display: none; }
  dialog[open] { position: static; width: 100%; max-height: none; overflow: visible; border: 0; padding: 0; }
  dialog::backdrop, .dialog-actions, .adventure-nav, .toast { display: none; }
  body { background: white; }
}
@media print { .certificate-input { display: none; } }
.mission-art { display: block; width: min(100%, 22rem); max-height: 13rem; object-fit: contain; object-position: left center; margin-top: 1rem; border-radius: .75rem; }
.story img, .world-link img { object-position: center top; }

@font-face {
  font-family: "Patrick Hand";
  src: url("assets/fonts/patrick-hand.woff2") format("woff2");
  font-display: swap;
}

.quest-hero,
.quest-mission,
.quest-progress {
  border: 1px solid #cdd9b8;
  border-radius: 1.45rem;
  overflow: hidden;
}

.quest-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr);
  align-items: center;
  gap: 1rem;
  padding: clamp(1.2rem, 4vw, 3.25rem);
  color: #19432e;
  background: #e7efd4 url("assets/brain-story/picture-book-meadow.webp") center bottom / cover;
}

.quest-hero h1,
.quest-roadmap h2 {
  font-family: "Patrick Hand", system-ui, sans-serif;
}

.quest-hero h1 {
  max-width: 16ch;
  font-size: clamp(2.55rem, 6vw, 5.5rem);
  line-height: .95;
  letter-spacing: -.015em;
  margin-bottom: .35em;
}

.quest-hero-copy > p { max-width: 36ch; }
.quest-greeting { font-weight: 850; color: #78431b; }
.quest-entry-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .85rem; }
.quest-progress a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .38rem .75rem;
  border: 1px solid #9cb592;
  border-radius: 999px;
  background: #fffdf2;
  font-weight: 750;
  text-decoration: none;
}
.quest-progress a:hover { background: #eaf2d9; }

.quest-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 1rem;
  margin-block: 1rem 1.9rem;
}

.quest-mission {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1fr);
  align-items: stretch;
  background: #f1f5de;
}

.quest-mission > img { width: 100%; height: 100%; min-height: 11rem; object-fit: cover; }
.quest-mission-copy, .quest-progress { padding: clamp(1rem, 2.4vw, 1.6rem); }
.quest-mission h2, .quest-progress h2 { font-size: clamp(1.35rem, 2.3vw, 1.85rem); }
.quest-mission .eyebrow { margin-bottom: .35rem; }
.quest-mission .action { margin-top: .2rem; }
.quest-progress { background: #fffdf4; }
.quest-progress-label { color: #214d34; }
.quest-progress progress { display: block; width: 100%; height: .85rem; margin: .45rem 0 .95rem; accent-color: #297248; }
.quest-coins { display: flex; align-items: center; gap: .55rem; margin-bottom: .3rem; }
.quest-coin { display: grid; place-items: center; border-radius: 50%; width: 1.65rem; height: 1.65rem; background: #fad77c; color: #704215; }
.quest-progress a { margin: .22rem .35rem .05rem 0; }

.quest-roadmap h2 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: .35em; color: #19432e; }
.quest-chapters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.quest-chapter {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #0002;
  border-top: .27rem solid var(--accent);
  border-radius: 1.1rem;
  background: var(--tint);
}

.quest-chapter > img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.quest-chapter-copy { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: .85rem 1rem 1rem; }
.quest-week { margin-bottom: .3rem; color: var(--accent); font-size: .9rem; font-weight: 850; }
.quest-chapter h3 { margin-bottom: .65rem; }
.quest-chapter :is(.action, .quest-status) { margin-top: auto; }
.quest-status { font-size: .9rem; font-weight: 750; color: var(--accent); }

@media (max-width: 940px) {
  .quest-chapters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .quest-overview { grid-template-columns: minmax(0, 1fr); }
  .quest-hero { grid-template-columns: minmax(0, 1fr) minmax(0, .42fr); }
  .quest-hero h1 { font-size: clamp(2.15rem, 7.5vw, 3.7rem); }
}

@media (max-width: 480px) {
  .quest-hero { gap: .35rem; }
  .quest-mission { grid-template-columns: minmax(0, 1fr); }
  .quest-mission > img { min-height: 0; height: auto; aspect-ratio: 16 / 9; }
  .quest-chapters { gap: .65rem; }
  .quest-chapter-copy { padding: .65rem; }
  .quest-chapter h3 { font-size: 1rem; }
}

.coin-shop-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid #cdd9b8;
  border-radius: 1.55rem;
  background: #e7efd4 url("assets/brain-story/picture-book-meadow.webp") center bottom / cover;
}

.coin-shop-intro { padding: clamp(1.2rem, 3.7vw, 3rem); }
.coin-shop-intro h1, .coin-shop-rewards h2 {
  font-family: "Patrick Hand", system-ui, sans-serif;
  color: #19432e;
}
.coin-shop-intro h1 { margin-bottom: .28em; }
.coin-shop-art { display: block; width: min(100%, 21rem); height: min(25rem, 52vw); object-fit: contain; align-self: end; justify-self: center; padding: .7rem .65rem 0; }
.coin-shop-totals { display: flex; flex-wrap: wrap; gap: .65rem; margin-block: 1rem; }
.coin-shop-totals > div {
  min-width: 8rem;
  padding: .6rem .85rem;
  border: 1px solid #cad7b6;
  border-radius: .8rem;
  background: #fffdf3;
}
.coin-shop-totals dt { font-size: .83rem; font-weight: 750; }
.coin-shop-totals dd { margin: 0; color: #19432e; font-size: 1.65rem; font-weight: 850; line-height: 1.25; }
.coin-bonus {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem;
  border: 1px solid #edca70;
  border-radius: .8rem;
  background: #fff0ba;
  color: #533508;
}
.coin-bonus .quest-coin { flex: none; }
.coin-bonus p { margin: .13rem 0 0; font-size: .9rem; }
.coin-shop-rewards { margin-block-start: 1.45rem; }
.coin-shop-rewards h2 { font-size: clamp(1.85rem, 4vw, 2.7rem); }
.coin-shop-rewards .shop-item, .coin-shop-rewards .shop-copy { display: flex; flex-direction: column; }
.coin-shop-rewards .shop-copy { flex: 1; }
.coin-shop-rewards .shop-copy p { margin-bottom: .8rem; }
.coin-shop-buy { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: auto; }
.coin-shop-buy .action { margin: 0; border-radius: 999px; }
.coin-shop-buy .pill { background: #fff1c4; color: #63420c; }
.coin-shop-rewards .item-art { height: auto; aspect-ratio: 16 / 9; overflow: hidden; }
.coin-shop-rewards .item-art img { width: 100%; height: 100%; padding: 0; object-fit: cover; }
.coin-shop-rewards .coin-place-type { color: var(--accent); font-size: .82rem; font-weight: 800; margin-bottom: .33rem; }
.coin-shop-rewards small { margin-top: .45rem; color: #405c4b; }
.coin-visit-art { width: 100%; height: auto; max-height: 16rem; object-fit: cover; border-radius: .75rem; margin-bottom: .75rem; }

@media (max-width: 720px) {
  .coin-shop-hero { grid-template-columns: minmax(0, 1fr); }
  .coin-shop-art { grid-row: 1; height: clamp(10rem, 48vw, 17rem); }
}
