/* Main-menu pages, full screen (ui/menu-pages.js). Like the Animals page:
   the blurred hall behind, the carved Back button top left, a hanging title
   plank in the middle and the purse top right; the page itself scrolls under
   them in one centred column (--mw wide) with the scrollbar at the screen's
   edge. Cards, buttons and tabs keep the moss-and-gold skin they wear inside
   the frame (.pz-sheet, ui/pause.css); this file lays them out for the whole
   screen. Loaded after ui/pages.css. */

.overlay.is-menu-page { padding: 0; place-items: stretch; background: #0f2416; -webkit-backdrop-filter: none; backdrop-filter: none; }
.app[data-screen="menu"][data-overlay]:not([data-overlay=""]) .rotate { display: none; }

/* --mw: the column's width (set per page below); --pad: the side padding that
   centres it (resolved where it's used, so 100% is that box's width). */
.mp { --gut: clamp(14px, 3vw, 44px); --mw: 1240px; --pad: max(var(--gut), calc((100% - var(--mw)) / 2)); }
.overlay.is-menu-page .pz.mp {
  position: absolute; inset: 0; width: auto; height: auto; max-height: none; min-height: 0; margin: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  color: var(--cream); text-align: center;
}
.overlay.is-menu-page .pz.mp.is-update { animation: none; }

/* ---- Header: Back, the plank, the purse ---- */
.mp-top { position: relative; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 10px;
  padding: 0 clamp(10px, 2vw, 26px); }
.mp-top .pg-back { justify-self: start; margin-top: 10px; }
.mp-top .pg-plank { justify-self: center; max-width: min(56vw, 640px); }
.mp-top .pg-plank h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-purse { justify-self: end; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.mp-purse .pg-pill { height: clamp(30px, 6.4vh, 42px); font-size: clamp(13px, 3vh, 19px); }
.mp-purse .pg-pill svg { width: 1.35em; height: 1.35em; }
.mp-purse .mp-trophies { color: #ffe9a8; }

/* ---- Body: one centred column that scrolls under the header ---- */
.mp-body { position: relative; z-index: 1; min-height: 0; display: flex; flex-direction: column; }
.overlay.is-menu-page .mp .sheet {
  flex: 1 1 auto; width: 100%; max-width: none; height: auto; max-height: none; min-height: 0; margin: 0;
  overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: clamp(12px, 2.6vh, 26px) var(--pad) calc(28px + var(--safe-b, 0px));
  border: 0; border-radius: 0; box-shadow: none; background: none;
  -webkit-mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 24px), transparent);
}
/* The plank names the page: its own close button and heading step aside. */
.mp :is(.sheet-close, .mp-lift), .mp .m-head .m-wallet, .mp .m-head > span:has(> .mp-lift) { display: none; }
.mp .m-head { justify-content: center; padding-right: 0; margin-bottom: 14px; }
.mp .m-head:not(:has(> :not(.m-wallet, span:has(> .mp-lift)))) { display: none; }
.mp .sheet > .eyebrow, .mp .sheet > .title { padding-right: 0; }
.mp .sheet .lede { max-width: 68ch; margin-left: auto; margin-right: auto; text-align: center; font-size: clamp(14px, 1.2vw + 6px, 17px); }
.mp .m-fine, .mp .m-note, .mp .quest-fine { max-width: 92ch; margin-left: auto; margin-right: auto; text-align: center; }
.mp .m-status:empty { display: none; }
.mp .m-ev-sec + .m-ev-sec, .mp .qa-group + .qa-group { margin-top: clamp(18px, 3vh, 30px); }
.mp .m-ev-head, .mp .m-sub { font-size: clamp(17px, 1vw + 10px, 22px); }

/* Tabs: a sunken gold-ringed track in the middle, not stretched edge to edge. */
.mp :is(.m-tabs, .trail-tabs) {
  flex-wrap: wrap; justify-content: center; width: fit-content; max-width: 100%; margin: 0 auto clamp(14px, 2.4vh, 22px); overflow: visible;
  gap: 8px; padding: 7px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(6,18,10,.5), rgba(6,18,10,.68));
  box-shadow: inset 0 0 0 2px rgba(201,150,65,.45), inset 0 4px 10px rgba(0,0,0,.35);
}
.mp .m-tab { flex: 0 0 auto; min-height: 42px; padding: 0 clamp(14px, 1.6vw, 24px); font-size: clamp(14px, .5vw + 11px, 17px); }

/* Pointer devices: cards rise a little under the mouse. */
@media (hover: hover) and (pointer: fine) {
  .mp :is(.trail, .m-event, .m-card, .m-award, .m-hero, .m-mode:not(.locked), .mm-card, .od-pick) { transition: transform .18s var(--spring, ease), filter .18s; }
  .mp :is(.trail, .m-event, .m-card, .m-hero, .mm-card, .od-pick):hover { transform: translateY(-4px); filter: brightness(1.06); }
  .mp .m-mode:not(.locked):hover { transform: translateY(-2px); filter: brightness(1.1); }
  .mp .trail:hover .trail-art img { transform: scale(1.05); }
  .mp .pg-back:hover { filter: brightness(1.12); }
}

/* ---- Choose a trail ---- */
/* --tw: a card's narrowest width, from the screen's height, so a whole card
   (picture, name, pips, best) always fits under the tabs: 4 across on a
   landscape phone, 5 on a desktop. */
.mp-k-levels { --mw: 1320px; }
.mp .trail-tab {
  flex: 0 0 auto; min-height: 46px; padding: 0 clamp(14px, 1.6vw, 24px); border: 2px solid rgba(201,150,65,.6); border-radius: 13px;
  color: var(--leaf-text); background: linear-gradient(180deg, #2c5532, #1c3c22); box-shadow: 0 0 0 2px var(--bark), 0 3px 0 2px #160c04;
}
.mp .trail-tab b { font-size: clamp(14px, .5vw + 11px, 17px); }
.mp .trail-tab small { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.25); opacity: 1; }
.mp .trail-tab.on { color: #fffaf0; border-color: #f4c95a; text-shadow: 0 1px 0 rgba(0,0,0,.45); }
.overlay.is-menu-page .mp .trails {
  --tw: clamp(164px, 38vh, 220px);
  grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--tw)), 1fr));
  align-content: start; overflow: visible; scroll-snap-type: none; margin: 0; padding: 6px 2px 10px; gap: clamp(12px, 1.8vw, 22px);
}
.mp .trail { border-radius: 18px; }
.mp .trail-art { aspect-ratio: 16 / 10; }
.mp .trail-num { width: 30px; height: 30px; font-size: 14px; left: 9px; top: 9px; }
.mp .trail-body { gap: 6px; padding: 10px 12px 12px; }
.mp .trail-body > b { font-size: clamp(16px, .4vw + 12px, 19px); }
.mp .trail-tag { font-size: 13px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.mp .trail-feats { display: none; }
.mp .trail.maker .trail-art { display: grid; place-items: center; }
.mp .trail.maker .trail-art svg { width: 30%; height: auto; }

/* ---- Difficulty and mode: the trail on the left, three columns of modes ---- */
.mp-k-modes, .mp-k-event, .mp-k-mm-play { --mw: 1320px; }
.overlay.is-menu-page .mp .m-modes {
  display: grid; grid-template-columns: minmax(230px, 330px) minmax(0, 1fr); grid-template-rows: auto 1fr;
  grid-template-areas: "head diffs" "foot diffs"; gap: clamp(14px, 2.4vh, 22px) clamp(16px, 2.4vw, 32px); align-content: start;
}
.mp .m-modes > .m-modes-head, .mp .m-event-sheet > .m-modes-head {
  grid-area: head; display: grid; gap: 12px; align-content: start; margin: 0; padding: 12px 12px 16px; border-radius: 22px; text-align: left;
  border: 2px solid rgba(201,150,65,.72);
  background: radial-gradient(120% 70% at 50% 0, rgba(166,215,122,.16), transparent 60%), linear-gradient(180deg, #2e5834 0%, #1d3e24 60%, #15301b 100%);
  box-shadow: 0 0 0 2px var(--bark), 0 5px 0 2px #160c04, inset 0 2px 0 rgba(255,236,170,.14);
}
.mp .m-modes-head .m-thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 15px; }
.mp .m-modes-head .eyebrow { margin: 0 0 2px; }
.mp .m-modes-head .title { font-size: clamp(26px, 1.6vw + 14px, 40px); }
.mp .m-modes-head .m-medal-count { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--leaf-text); }
.mp .m-modes-head .m-medal-count svg { width: 20px; height: 20px; flex: none; }
.mp .m-modes .m-diffs { grid-area: diffs; gap: clamp(12px, 1.6vw, 20px); align-items: stretch; }
.mp .m-diff { gap: 10px; padding: 14px; border-radius: 22px; align-content: start; }
.mp .m-diff h3 { margin-bottom: 4px; text-align: center; }
.mp .m-diff h3 b { font-size: clamp(22px, 1vw + 14px, 30px); }
.mp .m-diff h3 small { font-size: 13px; }
.mp .m-mode { min-height: 62px; padding-top: 8px; padding-bottom: 8px; }
.mp .m-mode.std { min-height: 76px; }
.mp .m-mode-t b { font-size: 16px; }
.mp .m-mode-t small { font-size: 12.5px; }
.mp .m-mode-r { font-size: 15px; }
.mp .m-modes-foot { grid-area: foot; flex-direction: column; align-items: stretch; margin: 0; }
.mp .m-modes-foot .m-chip { justify-content: flex-start; min-height: 46px; }
/* One event: the banner on top, its rules and prizes below. */
.mp .m-event-sheet > .m-modes-head { grid-template-columns: minmax(160px, 300px) minmax(0, 1fr); align-items: center; margin-bottom: 18px; }
.mp .m-event-sheet .m-foot-row { max-width: 640px; margin-left: auto; margin-right: auto; }

/* ---- Settings ---- */
.overlay.is-menu-page .pz.mp-k-settings { --mw: 1120px; --k: clamp(.55px, min(100cqh / 1000, 100cqw / 1250), .95px); }
.overlay.is-menu-page .mp .pz-scroll {
  flex: 1 1 auto; min-height: 0; margin: 0; text-align: left;
  padding: clamp(12px, 2.6vh, 26px) var(--pad) 18px;
}
.mp .pz-set-grid { gap: clamp(12px, 1.6vw, 20px); }
.mp .pz-more { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.mp .pz-reset { justify-content: center; }
.overlay.is-menu-page .mp .pz-done { flex: none; align-self: center; width: min(440px, calc(100% - 2 * var(--gut))); height: clamp(48px, 8vh, 66px); margin: 6px auto calc(14px + var(--safe-b, 0px));
  font-size: clamp(19px, 3.4vh, 28px); }
.overlay.is-menu-page .mp .pz-done svg { width: 1.2em; height: 1.2em; }

/* ---- Events ---- */
.mp-k-events, .mp-k-leaderboards, .mp-k-community { --mw: 1440px; }
.mp .m-events-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: clamp(14px, 1.6vw, 22px); }
.mp .m-event { gap: 9px; padding: 14px; border-radius: 20px; }
.mp .m-event header .m-thumb { width: 92px; height: 60px; }
.mp .m-event header b { font-size: 18px; }
.mp .m-event p { font-size: 13.5px; }
.mp .m-event footer .sbtn { height: 42px; font-size: 15px; }
.mp .m-events .m-head { justify-content: center; }

/* ---- Market, Profile, Knowledge, Awards ---- */
.mp-k-store { --mw: 1400px; }
.mp .m-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: clamp(14px, 1.6vw, 22px); }
.mp .m-grid.looks { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.mp-k-profile { --mw: 1120px; }
.mp .m-card-banner { padding: clamp(14px, 2vh, 22px) clamp(16px, 2vw, 26px); border-radius: 22px; }
.mp .m-stats { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 14px; }
.mp .m-stats dd { font-size: clamp(19px, .6vw + 14px, 24px); }
.mp .m-avatars { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.mp-k-knowledge { --mw: 1400px; }
.mp .m-branches { gap: clamp(12px, 1.6vw, 22px); }
.mp .m-points { display: inline-flex; align-items: baseline; gap: 6px; }
.mp-k-achievements { --mw: 1400px; }
.mp .m-award-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.mp .m-awards > .sbtn.primary { max-width: 440px; margin-left: auto !important; margin-right: auto !important; }

/* ---- Quests ---- */
.mp-k-quests { --mw: 1320px; }
.mp .quest-reserve { max-width: 960px; margin-left: auto; margin-right: auto; }
.mp .quest-groups { gap: clamp(16px, 2vw, 26px); }
.mp .quest-sheet > .sbtn.big { display: none; }

/* ---- Small pages (daily gift, help, backups, install, first hero): one
   readable column in the middle of the screen ---- */
.mp-k-daily, .mp-k-backup, .mp-k-restore, .mp-k-ios-install { --mw: 820px; }
.mp-k-howto { --mw: 1360px; }
.mp-k-starter { --mw: 1200px; }
.overlay.is-menu-page .mp:is(.mp-k-daily, .mp-k-backup, .mp-k-restore, .mp-k-ios-install, .mp-k-howto, .mp-k-starter) .sheet {
  display: flex; flex-direction: column; justify-content: flex-start; justify-content: safe center;
}
.mp :is(.m-daily, .m-starter, .sheet.wide) > .sbtn.big, .mp .m-starter > .sbtn.primary { width: min(100%, 460px) !important; margin-left: auto; margin-right: auto; }
.mp .m-daily .m-days { gap: clamp(8px, 1.4vw, 16px); }
.mp .steps { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: clamp(12px, 1.6vw, 20px); }
.mp .steps li { padding: 16px; }
.mp .steps .step-ico { width: 54px; height: 54px; }
.mp .keys { text-align: center; }
.mp .m-hero-row { justify-content: center; }

/* ---- Teams, trials, odyssey, trail maker: wider columns ---- */
.mp-k-teams, .mp-k-territory, .mp-k-trials, .mp-k-odyssey, .mp-k-trails { --mw: 1360px; }

/* ---- Co-op: its own header row / scrolling body / footer, at full width ---- */
.mp-k-coop { --mw: 1320px; }
.overlay.is-menu-page .mp .sheet.coop-sheet { padding: 0; overflow: hidden; -webkit-mask-image: none; mask-image: none; display: flex; flex-direction: column; }
.mp .coop-sheet :is(.coop-head, .coop-body, .coop-foot) { padding-left: var(--pad); padding-right: var(--pad); }
.mp .coop-sheet .coop-head { padding-top: 12px; }
.mp .coop-sheet .coop-foot { padding-bottom: calc(14px + var(--safe-b, 0px)); }

/* ---- Trail Maker editor: the canvas takes the room ---- */
.mp-k-mapeditor { --mw: 1600px; }
.overlay.is-menu-page .mp .sheet.mm-editor { overflow: hidden; height: auto; padding: 10px var(--pad) calc(12px + var(--safe-b, 0px)); -webkit-mask-image: none; mask-image: none; }

/* ---- Phones in landscape: a slim header ---- */
@media (max-height: 520px) {
  .mp-top { align-items: center; padding-top: 6px; }
  .mp-top .pg-back { margin-top: 0; }
  .mp-top .pg-plank { padding-bottom: 4px; }
  .mp-top .pg-plank::before, .mp-top .pg-plank::after, .mp-top .pg-plank p { display: none; }
  .mp-top .pg-plank h2 { font-size: clamp(18px, 6vh, 26px); }
  .mp-purse { margin-top: 0; gap: 6px; }
  .mp-purse .pg-pill { height: 30px; font-size: 13.5px; border-width: 2px; }
  .overlay.is-menu-page .mp .sheet, .overlay.is-menu-page .mp .pz-scroll { padding-top: 10px; }
  .mp :is(.m-tabs, .trail-tabs) { padding: 5px; gap: 6px; margin-bottom: 10px; }
  .mp :is(.m-tab, .trail-tab) { min-height: 36px; }
  .mp .trail-tab { gap: 6px; padding: 0 10px; border-radius: 11px; }
  .mp .trail-tab b { font-size: 14px; }
  .mp .trail-tab small { font-size: 11px; padding: 1px 6px; }
  .overlay.is-menu-page .mp .trails { gap: 12px; padding-top: 2px; }
  .mp .trail { border-radius: 15px; }
  .mp .trail-num { width: 24px; height: 24px; font-size: 12px; left: 7px; top: 7px; }
  .mp .trail-body { gap: 4px; padding: 6px 9px 8px; }
  .mp .trail-body > b { font-size: 15px; }
  .mp .trail-tag { display: none; }
  .mp .m-diff { padding: 9px; }
  .mp .m-mode, .mp .m-mode.std { min-height: 50px; }
  .overlay.is-menu-page .mp .m-modes { grid-template-columns: minmax(190px, 250px) minmax(0, 1fr); }
  .mp .m-modes-head .title { font-size: 22px; }
}

/* Windows around 800px wide: the trail card sits above the difficulties so each mode card keeps room for its text. */
@media (max-width: 900px) {
  .overlay.is-menu-page .mp .m-modes { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "diffs" "foot"; }
  .mp .m-modes > .m-modes-head { grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); align-items: center; }
  .mp .m-modes-foot { flex-direction: row; flex-wrap: wrap; }
}

/* ---- Narrow windows and portrait: one column ---- */
@media (max-width: 760px) {
  .overlay.is-menu-page .mp .m-modes { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "diffs" "foot"; }
  .mp .m-modes > .m-modes-head { grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); align-items: center; }
  .mp .m-modes .m-diffs { grid-template-columns: minmax(0, 1fr); }
  .mp .m-modes-foot { flex-direction: row; flex-wrap: wrap; }
  .mp .m-event-sheet > .m-modes-head { grid-template-columns: minmax(0, 1fr); }
  .mp .pz-set-grid { grid-template-columns: minmax(0, 1fr); }
  .mp :is(.m-tab, .trail-tab) { flex: 1 1 auto; padding: 0 12px; }
  .overlay.is-menu-page .mp .trails { --tw: 148px; }
}
@media (orientation: portrait) {
  .mp-top { grid-template-columns: auto minmax(0, 1fr); padding-top: 4px; }
  .mp-top .pg-plank { max-width: 100%; justify-self: stretch; }
  .mp-top .pg-plank p { display: none; }
  .mp-purse { grid-column: 1 / -1; justify-self: center; margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mp, .mp * { transition: none !important; }
}
