/* ===== 換衣間 v2.4（設計 A）：飼育房右上衣服鈕／點頭像進來。第一次「選擇你的形象」仍是 #avatar-screen，沒有動 ===== */
/* HUD：頭像放大到 60px（頭像原圖 120 → 剛好 1:2，像素不糊），拿掉「換裝」字牌 */
#hud-face{width:60px;height:60px;border-width:3px;border-radius:10px}
#open-wardrobe span{display:none}
#open-wardrobe{position:relative}
/* 右上小按鈕：多一顆衣服（換衣間）。正式模式 4 顆 = 2×2；測試模式多「選蛋」時排成 3 欄、選蛋佔 2 格 */
.hud-mini:has(#back:not([hidden])){grid-template-columns:repeat(3,auto)}
.hud-mini:has(#back:not([hidden])) #back{grid-column:span 2}
#open-closet{font-size:0;padding:0 2px;display:grid;place-items:center;position:relative}
#open-closet::before{content:"";display:block;width:24px;height:24px;image-rendering:pixelated;background:url("assets/closet/closet-icons.png?v=438fe3d1c4") no-repeat 0 0/80px 24px}
/* v2.4b：新解鎖記號＝小圓紅點＋白色「!」，壓在按鈕右上角外側，不蓋到衣服圖示（原本是 8px 方塊，看起來像紅色大方塊） */
#open-closet[data-new]::after,.cl-tab[data-new]::after{content:"!";position:absolute;z-index:2;box-sizing:border-box;width:16px;height:16px;display:grid;place-items:center;
  border-radius:50%;background:#e83a3a;border:2px solid #3a1d00;color:#fff;font:700 11px/1 "Cubic11",system-ui,sans-serif;text-align:center;
  box-shadow:inset 0 -2px 0 rgba(58,29,0,.28);pointer-events:none}
#open-closet[data-new]::after{top:-9px;right:-9px}

main:has(#closet-screen:not([hidden])) header{display:none}
.closet{display:grid;gap:6px;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto auto auto auto;min-height:0;padding:8px}
.closet > *,.cl-body > *{min-width:0}
.closet[hidden]{display:none}
.cl-top{display:flex;align-items:center;gap:6px}
.cl-top h2{flex:1;margin:0;text-align:center;font-size:1.15rem}
.cl-top h2 span{display:inline-block;padding:0 6px;border:8px solid transparent;border-width:8px 16px;border-image:url("assets/ui2-title.png?v=438fe3d1c4") 8 16 fill / 8px 16px stretch;line-height:1.4}
.cl-top .back{min-height:44px;min-width:64px;padding:0 6px;font-weight:700}
.cl-gender{display:flex;gap:2px}
.cl-gender button{min-width:44px;min-height:44px;font-weight:700;font-size:.85rem;padding:0 4px}
.cl-stage{position:relative;min-height:150px;display:grid;place-items:end center;background:#f3e3d3 url("assets/dressing-room.png?v=438fe3d1c4") center bottom/384px auto no-repeat;image-rendering:pixelated;border:3px solid var(--edge,#1b1430);border-radius:12px;overflow:hidden}
.cl-stage canvas{image-rendering:pixelated;max-width:none}
.cl-stage canvas.pop{animation:avatar-pop .28s steps(4,end)}
.cl-tryon{position:absolute;left:8px;top:8px;margin:0;padding:3px 8px;font-size:.78rem;font-weight:700;color:#fff;background:#6a3f9a;border:2px solid #1b1430;display:flex;gap:4px;align-items:center}
.cl-tryon[hidden]{display:none}
.cl-dirty{position:absolute;right:8px;top:8px;margin:0;padding:2px 8px;font-size:.74rem;font-weight:700;background:#fff6d6;color:#6b4b00;border:2px solid #1b1430}
.cl-dirty[hidden]{display:none}
/* 分類：一排 7 個圖示分頁（圖示＋字），選中的往上浮、接著下面的格子 */
.cl-tabs{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:2px}
.cl-tab{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0;min-height:52px;padding:2px 0;font-size:.7rem;font-weight:700;line-height:1.2;color:#2b2140;
  border:6px solid transparent;border-image:url("assets/ui2-chip.png?v=438fe3d1c4") 6 fill / 6px stretch;background:none}
.cl-tab[aria-selected="true"]{border-image-source:url("assets/ui2-chip-on.png?v=438fe3d1c4");translate:0 -3px}
.cl-tab i{width:24px;height:24px;image-rendering:pixelated;background:url("assets/ui2-icons.png?v=438fe3d1c4") no-repeat 0 0/384px 24px}
.cl-tab i.cl-own{background:url("assets/closet/closet-icons.png?v=438fe3d1c4") no-repeat 0 0/80px 24px}
.cl-panel{display:flex;flex-direction:column;gap:6px;min-height:0;height:clamp(196px,32dvh,290px);padding:4px;border:8px solid transparent;border-image:url("assets/ui2-card.png?v=438fe3d1c4") 8 fill / 8px stretch}
.cl-sw-row{display:grid;grid-template-columns:2.6em minmax(0,1fr);align-items:center;gap:4px}
.cl-sw-row b{font-size:.74rem;line-height:1.1;text-align:left}
.cl-swatches{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}
.cl-sw{position:relative;width:100%;height:44px;min-width:0;padding:0;border:3px solid #1b1430;background:var(--c,repeating-linear-gradient(45deg,#fff 0 4px,#ddd 4px 8px));box-shadow:inset 0 -4px rgba(0,0,0,.18),inset 0 3px rgba(255,255,255,.35)}
.cl-sw[aria-pressed="true"]{outline:3px solid #ffd34d;outline-offset:2px}
.cl-sw[aria-pressed="true"]::after,.cl-item[aria-pressed="true"]::after{content:"";position:absolute;right:-6px;top:-6px;width:16px;height:16px;background:url("assets/closet/closet-icons.png?v=438fe3d1c4") no-repeat -64px -4px/80px 24px;image-rendering:pixelated}
.cl-sw[data-orig]::before{content:"原";position:absolute;inset:0;display:grid;place-items:center;font-size:.72rem;font-weight:700;color:#2b2140}
.cl-grid{flex:1;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;align-content:start;overflow-y:auto;min-height:0;padding:6px 4px 2px}
.cl-grid.cl-big{grid-template-columns:repeat(4,minmax(0,1fr))}
.cl-item{position:relative;display:flex;flex-direction:column;align-items:center;gap:2px;padding:4px 2px 3px;min-height:44px;font-size:.68rem;font-weight:700;line-height:1.2;color:#2b2140;
  border:6px solid transparent;border-image:url("assets/ui2-chip.png?v=438fe3d1c4") 6 fill / 6px stretch;background:none}
.cl-item[aria-pressed="true"]{border-image-source:url("assets/ui2-chip-on.png?v=438fe3d1c4")}
.cl-item canvas{width:60px;height:60px;image-rendering:pixelated;background:#fff8e6;border:2px solid #d9c6a2}
.cl-item .cl-name{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cl-item[data-locked] canvas{filter:brightness(0) opacity(.28)}
.cl-item[data-locked] .cl-name{color:#7a6a80}
.cl-item[data-locked]::before{content:"";position:absolute;left:50%;top:22px;translate:-50% 0;width:32px;height:32px;background:url("assets/closet/closet-icons.png?v=438fe3d1c4") no-repeat -96px -8px/160px 48px;image-rendering:pixelated}
.cl-item .cl-hint{font-size:.6rem;font-weight:400;color:#7a4a3a;line-height:1.15;text-align:center;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}
.cl-item[data-planned]{border-image-source:none;border:3px dashed #9fb399;opacity:.7}
.cl-item[data-tapped]{animation:cl-shake .3s steps(3,end)}
@keyframes cl-shake{33%{translate:-3px 0}66%{translate:3px 0}}
.cl-none{display:grid;place-items:center;width:60px;height:60px;background:#fff8e6;border:2px solid #d9c6a2;font-size:1.4rem;color:#b9a487}
.cl-note{position:absolute;left:6px;right:6px;bottom:6px;margin:0;padding:4px 8px;font-size:.8rem;font-weight:700;color:#fff;background:rgba(27,20,48,.86);text-align:center;border:2px solid #1b1430}
.cl-note:empty{display:none}
.cl-actions{display:grid;grid-template-columns:1fr 2fr;gap:8px}
.cl-actions button{min-height:48px;font-weight:700;font-size:1rem}
.cl-actions .confirm:disabled{opacity:.5}

.closet .cl-body{display:contents}
#open-wardrobe:focus-visible,#open-closet:focus-visible{outline:3px solid #325247;outline-offset:2px}
/* 新解鎖的格子／分類：小紅點＋NEW */
.cl-tab{position:relative}
.cl-tab[data-new]::after{top:-8px;right:-8px}
.cl-item .cl-newtag{position:absolute;left:-4px;top:-6px;z-index:1;padding:0 3px;font-size:.58rem;line-height:1.3;font-weight:700;color:#fff;background:#ff5a6e;border:2px solid #1b1430}
.cl-tab:focus-visible,.cl-item:focus-visible,.cl-sw:focus-visible,.cl-gender button:focus-visible,.cl-actions button:focus-visible,.cl-top .back:focus-visible{outline:3px solid #325247;outline-offset:2px}
.cl-sw[aria-pressed="true"]:focus-visible{outline-color:#ffd34d}
.closet h2:focus{outline:none}
/* 正在試穿的鎖住格子：剪影拿掉、框變紫，看得出來現在預覽的是哪一件 */
.cl-item[data-trying]{border-image-source:url("assets/ui2-chip-on.png?v=438fe3d1c4")}
.cl-item[data-trying] canvas{filter:none;opacity:.85}
.cl-item[data-trying]::before{top:4px;left:auto;right:2px;translate:none;width:16px;height:16px;background-position:-48px -4px;background-size:80px 24px}
/* 上面有「離線中」橫幅時，格子區矮一點，讓人物在 360×740 也能維持 2 倍 */
:root:has(#sync-status:not([hidden])) .closet .cl-panel{height:clamp(170px,26dvh,290px)}
