/* Memory Quest is scoped to its panel; existing lesson layouts stay untouched. */
.mq-panel { position: relative; width: 100%; min-width: 0; max-width: 920px; margin: 0 auto; overflow: hidden; }
.mq-controls { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0; }
.mq-controls label { display: grid; gap: .5rem; flex: 1 1 240px; min-width: 0; font-weight: 700; }
.mq-controls select { width: 100%; min-width: 0; max-width: 100%; padding: .8rem; border: 1px solid #a8b4c8; border-radius: 12px; background: #fff; color: #20344e; font: inherit; }
.mq-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; font-size: 1.1rem; margin: 1rem 0 .5rem; font-variant-numeric: tabular-nums; }
.mq-phase { min-height: 1.5em; }
.mq-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(6px, 1.5vw, 14px); margin: 1rem 0; }
.mq-card { position: relative; display: block; padding: 0; width: 100%; min-width: 0; min-height: clamp(110px, 15vw, 154px); border: 0; background: transparent; color: #20344e; cursor: pointer; perspective: 900px; font: inherit; touch-action: manipulation; }
.mq-card-inner { display: grid; width: 100%; height: 100%; min-height: inherit; transform-style: preserve-3d; transition: transform .3s ease; }
.mq-card.is-face-up .mq-card-inner { transform: rotateY(180deg); }
.mq-card-back, .mq-card-front { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; padding: clamp(4px, 1vw, 12px); border: 2px solid #8faae0; border-radius: 12px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow-wrap: anywhere; line-height: 1.25; font-size: clamp(12px, 2vw, 19px); font-weight: 700; }
.mq-card-back { background: linear-gradient(145deg, #e7efff, #cedcf6); }
.mq-card-front { background: #fff; transform: rotateY(180deg); }
/* Reserve the old label height to keep the existing thumbs-up position unchanged. */
.mq-card-front::before { content: ""; height: .8125em; flex-shrink: 0; }
.mq-check { display: none; }
.mq-card.is-matched { cursor: default; opacity: .58; }
.mq-card.is-matched .mq-card-front { border-color: #529774; background: #ecf8f0; }
.mq-card.is-matched .mq-check { display: inline; }
.mq-card:focus-visible { outline: 3px solid #6245be; outline-offset: 3px; border-radius: 12px; }
.mq-empty { border-radius: 12px; background: #e7eaf0; opacity: .35; }
.mq-notice { padding: .8rem; border-radius: 10px; background: #fff2ce; color: #59440d; }
.mq-boundary { color: #536278; font-size: .9rem; margin-top: 1.3rem; }
.mq-result { text-align: center; }
.mq-result:empty { display: none; }
.mq-confetti { position: absolute; z-index: 2; inset: 0; overflow: hidden; pointer-events: none; }
@media (max-width: 480px) { .mq-panel { padding: 14px; } .mq-card { min-height: 122px; } .mq-status { font-size: .95rem; } .mq-panel h1 { font-size: 1.6rem; } }
@media (prefers-reduced-motion: reduce) { .mq-card-inner { transition: none; } }
/* Five columns × three rows leave a stable fifteen-section painting layout. */
.mq-tier { margin: 1.5rem 0 2rem; padding-top: 1rem; border-top: 1px solid #ccd9e5; }
.mq-tier h2 { overflow-wrap: anywhere; }
.mq-puzzle-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(4px, 1vw, 9px); }
.mq-puzzle-piece { display: flex; min-width: 0; min-height: 95px; flex-direction: column; justify-content: center; align-items: center; gap: .4rem; padding: 6px; border: 1px dashed #8a9bb3; border-radius: 9px; background: #e9eef4; color: #43546c; text-align: center; overflow-wrap: anywhere; }
.mq-puzzle-piece.is-collected { border: 2px solid #529774; background: #e5f5ea; color: #203f2e; }
.mq-piece-label { font-size: clamp(10px, 1.4vw, 14px); line-height: 1.3; }
[data-mq-eligibility] { min-height: 1.5em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.mq-panel .action-row { flex-wrap: wrap; }
.mq-panel .action-row button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

/* Scope the smaller heading to the current game lesson, leaving collection/setup titles alone. */
.mq-panel .mq-lesson-title { font-size: inherit; color: inherit; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.mq-board-stage { position: relative; isolation: isolate; margin: 1rem 0; }
.mq-board-stage .mq-board { position: relative; z-index: 0; margin: 0; }
/* Typography copied from .story-champion-panel h1 (Perfect Story). */
.mq-victory { position: absolute; z-index: 3; top: 50%; left: 0; right: 0; transform: translateY(-50%); margin: 0; padding: .35em .12em; background: transparent; color: #d69200; font-size: clamp(3.75rem, 7.5vw, 6.45rem); font-weight: 950; letter-spacing: .02em; line-height: 1; text-align: center; text-shadow: 0 2px 0 #fff3b0, 0 5px 14px rgba(177, 110, 0, .22); pointer-events: none; white-space: nowrap; }
.mq-retry-controls { display: inline-flex; align-items: center; justify-content: center; gap: .65rem; max-width: 100%; }
[data-mq-cooldown] { flex-shrink: 0; font-size: clamp(.75rem, 2.8vw, .95rem); font-variant-numeric: tabular-nums; white-space: nowrap; color: #41586a; }
.mq-retry-controls button { min-width: 0; }
.mq-retry-controls button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
@media (max-width: 700px) { .mq-victory { font-size: clamp(3.525rem, 17.55vw, 6.075rem); } }

.mq-cooldown-label { color: #247347; }
.mq-cooldown-time { color: #ba3038; }

.mq-lesson-heading { display: flex; align-items: center; justify-content: center; gap: .8em; color: #147d86; font-size: clamp(1.25rem, 3.2vw, 2.16rem); text-align: center; }
.mq-lesson-heading .mq-lesson-title { min-width: 0; font-size: inherit; }
.mq-speed-label { flex-shrink: 0; font-size: .5em; font-weight: 750; }

/* Approved transparent video stays below the gold lettering and ignores input. */
.mq-confetti-video { position: absolute; top: 0; display: block; width: var(--mq-confetti-frame-width); height: 100%; object-fit: contain; object-position: center bottom; background: transparent; pointer-events: none; }
.mq-confetti-video:first-child { left: max(0px, calc(50% - var(--mq-confetti-frame-width))); }
.mq-confetti-video:nth-child(2) { right: max(0px, calc(50% - var(--mq-confetti-frame-width))); transform: scaleX(-1); }
.mq-confetti-video[hidden] { display: none; }
.mq-static-confetti { position: absolute; width: 8px; height: 14px; border-radius: 2px; opacity: .8; }
.mq-companion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 1rem 0 2rem; }
.mq-companion-card { position: relative; min-width: 0; padding: clamp(16px, 3vw, 24px); background: #fff; border: 1px solid #cbdfe1; border-radius: 20px; box-shadow: 0 5px 18px #147d8609; overflow-wrap: anywhere; }
.mq-companion-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mq-companion-heading .eyebrow { margin: 0 0 .3rem; font-size: .75rem; }
.mq-companion-heading h3 { margin: 0; color: #147d86; font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
.mq-stage-badge { flex-shrink: 0; padding: 5px 8px; border-radius: 20px; background: #e7f5f4; color: #23636a; font-size: .75rem; font-weight: 750; }
.mq-companion-portrait { display: grid; place-items: center; height: 155px; margin: 1rem 0 .3rem; border-radius: 16px; background: #f2f8f9; }
.mq-companion-mark { display: grid; place-content: center; gap: 12px; width: 86px; height: 86px; background: #e3f1f1; border: 2px solid #8bbfc2; border-radius: 26px; color: #147d86; }
.mq-companion-mark > span { display: block; font-size: 1.8rem; font-weight: 850; text-align: center; line-height: 1; }
.mq-companion-mark.stage-2 { width: 98px; height: 98px; border-radius: 30px; background: #d5eeee; box-shadow: 0 0 0 5px #e5f4f4; }
.mq-companion-mark.stage-3 { width: 110px; height: 110px; border-radius: 34px; background: #bce4e4; box-shadow: 0 0 0 5px #e5f4f4, 0 0 0 9px #d4eaea; }
.mq-companion-mark.stage-4 { width: 118px; height: 118px; border-radius: 38px; background: #fff0bf; border-color: #d8aa39; color: #956818; box-shadow: 0 0 0 5px #fff8e4, 0 0 0 9px #f3e4ba; }
.mq-growth-marks { display: flex; gap: 4px; justify-content: center; }
.mq-growth-marks i { width: 10px; height: 5px; border-radius: 3px; background: #a9c7c9; }
.mq-growth-marks .is-filled { background: currentColor; }
.mq-growth-label { text-align: center; margin: .6rem 0 1rem; color: #23636a; font-weight: 750; }
.mq-treat-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 1rem 0; }
.mq-treat-stats > div { text-align: center; padding: 10px 3px; border-radius: 10px; background: #f4f7fa; }
.mq-treat-stats dt { font-size: .75rem; color: #536278; }
.mq-treat-stats dd { margin: 4px 0 0; font-weight: 850; font-size: 1.35rem; color: #20344e; }
.mq-growth-progress { display: grid; gap: 8px; font-size: .9rem; }
.mq-growth-progress progress { width: 100%; height: 10px; accent-color: #147d86; }
.mq-milestones { font-size: .78rem; color: #536278; line-height: 1.5; }
.mq-feed-button { min-height: 46px; width: 100%; margin-top: 8px; }
.mq-feed-button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.mq-feed-status { min-height: 1.5em; margin: 1.25rem 0; color: #23636a; font-weight: 700; }
.mq-reserve { padding-top: 1.5rem; border-top: 1px solid #ccd9e5; }
.mq-companion-card.is-grown { border-color: #d8c68a; }
.mq-reserve-complete { color: #7d6221; text-align: center; font-weight: 750; padding: .8rem; background: #fff8e4; border-radius: 10px; }
.mq-feeding-treat { position: absolute; z-index: 5; color: #f09a21; font-size: 30px; line-height: 1; pointer-events: none; text-shadow: 0 2px 6px #d3882333; }
@media (max-width: 640px) { .mq-companion-grid { grid-template-columns: minmax(0, 1fr); } }

/* Companion Painting 1 shares the existing Speed 2 inventory. */
.mq-art-wall { margin: 1.5rem 0 2.5rem; padding: clamp(12px, 3vw, 28px); border: 1px solid #cbdcd6; border-radius: 20px; background: linear-gradient(145deg, #f2f8f4, #fdf9ee); }
.mq-art-wall h2 { margin-top: 0; color: #26746e; }
.mq-painting-heading { text-align: center; margin: 1.5rem 0 1.2rem; }
.mq-painting-heading h3 { margin: .4rem 0; color: #335855; font-size: clamp(1.2rem, 3vw, 1.7rem); }
.mq-painting-heading p { margin: .5rem 0; }
.mq-painting-status { display: inline-block; border-radius: 999px; padding: .35rem .9rem; background: #e5eee7; color: #315d47; font-weight: 750; }
.mq-painting-status.is-complete { background: #fae4a6; color: #674613; }
.mq-painting-frame { width: min(100%, 530px); margin: 0 auto; padding: clamp(9px, 2.3vw, 17px); border: clamp(5px, 1vw, 9px) solid #8c6940; border-radius: 5px; background: #f7edda; box-shadow: inset 0 0 0 2px #d6b77e, 0 8px 22px #604a2520; box-sizing: border-box; }
.mq-jigsaw { display: block; width: 100%; height: auto; aspect-ratio: 1; background: #eee9df; box-shadow: 0 0 0 2px #b89b67; }
.mq-jigsaw-key { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 1.3rem 0; list-style: none; }
.mq-jigsaw-key li { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .5rem .2rem; min-width: 0; border-radius: 9px; color: #64716a; background: #e7ece7; text-align: center; font-size: clamp(10px, 1.35vw, 13px); line-height: 1.35; overflow-wrap: anywhere; }
.mq-jigsaw-key li.is-collected { background: #dceee2; color: #234d3d; }
.mq-jigsaw-key-number { font-weight: 800; font-variant-numeric: tabular-nums; }
.mq-art-preview { margin: 1.5rem 0 0; border-top: 1px solid #cad9d1; padding-top: 1rem; }
.mq-art-preview summary { cursor: pointer; color: #35665e; font-weight: 700; }
.mq-art-preview p { font-size: .9rem; line-height: 1.5; }
.mq-art-preview .action-row { gap: .5rem; margin: .6rem 0 0; }
.mq-art-preview button { font-size: .85rem; padding: .6rem .75rem; min-width: 0; }
.mq-art-preview button[aria-pressed="true"] { background: #245c53; color: #fff; border-color: #245c53; }
.mq-preview-notice { padding: .7rem 1rem; border: 1px dashed #ae935b; border-radius: 10px; background: #fff5d8; color: #695322; }
.mq-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 480px) { .mq-art-wall { padding: 10px; } .mq-jigsaw-key { gap: 4px; } }

/* Reward announcement is a separate transparent line below the unchanged gold title. */
.mq-victory-stack { position: absolute; z-index: 3; top: 50%; left: 0; right: 0; transform: translateY(-50%); pointer-events: none; }
.mq-victory-stack .mq-victory { position: static; transform: none; }
.mq-puzzle-announcement { position: absolute; top: calc(100% - clamp(10px, 2vw, 20px)); left: 0; right: 0; margin: clamp(4px, .8vw, 8px) 0 0; padding: 0 .7rem; color: #087b80; font-size: clamp(1.05rem, 2.8vw, 1.75rem); font-weight: 850; line-height: 1.35; text-align: center; overflow-wrap: anywhere; text-shadow: 0 1px 2px #fff, 0 -1px 2px #fff, 1px 0 2px #fff, -1px 0 2px #fff; }
.mq-indicator-legend { color: #4a6667; font-size: .85rem; margin: -.5rem 0 1rem; }
/* One active painting, optional neighboring previews, and no page-wide scrolling. */
.mq-carousel { margin-top: 1.5rem; }
.mq-carousel-navigation { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1.3rem; }
.mq-carousel-navigation button { min-width: 0; max-width: 42%; padding: .75rem 1rem; overflow-wrap: anywhere; white-space: normal; }
.mq-carousel-navigation button:disabled { opacity: .4; cursor: default; box-shadow: none; }
.mq-carousel-navigation p { margin: 0; color: #55716d; font-size: .85rem; white-space: nowrap; }
.mq-carousel-track { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3.6fr) minmax(0, 1fr); align-items: center; gap: 14px; }
.mq-carousel .mq-carousel-active { min-width: 0; margin: 0; padding: 0; border: 0; }
.mq-carousel-heading { text-align: center; margin: 0 0 1rem; }
.mq-carousel-heading h2 { margin: 0 0 .65rem; color: #26746e; font-size: clamp(1.3rem, 3vw, 1.85rem); }
.mq-carousel-heading p { margin: 0; }
.mq-carousel-neighbour { display: block; align-self: center; min-width: 0; width: 100%; padding: .65rem .25rem; border: 0; border-radius: 12px; background: transparent; color: #496965; box-shadow: none; opacity: .72; cursor: pointer; font: inherit; }
.mq-carousel-neighbour:hover { opacity: 1; background: #e5f2ef; }
.mq-carousel-neighbour:focus-visible { opacity: 1; outline: 3px solid #247c78; outline-offset: 2px; }
.mq-carousel-empty { pointer-events: none; }
.mq-neighbour-title { display: block; font-size: .85rem; font-weight: 750; overflow-wrap: anywhere; }
.mq-neighbour-count { display: block; margin: .35rem 0 .7rem; font-size: .7rem; }
.mq-carousel-neighbour .mq-painting-frame { padding: 4px; border-width: 3px; box-shadow: 0 3px 9px #604a2518; }
.mq-carousel-neighbour .mq-puzzle-piece { padding: 0; min-height: 0; border-radius: 2px; border-width: 1px; font-size: .55rem; }
.mq-placeholder-painting { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 4px; width: 100%; aspect-ratio: 1; background: #f3eee4; }
.mq-placeholder-painting .mq-puzzle-piece { min-height: 0; padding: 2px; border-radius: 5px; font-size: clamp(1rem, 3vw, 1.8rem); }
.mq-carousel-neighbour .mq-placeholder-painting { gap: 2px; }
.mq-carousel-neighbour .mq-placeholder-painting .mq-puzzle-piece { font-size: clamp(.5rem, 1vw, .85rem); }
.mq-carousel[data-direction="next"] .mq-carousel-active { animation: mq-level-next .2s ease-out; }
.mq-carousel[data-direction="previous"] .mq-carousel-active { animation: mq-level-previous .2s ease-out; }
@keyframes mq-level-next { from { opacity: .65; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes mq-level-previous { from { opacity: .65; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@media (max-width: 640px) { .mq-carousel-track { grid-template-columns: minmax(0, 1fr); } .mq-carousel-neighbour { display: none; } .mq-carousel-navigation button { font-size: .85rem; padding: .65rem .7rem; } }
@media (prefers-reduced-motion: reduce) { .mq-carousel[data-direction] .mq-carousel-active { animation: none; } }

/* Keep lesson numeric ranges together while allowing a natural break before them. */
.mq-jigsaw-key .mq-number-range { display: inline-block; white-space: nowrap; overflow-wrap: normal; word-break: normal; }

/* Endangereds portraits retain the whole original image at every source aspect ratio. */
.mq-companion-portrait { position: relative; height: clamp(210px, 27vw, 300px); isolation: isolate; }
.mq-companion-image { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center; border-radius: 12px; }
.mq-companion-image[hidden], .mq-art-fallback[hidden] { display: none; }
.mq-art-fallback { margin: auto; padding: 1rem; text-align: center; color: #23636a; }
.mq-stage-badge { flex-shrink: 1; text-align: center; }
.mq-feed-effect { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.mq-effect-old { position: absolute; inset: 0; }
.mq-opening-crate { position: absolute; height: 100%; aspect-ratio: 1; max-width: 100%; left: 50%; top: 50%; transform: translate(-50%,-50%); }
.mq-crate-shell, .mq-crate-panel { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* Copies of the original PNG supply the panel texture; no generated artwork. */
.mq-crate-interior, .mq-crate-panel { clip-path: polygon(28.5% 45.5%, 56.5% 53%, 56.5% 83%, 28.5% 73%); }
.mq-crate-interior { position: absolute; inset: 0; background: #48362c; }
.mq-crate-panel { transform-origin: 43% 79%; }
.mq-reveal-smoke { position: absolute; inset: 18% 7% 3%; filter: drop-shadow(0 3px 5px #c7d6df55); }
.mq-reveal-smoke i { position: absolute; width: 46%; height: 47%; border-radius: 50%; background: radial-gradient(ellipse at 45% 35%, #fff 20%, #edf4f7 65%, #dce8ed 100%); }
.mq-reveal-smoke i:nth-child(1) { left: 1%; top: 30%; }
.mq-reveal-smoke i:nth-child(2) { left: 17%; top: 6%; }
.mq-reveal-smoke i:nth-child(3) { left: 42%; top: 10%; }
.mq-reveal-smoke i:nth-child(4) { left: 55%; top: 35%; }
.mq-reveal-smoke i:nth-child(5) { left: 31%; top: 54%; }
.mq-reveal-smoke i:nth-child(6) { left: 8%; top: 53%; }
.mq-reveal-smoke i:nth-child(7) { left: 27%; top: 31%; }
@media (prefers-reduced-motion: reduce) {
  .mq-feed-effect { display: none !important; }
  .mq-companion-image { visibility: visible !important; opacity: 1 !important; transform: none !important; }
}

/* Earned rewards share a five-second pulse/turn window; replay text keeps its existing timing. */
.mq-reward-copy { position: relative; display: inline-block; }
.mq-reward-label { display: inline-block; animation: mq-reward-pulse var(--mq-reward-duration, 7s) ease-in-out 1; }
.mq-reward-piece { position: absolute; left: 50%; top: calc(100% + .35em); width: clamp(132px, 18vw, 198px); height: clamp(132px, 18vw, 198px); transform: translateX(-50%); perspective: 450px; display: grid; place-items: center; }
.mq-reward-piece svg, .mq-reward-piece img { display: block; width: 100%; height: 100%; transform-origin: center; animation: mq-reward-turn var(--mq-reward-duration, 5s) linear 1; filter: drop-shadow(0 2px 3px #6c3aa744); }
@keyframes mq-reward-pulse { 0%, 33.3333%, 66.6667%, 100% { filter: brightness(1); } 16.6667%, 50%, 83.3333% { filter: brightness(1.7); text-shadow: 0 0 7px #fff, 0 0 12px #71f4ef; } }
@keyframes mq-reward-turn { from { transform: rotateY(0deg); } to { transform: rotateY(1080deg); } }
@media (prefers-reduced-motion: reduce) { .mq-reward-label, .mq-reward-piece svg, .mq-reward-piece img { animation: none !important; } }

/* Shared square display area: the puzzle silhouette is 2:1 tall; the cookie stays round. */
.mq-reward-piece[data-mq-reward-kind="puzzle"] svg { width: 50%; height: 100%; }

/* One responsive type step for newly earned rewards; preserve the old line box/art anchors. */
.mq-reward-copy.is-earned-reward { --mq-reward-duration: 5s; height: clamp(1.4175rem, 3.78vw, 2.3625rem); vertical-align: top; }
.mq-reward-copy.is-earned-reward .mq-reward-label { display: flex; align-items: center; justify-content: center; height: 100%; font-size: clamp(1.125rem, 3.2vw, 2rem); line-height: 1; white-space: nowrap; animation-name: mq-earned-reward-pulse; }
.mq-reward-piece img { object-fit: contain; }
/* Five strong, readable peaks over the same shared duration as the three Y rotations. */
@keyframes mq-earned-reward-pulse {
  0%, 20%, 40%, 60%, 80%, 100% { color: #087b80; filter: brightness(1); text-shadow: 0 1px 2px #fff, 0 -1px 2px #fff, 1px 0 2px #fff, -1px 0 2px #fff; }
  10%, 30%, 50%, 70%, 90% { color: #00bac2; filter: brightness(1.55); text-shadow: 0 0 3px #fff, 0 0 8px #fff, 0 0 16px #16eee6, 0 0 24px #16eee6; }
}

/* Active game only: keep panel geometry/card sizing, show the existing page blue. */
.mq-panel.mq-round { background: transparent; border-color: transparent; box-shadow: none; }
.mq-round .mq-round-navigation { justify-content: center; align-items: stretch; gap: 12px; margin-top: 18px; }
.mq-round .mq-round-navigation .secondary-action {
  flex: 0 1 auto; width: auto; min-height: 48px; padding: 12px 22px;
  border: 2px solid #bca4df; border-radius: 16px; background: #e5d7fa; color: #231b32;
  box-shadow: 0 3px 8px #59407820;
}
.mq-round .mq-round-navigation .secondary-action:hover { background: #d9c5f4; box-shadow: 0 4px 10px #59407830; }
.mq-round .mq-round-navigation .secondary-action:focus-visible { outline: 3px solid #6245be; outline-offset: 3px; }

/* Only the setup, Companions and Puzzle Collection titles: 65% of existing sizes. */
.mq-panel .mq-page-title { font-size: clamp(1.56rem, 5.2vw, 3.51rem); line-height: 1.15; text-align: center; overflow-wrap: anywhere; margin-bottom: .35em; }
@media (max-width: 480px) { .mq-panel .mq-page-title { font-size: 1.04rem; } }

/* Shared Memory Quest board layout and the Apprentice's home-page accent palette. */
/* Scale each card to 90%, then add back the unchanged three grid gaps. */
.mq-round { --mq-apprentice-color: #d6a72d; --mq-grid-gap: clamp(6px, 1.5vw, 14px); --mq-board-width: calc(828px + var(--mq-grid-gap) * .3); }
.mq-round .mq-card { min-height: clamp(99px, 13.5vw, 138.6px); }
@media (max-width: 480px) { .mq-round .mq-card { min-height: 109.8px; } }
.mq-game-layout { display: block; min-width: 0; }
.mq-board-column { width: calc(90% + var(--mq-grid-gap) * .3); min-width: 0; max-width: var(--mq-board-width); margin-inline: auto; }
.mq-board-stage { width: 100%; max-width: 920px; margin: 1rem auto; }
.mq-board-stage .mq-board { width: 100%; }
.mq-status { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .35rem .75rem; margin: .75rem 0 .25rem; color: #20344e; }
.mq-status [data-mq-timer] { grid-column: 2; justify-self: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mq-status .mq-attempts-side { grid-column: 3; justify-self: end; min-width: 0; max-width: 300px; }
.mq-status .mq-attempts-side { min-width: 0; }
.mq-status .mq-attempts-side [data-mq-eligibility] { margin: 0; color: #20344e; font-size: .85rem; line-height: 1.25; text-align: right; overflow-wrap: anywhere; }
.mq-status [data-mq-eligibility] strong { font-weight: 850; }
.mq-status .mq-attempts-side [data-mq-cooldown] { display: block; text-align: right; font-size: .78rem; line-height: 1.2; }
.mq-status .mq-attempts-side [data-mq-cooldown][hidden] { display: none; }
.mq-round .mq-phase:empty { display: none; }
.mq-round .mq-card-back { background: linear-gradient(145deg, color-mix(in srgb, var(--mq-apprentice-color) 22%, #fff), color-mix(in srgb, var(--mq-apprentice-color) 10%, #fff)); border-color: color-mix(in srgb, var(--mq-apprentice-color) 46%, #8faae0); }
.mq-round .mq-card:not(.is-face-up):not(.is-matched):not([aria-disabled="true"]) .mq-card-back,
.mq-round.has-incorrect-pair .mq-card:not(.is-face-up):not(.is-matched) .mq-card-back { background: linear-gradient(145deg, color-mix(in srgb, var(--mq-apprentice-color) 55%, #fff), color-mix(in srgb, var(--mq-apprentice-color) 38%, #fff)); border-color: color-mix(in srgb, var(--mq-apprentice-color) 64%, #8faae0); }
.mq-round .mq-card-front { background: color-mix(in srgb, var(--mq-apprentice-color) 9%, #fff); border-color: color-mix(in srgb, var(--mq-apprentice-color) 38%, #8faae0); }
.mq-round .mq-card.is-matched .mq-card-front { background: color-mix(in srgb, var(--mq-apprentice-color) 25%, #ecf8f0); border-color: #529774; }
.mq-round .mq-card[aria-disabled="true"] { cursor: default; }
.mq-round .mq-card[aria-disabled="true"].is-face-up:not(.is-matched) .mq-card-front { border-style: dashed; }
.mq-round .mq-card[aria-disabled="true"]:not(.is-face-up):not(.is-matched) { opacity: .7; }
/* Incorrect pairs retain the ordinary card presentation; only the normal flip runs. */
.mq-round.has-incorrect-pair .mq-card[aria-disabled="true"]:not(.is-face-up):not(.is-matched) { opacity: 1; }
.mq-round:has(.mq-card[aria-disabled="false"]) .mq-card[aria-disabled="true"].is-face-up:not(.is-matched) .mq-card-front,
.mq-round.has-incorrect-pair .mq-card[aria-disabled="true"].is-face-up:not(.is-matched) .mq-card-front { border-style: solid; }
.mq-round .mq-card-back-icon { display: block; width: min(70%, 88px); height: auto; max-height: 80%; object-fit: contain; flex-shrink: 1; pointer-events: none; }

.mq-apprentice-display { display: none; }
.mq-timeout { position: absolute; z-index: 4; inset: 0; display: grid; align-content: center; justify-items: center; gap: .85rem; padding: 1rem; text-align: center; background: radial-gradient(ellipse at center, rgb(237 248 249 / 94%) 0 35%, rgb(237 248 249 / 80%) 62%, transparent 100%); }
.mq-timeout[hidden] { display: none; }
.mq-timeout h2 { color: #20344e; font-size: clamp(1.75rem, 4.5vw, 3rem); font-weight: 900; line-height: 1.1; text-shadow: 0 1px 0 #fff, 0 0 12px #fff; }
.mq-timeout .primary-action { margin: 0; }
.mq-round .mq-round-navigation { display: flex; width: fit-content; max-width: 100%; margin-inline: auto; justify-content: center; align-items: center; gap: 16px; }
.mq-round-link-group { display: contents; }
.mq-round .mq-round-navigation .mq-return-button { margin-right: 0; border-color: color-mix(in srgb, var(--mq-apprentice-color) 70%, #26211f); background: var(--mq-apprentice-color); color: #111; }
.mq-round .mq-round-navigation .mq-round-link-group .secondary-action { border-color: #a9d4b5; background: #dff1e3; color: #183b25; }
.mq-round .mq-round-navigation .mq-round-link-group .secondary-action:hover { background: #d0e9d6; }
/* The board owns the centerline. Artwork uses only the viewport space to its right. */
@media (min-width: 1250px) {
  .mq-panel.mq-round { max-width: none; overflow: visible; }
  .mq-game-layout { position: relative; display: grid; grid-template-columns: minmax(0, 920px); justify-content: center; }
  .mq-apprentice-display {
    position: absolute; left: calc(50% + var(--mq-board-width) / 2 + 24px); top: 0; bottom: 0; margin-block: auto;
    display: grid; place-items: center; width: clamp(0px, calc((100vw - var(--mq-board-width)) / 2 - 44px), 400px);
    min-width: 0; height: auto; aspect-ratio: 10 / 21; max-height: 100%;
  }
  .mq-apprentice-display img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
}
/* Keep the compact surrounding spacing and the approved grid gaps. */
.app-shell:has(> .mq-round) { padding-block: 40px 12px; }
.mq-panel.mq-round { padding-block: 8px; }
.mq-round .mq-status { margin-block: .25rem .125rem; }
.mq-round .mq-phase { min-height: 0; }
.mq-round .mq-board-stage { margin-block: .375rem; }
.mq-round .mq-round-navigation { margin-top: 8px; }
@media (max-width: 480px) {
  .app-shell:has(> .mq-round) { padding-top: 24px; }
}
@media (max-width: 640px) {
  .mq-status { grid-template-columns: minmax(0, 1fr); row-gap: .25rem; }
  .mq-status [data-mq-timer] { grid-column: 1; grid-row: 1; }
  .mq-status .mq-attempts-side { grid-column: 1; grid-row: 2; justify-self: center; max-width: 100%; text-align: center; }
  .mq-status .mq-attempts-side [data-mq-eligibility] { text-align: center; }
  .mq-status .mq-attempts-side [data-mq-cooldown] { text-align: center; }
  .mq-round .mq-round-navigation { align-items: stretch; gap: 12px; }
  .mq-round .mq-round-navigation .mq-return-button { margin-right: 0; }
}
@media (max-width: 420px) {
  .mq-round .mq-round-navigation { flex-wrap: wrap; justify-content: center; }
  .mq-round .mq-round-navigation .mq-return-button { margin-right: 0; }
}

/* Gallery V2: painting and cookie growth remain independent, read-only presentations of ownership. */
.app-shell:has(> .mq-gallery-panel) { padding-block: 40px 12px; }
.mq-gallery-panel {
  --mq-gallery-painting-size: clamp(210px, 28dvh, 300px);
  --mq-gallery-animal-height: clamp(210px, calc(100dvh - var(--mq-gallery-painting-size) - 320px), 440px);
  --mq-gallery-cookie-size: clamp(22px, 3dvh, 30px);
  display: grid; gap: 8px; max-width: 760px; padding: 12px 22px;
  background: linear-gradient(160deg, #fffdf7, #edf7f3); border-color: #b7d4cd;
  box-shadow: 0 8px 30px #29595218; overflow: visible;
}
.mq-gallery-panel > h1 { margin: 0; text-align: center; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.1; color: #147d86; }
.mq-gallery-exhibit { display: grid; gap: 6px; min-width: 0; }
.mq-gallery-meta { margin: 0; text-align: center; color: #335855; font-size: .95rem; line-height: 1.3; font-weight: 700; }
.mq-gallery-painting-row { display: grid; grid-template-columns: 44px minmax(0, var(--mq-gallery-painting-size)) 44px; justify-content: center; align-items: center; gap: 12px; min-width: 0; }
.mq-gallery-painting-row .mq-painting-frame { width: 100%; padding: 8px; border-width: 5px; border-radius: 7px; background: #f9f0df; }
.mq-gallery-painting-row .mq-jigsaw { background: #969da2; }
.mq-gallery-painting-row .mq-jigsaw-position:not(.is-collected) > use { stroke: #424d54; stroke-width: 4; }
.mq-gallery-painting-row .mq-jigsaw-position.is-collected > use { stroke: #816940; stroke-width: 3; }
.mq-gallery-painting-row .mq-gallery-arrow { width: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 1px solid #b6d6ce; background: #e3f1e9; color: #24736c; font-size: 2rem; line-height: 1; }
.mq-gallery-painting-row .mq-gallery-arrow:hover { background: #cce7da; }
.mq-gallery-arrow:focus-visible, .mq-gallery-meter:focus-visible { outline: 3px solid #6245be; outline-offset: 3px; }
.mq-gallery-care { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px 14px; width: min(100%, 560px); margin-inline: auto; min-width: 0; }
.mq-gallery-cookies { grid-column: 1; display: grid; grid-template-columns: repeat(5, var(--mq-gallery-cookie-size)); grid-template-rows: repeat(3, var(--mq-gallery-cookie-size)); gap: 4px; justify-self: center; align-self: end; }
.mq-gallery-cookies img { display: block; width: var(--mq-gallery-cookie-size); height: var(--mq-gallery-cookie-size); object-fit: contain; }
.mq-gallery-panel .mq-gallery-animal { grid-column: 1; grid-row: 2; width: 100%; height: var(--mq-gallery-animal-height); margin: 0; border-radius: 18px; background: radial-gradient(ellipse at 50% 90%, #cce5d466, transparent 64%); }
.mq-gallery-animal .mq-companion-image { border-radius: 0; object-fit: contain; object-position: center; }
.mq-gallery-controls { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.mq-gallery-feed { width: 100%; min-width: 0; min-height: 42px; padding: 8px 10px; white-space: normal; overflow-wrap: anywhere; }
.mq-gallery-feed:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.mq-gallery-meter { position: relative; width: 28px; height: clamp(96px, 16dvh, 144px); border: 2px solid #75aaa0; border-radius: 15px; overflow: hidden; background: linear-gradient(90deg, #c0d9d555, #ffffffd9 45%, #c0d9d588); box-shadow: inset 2px 0 4px #ffffffdd, inset -2px 0 5px #3d6f6d33, 0 2px 5px #244e4820; }
.mq-gallery-liquid { position: absolute; inset: auto 0 0; height: var(--mq-growth-percent); border-radius: 6px 6px 10px 10px; background: linear-gradient(90deg, #087c59, #32d492 42%, #0c9f6c); box-shadow: inset 2px 0 3px #c5ffe577; transition: height 180ms ease-out; }
.mq-gallery-divisions { position: absolute; inset: 0; background: repeating-linear-gradient(to top, transparent 0 calc(20% - 1px), #436b627d calc(20% - 1px) 20%); border-left: 4px solid #ffffff6b; pointer-events: none; }
.mq-gallery-meter.is-complete { border-color: #cba33b; }
.mq-gallery-dropping-cookie { position: absolute; z-index: 8; display: block; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 3px #74571b22); }
.mq-gallery-care > .mq-notice { grid-column: 1 / -1; }
.mq-gallery-panel .mq-gallery-status { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.mq-gallery-panel .mq-gallery-status.is-error { position: static; width: auto; height: auto; clip-path: none; white-space: normal; color: #983e39; font-size: .85rem; text-align: center; }
.mq-gallery-navigation { justify-content: center; gap: 12px; margin: 0; }
.mq-gallery-navigation .secondary-action { min-height: 44px; padding: 8px 18px; border-radius: 14px; background: #dff1e3; border: 1px solid #a9d4b5; color: #183b25; }
@keyframes mq-gallery-cookie-drop { 0% { transform: translateY(0); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(var(--mq-drop-distance)); opacity: 0; } }
@keyframes mq-gallery-meter-glow { 0%, 100% { box-shadow: inset 2px 0 4px #ffffffdd, 0 0 0 #eac25600; } 45% { border-color: #edbd35; box-shadow: inset 2px 0 4px #fff, 0 0 14px 5px #edc250b0; } }
@keyframes mq-gallery-crate-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 55% { transform: rotate(4deg); } 80% { transform: rotate(-2deg); } }
@keyframes mq-gallery-crate-open { from { transform: perspective(500px) rotateX(0); } to { transform: perspective(500px) translateY(9%) rotateX(72deg); } }
@keyframes mq-gallery-reveal-smoke { 0% { opacity: 0; transform: scale(.5); } 30% { opacity: 1; transform: scale(1); } 60% { opacity: .9; } 100% { opacity: 0; transform: scale(1.2); } }
@keyframes mq-gallery-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes mq-gallery-animal-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@media (max-width: 640px) {
  .mq-gallery-panel { padding: 12px; }
  .mq-gallery-painting-row { gap: 8px; grid-template-columns: 40px minmax(0, var(--mq-gallery-painting-size)) 40px; }
  .mq-gallery-painting-row .mq-gallery-arrow { width: 40px; }
}
@media (max-width: 480px) {
  .app-shell:has(> .mq-gallery-panel) { padding-block: 32px 12px; }
  .mq-gallery-panel { --mq-gallery-painting-size: 210px; --mq-gallery-animal-height: clamp(210px, 32dvh, 280px); }
  .mq-gallery-meta { font-size: .85rem; }
  .mq-gallery-care { grid-template-columns: minmax(0, 1fr) 86px; column-gap: 10px; }
  .mq-gallery-feed { font-size: .85rem; padding-inline: 6px; }
  .mq-gallery-painting-row { gap: 6px; grid-template-columns: 36px minmax(0, 210px) 36px; }
  .mq-gallery-painting-row .mq-gallery-arrow { width: 36px; min-height: 40px; }
  .mq-gallery-navigation { gap: 8px; }
  .mq-gallery-navigation .secondary-action { padding-inline: 12px; font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mq-gallery-panel *, .mq-gallery-panel *::before, .mq-gallery-panel *::after { animation: none !important; transition: none !important; }
}
