@layer reset, tokens, base, layout, components, states, responsive, motion;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { height: 100%; overflow: hidden; }
  * { scrollbar-width: none; }
  *::-webkit-scrollbar { display: none; }
  body, h1, h2, h3, p { margin: 0; }
  button, input, select { font: inherit; }
  button { color: inherit; }
  img, svg { display: block; max-width: 100%; }
  [hidden] { display: none !important; }
}

@layer tokens {
  :root {
    --ink-950: #080810;
    --ink-900: #0e0e18;
    --ink-850: #15151f;
    --ink-800: #1b1b27;
    --ink-700: #292936;
    --paper: #f1e4c5;
    --paper-dim: #cbbb9b;
    --paper-dark: #302a24;
    --blood: #bd3e3c;
    --blood-bright: #ee6258;
    --amber: #e9b65c;
    --amber-soft: #f4d390;
    --green: #74c69d;
    --muted: #a7a3ad;
    --focus: #ffd477;
    --danger: #ff6b63;
    --border: rgba(241, 228, 197, .16);
    --shadow: 0 20px 50px rgba(0, 0, 0, .35);
    --radius: 18px;
    --serif: Georgia, "Times New Roman", serif;
    --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --cabinet-art-size: 100px;
    --cabinet-card-min: 138px;
    --cabinet-column-min: 132px;
  }
}

@layer base {
  html { background: var(--ink-950); color: var(--paper); font-family: var(--sans); }
  body {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
    background:
      radial-gradient(circle at 55% -10%, rgba(189, 62, 60, .12), transparent 30rem),
      linear-gradient(145deg, var(--ink-950), #111019 55%, #090910);
  }
  body::before {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
    background: repeating-linear-gradient(90deg, transparent 0 11.9%, rgba(255,255,255,.012) 12%);
  }
  button, input, select { min-height: 44px; }
  button { cursor: pointer; }
  button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--focus); outline-offset: 3px;
  }
  h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.025em; }
  h1 { font-size: clamp(1.3rem, 3vw, 1.9rem); line-height: 1; }
  h2 { font-size: clamp(1.5rem, 4vw, 2.15rem); line-height: 1.08; }
  h3 { font-size: 1.2rem; }
  .eyebrow { color: var(--amber); font-size: .67rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
  .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .skip-link { position: fixed; z-index: 100; top: .5rem; left: .5rem; min-height: 44px; transform: translateY(-150%); padding: .75rem 1rem; color: var(--ink-950); background: var(--focus); font-weight: 800; border-radius: 8px; }
  .skip-link:focus { transform: translateY(0); }
  .grain { position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: .18; mix-blend-mode: soft-light; background-image: radial-gradient(rgba(255,255,255,.2) .5px, transparent .7px); background-size: 5px 5px; }
  .noscript { margin: 2rem; padding: 1rem; border: 2px solid var(--danger); background: var(--ink-800); }
}

@layer layout {
  .topbar { min-height: 78px; padding: 1rem clamp(1rem, 3vw, 2.5rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); }
  .brand { display: flex; align-items: center; gap: .8rem; min-width: 0; }
  .brand-mark { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border: 1px solid var(--blood-bright); color: var(--blood-bright); font-family: var(--serif); font-weight: 900; font-size: .78rem; transform: rotate(-2deg); box-shadow: inset 0 0 0 3px var(--ink-950), inset 0 0 0 4px rgba(238,98,88,.4); }
  .brand .eyebrow { margin-bottom: .2rem; }
  .header-actions { display: flex; align-items: center; gap: .55rem; }
  .film-counter { white-space: nowrap; font-family: var(--serif); color: var(--amber-soft); }
  .film-counter span:first-child { font-size: 1.3rem; font-weight: 800; }
  .workspace-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--border); }
  .view-tabs { align-self: stretch; display: flex; flex: 0 0 auto; gap: .25rem; }
  main { width: 100%; min-width: 0; min-height: 0; overflow: hidden; }
  .game-layout { display: grid; grid-template-columns: clamp(300px, 25vw, 360px) minmax(0, 1fr); height: 100%; min-height: 0; }
  .collection-panel { position: relative; align-self: stretch; min-width: 0; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: clamp(1rem, 2vw, 1.5rem); padding-top: clamp(1.1rem, 3vw, 2.5rem); border-right: 1px solid var(--border); background: linear-gradient(160deg, rgba(35,32,38,.94), rgba(14,14,24,.96)); box-shadow: 20px 0 50px rgba(0,0,0,.12); }
  .laboratory-panel { display: flex; flex-direction: column; height: 100%; min-width: 0; min-height: 0; overflow: hidden; padding: clamp(1.1rem, 3vw, 2.5rem); }
  .laboratory-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: .5rem; min-width: 0; }
  .section-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
  .collection-tools, .gallery-tools { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; }
  .collection-panel .collection-tools { display: grid; gap: .55rem; }
  .filter-group { display: flex; flex-wrap: wrap; gap: .35rem; overflow-x: auto; padding: 3px; }
  .item-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; padding: .4rem .2rem 1rem; }
  .gallery-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; padding: clamp(1rem, 4vw, 3rem); }
  .gallery-hero { flex: 0 0 auto; min-height: 120px; display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding: clamp(1.25rem, 4vw, 3rem); margin-bottom: 1.25rem; border: 1px solid rgba(233,182,92,.35); background: radial-gradient(circle at 85% 50%, rgba(233,182,92,.12), transparent 28%), linear-gradient(135deg, #271013, #17141d 55%, #101018); box-shadow: var(--shadow); }
  .gallery-hero h2 { font-size: clamp(2rem, 8vw, 4.5rem); margin: .2rem 0 .5rem; }
  .gallery-hero > div > p:last-child { max-width: 55ch; color: var(--paper-dim); }
  /* The viewport may shrink, but each scrollable row must fit its poster and caption. */
  .poster-grid { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: .4rem .25rem 1rem; align-content: start; display: grid; grid-auto-rows: max-content; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: clamp(.8rem, 2vw, 1.4rem); }
}

@layer components {
  .icon-button { width: 44px; border: 1px solid var(--border); border-radius: 50%; background: var(--ink-800); font-weight: 850; }
  .icon-button:hover { border-color: var(--amber); color: var(--amber); }
  .icon-button svg { width: 20px; height: 20px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab { min-height: 53px; padding: 0 1rem; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 750; }
  .tab:hover { color: var(--paper); }
  .tab.is-active { border-bottom-color: var(--blood-bright); color: var(--paper); }
  .tab #tab-movie-count { margin-left: .3rem; color: var(--amber); font-size: .76em; }
  .count-pill { padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--paper-dim); font-size: .75rem; white-space: nowrap; }
  .search-field { min-width: min(270px, 100%); min-height: 46px; display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--ink-850); }
  .search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(255,212,119,.18); }
  .search-field svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; color: var(--muted); }
  .search-field input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--paper); background: transparent; }
  .search-field input::placeholder { color: #8e8994; }
  .filter-chip { min-width: 44px; min-height: 44px; padding: .3rem .75rem; border: 1px solid var(--border); border-radius: 999px; color: var(--paper-dim); background: transparent; font-size: .78rem; font-weight: 750; white-space: nowrap; }
  .filter-chip:hover, .filter-chip.is-active { color: var(--ink-950); border-color: var(--paper); background: var(--paper); }
  .filter-count { min-width: 1.35rem; height: 1.35rem; display: inline-grid; place-items: center; margin-left: .25rem; padding: 0 .25rem; border-radius: 999px; color: var(--paper); background: var(--blood); font-size: .68rem; line-height: 1; }
  .filter-chip.is-active .filter-count, .filter-chip:hover .filter-count { color: #fff8e8; }
  .item-card { position: relative; min-width: 0; min-height: var(--cabinet-card-min); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: .45rem .3rem; border: 1px solid transparent; border-radius: 13px; color: var(--paper); background: transparent; box-shadow: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
  .item-card:hover { transform: translateY(-2px); background: rgba(241,228,197,.055); }
  .item-card .item-icon { width: var(--cabinet-art-size); height: var(--cabinet-art-size); display: grid; place-items: center; touch-action: none; }
  .item-card .item-icon svg { width: 100%; height: 100%; overflow: visible; pointer-events: none; }
  .element-art-frame { position: relative; width: 100%; height: 100%; display: block; overflow: hidden; pointer-events: none; user-select: none; }
  .element-art { position: absolute; top: var(--atlas-top); left: var(--atlas-left); width: var(--atlas-width); height: var(--atlas-height); max-width: none; pointer-events: none; user-select: none; }
  .poster-atlas-frame { position: relative; width: 100%; aspect-ratio: 2 / 3; display: block; overflow: hidden; pointer-events: none; user-select: none; }
  .poster-atlas { position: absolute; top: var(--poster-atlas-top); left: var(--poster-atlas-left); width: var(--poster-atlas-width); height: var(--poster-atlas-height); max-width: none; pointer-events: none; user-select: none; }
  .poster-source { width: 100%; height: 100%; display: block; object-fit: cover; pointer-events: none; user-select: none; }
  .item-label { max-width: 100%; font-size: .78rem; font-weight: 740; line-height: 1.12; text-align: center; overflow-wrap: anywhere; pointer-events: none; }
  .new-badge { position: absolute; top: -6px; right: -5px; padding: .18rem .32rem; border-radius: 4px; color: #250c0d; background: var(--blood-bright); font-size: .55rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; transform: rotate(3deg); pointer-events: none; }
  .lab-new-badge { top: .25rem; right: auto; left: .25rem; }
  .cabinet-heading-actions { display: flex; align-items: center; gap: .4rem; }
  .cabinet-close, .cabinet-toggle { display: none; }
  .cabinet-filter-row { display: flex; align-items: center; gap: .35rem; }
  .cabinet-filter-row .filter-group { flex: 0 0 auto; flex-wrap: nowrap; padding-inline: 0; }
  .cabinet-filter-row .cabinet-add { flex: 1; min-width: 0; min-height: 44px; margin: 0; padding: .3rem .4rem; font-size: .7rem; line-height: 1.2; }
  .laboratory-canvas { position: relative; flex: 1 1 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; border: 1px solid rgba(241,228,197,.2); border-radius: var(--radius); background: #0c0c14; box-shadow: inset 0 0 70px rgba(0,0,0,.5), var(--shadow); isolation: isolate; scrollbar-color: rgba(233,182,92,.45) rgba(14,14,24,.7); }
  .laboratory-stage { position: relative; width: 100%; min-height: max(100%, 300px); background: radial-gradient(circle at 50% 18rem, rgba(233,182,92,.07), transparent 28rem), linear-gradient(rgba(241,228,197,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(241,228,197,.035) 1px, transparent 1px); background-size: auto, 36px 36px, 36px 36px; }
  .laboratory-stage::before { content: ""; position: absolute; z-index: 1; inset: 1rem; pointer-events: none; border: 1px dashed rgba(241,228,197,.09); border-radius: calc(var(--radius) - 5px); }
  .laboratory-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 2rem; color: var(--muted); text-align: center; }
  .lab-item { position: absolute; z-index: 2; width: 116px; transform: translate(-50%, -50%); }
  .lab-specimen { position: relative; width: 100%; min-height: 134px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; padding: .4rem .25rem; border: 1px solid transparent; border-radius: 16px; color: var(--paper); background: rgba(14,14,24,.52); touch-action: none; user-select: none; -webkit-user-select: none; }
  .lab-specimen:hover { border-color: rgba(241,228,197,.25); background: rgba(35,32,38,.8); }
  .lab-item-art { width: 100px; height: 100px; display: block; }
  .lab-item-label { max-width: 100%; font-size: .78rem; font-weight: 780; line-height: 1.1; text-align: center; overflow-wrap: anywhere; pointer-events: none; }
  .lab-remove { position: absolute; z-index: 3; top: -10px; right: -10px; width: 44px; padding: 0; border: 1px solid var(--border); border-radius: 50%; color: var(--paper-dim); background: var(--ink-800); font-size: 1.2rem; opacity: 0; pointer-events: none; }
  .lab-item:hover .lab-remove, .lab-remove:focus-visible, .lab-item.is-selected .lab-remove { opacity: 1; pointer-events: auto; }
  .primary-button, .secondary-button, .danger-button { min-height: 44px; padding: .65rem 1rem; border-radius: 8px; font-weight: 800; }
  .primary-button { border: 1px solid var(--blood-bright); color: #fff8e8; background: var(--blood); box-shadow: 0 8px 18px rgba(189,62,60,.2); }
  .primary-button:hover { background: #d24946; }
  .secondary-button { border: 1px solid var(--border); color: var(--paper); background: var(--ink-700); }
  .secondary-button:hover { border-color: var(--amber); }
  .secondary-button:disabled { cursor: default; opacity: .45; }
  .danger-button { border: 1px solid rgba(255,107,99,.6); color: var(--danger); background: rgba(189,62,60,.08); }
  .recipe-origin { flex: 0 1 auto; min-height: 0; max-height: 20%; overflow-y: auto; overscroll-behavior: contain; margin-top: .75rem; padding: .7rem .8rem; border-left: 3px solid var(--amber); color: var(--paper-dim); background: rgba(233,182,92,.06); font-size: .75rem; line-height: 1.4; }
  .recipe-origin strong { color: var(--paper); }
  .hint-card { flex: 0 0 clamp(270px, 30vw, 370px); height: 3.75rem; min-width: 270px; display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem .4rem .65rem; border: 1px solid rgba(233,182,92,.25); border-radius: 10px; background: linear-gradient(145deg, rgba(233,182,92,.08), transparent); }
  .hint-copy { min-width: 0; height: 100%; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .hint-copy .eyebrow { font-size: .58rem; letter-spacing: .1em; }
  .hint-copy #hint-text { min-height: 0; flex: 1; margin-top: .2rem; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; color: var(--paper-dim); font-size: .7rem; line-height: 1.3; overflow-wrap: anywhere; }
  .hint-button { flex: 0 0 44px; color: var(--amber-soft); }
  .laboratory-clear { flex: 0 0 44px; align-self: center; border-radius: 10px; color: var(--paper-dim); }
  .laboratory-clear:hover { border-color: var(--danger); color: var(--danger); }
  .laboratory-clear:disabled { cursor: default; opacity: .45; }
  .empty-state { padding: 3rem 1rem; color: var(--muted); text-align: center; }
  .marquee-count { flex: 0 0 120px; aspect-ratio: 1; display: grid; place-content: center; border: 1px solid var(--amber); border-radius: 50%; color: var(--amber-soft); text-align: center; box-shadow: 0 0 40px rgba(233,182,92,.08); }
  .marquee-count strong { font-family: var(--serif); font-size: 2.7rem; line-height: .9; }
  .marquee-count span { margin-top: .25rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; }
  .select-field { display: flex; align-items: center; gap: .5rem; color: var(--paper-dim); font-size: .76rem; font-weight: 750; }
  select, .select-trigger {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23cbbb9b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    background-size: 12px 8px;
  }
  select:focus-visible, .select-trigger:focus-visible { outline: 2px solid var(--paper-dim); outline-offset: 2px; }
  .select-field select, .select-trigger, .setting-row select { padding: 0 2.3rem 0 .7rem; border: 1px solid var(--border); border-radius: 8px; color: var(--paper); background-color: var(--ink-800); }
  .select-trigger { text-align: left; box-shadow: none; cursor: pointer; }
  .era-field .select-trigger { min-width: 10rem; }
  .select-trigger, .select-options { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .select-trigger:hover, .select-trigger[aria-expanded="true"] { border-color: var(--paper-dim); background-color: var(--ink-700); }
  .select-options { position: fixed; z-index: 80; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; color: var(--paper); background: var(--ink-800); box-shadow: 0 12px 28px rgba(0,0,0,.45); font-size: .85rem; }
  .select-options [role="option"] { position: relative; min-height: 44px; display: flex; align-items: center; padding: .6rem 2rem .6rem .65rem; border-radius: 4px; cursor: pointer; }
  .select-options [role="option"]:hover, .select-options .is-active { background: var(--ink-700); }
  .select-options [aria-selected="true"]::after { content: "✓"; position: absolute; right: .65rem; color: var(--paper-dim); }
  #mode-select-options { font-family: var(--serif); font-size: 1rem; }
  #language-select-options { font-size: .75rem; font-weight: 800; }
  .poster-card { min-width: 0; border: 0; padding: 0; color: var(--paper); background: transparent; text-align: left; }
  .poster-art { position: relative; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: .65rem; color: #f3e4c7; background: #0b0b12; box-shadow: 0 12px 30px rgba(0,0,0,.42); isolation: isolate; }
  .poster-art > .poster-atlas-frame { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
  .poster-art::before { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(to bottom, transparent 48%, rgba(5,5,10,.52) 70%, rgba(5,5,10,.94) 100%); }
  .poster-art::after { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; box-shadow: inset 0 -3rem 3rem -2.4rem rgba(0,0,0,.9); }
  .poster-billing { position: relative; z-index: 2; }
  .poster-title { font-family: var(--serif); font-size: clamp(.9rem, 2.2vw, 1.25rem); font-weight: 900; line-height: .88; text-transform: uppercase; overflow-wrap: anywhere; text-wrap: balance; text-shadow: 0 2px 7px #000, 0 1px 1px #000; }
  .poster-title-1 { letter-spacing: .08em; line-height: 1; }
  .poster-title-2 { max-width: 82%; padding-left: .35rem; border-left: 4px solid #d5544c; font-family: var(--sans); }
  .poster-title-3 { text-align: center; font-style: italic; }
  .poster-title-4 { color: #e56a5d; }
  .poster-year { margin-top: .35rem; font-size: .6rem; letter-spacing: .12em; text-shadow: 0 1px 4px #000; }
  .poster-card > .poster-caption { display: block; padding: .55rem .2rem 0; }
  .poster-caption strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
  .poster-caption span { color: var(--muted); font-size: .7rem; }
  .poster-caption .poster-recipe { display: -webkit-box; margin-top: .3rem; overflow: hidden; color: var(--paper-dim); font-size: .62rem; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .poster-card:hover .poster-art { transform: translateY(-5px) rotate(-.5deg); border-color: var(--amber); }
  .poster-locked { min-width: 0; aspect-ratio: 2/3; position: relative; display: grid; place-content: center; gap: .4rem; border: 1px dashed rgba(241,228,197,.22); color: #aaa4b0; background: repeating-linear-gradient(-45deg, #13131c 0 9px, #171721 9px 18px); text-align: center; }
  .poster-locked span:first-child { font-family: var(--serif); font-size: 2rem; }
  .poster-locked span:last-child { font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; }
  .item-locked { cursor: default; color: #8f8b95; background: transparent; }
  .item-locked .item-icon { font-family: var(--serif); font-size: 2rem; color: #77727e; }
  .drag-ghost { position: fixed; z-index: 80; width: 104px; min-height: 104px; pointer-events: none; transform: translate(-50%, -50%) rotate(3deg); opacity: .92; }
  .drag-ghost .item-card, .drag-ghost .lab-specimen { box-shadow: 0 18px 40px rgba(0,0,0,.5); border-color: var(--amber); background: var(--ink-700); }
  .drag-ghost .item-card { min-height: 120px; }
  .drag-ghost .item-icon, .drag-ghost .lab-item-art { width: 82px; height: 82px; }
  .toast-region { position: fixed; z-index: 99; left: 50%; bottom: 1rem; width: min(92vw, 430px); transform: translateX(-50%); pointer-events: none; }
  .toast { padding: .8rem 1rem; border: 1px solid var(--amber); border-radius: 10px; color: var(--paper); background: #24212a; box-shadow: var(--shadow); text-align: center; font-weight: 720; }
  dialog { max-width: min(92vw, 650px); max-height: min(90dvh, 800px); overflow: auto; padding: 0; border: 1px solid rgba(241,228,197,.25); color: var(--paper-dark); background: var(--paper); box-shadow: 0 30px 90px rgba(0,0,0,.65); }
  dialog::backdrop { background: rgba(3,3,8,.78); backdrop-filter: blur(5px); }
  dialog form { position: relative; padding: clamp(1.3rem, 5vw, 2.5rem); }
  .dialog-close { position: absolute; z-index: 5; top: .5rem; right: .5rem; width: 44px; border: 0; border-radius: 50%; color: var(--paper-dark); background: transparent; font-size: 1.8rem; }
  .dialog-close.light { color: var(--paper); }
  dialog .eyebrow { color: #7b2a29; }
  dialog h2 { margin: .25rem 2rem 1rem 0; font-size: clamp(1.8rem, 6vw, 3rem); }
  .onboarding-steps { display: grid; gap: .75rem; margin: 1.3rem 0; }
  .onboarding-steps > div { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: .6rem; padding: .7rem; border-top: 1px solid rgba(48,42,36,.2); }
  .onboarding-steps > div > span { font-family: var(--serif); font-size: 1.3rem; color: #942f30; }
  .onboarding-steps p { line-height: 1.45; }
  .onboarding-toolbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; padding-block: .25rem; background: var(--paper); }
  .onboarding-toolbar .dialog-close { position: static; flex: 0 0 44px; }
  .onboarding-language { display: flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 750; }
  .onboarding-language > span { margin-right: .25rem; }
  .onboarding-language button { min-width: 44px; border: 1px solid rgba(48,42,36,.3); border-radius: 8px; color: var(--paper-dark); background: transparent; font-size: .75rem; font-weight: 800; }
  .onboarding-language button:hover { background: rgba(48,42,36,.08); }
  .onboarding-language button[aria-pressed="true"] { color: var(--paper); background: var(--ink-800); border-color: var(--ink-800); }
  #onboarding-title { margin-right: 0; font-size: clamp(1.65rem, 5vw, 2.4rem); }
  #onboarding-dialog .onboarding-steps { gap: .4rem; margin-block: .8rem; font-size: .85rem; }
  #onboarding-dialog .onboarding-steps > div { grid-template-columns: 28px minmax(0, 1fr); align-items: start; padding: .65rem 0; }
  .fine-print { margin: 1rem 0; font-size: .77rem; line-height: 1.45; opacity: .75; }
  .poster-dialog { width: min(94vw, 590px); max-height: min(94dvh, 900px); color: var(--paper); background: var(--ink-850); }
  .poster-dialog form { display: flex; flex-direction: column; align-items: center; gap: clamp(.8rem, 2.4vw, 1.2rem); padding: clamp(.75rem, 2.5vw, 1.35rem); }
  .poster-dialog .dialog-close { position: sticky; align-self: flex-end; flex: 0 0 44px; top: .7rem; right: auto; margin-bottom: -44px; color: var(--paper); background: rgba(5,5,10,.7); backdrop-filter: blur(4px); }
  .poster-dialog-art { width: min(100%, 420px); }
  .poster-image-status { position: absolute; z-index: 2; inset: 10% 1rem 25%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; color: var(--paper-dim); text-align: center; font-size: .85rem; }
  .poster-art[data-image-state="loading"], .poster-art[data-image-state="error"] { border: 1px solid var(--border); background: var(--ink-900); }
  .poster-image-retry { min-width: 100px; }
  .poster-image-retry[aria-disabled="true"] { opacity: .55; cursor: wait; }
  .poster-dialog-art .poster-title { font-size: clamp(1.25rem, 3.5vw, 2rem); }
  .poster-dialog-copy { width: min(100%, 420px); display: grid; gap: .8rem; text-align: center; }
  .poster-dialog-copy > p { margin: 0; color: var(--paper-dim); line-height: 1.5; text-wrap: balance; }
  .poster-dialog-copy > .poster-dialog-recipe { padding-top: .65rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .68rem; line-height: 1.4; }
  .tag-list { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; padding: 0; margin: 0; list-style: none; }
  .tag-list li { min-height: 32px; display: grid; place-items: center; padding: .3rem .35rem; border: 1px solid var(--border); border-radius: 999px; color: var(--amber-soft); font-size: .66rem; line-height: 1.15; overflow-wrap: anywhere; }
  .setting-row { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-top: 1px solid rgba(48,42,36,.2); }
  .setting-row span { display: grid; gap: .15rem; }
  .setting-row small { max-width: 36ch; opacity: .7; }
  .setting-row input[type="checkbox"] { width: 44px; min-height: 44px; accent-color: var(--blood); }
  .setting-row select { color: var(--paper-dark); border-color: rgba(48,42,36,.3); background: rgba(255,255,255,.25); }
  .save-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }
  .stacked { flex-direction: column; }
}

@layer states {
  .item-card.is-selected { border-color: transparent; background: rgba(233,182,92,.1); box-shadow: 0 0 0 3px var(--amber); }
  .item-card.is-dragging { opacity: .25; }
  .lab-item.is-dragging { opacity: .22; }
  .lab-item.is-selected .lab-specimen { border-color: var(--amber); box-shadow: 0 0 0 4px rgba(233,182,92,.24); background: rgba(233,182,92,.09); }
  .lab-item.is-reacting .lab-specimen { border-color: var(--amber-soft); box-shadow: 0 0 0 5px rgba(233,182,92,.3), 0 0 38px rgba(233,182,92,.16); }
  .lab-item.is-drop-target .lab-specimen { border-color: var(--green); box-shadow: 0 0 0 5px rgba(116,198,157,.25); }
  .lab-item.is-invalid-target .lab-specimen { border-color: var(--danger); box-shadow: 0 0 0 5px rgba(255,107,99,.2); }
  .laboratory-canvas.is-drag-over { border-color: rgba(233,182,92,.6); }
  body[data-motion="reduced"] *, body[data-motion="reduced"] *::before, body[data-motion="reduced"] *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@layer responsive {
  @media (max-width: 850px) {
    .game-layout { display: block; position: relative; }
    .laboratory-panel { padding: 1.25rem; }
    .laboratory-actions { max-width: 390px; }
    .cabinet-toggle, .cabinet-close { display: inline-grid; place-items: center; }
    .collection-panel { position: absolute; z-index: 45; inset: 0 auto 0 0; width: min(360px, calc(100% - 64px)); height: 100%; max-height: none; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); border: 1px solid var(--border); border-width: 0 1px 0 0; background: var(--ink-900); box-shadow: 24px 0 60px rgba(0,0,0,.5); transform: translateX(-102%); transition: transform .22s ease; }
    .collection-panel.is-open { transform: translateX(0); }
    .collection-panel .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .collection-panel .section-heading { display: grid; grid-template-columns: minmax(0, 1fr) 44px; }
    .cabinet-heading-actions { display: contents; }
    .cabinet-heading-actions .count-pill { grid-column: 1; grid-row: 2; justify-self: start; }
    .cabinet-close { grid-column: 2; grid-row: 1; }
    .poster-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
  }
  @media (max-width: 600px) {
    :root { --cabinet-art-size: 68px; --cabinet-card-min: 104px; }
    .topbar { min-height: 66px; padding: .7rem .8rem; }
    .brand-mark { display: none; }
    .brand .eyebrow { display: none; }
    .film-counter { font-size: .7rem; }
    .view-tabs { padding: 0 .55rem; }
    .tab { flex: 1; padding: 0 .45rem; font-size: .78rem; }
    .collection-panel { padding: .9rem .7rem calc(.9rem + env(safe-area-inset-bottom)); }
    .section-heading { margin-bottom: .7rem; }
    .collection-tools { display: grid; gap: .45rem; }
    .search-field { width: 100%; }
    .item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; padding-inline: 0; }
    .item-card { padding-inline: .15rem; }
    .item-label { font-size: .7rem; }
    .laboratory-panel { padding: 1rem .7rem; }
    .laboratory-actions { display: grid; grid-template-columns: minmax(0, 1fr) 44px; max-width: none; }
    .laboratory-actions .cabinet-toggle { grid-column: 1; grid-row: 1; justify-self: start; padding-inline: .75rem; font-size: .7rem; }
    .laboratory-actions .hint-card { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; }
    .laboratory-actions .laboratory-clear { grid-column: 2; grid-row: 1; }
    .lab-item { width: 94px; }
    .lab-specimen { min-height: 112px; }
    .lab-item-art { width: 80px; height: 80px; }
    .lab-item-label { font-size: .7rem; }
    .lab-remove { display: none; }
    .gallery-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; padding: .7rem; }
    .gallery-hero { min-height: 138px; padding: 1rem; gap: 1rem; }
    .gallery-hero h2 { font-size: 2rem; }
    .gallery-hero > div > p:last-child { font-size: .75rem; }
    .marquee-count { flex-basis: 86px; }
    .marquee-count strong { font-size: 2rem; }
    .gallery-tools { display: grid; align-items: stretch; }
    .select-field { justify-content: space-between; }
    .poster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
    .poster-dialog { width: min(96vw, 590px); }
  }
  @media (max-width: 360px) {
    .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .header-actions { gap: .2rem; }
    .icon-button { width: 44px; }
  }
}

@layer motion {
  .item-card, .lab-item, .lab-specimen, .lab-remove, .poster-art, .laboratory-canvas { transition: transform .16s ease, border-color .16s ease, background .16s ease, opacity .16s ease, box-shadow .16s ease; }
  .item-card.is-new { animation: arrive .6s cubic-bezier(.2,.8,.2,1) both; }
  .lab-item.is-rejected { animation: reaction-failed .42s ease both; }
  .lab-item.is-reacting .lab-specimen { animation: reaction-ready .7s ease-in-out infinite alternate; }
  .poster-dialog[open] .poster-art { animation: poster-reveal .7s cubic-bezier(.16,.9,.24,1) both; }
  .toast { animation: toast-in .25s ease both; }
  @keyframes arrive { 0% { opacity: 0; transform: translateY(14px) scale(.9); } 70% { transform: translateY(-3px) scale(1.03); } }
  @keyframes reaction-failed { 20%, 60% { margin-left: -7px; } 40%, 80% { margin-left: 7px; } }
  @keyframes reaction-ready { to { filter: brightness(1.18); } }
  @keyframes poster-reveal { from { opacity: 0; transform: perspective(700px) rotateY(-16deg) translateY(18px); filter: brightness(2); } }
  @keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  }
}

@layer components {
  .language-field { flex: 0 0 auto; }
  .collection-panel { padding-top: 1.1rem; }
  .collection-panel .section-heading { gap: .5rem; align-items: center; }
  .collection-panel .section-heading > div:first-child { flex: 1; min-width: 0; }
  .collection-panel .section-heading h2 { font-size: clamp(1.3rem, 2.1vw, 1.75rem); }
  .collection-panel .count-pill { font-size: .65rem; padding: .3rem .45rem; }
  .collection-panel .eyebrow { font-size: .58rem; letter-spacing: .1em; }
  .language-field :is(select, .select-trigger) { width: 4.3rem; font-size: .75rem; font-weight: 800; cursor: pointer; }
  .cinema-program { display: flex; align-items: center; gap: 1.5rem; padding: .65rem clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid var(--border); background: linear-gradient(100deg, rgba(233,182,92,.05), transparent 70%); }
  .program-choice { flex: 0 0 auto; display: grid; gap: .3rem; }
  .mode-field :is(select, .select-trigger) { min-width: 15rem; max-width: 100%; color: var(--paper); font-family: var(--serif); font-size: 1rem; font-weight: 700; cursor: pointer; }
  .program-copy { display: grid; gap: .25rem; max-width: 48rem; }
  .program-copy > p:first-child { font-size: .82rem; color: var(--paper); line-height: 1.4; }
  .program-copy .fine-print { margin: 0; color: var(--muted); font-size: .72rem; }
}

@layer responsive {
  @media (max-height: 800px) {
    .lab-item { width: 94px; }
    .lab-item-art { width: 80px; height: 80px; }
    .lab-specimen { min-height: 112px; }
    .collection-panel { --cabinet-art-size: 64px; --cabinet-card-min: 94px; }
    .collection-panel .filter-chip { padding-inline: .5rem; font-size: .72rem; }
    .collection-panel .cabinet-add { font-size: .72rem; padding-inline: .4rem; }
  }
  @media (max-width: 850px), (max-height: 700px) {
    .topbar { min-height: 56px; padding-block: .35rem; }
    .brand .eyebrow { display: none; }
    .cinema-program { padding-block: .35rem; }
    .program-choice > .eyebrow, .program-copy {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    }
    .tab { min-height: 44px; }
    .laboratory-panel { padding: .7rem; }
    .recipe-origin { margin-top: .45rem; padding: .4rem .6rem; font-size: .7rem; }
    .gallery-panel { padding: .7rem; }
    .gallery-hero { min-height: 0; padding: .8rem 1rem; margin-bottom: .65rem; gap: 1rem; }
    .gallery-hero h2 { font-size: 2rem; }
    .gallery-hero > div > p:last-child { display: none; }
    .marquee-count { flex-basis: 76px; }
    .marquee-count strong { font-size: 2rem; }
    .gallery-tools { flex: 0 0 auto; margin-bottom: .6rem; }
  }
  @media (max-width: 600px) {
    .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px 44px; gap: .3rem; padding-inline: .65rem; }
    .topbar h1 { font-size: 1.08rem; line-height: 1.1; }
    .header-actions { display: contents; }
    .film-counter { display: none; }
    .language-field :is(select, .select-trigger) { width: 4rem; padding-left: .6rem; }
    .cinema-program { padding-inline: .65rem; }
    .program-choice, .mode-field, .mode-field :is(select, .select-trigger) { width: 100%; min-width: 0; }
    .laboratory-actions { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr) 44px; max-width: none; gap: .4rem; }
    .laboratory-actions .cabinet-toggle { grid-column: 1; grid-row: 1; padding-inline: .6rem; }
    .laboratory-actions .laboratory-clear { grid-column: 3; grid-row: 1; }
    .laboratory-actions .hint-card { grid-column: 2; grid-row: 1; min-width: 0; width: 100%; height: 60px; padding: .25rem; gap: .2rem; border-color: var(--border); }
    .hint-copy .eyebrow { display: none; }
    .hint-copy #hint-text { margin: 0; font-size: .66rem; }
    .gallery-tools { display: flex; flex-wrap: wrap; gap: .45rem; }
    .gallery-tools .search-field { flex: 1 1 100%; }
    .gallery-tools .select-field { width: 100%; }
    .gallery-hero h2 { font-size: 1.65rem; }
  }
  @media (max-height: 700px) {
    .collection-panel { padding: .85rem; }
    .collection-panel .eyebrow { display: none; }
    .section-heading { margin-bottom: .65rem; gap: .5rem; }
    .section-heading h2 { font-size: 1.6rem; }
    .collection-tools { margin-bottom: .5rem; }
    .cabinet-add { font-size: .75rem; padding-inline: .4rem; }
    .lab-item { width: 88px; }
    .lab-item-art { width: 64px; height: 64px; }
    .lab-specimen { min-height: 96px; }
    .laboratory-stage { min-height: max(100%, 260px); }
  }
  @media (max-height: 520px) and (min-width: 601px) {
    body { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr); }
    .topbar { grid-column: 1; min-width: 0; padding-inline: .65rem; gap: .5rem; }
    .topbar h1 { font-size: 1.15rem; }
    .brand-mark, .film-counter { display: none; }
    .header-actions { gap: .3rem; }
    .cinema-program { grid-column: 2; padding-inline: .65rem; }
    .mode-field :is(select, .select-trigger) { min-width: 0; width: 15rem; font-size: .85rem; }
    .workspace-toolbar, main { grid-column: 1 / -1; }
    .laboratory-panel { padding: .4rem .65rem; }
    .laboratory-actions { flex: 1; max-width: none; justify-content: space-between; }
    .hint-card { flex: 1; min-width: 0; max-width: 440px; height: 44px; padding-block: 0; }
    .hint-copy .eyebrow { display: none; }
    .lab-item { width: 80px; }
    .lab-item-art { width: 44px; height: 44px; }
    .lab-specimen { min-height: 76px; }
    .laboratory-stage { min-height: max(100%, 200px); }
    .recipe-origin { margin-top: .3rem; padding-block: .2rem; }
    .gallery-hero { padding-block: .4rem; }
    .gallery-hero h2 { font-size: 1.5rem; margin: .15rem 0; }
    .marquee-count { flex-basis: 54px; }
    .marquee-count strong { font-size: 1.4rem; }
    .marquee-count span { font-size: .5rem; }
  }
  @media (forced-colors: active) {
    select { appearance: auto; background-image: none; }
  }
}

@layer responsive {
  .workspace-toolbar .tab { min-height: 44px; }
  .workspace-toolbar .laboratory-actions { flex: 0 1 520px; display: flex; justify-content: flex-end; gap: .5rem; }
  .workspace-toolbar .hint-card { flex: 1; min-width: 0; max-width: 440px; height: 52px; padding: .2rem .3rem .2rem .65rem; }
  .workspace-toolbar .hint-copy { justify-content: center; height: auto; max-height: 100%; }
  .workspace-toolbar #hint-text { margin: 0; flex: 0 1 auto; }
  .workspace-toolbar .cabinet-toggle { flex: 0 0 auto; }
  .laboratory-panel { padding-top: 1rem; }
  @media (max-width: 850px) {
    .workspace-toolbar { gap: .5rem; padding-inline: .65rem; }
    .workspace-toolbar .tab { padding-inline: .65rem; font-size: .8rem; }
    .workspace-toolbar .cabinet-toggle { padding-inline: .6rem; font-size: .7rem; }
  }
  @media (max-width: 600px) {
    .workspace-toolbar { flex-wrap: wrap; gap: .25rem; padding-top: 0; padding-bottom: .35rem; }
    .workspace-toolbar .view-tabs { flex: 1 1 100%; padding: 0; }
    .workspace-toolbar .laboratory-actions { flex: 1 1 100%; }
    .workspace-toolbar .hint-card { height: 52px; padding-left: .4rem; }
    .laboratory-panel { padding-top: .5rem; }
  }
  @media (max-height: 520px) and (min-width: 601px) {
    .workspace-toolbar { gap: .4rem; padding-block: .2rem; }
    .workspace-toolbar .hint-card { height: 44px; }
    .laboratory-panel { padding-top: .4rem; }
  }
}

@layer components {
/* Loading feedback occupies the existing viewport and respects reduced motion. */
.startup-feedback { margin-block: 1rem; padding: .85rem 1rem; border: 1px solid rgba(48,42,36,.25); background: rgba(48,42,36,.04); }
.startup-feedback > p { margin: 0 0 .65rem; font-size: .85rem; line-height: 1.45; }
.startup-feedback > .startup-detail { margin: .5rem 0 0; font-size: .75rem; font-variant-numeric: tabular-nums; }
.startup-feedback button { margin-top: .75rem; }
.film-progress { position: relative; height: 16px; overflow: hidden; border-block: 3px dotted var(--paper); background: var(--ink-800); }
.film-progress > span { display: block; width: 0; height: 100%; background: var(--amber); }
.film-progress.is-indeterminate > span { width: 28%; animation: projector-loading 2.4s ease-in-out infinite alternate; }
body[data-motion="reduced"] .film-progress.is-indeterminate > span { animation: none; width: 100%; opacity: .6; }
@keyframes projector-loading { from { transform: translateX(0); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .film-progress.is-indeterminate > span { animation: none; width: 100%; opacity: .6; } }
#onboarding-dialog .primary-button:disabled { opacity: .65; cursor: wait; }
.gallery-art-status { display: flex; align-items: center; gap: .8rem; flex: 0 0 auto; padding: .3rem 0; }
.gallery-art-status[hidden] { display: none; }
.gallery-art-status p { margin: 0; color: var(--muted); font-size: .85rem; }
.gallery-art-status button { flex-shrink: 0; min-height: 44px; }
.privacy-notice { margin-top: 1rem; border-top: 1px solid currentColor; padding-top: .5rem; font-size: .82rem; line-height: 1.5; }
.privacy-notice summary { cursor: pointer; min-height: 44px; display: list-item; align-content: center; }
.privacy-notice summary:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.privacy-notice a { color: inherit; display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: .2em; }
.privacy-notice a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

}

/* Touch deletion lives in a deliberate action dialog, away from mixing taps. */
.laboratory-touch-tip { display: none; flex: 0 0 auto; margin: .35rem 0 0; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.lab-specimen { -webkit-touch-callout: none; }
.lab-item.is-actions-ready .lab-specimen { outline: 2px solid var(--amber); outline-offset: 3px; }
@media (any-pointer: coarse), (max-width: 600px) {
  .lab-remove { display: none; }
  .laboratory-touch-tip { display: block; }
}

/* Compact phone navigation: one header, the two views, and tools by the canvas. */
@layer responsive {
  .mobile-action-label, .mobile-menu-toggle, .mobile-laboratory-dock { display: none; }
  .mobile-menu-actions { display: grid; gap: .65rem; }
  .mobile-menu-actions .icon-button { color: var(--paper); display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: .75rem; width: 100%; min-height: 52px; padding: .75rem; border-radius: 10px; font-size: 1rem; text-align: left; }
  .mobile-menu-actions .icon-button > :first-child { display: grid; place-items: center; width: 24px; height: 24px; margin: 0; color: var(--paper-dim); font-size: 20px; line-height: 1; }
  .mobile-menu-actions .mobile-action-label { display: block; font: 700 .9rem/1.4 var(--sans); }
  .specimen-action-recipe { font-size: .85rem; }
  @media (max-width: 600px), (max-width: 850px) and (max-height: 520px) {
    body { grid-template-columns: 1fr; grid-template-rows: 72px 46px minmax(0, 1fr); }
    .topbar { grid-column: 1; display: flex; height: 72px; min-height: 0; padding: 8px 14px; gap: 8px; background: linear-gradient(110deg, #1f1016, #101019); }
    .topbar .brand { position: relative; flex: 1; height: 56px; align-items: flex-start; }
    .brand > div { width: 100%; }
    .topbar .brand h1 { font-size: clamp(17px, 5.6vw, 22px); line-height: 26px; padding-top: 3px; letter-spacing: -.5px; }
    .brand-mark, .brand .eyebrow, .film-counter, .cinema-program { display: none; }
    .brand .mode-field { position: static; }
    .brand #mode-select-trigger { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 9px; min-width: 0; width: 100%; height: 56px; padding: 0 0 7px; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--paper-dim); font: 650 11px var(--sans); text-align: left; }
    .brand #mode-select-trigger::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--amber); border-bottom: 1.5px solid var(--amber); position: static; flex: 0 0 7px; margin-bottom: 4px; transform: rotate(45deg); }
    .topbar .header-actions { display: contents; }
    .topbar #language-select-trigger { width: 48px; height: 44px; min-height: 44px; border-radius: 10px; padding: 0; text-align: center; background: #1a1923; font-size: 11px; }
    .topbar #language-select-trigger::after { display: none; }
    .mobile-menu-toggle { display: block; height: 44px; width: 44px; flex: 0 0 44px; border-radius: 10px; background: #1a1923; font: 700 23px var(--serif); padding: 0; }
    .workspace-toolbar { display: block; height: 46px; padding: 0 12px; background: #111018; }
    .workspace-toolbar .view-tabs { width: 100%; height: 100%; padding: 0; gap: 16px; }
    .workspace-toolbar .tab { flex: 1; min-height: 44px; font-size: 12px; padding: 0 10px; border-bottom-width: 3px; }
    .tab #tab-movie-count { margin-left: 6px; font-size: 10px; }
    #laboratory-tools { display: none; }
    .laboratory-panel { position: relative; padding: 10px 10px 0; gap: 0; }
    .laboratory-canvas { border-radius: 14px; }
    .recipe-origin, .laboratory-touch-tip { display: none; }
    .mobile-laboratory-dock { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 0 0 calc(66px + env(safe-area-inset-bottom)); align-items: center; padding: 9px 0 calc(11px + env(safe-area-inset-bottom)); }
    .mobile-laboratory-dock button { display: flex; justify-content: center; align-items: center; gap: 8px; width: 100%; height: 46px; min-height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; background: #25232f; font: 750 12px var(--sans); }
    .mobile-laboratory-dock #hint-button { background: #1b191f; border-color: #55412c; }
    .mobile-laboratory-dock .mobile-action-label { display: inline; }
    .mobile-laboratory-dock svg { width: 18px; height: 18px; margin: 0; fill: none; stroke: var(--paper-dim); stroke-width: 1.6; }
    .mobile-laboratory-dock #hint-button svg { stroke: var(--amber); }
    .mobile-laboratory-dock small { padding-left: 3px; font-size: 10px; color: var(--paper-dim); font-weight: 500; }
    .mobile-hint-panel { position: absolute; bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; right: 12px; z-index: 20; max-height: min(220px, 70%); padding: 14px 48px 14px 16px; border: 1px solid #80613a; border-radius: 12px; background: #201c23; box-shadow: 0 8px 24px #0008; overflow: auto; }
    .mobile-hint-panel .hint-copy { height: auto; overflow: visible; }
    .mobile-hint-panel #hint-text { margin: 0; font-size: 13px; line-height: 1.5; overflow: visible; }
    #mobile-hint-close { position: absolute; right: 2px; top: 2px; width: 44px; height: 44px; }
    .gallery-panel { padding: 12px 12px 0; }
    .gallery-hero { display: none; }
    .gallery-tools { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 8px; margin-bottom: 10px; }
    html[lang="es-AR"] .gallery-tools { grid-template-columns: minmax(0, 1fr) 126px; }
    .gallery-tools .search-field { min-width: 0; width: 100%; height: 44px; padding: 0 10px; gap: 7px; border-radius: 10px; }
    .gallery-tools .search-field svg { width: 16px; flex: 0 0 16px; }
    .gallery-tools input { font-size: 11px; min-width: 0; padding: 0; }
    .gallery-tools .select-field { min-width: 0; width: 100%; }
    .gallery-tools .select-field > span { display: none; }
    .gallery-tools .select-trigger { width: 100%; min-width: 0; padding: 0 24px 0 10px; min-height: 44px; font-size: 11px; border-radius: 10px; }
    .gallery-tools .select-trigger::after { right: 11px; }
    .poster-grid { gap: 18px 12px; padding: 0 0 12px; }
    .poster-caption .poster-recipe { display: none; }
  }
}

@media (max-width: 600px), (max-width: 850px) and (max-height: 520px) {
  .laboratory-touch-tip { display: none; }
}

/* Shared dialog shell: stable headers/actions around scrollable content. */
@layer responsive {

    .game-dialog {width:min(600px, calc(100vw - 32px));max-width:600px;max-height:calc(100dvh - 48px);padding:0;border:1px solid #49414a;border-radius:18px;background:linear-gradient(140deg,#211b23,#12121c 65%);color:#f1e4c5;box-shadow:0 24px 80px #000a;overflow:hidden;}
    .game-dialog::backdrop {background:#05050bd6;backdrop-filter:blur(5px);}
    .game-dialog > form,.game-dialog > .dialog-shell {padding:0;display:flex;flex-direction:column;max-height:calc(100dvh - 50px);overflow:hidden;align-items:stretch;gap:0;}
    .dialog-header {position:relative;flex:0 0 auto;min-height:66px;padding:22px 20px 18px;border-bottom:1px solid #f1e4c51c;}
    .dialog-header:has(.dialog-close) {padding-right:64px;}
    .game-dialog .dialog-close {position:absolute;top:14px;right:14px;width:44px;height:44px;min-height:44px;margin:0;flex:none;align-self:auto;border:1px solid #f1e4c526;border-radius:50%;color:#f1e4c5;background:#1b1b27;font-size:28px;line-height:1;backdrop-filter:none;}
    .game-dialog h2,.game-dialog #onboarding-title {font-family:Georgia,serif;font-size:26px;line-height:1.14;letter-spacing:-.5px;margin:0;color:#f1e4c5;overflow-wrap:anywhere;}
    .game-dialog .eyebrow {color:#e9b65c;font-size:9px;letter-spacing:1.6px;margin:0 0 8px;line-height:1.4;}
    .dialog-body {min-height:0;overflow:auto;overscroll-behavior:contain;padding:18px 20px 20px;scrollbar-width:thin;scrollbar-color:#62544c transparent;}
    .dialog-body p {color:#cbbb9b;font-size:13px;line-height:1.55;}
    .game-dialog strong {color:#f1e4c5;}
    .dialog-footer {flex:none;padding:14px 20px 18px;border-top:1px solid #f1e4c51c;background:#15141e;}
    .game-dialog .secondary-button,.game-dialog .danger-button,.game-dialog .primary-button {min-height:46px;padding:11px 13px;border-radius:10px;font-size:12px;font-weight:750;line-height:1.4;}
    .game-dialog .secondary-button {background:#24232f;color:#f1e4c5;border:1px solid #f1e4c526;}
    .game-dialog .primary-button {background:#e9b65c;color:#17131b;border:1px solid #e9b65c;width:100%;}
    .game-dialog .danger-button {background:#43242b;color:#ffa89c;border:1px solid #9a494a;}
    .game-dialog :is(button,input,select):focus-visible {outline:2px solid #ffd477;outline-offset:3px;}
    .game-dialog .dialog-actions {margin:0;display:grid;grid-template-columns:1fr;gap:9px;}
    .game-dialog .onboarding-language {display:flex;align-items:center;gap:5px;font-size:11px;color:#cbbb9b;}
    .game-dialog .onboarding-language button {min-height:44px;min-width:44px;background:#1b1b27;color:#cbbb9b;border:1px solid #f1e4c526;border-radius:9px;font-size:11px;}
    .game-dialog .onboarding-language button[aria-pressed=true] {background:#332c24;border-color:#b48b4c;color:#f4d390;}
    .game-dialog .onboarding-toolbar {background:transparent;position:static;padding:0;margin:0 0 20px;}
    .game-dialog .onboarding-toolbar .dialog-close {position:absolute;}
    #onboarding-dialog .dialog-header {padding-right:20px;}
    #onboarding-dialog .dialog-header .eyebrow {margin-top:2px;}
    #onboarding-dialog .onboarding-steps {margin:0;gap:0;}
    #onboarding-dialog .onboarding-steps>div {grid-template-columns:24px minmax(0,1fr);gap:10px;padding:15px 0;border-top:1px solid #f1e4c51c;}
    #onboarding-dialog .onboarding-steps>div:first-child {border:0;padding-top:0;}
    .game-dialog .onboarding-steps>div>span {font-size:17px;color:#e9b65c;line-height:1.5;}
    .game-dialog .onboarding-steps strong {display:block;margin-bottom:5px;}
    .game-dialog .fine-print {opacity:1;font-size:11px;color:#aaa3ad;margin:14px 0 0;}
    .game-dialog .mobile-help-note {margin-top:10px;}
    .game-dialog .setting-row {border-top:1px solid #f1e4c51c;gap:12px;min-height:78px;padding:14px 0;}
    .game-dialog .setting-row:first-child {padding-top:0;border:0;}
    .game-dialog .setting-row strong {font-size:13px;}
    .game-dialog .setting-row small {font-size:11px;color:#aaa3ad;opacity:1;line-height:1.5;max-width:22ch;}
    .game-dialog .setting-row select {flex:none;max-width:110px;min-height:44px;background-color:#24232f;border:1px solid #f1e4c526;color:#f1e4c5;font-size:12px;padding-left:10px;}
    .game-dialog #sound-toggle {appearance:none;position:relative;flex:0 0 42px;width:42px;height:44px;min-height:44px;margin:0;border:0;background:transparent;}
    .game-dialog #sound-toggle::before {content:"";position:absolute;left:0;top:10px;width:42px;height:24px;border-radius:999px;background:#34323e;border:1px solid #f1e4c526;}
    .game-dialog #sound-toggle::after {content:"";position:absolute;left:5px;top:15px;width:14px;height:14px;border-radius:50%;background:#cbbb9b;}
    .game-dialog #sound-toggle:checked::before {background:#e9b65c;}
    .game-dialog #sound-toggle:checked::after {left:23px;background:#17131b;}
    .game-dialog .setting-row select {background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23cbbb9b' stroke-width='1.6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:10px 7px;}
    .game-dialog .save-actions {margin:14px 0 0;display:grid;grid-template-columns:1fr 1fr;gap:10px;}
    .game-dialog #reset-button {grid-column:1/-1;margin-top:4px;}
    .game-dialog .privacy-notice {border-color:#f1e4c51c;margin-top:18px;}
    .game-dialog .privacy-notice summary {font-size:12px;color:#cbbb9b;}
    .game-dialog .mobile-menu-actions {gap:10px;}
    .game-dialog .mobile-menu-actions button {min-height:52px;background:#24232f;}
    .game-dialog .mobile-menu-actions .mobile-action-label {font-weight:700;font-size:13px;}
    .game-dialog .specimen-action-recipe {padding:12px;border:1px solid #f1e4c51c;border-radius:10px;background:#0e0e18;margin-bottom:14px;font-size:12px;}
    .game-dialog .startup-feedback {margin:0;background:#0e0e18;border:1px solid #f1e4c51c;border-radius:10px;padding:14px;}
    .game-dialog .startup-feedback p {font-size:12px;}
    .game-dialog .startup-detail {color:#aaa3ad;}
    .game-dialog .film-progress {margin-block:12px;border-color:#0e0e18;}
    #startup-dialog .dialog-header .onboarding-language {margin-bottom:20px;}
    #poster-dialog .dialog-header {padding:18px 64px 18px 20px;}
    #poster-dialog .dialog-header h2 {font-size:23px;}
    #poster-dialog .dialog-body {padding:16px;}
    #poster-dialog .poster-dialog-art,#poster-dialog .poster-dialog-copy {width:100%;}
    #poster-dialog .poster-dialog-copy {margin-top:16px;gap:12px;}
    #poster-dialog .poster-dialog-copy>p {font-size:12px;}
    #poster-dialog .poster-dialog-recipe {font-size:10px;}
    #poster-dialog .poster-art {max-width:250px;margin:auto;}
    #poster-dialog .poster-title {font-size:22px;}
    .game-dialog .dialog-body:empty {display:none;}

    .game-dialog:is(.mobile-menu-dialog,.specimen-actions-dialog,#confirm-dialog,#import-confirm-dialog,#recovery-dialog) {width:min(448px,calc(100vw - 32px));}
    .game-dialog .dialog-body {scrollbar-width:none;}
    .game-dialog .dialog-header,.game-dialog .dialog-footer {overflow:auto;overscroll-behavior:contain;}
    .game-dialog .dialog-header {max-height:40dvh;}
    .game-dialog .dialog-footer {max-height:40dvh;}
    .game-dialog .setting-row select {max-width:130px;}
    .specimen-action-art {display:block;width:132px;height:132px;margin:0 auto 16px;}
    .game-dialog .specimen-action-recipe {text-align:center;}
    .game-dialog .dialog-actions.specimen-action-buttons {grid-template-columns:1fr 1fr;gap:10px;}
    .game-dialog .specimen-action-buttons button {min-height:44px;padding:10px 12px;}
    .game-dialog #specimen-action-note {font-size:12px;}
    .game-dialog #welcome-loading-slot:not(:empty) {margin-bottom:18px;}
    .game-dialog .privacy-notice p + p {margin-top:12px;}
    .game-dialog .poster-dialog-copy {margin-inline:auto;max-width:420px;}
    @media (min-width:601px) {
      #poster-dialog .poster-art {max-width:420px;}
    }
    @media (max-height:520px) {
      .game-dialog .dialog-header {min-height:60px;padding-top:12px;padding-bottom:12px;max-height:35dvh;}
      .game-dialog .dialog-footer {padding-top:10px;padding-bottom:10px;max-height:40dvh;}
      .game-dialog .dialog-actions:not(.specimen-action-buttons) {grid-template-columns:repeat(2,minmax(0,1fr));}
      .game-dialog .onboarding-toolbar {margin-bottom:10px;}
      .game-dialog h2,.game-dialog #onboarding-title {font-size:22px;}
      .game-dialog .dialog-close {top:8px;}
    }
    @media (forced-colors:active) {
      .game-dialog #sound-toggle {appearance:auto;}
      .game-dialog #sound-toggle::before,.game-dialog #sound-toggle::after {display:none;}
      .game-dialog :is(.secondary-button,.primary-button,.danger-button,.dialog-close) {border:1px solid ButtonText;}
      .game-dialog {border-color:CanvasText;}
    }
}

/* Laboratory utilities stay outside the draggable surface. */
@layer responsive {
  .laboratory-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; flex: 1 1 0; min-height: 0; min-width: 0; }
  .laboratory-rail { display: flex; flex-direction: column; gap: 8px; align-items: center; min-height: 0; }
  #sort-laboratory { width: 44px; height: 44px; min-height: 44px; flex: 0 0 44px; border-radius: 10px; }
  #sort-laboratory, #laboratory-scroll, .mobile-laboratory-dock button { -webkit-tap-highlight-color: transparent; }
  #sort-laboratory:disabled { opacity: .4; cursor: default; }
  #laboratory-scroll { appearance: none; -webkit-appearance: none; writing-mode: vertical-lr; direction: ltr; width: 44px; min-width: 44px; height: 100%; min-height: 44px; flex: 1; margin: 0; padding: 0 12px; border: 0; border-radius: 10px; background: var(--ink-850); touch-action: none; cursor: ns-resize; }
  #laboratory-scroll::-webkit-slider-runnable-track { width: 4px; height: 100%; background: var(--border); border-radius: 8px; }
  #laboratory-scroll::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 20px; height: var(--scroll-thumb-height, 44px); margin-left: -8px; border: 1px solid var(--amber); border-radius: 8px; background: #655039; }
  #laboratory-scroll::-moz-range-track { width: 4px; height: 100%; background: var(--border); border-radius: 8px; }
  #laboratory-scroll::-moz-range-thumb { width: 18px; height: var(--scroll-thumb-height, 44px); border: 1px solid var(--amber); border-radius: 8px; background: #655039; }
  @media (max-width: 600px), (max-width: 850px) and (max-height: 520px) {
    .mobile-laboratory-dock { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .mobile-laboratory-dock button { flex-direction: column; gap: 2px; padding: 4px; font-size: 11px; line-height: 15px; }
    .mobile-laboratory-dock svg { width: 16px; height: 16px; }
    .mobile-laboratory-dock #cabinet-toggle-count { display: none; }
  }
  @media (forced-colors: active) {
    #laboratory-scroll::-webkit-slider-thumb { background: Highlight; border-color: ButtonText; }
    #laboratory-scroll::-moz-range-thumb { background: Highlight; border-color: ButtonText; }
  }
}
