/* T-040: the inventory is an open bag lying in the dungeon, not a menu.
   The dungeon stays visible, dimmed. Each backpack has its own generated picture; the grid sits on its lining
   and the amulet slots hang from the four rings of its belt. Everything is sized from --bag-w, the width of
   the picture. The numbers per backpack (lining box, ring centres, picture ratio) are measured from the
   pictures by scripts/bag-art-pack.py; do not edit them by hand. */

/* generated: per-backpack measurements */
#amulet-panel.bag-open[data-backpack="pouch"] { --bag-art:url("assets/ui/bag/bag-pouch.png"); --bag-ratio:750 / 453; --bag-hw:0.6040; --lin-x:20.00%; --lin-y:19.07%; --lin-w:0.6000; --lin-h:0.5755; --ring-y:94.40%; --ring-0:26.97%; --ring-1:42.10%; --ring-2:58.23%; --ring-3:74.17%; }
#amulet-panel.bag-open[data-backpack="satchel"] { --bag-art:url("assets/ui/bag/bag-satchel.png"); --bag-ratio:749 / 442; --bag-hw:0.5901; --lin-x:27.90%; --lin-y:17.76%; --lin-w:0.4419; --lin-h:0.6188; --ring-y:95.59%; --ring-0:26.70%; --ring-1:41.89%; --ring-2:58.11%; --ring-3:73.40%; }
#amulet-panel.bag-open[data-backpack="basic"] { --bag-art:url("assets/ui/bag/bag-basic.png"); --bag-ratio:701 / 455; --bag-hw:0.6491; --lin-x:29.01%; --lin-y:18.44%; --lin-w:0.4212; --lin-h:0.5708; --ring-y:95.58%; --ring-0:28.47%; --ring-1:42.59%; --ring-2:57.45%; --ring-3:71.63%; }
#amulet-panel.bag-open[data-backpack="field"] { --bag-art:url("assets/ui/bag/bag-field.png"); --bag-ratio:512 / 686; --bag-hw:1.3398; --lin-x:15.92%; --lin-y:26.66%; --lin-w:0.6816; --lin-h:0.5601; --ring-y:94.97%; --ring-0:23.83%; --ring-1:40.87%; --ring-2:59.18%; --ring-3:76.17%; }
#amulet-panel.bag-open[data-backpack="wide"] { --bag-art:url("assets/ui/bag/bag-wide.png"); --bag-ratio:762 / 442; --bag-hw:0.5801; --lin-x:23.16%; --lin-y:11.53%; --lin-w:0.5374; --lin-h:0.6768; --ring-y:96.38%; --ring-0:27.69%; --ring-1:42.29%; --ring-2:57.41%; --ring-3:72.28%; }
#amulet-panel.bag-open[data-backpack="expedition"] { --bag-art:url("assets/ui/bag/bag-expedition.png"); --bag-ratio:621 / 544; --bag-hw:0.8760; --lin-x:19.89%; --lin-y:21.30%; --lin-w:0.6023; --lin-h:0.6189; --ring-y:97.58%; --ring-0:24.44%; --ring-1:41.10%; --ring-2:58.49%; --ring-3:75.56%; }
/* end generated */

/* An unknown backpack is drawn as the pouch. */
#amulet-panel.bag-open { --bag-art:url("assets/ui/bag/bag-pouch.png"); --bag-ratio:750 / 453; --bag-hw:0.6040; --lin-x:20.00%; --lin-y:19.07%; --lin-w:0.6000; --lin-h:0.5755; --ring-y:94.40%; --ring-0:26.97%; --ring-1:42.10%; --ring-2:58.23%; --ring-3:74.17%; --charm-w:84px;
  /* T-119: the PICTURE is sized to the window and the cell follows from it, per backpack. The cell is the smaller of two fits: --bag-columns cells across the lining
     (--bag-k) and min(rows, 8) rows down the lining (the second term of --bag-k, T-074's frame: a taller bag scrolls INSIDE .bag-board, never a smaller cell or a scrolling window).
     Height: the picture, the tag above it (36px) and the keyring guide under the hanging charms (1.98 charm widths + 19px; the picture's own share is .954 because the
     rings sit near its bottom edge), or the picture's own bottom margin (1.75 charm widths) when that is more. Width: the picture, the floor panel (4 cells, always reserved so the cell does not jump when a weapon lands) and the item panel
     plus gaps (380px, the item panel may squeeze a little below 300px). The picture is never smaller than T-074's. dist/bag-layout.mjs holds the same numbers (a test compares them). */
  --bag-hmax:min(calc((100vh - 36px - var(--charm-w) * 1.98 - 19px) / .954),calc(100vh - 36px - var(--charm-w) * 1.75 - 2px)); --bag-k:min(calc(var(--lin-w) * .96 / var(--bag-columns,5)),calc(var(--lin-h) * .95 * var(--bag-hw) / min(var(--bag-rows,3),8)));
  --bag-w:min(calc(var(--bag-hmax) / var(--bag-hw)),calc((100vw - 380px) / (1 + 4 * var(--bag-k))),calc(128px / var(--bag-k)));
  --cell:calc(var(--bag-w) * var(--bag-k)); --floor-col:calc(var(--cell) * 4 + 16px);
  /* T-126: one dark glass look for every frame and tag of the bag screen (sort tag, backpack tag, keyring tag and guide, floor panel, confirm card): near-black teal, a hairline border the colour of the grid lines, amber for numbers. No light backgrounds. */
  --ui-bg:#0c1715eb; --ui-bg-hi:#142623f2; --ui-line:#6f8a6c66; --ui-line-hi:#8bd8c4aa; --ui-text:#e4eee6; --ui-dim:#8fb3a6; --ui-amber:#edbf80; --ui-shadow:0 6px 18px #000a,inset 0 0 0 1px #ffffff0a; }
#amulet-panel.bag-open.amulet-overlay { padding:0; place-items:center; background:#0a1310c4; }
#amulet-panel.bag-open .amulet-content { display:grid; place-items:start center; width:100%; height:100%; max-width:none; max-height:none; margin:0; padding:0; overflow:auto; border:0; background:transparent; box-shadow:none; clip-path:none; }
/* The picture plus the hanging charms (about two charm widths tall) must fit the height; the info panel takes 300px. */
#amulet-panel.bag-open #bag-section {
  display:grid; grid-template-columns:var(--bag-w) minmax(220px,300px); align-items:center; justify-content:center; gap:24px; padding:0 16px; margin-block:auto;
}
#amulet-panel.bag-open .bag-body { position:relative; width:var(--bag-w); aspect-ratio:var(--bag-ratio); margin-top:36px; margin-bottom:calc(var(--charm-w) * 1.75); background:var(--bag-art) center / 100% 100% no-repeat; image-rendering:pixelated; filter:drop-shadow(0 14px 0 #0008); }

/* Grid on the lining. The cell is as large as fits both ways for this bag's columns and rows. */
#amulet-panel.bag-open .bag-layout { position:absolute; left:var(--lin-x); top:var(--lin-y); display:grid; place-items:center; width:calc(var(--lin-w) * 100%); height:calc(var(--lin-h) * 100%); min-height:0; gap:0; grid-template-columns:none; }
#amulet-panel.bag-open .bag-board { box-sizing:border-box; max-height:100%; overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:none; padding:0; border:0; background:transparent; }
#amulet-panel.bag-open .bag-board::-webkit-scrollbar { display:none; width:0; height:0; }
/* H1: the board is the only thing that scrolls. A fade at the cut edge and a small arrow tell the player there is more (bag-scroll-cue.mjs sets data-more / data-above). */
#amulet-panel.bag-open .bag-board[data-more="true"] { -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 26px),transparent); mask-image:linear-gradient(to bottom,#000 calc(100% - 26px),transparent); }
#amulet-panel.bag-open .bag-board[data-above="true"] { -webkit-mask-image:linear-gradient(to bottom,transparent,#000 26px); mask-image:linear-gradient(to bottom,transparent,#000 26px); }
#amulet-panel.bag-open .bag-board[data-more="true"][data-above="true"] { -webkit-mask-image:linear-gradient(to bottom,transparent,#000 26px,#000 calc(100% - 26px),transparent); mask-image:linear-gradient(to bottom,transparent,#000 26px,#000 calc(100% - 26px),transparent); }
#amulet-panel.bag-open .bag-layout:has(.bag-board[data-more="true"])::after,#amulet-panel.bag-open .bag-layout:has(.bag-board[data-above="true"])::before { position:absolute; left:50%; z-index:4; padding:0 8px; background:#17241fe6; color:#edbf80; font:700 11px/1.5 var(--mono,monospace); letter-spacing:.04em; transform:translateX(-50%); pointer-events:none; }
#amulet-panel.bag-open .bag-layout:has(.bag-board[data-more="true"])::after { content:"▼ つづき"; bottom:-1px; }
#amulet-panel.bag-open .bag-layout:has(.bag-board[data-above="true"])::before { content:"▲"; top:-1px; }
#amulet-panel.bag-open #bag-grid { --bag-cell-size:var(--cell); gap:0; }
#amulet-panel.bag-open .bag-cell { padding:0; border:0; border-radius:0; background:transparent; box-shadow:inset 0 0 0 1px #6f8a6c3d; }
#amulet-panel.bag-open .bag-cell::after { display:none; }
#amulet-panel.bag-open .bag-cell-number { display:none; }
#amulet-panel.bag-open .bag-cell:hover { background:#acd58a1f; }
#amulet-panel.bag-open .bag-cell[aria-selected="true"] { box-shadow:inset 0 0 0 2px #edbf80; }
#amulet-panel.bag-open #bag-grid[data-moving="true"] .bag-cell { box-shadow:inset 0 0 0 1px #8bd8c4; }

/* The one remaining control: a tag tied to the top of the bag. */
#amulet-panel.bag-open #bag-sort { position:absolute; right:calc(100% - var(--lin-x) - var(--lin-w) * 100%); top:calc(var(--lin-y) - 34px); min-height:0; padding:3px 12px 4px; border:1px solid var(--ui-line-hi); border-radius:2px; background:#0a1311; color:#fff; font-size:14px; font-weight:700; letter-spacing:.08em; line-height:1.3; box-shadow:var(--ui-shadow); backdrop-filter:blur(3px); }
#amulet-panel.bag-open #bag-sort:hover:not(:disabled) { border-color:var(--ui-line-hi); background:var(--ui-bg-hi); color:#fff; }
#amulet-panel.bag-open #bag-sort:focus-visible { outline:2px solid var(--ui-amber); outline-offset:2px; }
#amulet-panel.bag-open #bag-sort:disabled { opacity:1; color:#a9c4b9; border-color:var(--ui-line); background:#0d1a17; }
/* T-048: the equipped backpack, on a tag just above the picture (on the picture it covered the straps and the
   sort tag, and a narrow screen cut the name off). The whole name is always shown. T-126: dark glass tag, the backpack's colour as a 3px edge. */
#amulet-panel.bag-open #bag-pack-tag { position:absolute; left:50%; bottom:calc(100% + 8px); display:flex; align-items:baseline; gap:8px; margin:0; padding:3px 12px 4px 9px; border:1px solid var(--ui-line); border-left:3px solid var(--pack-color,#8bd8c4); border-radius:2px; background:var(--ui-bg); color:var(--ui-text); font-size:13px; line-height:1.3; white-space:nowrap; transform:translateX(-50%); box-shadow:var(--ui-shadow); backdrop-filter:blur(3px); pointer-events:none; }
#amulet-panel.bag-open #bag-pack-tag .bag-pack-label { color:var(--ui-dim); font-size:10px; font-weight:700; letter-spacing:.14em; }
#amulet-panel.bag-open #bag-pack-tag .bag-pack-name { font-weight:700; letter-spacing:.03em; }
#amulet-panel.bag-open #bag-pack-tag .bag-pack-size { color:var(--ui-amber); font:700 12px/1.3 var(--mono,monospace); }
#amulet-panel.bag-open #bag-pack-tag:empty { display:none; }

/* Amulet slots: charms on cords, hung from the belt rings. */
#amulet-panel.bag-open #amulet-slots { position:absolute; left:0; top:calc(var(--ring-y) - 2.2%); width:100%; height:calc(var(--charm-w) * 2); margin:0; padding:0; border:0; background:transparent; }
#amulet-panel.bag-open .amulet-slot-list { display:block; position:relative; width:100%; height:100%; margin:0; padding:0; gap:0; }
/* T-092: the keyring is a button (name + "護符 3/6", press it to read about it), with the ring itself drawn under the belt. The slots are charms hanging from that ring. */
#amulet-panel.bag-open .bag-body { --charm-real:min(var(--charm-w),calc(var(--bag-w) * .135)); }
#amulet-panel.bag-open .bag-keyring-tag { position:absolute; top:calc(var(--ring-y) - 2.2% - 30px); left:50%; z-index:3; display:flex; align-items:center; gap:6px; margin:0; padding:1px 9px 1px 4px; border:1px solid var(--ui-line); border-left:3px solid var(--ring-color,#8bd8c4); border-radius:2px; background:var(--ui-bg); color:var(--ui-text); font:inherit; font-size:12px; font-weight:700; letter-spacing:.04em; line-height:1.2; white-space:nowrap; transform:translateX(-50%); box-shadow:var(--ui-shadow); backdrop-filter:blur(3px); cursor:pointer; }
#amulet-panel.bag-open .bag-keyring-tag:hover { border-color:var(--ui-line-hi); background:var(--ui-bg-hi); }
#amulet-panel.bag-open .bag-keyring-tag[aria-pressed="true"] { border-color:var(--ui-amber); outline:1px solid var(--ui-amber); outline-offset:1px; }
#amulet-panel.bag-open .bag-keyring-tag:focus-visible { outline:2px solid var(--ui-amber); outline-offset:2px; }
#amulet-panel.bag-open .bag-keyring-count { font:700 12px/1.2 var(--mono,monospace); color:var(--ui-amber); }
#amulet-panel.bag-open .bag-keyring-tag[data-full="true"] .bag-keyring-count { color:#f08a7e; }
#amulet-panel.bag-open .bag-keyring-hoop { position:absolute; z-index:2; top:calc(var(--ring-y) - 2.2% + var(--charm-real) * .99 - 34px); left:calc(var(--hoop-l,26%) - 20px); width:calc(var(--hoop-r,74%) - var(--hoop-l,26%) + 40px); height:32px; display:flex; pointer-events:none; image-rendering:pixelated; filter:drop-shadow(0 3px 0 #0007); }
#amulet-panel.bag-open .bag-keyring-hoop canvas { display:block; height:32px; image-rendering:pixelated; }
#amulet-panel.bag-open .bag-hoop-left,#amulet-panel.bag-open .bag-hoop-right { flex:none; width:28px; }
#amulet-panel.bag-open .bag-hoop-mid { flex:1 1 auto; width:auto; min-width:0; }
#amulet-panel.bag-open .bag-keyring-hoop:empty { display:none; }
#amulet-panel.bag-open .bag-keyring-guide { position:absolute; left:50%; top:calc(var(--ring-y) - 2.2% + var(--charm-real) * 1.98); z-index:3; width:max-content; max-width:calc(var(--bag-w) + 40px); margin:0; padding:1px 10px; border-left:4px solid var(--ui-amber); border-radius:2px; background:var(--ui-bg); color:var(--ui-text); font-size:12px; line-height:1.25; box-shadow:inset 0 0 0 1px var(--ui-line); text-align:center; transform:translateX(-50%); pointer-events:none; }
#amulet-panel.bag-open .bag-keyring-guide:empty { display:none; }
#amulet-panel.bag-open .bag-keyring-guide[data-picking="true"] { border-left-color:#8bd8c4; color:#d8fff3; }
#amulet-panel.bag-open .bag-keyring-tag:empty { display:none; }
#amulet-panel.bag-open .bag-keyring-tag canvas { width:24px; height:24px; image-rendering:pixelated; }
#amulet-panel.bag-open .bag-detail-art.bag-keyring-art { display:block; width:72px; height:72px; margin:4px auto 0; image-rendering:pixelated; }
/* While an amulet is being dragged (or "輪に付ける" was pressed) the free slots of the ring light up; the slot under the pointer shows whether it fits. Static: no animation, so FX off changes nothing. */
#amulet-panel.bag-open .amulet-slot::after { content:""; position:absolute; left:3%; right:3%; bottom:1%; aspect-ratio:1; border:3px dashed transparent; border-radius:50%; pointer-events:none; }
#amulet-panel.bag-open[data-amulet-drag="true"] .amulet-slot[data-filled="false"]::after,#amulet-panel.bag-open .amulet-slot[data-equip-target="true"][data-filled="false"]::after { border-color:#8bd8c4; background:#8bd8c422; }
#amulet-panel.bag-open[data-amulet-drag="true"] .amulet-slot[data-filled="true"]::after { border-color:#edbf8099; }
#amulet-panel.bag-open .amulet-slot[data-bag-drop] { outline:0; }
#amulet-panel.bag-open .amulet-slot[data-bag-drop="valid"]::after { border-style:solid; border-color:#7fbf6a; background:#7fbf6a40; }
#amulet-panel.bag-open .amulet-slot[data-bag-drop="invalid"]::after { border-style:dashed; border-color:#d27b7b; background:#d27b7b33; }
#amulet-panel.bag-open .amulet-slot { position:absolute; top:0; left:50%; width:min(var(--charm-w),calc(var(--bag-w) * .135)); height:auto; min-width:0; max-width:none; min-height:0; aspect-ratio:113 / 224; margin:0; padding:0; border:0; border-radius:0; background:url("assets/ui/bag/charm-slot.png") center / 100% 100% no-repeat; box-shadow:none; image-rendering:pixelated; transform:translateX(-50%); transform-origin:50% 0; }
#amulet-panel.bag-open .amulet-slot[data-ring="0"] { left:var(--ring-0); }
#amulet-panel.bag-open .amulet-slot[data-ring="1"] { left:var(--ring-1); }
#amulet-panel.bag-open .amulet-slot[data-ring="2"] { left:var(--ring-2); }
#amulet-panel.bag-open .amulet-slot[data-ring="3"] { left:var(--ring-3); }
#amulet-panel.bag-open .amulet-slot[aria-pressed="true"],#amulet-panel.bag-open .amulet-slot[data-equip-target="true"],#amulet-panel.bag-open .amulet-slot:focus-visible { background-image:url("assets/ui/bag/charm-slot-selected.png"); outline:0; }
/* Hover must not move the slot: moving it out from under the pointer makes it flicker and breaks dragging. */
#amulet-panel.bag-open .amulet-slot:hover { filter:brightness(1.18); }
#amulet-panel.bag-open .amulet-slot:disabled { opacity:.7; }
#amulet-panel.bag-open .amulet-slot-art { position:absolute; left:50%; top:76.5%; width:88%; height:auto; max-height:none; transform:translate(-50%,-50%); image-rendering:pixelated; pointer-events:none; }

/* What the pointer is on, to the right of the bag. Nothing is shown for an empty cell. */
#amulet-panel.bag-open #bag-details { align-self:center; width:100%; max-height:min(74vh,560px); overflow:auto; box-shadow:0 10px 0 #0007; }
#amulet-panel.bag-open #bag-details[data-shown="false"] { visibility:hidden; }

/* Only a refusal or a confirmation is worth a line; it sits at the bottom and is otherwise absent. */
#amulet-panel.bag-open #bag-status { position:absolute; left:50%; bottom:14px; margin:0; padding:6px 14px; border:0; border-left:4px solid #edbf80; background:#14272af0; color:#efe6cf; font-size:14px; transform:translateX(-50%); pointer-events:none; }
/* Not display:none: a live region that appears and changes text at once may go unannounced. The hints stay
   in the page for assistive technology and are only kept off the screen. */
#amulet-panel.bag-open #bag-status:not([data-kind="reason"]),#amulet-panel.bag-open #bag-status:empty { width:1px; height:1px; padding:0; border:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }

@media (max-width:900px) {
  #amulet-panel.bag-open { --charm-w:54px; --bag-hmax:calc(74vh - 36px - var(--charm-w) * 1.75); --bag-w:min(calc(var(--bag-hmax) / var(--bag-hw)),calc((100vw - 24px) / (1 + 4 * var(--bag-k))),calc(52px / var(--bag-k))); }
  #amulet-panel.bag-open #bag-section { grid-template-columns:var(--bag-w); gap:8px; align-content:center; }
  #amulet-panel.bag-open #bag-details { max-height:26vh; }
  /* T-048: a long name wraps instead of running off a narrow screen (.amulet-content hides overflow). */
  #amulet-panel.bag-open #bag-pack-tag { flex-wrap:wrap; justify-content:center; width:max-content; max-width:calc(100vw - 24px); white-space:normal; column-gap:8px; row-gap:0; }
}


/* T-061: the floor panel to the left of the bag. It only exists while weapons lie in the room (renderInventoryScreen
   sets data-floor-panel and unhides it). Its cells are as large as the bag's, up to 52px, and a weapon covers its real
   bag footprint. The bag gives up the width the panel takes (--floor-w, panel plus gap). */
#amulet-panel.bag-open #bag-section { --floor-cell:var(--cell); }
#amulet-panel.bag-open[data-floor-panel="true"] #bag-section { grid-template-columns:var(--floor-col) var(--bag-w) minmax(220px,300px); }
#floor-panel[hidden] { display:none; }
#amulet-panel.bag-open #floor-panel { align-self:center; box-sizing:border-box; width:var(--floor-col); max-height:min(74vh,560px); overflow-x:hidden; overflow-y:auto; padding:6px 0 6px 4px; border:1px solid var(--ui-line); border-radius:3px; background:linear-gradient(#112220f2,#0b1513f2); color:var(--ui-text); box-shadow:var(--ui-shadow); overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#8bd8c488 transparent; }
/* T-125: the panel is 4 cells + 16px wide: 1px borders and 4px left padding use 6px, which leaves 10px for the thin scrollbar (scrollbar-width:thin is about 8px in Chrome and Firefox; the old 3px border + 6px padding + thin bar used 18px+ and pushed the 4 cells past the content box, so the panel scrolled sideways). Never sideways: overflow-x is hidden. */
#amulet-panel.bag-open .floor-title { display:flex; align-items:center; gap:6px; margin:0 0 6px 2px; color:var(--ui-dim); font-size:11px; font-weight:700; letter-spacing:.24em; line-height:1.3; }
#amulet-panel.bag-open .floor-title::before { content:""; width:3px; height:11px; background:var(--ui-amber); }
#amulet-panel.bag-open #floor-grid { display:grid; grid-template-columns:repeat(var(--floor-columns,4),var(--floor-cell)); grid-template-rows:repeat(var(--floor-rows,3),var(--floor-cell)); grid-auto-rows:var(--floor-cell); gap:0; width:max-content; max-width:100%; touch-action:none; user-select:none; background:transparent; background-image:linear-gradient(#6f8a6c3d 1px,transparent 1px),linear-gradient(90deg,#6f8a6c3d 1px,transparent 1px); background-size:var(--floor-cell) var(--floor-cell); box-shadow:inset -1px -1px 0 #6f8a6c3d; }
#amulet-panel.bag-open .bag-floor-item { cursor:grab; padding:0; }
#amulet-panel.bag-open #floor-grid .bag-item-art { inset:3px; width:calc(100% - 6px); height:calc(100% - 6px); max-height:none; }
#amulet-panel.bag-open .bag-floor-item .bag-rarity-marks { top:2px; left:2px; padding:0 2px; font-size:10px; }
#amulet-panel.bag-open .bag-floor-size { position:absolute; z-index:3; right:2px; bottom:1px; padding:0 3px; background:#17241fe0; color:#e9e3d7; font:11px/1.3 var(--mono,monospace); pointer-events:none; }
#amulet-panel.bag-open .bag-floor-item[data-bag-drop="valid"] { outline:3px solid #7fbf6a; outline-offset:-3px; }
#amulet-panel.bag-open .bag-floor-item[data-bag-drop="invalid"] { outline:3px dashed #d27b7b; outline-offset:-3px; }
#amulet-panel.bag-open #floor-panel[data-bag-drop="valid"] { outline:3px solid #7fbf6a; outline-offset:-3px; }
#amulet-panel.bag-open #floor-panel[data-bag-drop="invalid"] { outline:3px dashed #d27b7b; outline-offset:-3px; }
/* T-074: an empty floor is just the panel titled "床" with its empty grid (the rows are set by renderInventoryScreen, at least 3), so the
   bag never reflows when the first item lands or the last is taken. No sentence (the hint line under the items hides too). */
@media (max-width:900px) {
  #amulet-panel.bag-open[data-floor-panel="true"] #bag-section { grid-template-columns:var(--bag-w); }
  #amulet-panel.bag-open #floor-panel { order:3; width:var(--bag-w); max-height:22vh; }
}

/* QA-layout M5/L7: the item panel gets the whole free height of the window: from 8px below the top menu buttons (they end
   at 88 + 30 = 118px) to 12px above the bottom edge. It stays in the grid (the number of columns depends on the floor
   panel) but is pulled to that top: the section is centred in the window, so its top is (100vh - --hs) / 2 and the panel
   moves by the difference. A negative bottom margin keeps its size out of the row height (the bag does not move).
   The body scrolls, the buttons stay. */
@media (min-width:901px) {
  #amulet-panel.bag-open #bag-details {
    --zone-top:var(--bag-zone-top,126px); --zone-gap:12px;
    --hs:calc(var(--bag-w) * var(--bag-hw) + var(--charm-w) * 1.75 + 36px);
    --cap:min(calc(100vh - var(--zone-top) - var(--zone-gap)),760px);
    position:relative; align-self:start; max-height:var(--cap); margin-bottom:calc(var(--hs) - var(--cap)); overflow:hidden;
    top:calc(var(--zone-top) - max(0px,(100vh - var(--hs)) / 2));
  }
}
#amulet-panel.bag-open #bag-details .bag-detail-body { flex:1 1 auto; min-height:0; overflow-x:hidden; overflow-y:auto; scroll-snap-type:y proximity; scroll-padding-top:4px; }
#amulet-panel.bag-open #bag-details .bag-detail-body > *,#amulet-panel.bag-open #bag-details .bag-detail-stats > div { scroll-snap-align:start; }
#amulet-panel.bag-open #bag-details .bag-detail-body > :last-child { scroll-snap-align:end; }
/* A cue that there is more below: a fade at the lower edge while content is left (bag-scroll-cue.mjs sets data-more). */
#amulet-panel.bag-open #bag-details .bag-detail-body[data-more="true"] { -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 34px),transparent); mask-image:linear-gradient(to bottom,#000 calc(100% - 34px),transparent); }
#amulet-panel.bag-open #bag-details .bag-detail-body { scrollbar-width:thin; scrollbar-gutter:stable; }

/* T-098 review N2: the weapon description wraps the same way at every window size (15px, balanced lines: no one-character last line,
   no break in the middle of a word group) and takes less height than the 17px / 1.7 default, so the longest text does not make the body scroll. */
#amulet-panel.bag-open .bag-detail-description { font-size:15px; line-height:1.5; text-wrap:balance; }
/* The description now sits in the body, always visible, so the roomy 1080p spacing is tightened (same values as the short-window set) to keep
   the longest weapon (sunlance, expanded) inside the body without scrolling, as it was before. */
#amulet-panel.bag-open .bag-detail-art { height:64px; margin:4px 0 0; }
#amulet-panel.bag-open .bag-detail-state { margin:2px 0 0; }
#amulet-panel.bag-open .bag-detail-facts { padding-block:4px; }
#amulet-panel.bag-open .bag-detail-stats { gap:3px; margin:0 0 6px; }
#amulet-panel.bag-open .bag-detail-description { margin:4px 0 6px; word-break:auto-phrase; }

/* Short windows (720-ish): the same facts in less height, so the longest weapon fits without scrolling. */
@media (min-width:901px) and (max-height:820px) {
  #amulet-panel.bag-open #bag-details { padding:10px 12px; }
  #amulet-panel.bag-open .bag-detail-type { margin:0 0 2px; font-size:14px; line-height:1.35; }
  #amulet-panel.bag-open .bag-detail-name { font-size:21px; line-height:1.25; }
  #amulet-panel.bag-open .bag-detail-art { height:56px; margin:4px 0 0; }
  #amulet-panel.bag-open .bag-detail-state { margin:2px 0 0; font-size:15px; line-height:1.3; }
  #amulet-panel.bag-open .bag-detail-effect { margin:2px 0 4px; font-size:17px; line-height:1.35; }
  #amulet-panel.bag-open .bag-detail-size { margin:2px 0 6px; font-size:14px; line-height:1.3; }
  #amulet-panel.bag-open .bag-detail-summary { margin:4px 0; font-size:15px; line-height:1.4; }
  #amulet-panel.bag-open .bag-detail-facts { padding-block:4px; }
  #amulet-panel.bag-open .bag-detail-stats { gap:3px; margin:0 0 6px; font-size:15px; }
  #amulet-panel.bag-open .bag-detail-stats > div { padding-bottom:2px; }
  #amulet-panel.bag-open .bag-detail-description,#amulet-panel.bag-open .bag-detail-tag { margin:4px 0 6px; font-size:15px; line-height:1.45; text-wrap:balance; }
  #amulet-panel.bag-open .bag-detail-current{ margin:6px 0; padding:6px 8px; gap:2px; }
  #amulet-panel.bag-open .bag-detail-current span { font-size:14px; line-height:1.4; }
  #amulet-panel.bag-open .bag-detail-current strong { font-size:15px; line-height:1.4; }
  #amulet-panel.bag-open .bag-sale-reason { margin:4px 0; font-size:14px; line-height:1.4; }
  #amulet-panel.bag-open [data-disclosure-trigger] { min-height:34px; padding:4px 0; }
  #amulet-panel.bag-open .bag-detail-actions { gap:5px; margin-top:6px; padding-top:6px; }
  #amulet-panel.bag-open .bag-detail-actions .bag-action { min-height:36px; padding-block:4px; font-size:16px; }
  #amulet-panel.bag-open .bag-detail-actions > .bag-action:first-child { font-size:17px; }
}

/* T-092: asking before a keyring swap drops amulets on the floor. */
.keyring-confirm { position:absolute; z-index:60; inset:0; display:grid; place-items:center; padding:24px; background:#0a1310d8; }
.keyring-confirm[hidden] { display:none; }
.keyring-confirm-card { box-sizing:border-box; width:min(460px,100%); max-height:100%; overflow:auto; padding:16px 20px 14px; border:1px solid var(--ui-line,#6f8a6c66); border-top:3px solid #d27b7b; border-radius:3px; background:linear-gradient(#112220,#0b1513); color:#e4eee6; box-shadow:0 14px 36px #000c; text-align:left; }
.keyring-confirm-card h2 { margin:0 0 10px; color:#f08a7e; letter-spacing:.04em; font-size:19px; line-height:1.3; }
.keyring-confirm-swap { display:flex; align-items:center; gap:8px; margin:0 0 8px; }
.keyring-confirm-ring { display:flex; flex:1 1 0; align-items:center; gap:6px; min-width:0; padding:4px 6px; border:1px solid #6f8a6c66; border-radius:2px; background:#0c1715; }
.keyring-confirm-ring canvas { flex:none; width:36px; height:36px; image-rendering:pixelated; }
.keyring-confirm-ring-text { display:grid; min-width:0; line-height:1.25; }
.keyring-confirm-ring-text small { color:#8fb3a6; font-size:11px; }
.keyring-confirm-ring-text strong { font-size:14px; }
.keyring-confirm-slots { font-size:12px; }
.keyring-confirm-arrow { color:#8fb3a6; font-size:20px; font-weight:700; }
.keyring-confirm-drops { margin:6px 0; padding:6px 10px 6px 28px; border:1px dashed #d27b7b; border-radius:2px; background:#2a1517; color:#f4b4aa; font-size:15px; font-weight:700; line-height:1.5; }
.keyring-confirm-lead,.keyring-confirm-note { margin:6px 0; font-size:13px; line-height:1.5; }
.keyring-confirm-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:12px; }
.keyring-confirm-actions button { min-width:108px; min-height:40px; padding:6px 14px; border:1px solid #6f8a6c88; border-radius:2px; background:#0c1715; color:#e4eee6; font:inherit; font-size:15px; font-weight:700; cursor:pointer; }
.keyring-confirm-actions button:hover { border-color:#8bd8c4aa; background:#142623; }
.keyring-confirm-actions #keyring-confirm-ok { border-color:#f08a7e; background:#8c2f2f; color:#fff; }
.keyring-confirm-actions #keyring-confirm-ok:hover { background:#a63a3a; }
.keyring-confirm-actions button:focus-visible { outline:2px solid #edbf80; outline-offset:2px; }
