/* The collection is the screen: artwork first, one purchase decision at a time. */
.music-credit { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; padding: 8px 12px; color: var(--menu-ink); font-size: .7rem; text-underline-offset: 3px; }
:root body .game-chrome {
    position: absolute; inset: 0 0 auto; width: 100%; height: 0; min-height: 0; padding: 0;
}
:root body .chrome-home {
    position: fixed; top: 14px; left: 18px; width: 44px; height: 44px; padding: 9px;
}
:root body.screen-store-active .chrome-home { display: none; }
:root body.screen-commissions-active .chrome-home { display: none; }

/* One labelled return action, anchored above the gallery's scrolling content. */
:root body #screen-commissions { height: 100svh; padding-top: 64px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
:root body #screen-commissions .level-grid { flex: 1; min-height: min(100px, 18svh); max-height: none; align-content: start; grid-auto-rows: max-content; }
:root body #screen-commissions .level-card { height: auto; align-self: stretch; }
:root body #screen-commissions .level-thumb { flex-shrink: 0; }
:root body #screen-commissions :is(.gallery-heading, .gallery-toolbar, .gallery-footer) { flex-shrink: 0; }
:root body #screen-commissions .gallery-footer {
    display: grid; gap: 10px; width: 100%; padding: 12px 16px;
    background: var(--control-bottom); color: var(--control-ink); border-radius: 4px;
}
:root body #screen-commissions .gallery-footer:has(#gallery-scroll-hint[hidden]) { display: none; }
:root body #screen-commissions .gallery-scroll-hint {
    padding: 0; margin: 0; background: none; color: inherit;
    font-size: .75rem; line-height: 1.5; border-radius: 0;
}
:root body #commissions-back-button {
    position: fixed; z-index: 25; top: max(14px, env(safe-area-inset-top));
    left: max(18px, env(safe-area-inset-left)); margin: 0; min-height: 44px;
    padding: 10px 16px; font-size: .8rem;
}
:root body #screen-commissions .gallery-heading { margin-bottom: 22px; }
/* Completion status and set membership are separate browsing choices. */
:root body #screen-commissions .gallery-toolbar {
    display: flex; flex-flow: row wrap; align-items: center; justify-content: space-between;
    gap: 14px 24px; padding: 14px 16px;
}
:root body #screen-commissions .daily-play-note { order: 3; flex: 1 0 100%; }
:root body #screen-commissions .gallery-filters {
    display: flex; flex-wrap: nowrap; gap: 6px; margin: 0; align-self: center;
}
:root body #screen-commissions .gallery-filter { min-height: 44px; padding: 10px 18px; white-space: nowrap; }
.gallery-set-control {
    display: flex; align-items: center; gap: 12px; min-width: 0;
    color: var(--text-primary); font: 600 .85rem/1.4 var(--font-ui);
}
.gallery-set-control select {
    width: 220px; max-width: 100%; min-height: 44px; padding: 10px 32px 10px 12px;
    border: 1px solid var(--metal); border-radius: 6px;
    background: var(--surface); color: var(--text-primary); font: 500 .85rem/1.4 var(--font-ui);
    cursor: pointer;
}
.gallery-set-control select:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
:root body #screen-commissions .level-card-set {
    display: block; color: var(--text-muted); font: 500 .8rem/1.5 var(--font-ui);
    text-transform: none; letter-spacing: 0; margin-top: 3px;
}
:root body #screen-commissions .level-card-date { font: inherit; color: var(--text-muted); }
:root body #screen-commissions .level-card-info { min-height: 112px; flex: 1; gap: 8px; }
:root body #screen-commissions .level-card-title { min-height: 2.8em; }
:root body #screen-commissions .level-card-meta { margin-top: auto; padding-top: 8px; }
@media (max-width: 600px) {
    :root body #screen-commissions .gallery-toolbar { padding: 12px; gap: 12px; }
    :root body #screen-commissions .gallery-filters { width: 100%; }
    :root body #screen-commissions .gallery-filter { flex: 1; padding-inline: 10px; }
    .gallery-set-control { width: 100%; }
    .gallery-set-control select { flex: 1; width: 0; }
}
/* Keep the filter's focus ring and button shadows clear of each other. */
:root body #screen-commissions .gallery-toolbar { gap: 22px 24px; padding: 16px; }
:root body #screen-commissions .gallery-filters { gap: 12px; }
:root body #screen-commissions .level-grid { padding-block: 26px; gap: 24px 18px; }
:root body #screen-commissions .level-thumb { aspect-ratio: 1.2; }
:root body #screen-commissions .level-thumb-art.is-mystery { width: 58%; margin-block: 28px 16px; border-width: 6px; }
:root body #screen-commissions .level-card-info { padding: 16px 12px; }
:root body #screen-commissions .level-card-set { margin-top: 0; }
:root body #screen-commissions .gallery-footer {
    background: none; color: var(--menu-ink); padding: 8px 0 0; gap: 6px;
    text-shadow: 0 1px 3px var(--garden-shadow, #14232bcc);
}
@media (max-width: 600px) {
    :root body #screen-commissions .gallery-toolbar { gap: 22px; padding: 16px 12px; }
    :root body #screen-commissions .gallery-filter { font-size: .8rem; }
    :root body #screen-commissions .level-card-meta { flex-direction: row; align-items: center; gap: 8px; }
}
:root body .level-thumb-art.is-mystery {
    display: grid; place-items: center; width: 66%; height: auto; aspect-ratio: 1;
    margin: 18px auto; inset: auto; border: 8px ridge var(--metal); border-radius: 2px;
    background: radial-gradient(ellipse at 40% 25%, var(--control-top), var(--control-bottom));
    box-shadow: inset 0 0 0 2px var(--surface-deep), inset 0 3px 14px oklch(12% .02 160 / .3), 0 5px 10px oklch(12% .02 160 / .3);
    filter: none; transform: none; opacity: 1;
}
.mystery-mark { font: 600 clamp(2rem, 4vw, 3rem)/1 'Lora', Georgia, serif; color: var(--control-ink); text-shadow: 0 2px 2px oklch(12% .02 160 / .3); }
:root body .level-card.is-locked .level-lock { top: 12px; right: 12px; left: auto; bottom: auto; transform: none; width: 30px; height: 30px; }
:root body .level-card.is-locked .level-lock .ui-icon { width: 16px; height: 16px; }

:root body #screen-leaderboard {
    width: min(860px, 100%); min-height: 100svh; justify-content: flex-start;
    padding: 76px 28px 36px; max-width: none;
}
:root body #screen-leaderboard .leaderboard-heading { margin: 0 0 26px; }
:root body #screen-leaderboard .leaderboard-heading h2 { margin: 0; }
:root body #screen-leaderboard .leaderboard-shell { width: 100%; padding: 28px 32px; }
:root body #screen-leaderboard .leaderboard-tabs { gap: 10px; padding-bottom: 24px; }
:root body #screen-leaderboard .leaderboard-summary { padding: 20px 8px; }
:root body #screen-leaderboard .leaderboard-row { padding: 17px 12px; }
:root body #screen-leaderboard .leaderboard-note { margin: 24px 0; }

/* The same joinery continues from the exhibit wall into the collection bay. */
:root {
    --gallery-oak:linear-gradient(110deg,#583b24a8,#332418db 54%,#4d3424b8),url('assets/gallery/materials/oak.webp') center/230px;
    --gallery-brass:linear-gradient(115deg,#bc9456,#ebd3a0 43%,#c09a60);
}
:root body #screen-store {width:100%;max-width:none;min-height:100dvh;padding:0;margin:0;
    border:0;box-shadow:none;color:#f5e6c5;background:#182230;}
:root body #screen-store::before,:root body #screen-store::after {display:none;}
:root body #screen-store .collection-back {position:absolute;z-index:2;top:max(8px,env(safe-area-inset-top));left:max(8px,env(safe-area-inset-left));
    width:44px;height:44px;margin:0;padding:8px;display:grid;place-items:center;border:0;background:transparent;box-shadow:none;}
.collection-back img {height:29px;width:auto;}
:root body #screen-store .store-balance {position:absolute;top:14px;right:50px;z-index:2;}
.pack-carousel {position:relative;isolation:isolate;width:100%;min-height:100dvh;display:grid;align-content:center;
    justify-items:center;gap:22px;padding:clamp(64px,12dvh,108px) 0 clamp(36px,10dvh,84px);box-sizing:border-box;touch-action:pan-y;}
.pack-carousel::before {content:'';position:absolute;inset:0;z-index:-1;pointer-events:none;
    border-image:url('assets/cathedral-alcove.png') 490 305 160 fill / clamp(105px,29dvh,290px) clamp(24px,8vw,145px) clamp(40px,10dvh,95px) / 0 stretch;}
:root body #screen-store .store-packs {display:block;width:100%;max-width:none;margin:0;}
:root body #screen-store .premium-card {display:grid;justify-items:center;align-content:center;gap:clamp(16px,3dvh,30px);
    width:100%;max-width:none;margin:0;padding:0 10px;box-sizing:border-box;border:0;border-radius:0;backdrop-filter:none;
    background:none;box-shadow:none;color:inherit;text-align:center;overflow:visible;}
:root body #screen-store .premium-card[hidden] {display:none;}
:root body #screen-store .premium-card h3 {margin:0;max-width:90%;color:#f5e8c9;
    font:600 clamp(24px,5.6vw,39px)/1.12 Lora,Georgia,serif;letter-spacing:-.025em;text-shadow:0 2px 4px #090e18;}
.pack-presentation {width:min(88%,540px);display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;
    padding:7px 8px 9px;position:relative;box-sizing:border-box;
    background:var(--gallery-oak);border:2px ridge #ac8c5a;box-shadow:inset 0 0 0 2px #241b14,0 4px 7px #090c12;}
.pack-presentation::after {content:'';position:absolute;inset:auto -2.5% -6px;height:7px;
    border:1px solid #493b29;background:linear-gradient(#c2ad813d,#352b2499),url('assets/gallery/materials/stone.webp') center/240px;
    box-shadow:inset 0 2px #e5d8b675,0 2px 3px #11131a;}
.collection-window {min-width:0;margin:0;display:grid;align-content:start;gap:7px;color:#f7e7c3;}
.collection-art {position:relative;aspect-ratio:1;box-sizing:border-box;background:#1d2b2c center/100% 100% no-repeat;
    border:4px ridge #928365;outline:1px solid #1c211c;box-shadow:0 0 0 2px #9c8b6859,inset 2px 2px 4px #0b191f9c;}
.collection-window figcaption {font:600 clamp(12px,2.7vw,16px)/1.18 Lora,Georgia,serif;color:#eedcb6;text-align:center;}
.pack-details {max-width:min(88%,440px);text-align:center;}
:root body #screen-store .pack-quantity {margin:0;color:#ecdbb7;font:500 clamp(17px,3vw,22px)/1.3 Lora,Georgia,serif;}
:root body #screen-store .pack-difficulty {margin:4px 0 0;color:#efdbb5;font:600 14px/1.2 Lora,Georgia,serif;}
.pack-purchase {display:grid;justify-items:center;gap:8px;margin-top:12px;}
:root body #screen-store .pack-buy,:root body #screen-store .pack-compare {display:inline-flex;align-items:center;justify-content:center;gap:12px;
    width:auto;max-width:100%;min-height:46px;margin:0;padding:8px 16px;border:3px double #bc9c66;border-radius:6px;
    background:var(--gallery-brass);color:#302117;box-shadow:inset 0 1px #fff0ce,0 3px 5px #111016a8;
    text-transform:none;text-shadow:none;letter-spacing:normal;font:600 17px/1.2 Lora,Georgia,serif;}
:root body #screen-store .pack-compare {background:var(--gallery-oak);color:#efd9ad;font-size:15px;}
.pack-buy .pack-ticket {padding-left:12px;border-left:1px solid #957442;font:700 20px/1.15 system-ui,sans-serif;font-variant-numeric:lining-nums tabular-nums;white-space:nowrap;}
.pack-compare svg {width:14px;height:14px;transform:rotate(180deg);}
:root body #screen-store .pack-buy:active,:root body #screen-store .pack-compare:active {transform:translateY(1px);}
:root body #screen-store .pack-ownership,:root body #screen-store .pack-save,:root body #screen-store .pack-was {margin:0;color:#f0d9a7;font:500 14px/1.3 Lora,Georgia,serif;}
:root body #screen-store .pack-ownership {order:3;color:#c5bdab;font-size:12px;}
.collection-navigation {display:flex;align-items:center;justify-content:center;gap:10px;width:max-content;max-width:100%;
    padding:0 4px;background:var(--gallery-oak);border:1px solid #8d724c;border-radius:7px;box-shadow:0 2px 4px #101016;}
:root body #screen-store .collection-navigation > button {display:grid;place-items:center;width:44px;height:44px;min-height:44px;
    margin:0;padding:0;border:0;background:transparent;box-shadow:none;}
.collection-navigation img {height:19px;width:auto;}
#pack-next img {transform:rotate(180deg);}
.pack-dots {display:flex;}
:root body #screen-store .pack-dots button {display:grid;place-items:center;width:26px;min-width:0;height:44px;min-height:44px;margin:0;padding:0;border:0;box-shadow:none;background:none;}
:root body #screen-store .pack-dots button::before {content:'';position:static;width:7px;height:7px;border:1px solid #b89a66;border-radius:50%;background:#241b14;}
:root body #screen-store .pack-dots button[aria-current]::before {background:#f5daa1;box-shadow:0 0 4px #dfb76a80;}
:root body #screen-store :is(.pack-dots button,.collection-back,.collection-navigation > button)::after {display:none;}
@media (min-aspect-ratio: 6/5) and (max-height:580px) {
    .pack-carousel {padding:40px 0 16px;gap:12px;}
    :root body #screen-store .premium-card {grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);
        width:min(82%,940px);margin:auto;column-gap:16px;row-gap:13px;align-items:center;}
    :root body #screen-store .premium-card h3 {grid-column:1/-1;font-size:26px;}
    .pack-presentation {width:100%;}
    .pack-details {max-width:100%;}
    .pack-purchase {gap:5px;margin-top:5px;}
}
:root body #screen-store .store-toast { width: max-content; max-width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text-primary); }

@media (max-width: 760px) {
    :root body #screen-leaderboard { padding: 70px 18px 30px; }
    :root body #screen-leaderboard .leaderboard-shell { padding: 22px 18px; }
    :root body #screen-leaderboard .leaderboard-tabs { gap: 6px; flex-wrap: wrap; }
}

@media (max-height: 650px) {
    :root body #screen-commissions { padding-top: 64px; }
    :root body #screen-commissions .gallery-heading { margin-bottom: 12px; }
    :root body #screen-commissions .gallery-heading h2 { margin: 0; font-size: 1.75rem; }
    :root body #screen-commissions .gallery-toolbar { padding: 16px 12px; gap: 22px; }
    :root body #screen-commissions .daily-play-note { font-size: .75rem; line-height: 1.4; }
    :root body #screen-commissions .gallery-filters { gap: 6px; }
    :root body #screen-commissions .gallery-filter { padding: 9px 12px; min-height: 44px; }
    :root body #screen-commissions .level-grid { padding-block: 26px; min-height: 0; }
}
@media (max-height: 650px) and (max-width: 600px) {
    :root body #screen-commissions .gallery-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    :root body #screen-commissions .gallery-filter { padding-inline: 6px; font-size: .8rem; }
}

/* In short landscape, keep each window and its label together in the list.
   Portrait retains its roomier artwork and filter spacing. */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 601px) {
    :root body #screen-commissions {
        padding-top: max(66px, calc(env(safe-area-inset-top) + 52px));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    :root body #screen-commissions .gallery-heading {
        position: absolute; top: max(14px, env(safe-area-inset-top));
        left: max(198px, calc(env(safe-area-inset-left) + 180px));
        right: max(78px, calc(env(safe-area-inset-right) + 62px));
        min-height: 44px; margin: 0; display: grid; place-items: center;
    }
    :root body #screen-commissions .gallery-heading h2 { font-size: 1.5rem; line-height: 1.2; }
    :root body #screen-commissions .gallery-toolbar { padding: 8px 12px; gap: 16px; }
    :root body #screen-commissions .gallery-set-control { gap: 10px; }
    :root body #screen-commissions .gallery-set-control select { width: 204px; }
    :root body #screen-commissions .level-grid { padding-block: 12px; gap: 16px; }
    :root body #screen-commissions .level-thumb { height: 100px; aspect-ratio: auto; }
    :root body #screen-commissions .level-thumb-art { width: 78px; height: 78px; }
    :root body #screen-commissions .level-thumb-art.is-mystery { width: 78px; margin-block: 10px; border-width: 5px; }
    :root body #screen-commissions .level-card-info { min-height: 0; gap: 4px; padding: 10px; }
    :root body #screen-commissions .level-card-title { min-height: 0; }
    :root body #screen-commissions .level-card-meta { padding-top: 4px; }
    :root body #screen-commissions .gallery-footer { padding-top: 2px; }
}

/* Arena embeds can be shorter than a phone. Keep scrolling inside each
   screen, with a compact title layout and reachable collection controls. */
:root body:not([data-slice]) { height: 100svh; min-height: 0; overflow: hidden; }
:root body:not([data-slice]) > .screen.active { max-height: 100svh; overflow-y: auto; overscroll-behavior: contain; }
@media (max-height: 650px) {
    :root body #screen-menu .title-scene { padding: 24px; justify-content: center; }
    :root body #screen-menu .title-content { margin: 0; width: min(340px, 100%); text-align: center; }
    :root body #screen-menu .title-content::before { display: none; }
    :root body #screen-menu .title-content h1.wordmark { font-size: 2.8rem; margin: 0 0 16px; text-align: center; }
    :root body #screen-menu .title-actions { width: 100%; gap: 10px; }
    :root body #screen-menu .title-actions button { min-height: 46px; padding-block: 8px; font-size: 1rem; }
    :root body #screen-menu .title-links { margin-top: 10px; width: 100%; }
    :root body #screen-menu .title-links button { min-height: 48px; font-size: .75rem; }
    :root body #screen-menu .title-links .ui-icon { width: 24px; height: 24px; padding: 3px; }









}
@media (max-height: 380px) {
    /* The fixed sound button needs its own lane beside the compact menu,
       including when mobile browser bars shorten the landscape viewport. */
    :root[data-theme] body #screen-menu .title-scene {
        padding-left: max(24px, env(safe-area-inset-left));
        padding-right: max(80px, calc(env(safe-area-inset-right) + 62px));
    }
    :root body #screen-menu .title-content { display: grid; grid-template-columns: 1fr 1.25fr; align-items: center; gap: 8px 20px; width: min(620px, 100%); }
    :root body #screen-menu .title-content h1.wordmark { grid-column: 1; grid-row: 1 / 3; margin: 0; font-size: 2.1rem; }
    :root body #screen-menu .title-actions { grid-column: 2; }
    :root body #screen-menu .title-links { grid-column: 2; margin-top: 0; gap: 8px; }
    :root body #screen-menu .music-credit { grid-column: 1 / -1; margin: 0; }
    :root body #screen-game .restoration-frame { padding: 14px 12px 22px; }
    :root body #screen-game .game-topbar { padding: 0 42px 8px; }
    :root body #screen-game #puzzle-title { font-size: 1.05rem; }
    :root body #screen-game .puzzle-progress { margin-top: 8px; }
    :root body #screen-game .game-controls { margin-top: 10px; }
    :root body #screen-game .game-info { margin-top: 8px; }
}
