/* 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; }
:root body #sound-toggle {
    border: 1px solid var(--metal-bright);
    background: linear-gradient(var(--control-top), var(--control-bottom));
    color: var(--menu-ink); box-shadow: inset 0 1px 0 oklch(98% .02 85 / .3), 0 2px 7px oklch(12% .02 160 / .3);
}
:root body #sound-toggle:hover { background: linear-gradient(var(--control-hover-top), var(--control-hover-bottom)); }

/* 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(#level-progress[hidden]):has(#gallery-scroll-hint[hidden]) { display: none; }
:root body #screen-commissions .level-progress {
    margin: 0; color: inherit; font: 600 .875rem/1.5 var(--font-ui);
    text-transform: none; letter-spacing: 0;
}
: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; }

:root body #screen-store {
    --collection-glow: oklch(52% .12 28 / .33);
    width: 100%; max-width: none; min-height: 100svh; padding: 0; margin: 0;
    color: oklch(96% .035 87);
    background: linear-gradient(90deg, transparent 35%, oklch(15% .025 163 / .32) 72%), url('assets/themes/collection-atelier.svg') center / cover, oklch(19% .026 163);
}
:root body #screen-store[data-collection='heraldic'] { --collection-glow: oklch(52% .10 241 / .35); }
:root body #screen-store[data-collection='floral'] { --collection-glow: oklch(55% .12 151 / .32); }
:root body #screen-store[data-collection='cathedral'] { --collection-glow: oklch(51% .11 267 / .32); }
:root body #screen-store[data-collection='complete'] { --collection-glow: oklch(65% .12 82 / .27); }
:root body #screen-store::before,
:root body #screen-store::after { display: none; }
:root body #screen-store .collection-back {
    position: absolute; top: 14px; left: 22px; z-index: 2; min-height: 44px;
    padding: 8px 12px; background: transparent; box-shadow: none; border: 0;
    color: oklch(94% .035 87); font-size: .9rem;
}
:root body #screen-store .store-balance {
    position: absolute; top: 14px; right: 80px; z-index: 2; margin: 0; padding: 10px 12px;
    border: 0; background: transparent; color: oklch(94% .035 87); font-size: .85rem;
}
.pack-carousel { width: 100%; min-height: 100svh; display: flex; flex-direction: column; outline-offset: -6px; touch-action: pan-y; }
:root body #screen-store .store-packs { display: block; width: 100%; max-width: none; margin: 0; flex: 1; }
:root body #screen-store .premium-card {
    position: relative; display: grid; grid-template-columns: 1.15fr 1fr; align-items: center;
    width: 100%; min-height: calc(100svh - 88px); margin: 0; padding: 82px max(7vw, 48px) 24px;
    border: 0; border-radius: 0; box-shadow: none; overflow: hidden;
    background: radial-gradient(ellipse at 28% 48%, var(--collection-glow), transparent 56%);
    color: inherit; text-align: left; gap: clamp(36px, 6vw, 100px);
}
:root body #screen-store .premium-card[hidden] { display: none; }
.pack-presentation { position: relative; height: min(520px, 65svh); max-width: 610px; width: 100%; justify-self: end; }
.collection-window {
    position: absolute; top: 50%; margin: 0; padding: 7px; aspect-ratio: 1;
    width: 47%; background: linear-gradient(135deg, oklch(91% .075 85), oklch(48% .055 76) 35%, oklch(81% .085 85) 65%, oklch(37% .04 83));
    border: 1px solid oklch(86% .055 88 / .6); box-shadow: 0 18px 35px oklch(8% .02 165 / .6);
}
.collection-window-0 { left: 0; transform: translateY(-36%) rotate(-9deg); }
.collection-window-1 { width: 66%; left: 17%; transform: translateY(-55%); z-index: 1; padding: 10px; }
.collection-window-2 { right: 0; transform: translateY(-36%) rotate(9deg); }
.collection-art { width: 100%; height: 100%; background-size: 100% 100%; background-repeat: no-repeat; background-color: oklch(20% .03 220); border: 2px solid oklch(17% .025 93); }
.pack-details { max-width: 480px; }
:root body #screen-store .pack-count { color: oklch(85% .09 86); font: 600 .84rem/1.5 var(--font-ui); letter-spacing: .08em; margin: 0 0 18px; text-transform: uppercase; }
:root body #screen-store .premium-card h3 { font: 600 clamp(2.3rem, 4vw, 4.1rem)/1.12 'Lora', Georgia, serif; text-align: left; color: oklch(97% .025 89); text-shadow: none; margin: 0 0 23px; letter-spacing: -.035em; }
:root body #screen-store .pack-blurb { font: 400 1rem/1.8 var(--font-body); max-width: 34ch; margin: 0; color: oklch(84% .023 140); }
.pack-purchase { margin-top: 32px; }
:root body #screen-store .pack-buy { display: inline-flex; width: auto; max-width: 100%; min-height: 60px; gap: 22px; padding: 15px 22px; font-size: 1rem; }
.purchase-price { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .94rem; }
.purchase-price .ui-icon { width: 22px; height: 22px; }
:root body #screen-store .pack-ownership { color: oklch(84% .025 140); margin: 18px 0 0; font-size: .77rem; line-height: 1.6; }
:root body #screen-store .pack-save, :root body #screen-store .pack-was { display: block; color: oklch(85% .08 85); font-size: .77rem; margin: 9px 0 0; }
.collection-navigation { display: flex; align-items: center; justify-content: center; gap: 28px; min-height: 88px; padding: 6px 16px 20px; }
:root body #screen-store .collection-navigation > button { width: 48px; height: 48px; min-height: 48px; padding: 12px; border-radius: 50%; }
#pack-next .ui-icon { transform: rotate(180deg); }
.collection-pagination { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#store-position { font: 500 .78rem/1.5 var(--font-ui); letter-spacing: .15em; color: oklch(85% .035 87); }
.pack-dots { display: flex; gap: 0; }
:root body #screen-store .pack-dots button { display: grid; place-items: center; width: 30px; height: 30px; min-height: 30px; 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 oklch(80% .07 85); border-radius: 50%; background: transparent; }
:root body #screen-store .pack-dots button[aria-current]::before { background: oklch(87% .11 85); box-shadow: 0 0 8px oklch(85% .1 85 / .35); }
:root body #screen-store .pack-dots button::after { display: none; }
: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-store .premium-card { grid-template-columns: 1fr; gap: 8px; padding: 64px 24px 14px; min-height: calc(100svh - 80px); align-content: center; }
    .pack-presentation { height: clamp(180px, 31svh, 300px); max-width: 350px; justify-self: center; }
    :root body #screen-store { background-position: 30% center; }
    .collection-window { width: 40%; }
    .collection-window-0 { left: 6%; }
    .collection-window-1 { width: 57%; left: 21.5%; }
    .collection-window-2 { right: 6%; }
    .pack-details { justify-self: center; text-align: center; max-width: 440px; }
    :root body #screen-store .premium-card h3 { text-align: center; font-size: 2rem; margin-bottom: 15px; }
    :root body #screen-store .pack-count { font-size: .73rem; margin-bottom: 10px; }
    :root body #screen-store .pack-blurb { font-size: .86rem; line-height: 1.65; margin-inline: auto; }
    .pack-purchase { margin-top: 20px; }
    :root body #screen-store .pack-buy { min-height: 54px; padding: 12px 15px; font-size: .88rem; gap: 16px; }
    :root body #screen-store .pack-ownership { margin-top: 14px; font-size: .7rem; }
    .collection-navigation { min-height: 80px; gap: 24px; padding-bottom: 12px; }
    :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) and (min-width: 761px) {
    .pack-presentation { height: 360px; }
    :root body #screen-store .premium-card { padding-top: 60px; }
}
@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; }
    :root body #screen-store .premium-card { grid-template-columns: .8fr 1fr; gap: 20px; min-height: calc(100svh - 64px); padding: 64px 24px 12px; }
    :root body #screen-store .pack-presentation { height: 220px; }
    :root body #screen-store .pack-details { text-align: left; }
    :root body #screen-store .premium-card h3 { font-size: 1.7rem; margin-bottom: 12px; text-align: left; }
    :root body #screen-store .pack-blurb { font-size: .8rem; line-height: 1.5; }
    :root body #screen-store .pack-count { margin-bottom: 8px; }
    :root body #screen-store .pack-purchase { margin-top: 16px; }
    :root body #screen-store .pack-buy { min-height: 46px; padding: 9px 12px; gap: 8px; flex-wrap: wrap; font-size: .8rem; }
    :root body #screen-store .collection-navigation { min-height: 64px; padding-bottom: 10px; }
}
@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; }
}

/* Short portrait phones still lead with readable artwork, not a tiny side icon. */
@media (max-width: 600px) and (max-height: 650px) {
    :root body #screen-store .premium-card { grid-template-columns: 1fr; gap: 8px; padding: 64px 18px 12px; align-content: start; }
    :root body #screen-store .pack-presentation { height: clamp(150px, 31svh, 200px); max-width: 260px; }
    :root body #screen-store .pack-details { text-align: center; }
    :root body #screen-store .premium-card h3 { font-size: 1.5rem; text-align: center; margin-bottom: 8px; }
    :root body #screen-store .pack-count { margin-bottom: 6px; font-size: .7rem; }
    :root body #screen-store .pack-blurb { font-size: .78rem; line-height: 1.5; }
    :root body #screen-store .pack-purchase { margin-top: 12px; }
    :root body #screen-store .pack-ownership { margin-top: 8px; }
}
/* Equal label sizes for the three menu actions; gold still identifies Play. */
:root[data-theme='garden'] body #screen-menu :is(.title-actions button, #store-button) { font-size: 1.25rem; }
@media (max-width: 700px) {
    :root[data-theme='garden'] body #screen-menu :is(.title-actions button, #store-button) { font-size: 1.12rem; }
}
@media (max-height: 650px) {
    :root[data-theme='garden'] body #screen-menu :is(.title-actions button, #store-button) { font-size: 1rem; }
}
