.achievement-page {
  gap: 26px;
}
.achievement-page > .page-intro { margin-bottom: 0; }

.achievement-feature {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .7fr);
  align-items: center;
  gap: clamp(12px, 2.5cqi, 34px);
  padding: clamp(18px, 3.2cqi, 33px);
  border: 1px solid #ddd0b7;
  border-radius: 24px;
  background: linear-gradient(125deg, #f8efde, #f5edda 59%, #e6ecd9);
  box-shadow: 0 10px 30px #52401a0e;
}

.achievement-feature-copy { min-width: 0; display: grid; gap: 9px; }
.achievement-feature .eyebrow { color: #654a24; }
.achievement-feature h2 { font-size: clamp(23px, 3.3cqi, 39px); overflow-wrap: anywhere; }
.achievement-feature p { color: #645d4d; overflow-wrap: anywhere; }
.achievement-feature .button-row { margin-top: 5px; }
.achievement-feature-display {
  min-width: 0;
  position: relative;
  display: grid;
  place-items: center;
  padding: 10px 5px 28px;
  background: radial-gradient(ellipse, #fff9dfb5, transparent 69%);
}
.achievement-feature-display::before,
.achievement-feature-display::after {
  position: absolute;
  content: "";
  border-radius: 1px;
  background: #c7ae71;
  width: 7px;
  height: 7px;
  box-shadow: 8px 0 #ded1a2, -8px 0 #ded1a2, 0 8px #ded1a2, 0 -8px #ded1a2;
}
.achievement-feature-display::before { top: 23%; left: 12%; }
.achievement-feature-display::after { bottom: 40%; right: 9%; opacity: .64; }
.achievement-pedestal {
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: 7px;
  width: 82%;
  max-width: 205px;
  height: 30px;
  border-radius: 44% 44% 40% 40%;
  background: #b5c49d;
  border-top: 6px solid #cbd6ac;
  box-shadow: 0 6px 0 #a9b891, 0 13px 19px #5b714326;
  transform: translateX(-50%);
}
.achievement-collection-count { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 630; }
.achievement-collection-count .icon { color: #825f31; }

.achievement-art {
  --badge-size: 82px;
  --pixel: calc(var(--badge-size) * .063);
  --badge-light: #f8dfad;
  --badge-rim: #be9251;
  --badge-edge: #79542f;
  --badge-face: #fbf0d9;
  --badge-ribbon: #b1845a;
  position: relative;
  isolation: isolate;
  display: inline-grid;
  place-items: start center;
  width: var(--badge-size);
  height: calc(var(--badge-size) * 1.14);
  flex: 0 0 auto;
  vertical-align: middle;
}
.achievement-art[data-tier="2"] {
  --badge-light: #e6eadc;
  --badge-rim: #a2ac9b;
  --badge-edge: #667367;
  --badge-face: #f0f2e9;
  --badge-ribbon: #86948a;
}
.achievement-art[data-tier="3"] {
  --badge-light: #f8e4a9;
  --badge-rim: #cb9a43;
  --badge-edge: #8f652b;
  --badge-face: #fff4cc;
  --badge-ribbon: #c9954a;
}
.achievement-art[data-tier="4"] {
  --badge-light: #d8e9e1;
  --badge-rim: #82a9a2;
  --badge-edge: #4e7d78;
  --badge-face: #e9f3eb;
  --badge-ribbon: #77a69d;
}
.achievement-frame {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--badge-size);
  aspect-ratio: 1;
  overflow: hidden;
  border: max(2px, calc(var(--badge-size) * .044)) solid var(--badge-rim);
  border-radius: 34% 33% 36% 35%;
  background:
    radial-gradient(ellipse at 33% 25%, #fffef8, transparent 49%),
    linear-gradient(141deg,var(--badge-face),var(--badge-light));
  box-shadow: inset 0 0 0 max(1px, calc(var(--badge-size) * .021)) #fff9e8b0,
    inset 0 max(2px, calc(var(--badge-size) * .075)) 0 #fffaf357,
    0 max(2px, calc(var(--badge-size) * .04)) 0 var(--badge-edge),
    0 max(4px, calc(var(--badge-size) * .075)) max(3px, calc(var(--badge-size) * .09)) #50402c2b;
}
.achievement-frame img { width: 78%; height: 78%; display: block; object-fit: contain; border-radius: 18%; }
.achievement-pixel[data-motif="apple"] {
  --pixel-light: #b4775f;
  --pixel-bright: #d9987c;
  --pixel-main: #a86854;
  --pixel-spot: #9ba76a;
  --pixel-deep: #627849;
}
.achievement-pixel:is([data-motif="mountain"],[data-motif="wheat"],[data-motif="creature"]) {
  --pixel-spot: #9ba76a;
  --pixel-deep: #677b4c;
}
.achievement-pixel:is([data-motif="portal"],[data-motif="palette"]) {
  --pixel-spot: #9678a1;
  --pixel-deep: #655877;
}
.achievement-ribbons {
  position: absolute;
  z-index: 0;
  bottom: 0;
  width: 65%;
  height: 34%;
  background: linear-gradient(90deg,var(--badge-ribbon) 45%,var(--badge-light) 45% 52%,var(--badge-ribbon) 52%);
  clip-path: polygon(11% 0,89% 0,100% 100%,78% 86%,61% 98%,51% 80%,40% 98%,22% 86%,0 100%);
}
.achievement-pixel {
  --pixel-light: #be8557;
  --pixel-bright: #f4c883;
  --pixel-main: #926442;
  --pixel-shadow: #584230;
  --pixel-spot: #b18a52;
  --pixel-deep: #87663b;
  display: block;
  width: var(--pixel);
  height: var(--pixel);
  box-shadow: var(--sprite);
  transform: rotate(-4deg) translateY(-2%);
}
.achievement-pixel:is([data-motif="sprout"], [data-motif="map"], [data-motif="dialogue"]) {
  --pixel-spot: #8d9b64;
  --pixel-deep: #617342;
}
.achievement-pixel:is([data-motif="sun"], [data-motif="spark"], [data-motif="torch"]) {
  --pixel-light: #ce8d46;
  --pixel-bright: #f8d26d;
  --pixel-spot: #dbb264;
}
.achievement-pixel:is([data-motif="moon"], [data-motif="audio"], [data-motif="gem"]) {
  --pixel-light: #729591;
  --pixel-bright: #a8d8d2;
  --pixel-main: #658786;
  --pixel-shadow: #415e60;
  --pixel-spot: #83b8b1;
  --pixel-deep: #587974;
}
.achievement-pixel:is([data-motif="heart"],[data-motif="letter"]) {
  --pixel-light: #a5695e;
  --pixel-bright: #cf9b8b;
  --pixel-shadow: #774d46;
}
.achievement-art-small { --badge-size: 46px; }
.achievement-art-hero { --badge-size: clamp(96px, 18cqi, 174px); }

.achievement-gallery { gap: 15px; }
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr));
  gap: 12px;
}
.achievement-tile {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 9px;
  padding: clamp(12px, 1.9cqi, 21px);
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(150deg,#fffefa,#faf8f3);
}
.achievement-tile[data-state="unclaimed"] { border-color: #dec38b; background: #fbf5e7; }
.achievement-tile[data-state="in-progress"] { border-color: #dcdcc8; }
.achievement-tile[data-state="locked"] .achievement-art { filter: saturate(.42); opacity: .78; }
.achievement-tile[data-state="claimed"] .achievement-state { color: #44583b; }
.achievement-tile > .achievement-art { margin-top: 2px; }
.achievement-tile-copy { flex: 1; display: grid; align-content: start; gap: 4px; }
.achievement-tile h3, .achievement-tile p, .achievement-chip strong { overflow-wrap: anywhere; }
.achievement-state { font-size: 12px; font-weight: 650; color: #6f5329; }
.achievement-score { display: grid; gap: 4px; width: 100%; max-width: 280px; color: #654a24; font-size: 13px; font-weight: 700; }
.achievement-score .progress { margin: 0; background: #e7dcc9; }
.achievement-score .progress span { background: #8b753f; }
.achievement-earned-date { display: flex; align-items: center; gap: 5px; color: #4d6742; font-size: 12px; font-weight: 630; }
.achievement-evidence { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 13px; }
.achievement-evidence .text-button { padding: 0; min-height: 34px; }
.achievement-facets { display: flex; flex-wrap: wrap; gap: 6px; }
.achievement-facet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 13px;
  border: 1px solid #e4ded2;
  border-radius: 14px;
  background: #faf8f3;
  color: #5e5446;
  font-size: 13px;
  text-decoration: none;
}
.achievement-facet[aria-current] {
  border-color: #c2ab7f;
  color: #4f3c23;
  font-weight: 680;
  background: #eee2c9;
  box-shadow: inset 0 -2px #c2ab7f;
}
.achievement-status-facets { border-top: 1px solid var(--line); padding-top: 9px; }
.achievement-status-facets .achievement-facet { font-size: 12px; border-radius: 12px; }
:is(.achievement-trail,.achievement-growth-details) ol { list-style: none; display: grid; gap: 4px; margin: 0; padding: 0; }
:is(.achievement-trail,.achievement-growth-details) li { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 5px 12px; padding: 7px 0; }
:is(.achievement-trail,.achievement-growth-details) li + li { border-top: 1px solid var(--line); }
.achievement-growth-details > summary { width: fit-content; padding: 7px 0; cursor: pointer; color: #655030; font-weight: 650; }
.achievement-chips { display: flex; flex-wrap: wrap; gap: 13px 22px; }
.achievement-chip { display: flex; min-width: 0; align-items: center; gap: 9px; line-height: 1.4; }
.achievement-chip div { display: grid; gap: 2px; }
.achievement-chip time { color: var(--muted); font-size: 12px; }
.achievement-rule-item { min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 16px; }
.achievement-rule-item > summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; }
.achievement-rule-item > summary::-webkit-details-marker { display: none; }
.achievement-rule-item > summary::after { content: "+"; margin-inline-start: auto; padding-inline: 8px; color: var(--muted); }
.achievement-rule-item[open] > summary::after { content: "−"; }
.achievement-rule-item > summary > span:not(.achievement-art) { display: grid; min-width: 0; overflow-wrap: anywhere; }
.achievement-rule-item small { color: var(--muted); }
.achievement-rule-fields { margin-top: 12px; }

.achievement-history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 11px; }
.achievement-history-entry {
  display: grid;
  grid-template-columns: 46px minmax(0,1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 10px;
  padding-block: 8px;
}
.achievement-history-entry > :first-child { grid-row: 1 / 3; }
.achievement-history-entry > div { grid-row: 1 / 3; min-width: 0; overflow-wrap: anywhere; }
.achievement-history-entry > time, .achievement-history-entry > a { grid-column: 3; justify-self: end; }
.achievement-history-entry > time { color: var(--muted); font-size: 12px; }
.achievement-history-entry + .achievement-history-entry { border-top: 1px solid var(--line); }
.achievement-history-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #e4dbc7;
  border-radius: 14px;
  color: #70532c;
  background: #f4ecda;
  font-size: 18px;
}

.achievement-reward {
  width: min(440px, calc(100% - 28px));
  max-height: min(90dvh, 670px);
  padding: 0;
  border: 1px solid #deca9f;
  border-radius: 26px;
  color: var(--ink);
  background: #fffaf0;
  box-shadow: 0 25px 75px #31231455;
  animation: reward-arrival .32s cubic-bezier(.18,.66,.29,1.25) both;
}
.achievement-reward::backdrop { background: #33291b62; backdrop-filter: blur(4px); }
.achievement-reward-inner { display: grid; gap: 13px; padding: 16px 20px 21px; }
.achievement-reward-inner > h2 { font-size: clamp(21px,5.6vw,30px); text-align: center; }
.achievement-reward-stage { position: relative; display: grid; place-items: center; min-height: 131px; isolation: isolate; }
.achievement-reward-stage .achievement-art {
  --badge-size: 65px;
  position: absolute;
  bottom: 49%;
  margin-left: 4px;
  transform: rotate(-8deg);
  animation: reward-pop .5s .25s cubic-bezier(.18,.66,.29,1.25) both;
}
.achievement-reward-chest {
  position: absolute;
  bottom: 9px;
  width: 118px;
  height: 48px;
  border: 5px solid #805432;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background:
    repeating-linear-gradient(0deg, #a16a42 0 3px, transparent 3px 13px),
    linear-gradient(90deg,#b98049,#d09a58 60%,#a66d41);
  box-shadow: inset 0 -4px #95613c, 0 9px 0 -2px #e6d3aa, 0 13px 20px #5b412e28;
  animation: reward-chest .54s cubic-bezier(.26,.7,.3,1.2) both;
}
.achievement-reward-chest::before {
  position: absolute;
  content: "";
  inset: -14px -6px auto;
  height: 21px;
  border: 4px solid #805432;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(#e9b56e,#af7042);
  transform: translate(0,-7px) rotate(-6deg);
  transform-origin: right center;
  animation: reward-open .42s .17s ease-out both;
}
.achievement-reward-chest::after {
  position: absolute;
  content: "";
  inset: 6px auto auto 44px;
  width: 20px;
  height: 18px;
  border: 3px solid #9b6731;
  border-radius: 4px;
  background: radial-gradient(circle at 50% 54%,#674225 0 2px,#e7b85f 3px);
  box-shadow: inset 0 2px #ffdd93;
}
.achievement-reward-glow {
  position: absolute;
  z-index: -1;
  inset: 3px 0 0;
  background: radial-gradient(ellipse,#f5d98f91,transparent 62%);
  animation: reward-glow .55s .28s ease-out both;
}
.achievement-reward-glow::before, .achievement-reward-glow::after {
  position: absolute;
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #c99a51;
  box-shadow: 7px 0 #ecd491, -7px 0 #ecd491, 0 7px #ecd491, 0 -7px #ecd491;
}
.achievement-reward-glow::before { top: 26%; left: 27%; }
.achievement-reward-glow::after { top: 41%; right: 24%; }
.achievement-reward-list { list-style: none; display: grid; gap: 7px; padding: 0; margin: 0; max-height: min(37dvh,290px); overflow: auto; }
.achievement-reward-list li {
  animation: reward-arrival .28s calc(.32s + .07s * var(--reward-order, 0)) both;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 15px;
  background: #f5ebd8;
  overflow-wrap: anywhere;
}
.achievement-reward-inner > .primary { min-height: 46px; justify-self: stretch; }
@keyframes reward-arrival { from { opacity: 0; translate: 0 18px; scale: .96; } to { opacity: 1; translate: 0; scale: 1; } }
@keyframes reward-chest { 0% { translate: 0 20px; scale: .85; } 60% { translate: 0 -6px; scale: 1.05; } 100% { translate: 0; scale: 1; } }
@keyframes reward-open { from { transform: translate(0,0) rotate(0); } to { transform: translate(0,-7px) rotate(-6deg); } }
@keyframes reward-pop { from { opacity: 0; translate: 0 55px; scale: .65; } to { opacity: 1; translate: 0; scale: 1; } }
@keyframes reward-glow { from { opacity: 0; scale: .66; } to { opacity: 1; scale: 1; } }
.achievement-reward[data-motion="off"], .achievement-reward[data-motion="off"] *,
.achievement-reward[data-motion="off"] .achievement-reward-chest::before { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .achievement-reward, .achievement-reward *, .achievement-reward .achievement-reward-chest::before { animation: none; }
}

@container (max-width: 700px) {
  .dock.student-dock {
    display: grid;
    grid-template-columns: repeat(4, minmax(44px, 1fr));
    justify-items: stretch;
    gap: 2px 4px;
    margin-inline: 8px;
    padding: 5px;
    background-color: #fffdf7f2;
  }
  .dock.student-dock .nav-link { width: auto; max-width: none; min-height: 44px; font-size: 12px; border-radius: 14px; }
  .dock.student-dock .nav-link[aria-current="page"] { background: #f1eadc; }
  .achievement-page { gap: 20px; }
}
@container (max-width: 490px) {
  .achievement-feature { grid-template-columns: minmax(0,1fr) minmax(82px,.58fr); padding: 15px 13px; }
  .achievement-art-hero { --badge-size: clamp(75px, 24cqi, 107px); }
  .achievement-feature .button-row :is(.primary,.secondary) { padding-inline: 12px; }
  .achievement-feature-display::before { top: 20%; left: 2%; }
  .achievement-feature-display::after { bottom: 37%; right: -2%; }
  .achievement-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .achievement-tile > .achievement-art { --badge-size: 68px; }
  .achievement-tile h3 { font-size: 15px; }
  .achievement-tile .secondary, .achievement-tile .ghost { min-height: 44px; padding-inline: 8px; max-width: 100%; }
  :is(.achievement-trail,.achievement-growth-details) li { grid-template-columns: minmax(0, 1fr); }
  :is(.achievement-trail,.achievement-growth-details) .achievement-evidence { margin-left: 55px; }
  .achievement-history-entry { grid-template-columns: 42px minmax(0,1fr); grid-template-rows: auto auto auto; gap: 2px 7px; }
  .achievement-history-entry > :first-child { grid-row: 1 / 3; align-self: start; }
  .achievement-history-entry > div { grid-row: 1; }
  .achievement-history-entry > time, .achievement-history-entry > a { grid-column: 2; justify-self: start; }
  .achievement-facets { gap: 5px; }
  .achievement-facet { min-height: 44px; padding-inline: 9px; }
}
@media (max-width: 720px) {
  #frame[data-role="student"] + .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }
}
