/* 분신 용사 창(RB-22): 마이 티니 창 키트(prototype/Spikes/my-tiny/index.html .dim/.popup/.btn/.tabs/.toggle · .mail-row · .menu-pop) 그대로,
   구조·배치 수치는 EFZ(obj_mailbox_window · obj_setting_window · obj_inventory_window, references/games/efz/client/objects).
   #ui 는 게임 캔버스와 같은 상자(같이 90° 돌림)라 창도 가로 논리 화면 안에 뜬다. 창이 없으면 누르기는 캔버스로 지나간다. */
#ui {
  --ink: #5e3d22; --ink-soft: #8d6c47;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; color: var(--ink);
  pointer-events: none; overflow: hidden; user-select: none; -webkit-user-select: none; z-index: 5;
}
#ui * { box-sizing: border-box; margin: 0; }
#ui .zw { position: absolute; left: 0; top: 0; }
#ui button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* 팝업(마이 티니 .dim/.popup) — fixed 대신 #ui 안 absolute */
#ui .dim {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
  background: #1e2a1266; padding: 10px; opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
#ui .dim.open { opacity: 1; pointer-events: auto; }
#ui .popup {
  width: min(560px, 100%); border: 30px solid transparent; border-image: url(assets/ui/panel.webp) 72 fill / 30px stretch;
  filter: drop-shadow(0 10px 18px #0006); transform: scale(.9); transition: transform .18s cubic-bezier(.3, 1.5, .6, 1);
}
#ui .dim.open .popup { transform: scale(1); }
#ui .popup-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 10px; border-bottom: 2px solid #d6bd92; margin-bottom: 12px; }
#ui .popup-head h2 { font-size: 20px; font-weight: 800; }
#ui .close {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #e59a7a, #c0603f 70%); border: 3px solid #8e3f25;
  box-shadow: inset 0 2px #f6c3ad, 0 2px 0 #6f2f1b; color: #fff7ea; font-size: 18px; font-weight: 900; line-height: 1;
}
#ui .btn {
  min-height: 32px; padding: 4px 18px; border: 10px solid transparent; border-image: url(assets/ui/button-green.webp) 22 72 fill / 10px 24px stretch;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fffce7; font-size: 14px; font-weight: 800; text-shadow: 0 1px 2px #435022; transition: transform .1s ease, filter .1s ease;
}
#ui .btn.gold { border-image-source: url(assets/ui/button-gold.webp); text-shadow: 0 1px 2px #876025; }
#ui .btn.danger { border-image-source: url(assets/ui/button-gold.webp); filter: hue-rotate(-38deg) saturate(1.5) brightness(.92); text-shadow: 0 1px 2px #6a1c10; }
#ui .btn:not(:disabled):active { transform: scale(.95); }
#ui .btn:disabled { filter: grayscale(1) brightness(1.05); opacity: .6; cursor: default; }
#ui .btn.plain { border-image: none; border: 2px solid #c9ac77; border-bottom-width: 4px; border-radius: 10px; background: #fbf1da; color: var(--ink); text-shadow: none; }

/* 우편·설정(마이 티니 .sheet — EFZ 우편 560x430, 설정 380x430) */
#ui .popup.sheet { display: flex; flex-direction: column; max-height: calc(var(--uiH, 100vh) - 20px); }
#ui .popup.mail { width: min(560px, 100%); height: min(430px, calc(var(--uiH, 100vh) - 20px)); }
#ui .popup.settings { width: min(380px, 100%); height: min(430px, calc(var(--uiH, 100vh) - 20px)); }
#ui .popup-head .count { margin-left: auto; margin-right: 12px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
#ui .sheet-body { flex: 1; min-height: 0; overflow: auto; border: 2px solid #d6bd92; border-radius: 10px; background: #efe0c0; padding: 8px; box-shadow: inset 0 2px 4px #a17c4a40; }
#ui .sheet-foot { flex: none; display: flex; justify-content: center; padding-top: 10px; }
#ui .mail-list { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
#ui .mail-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; min-height: 74px; padding: 0 2px; border: 14px solid transparent; border-image: url(assets/hud/slot.webp) 72 fill / 14px stretch; }
#ui .mail-icon { width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center; background: #e3cfa4; border: 2px solid #c9ac77; box-shadow: inset 0 2px #f7ecd2; }
#ui .mail-icon img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
#ui .mail-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#ui .mail-text b { font-size: 15px; font-weight: 800; }
#ui .mail-text span { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
#ui .mail-text .expired { color: #b0492f; }
#ui .mail-row .btn { width: 72px; min-height: 30px; padding: 2px 0; font-size: 13px; }
#ui .empty { flex: 1; min-height: 100px; height: 100%; display: grid; place-items: center; color: var(--ink-soft); font-weight: 700; text-align: center; }
#ui .tabs { flex: none; display: grid; grid-template-columns: repeat(var(--n, 2), 1fr); gap: 6px; margin-bottom: 10px; }
#ui .tab { height: 34px; border-radius: 9px; font-size: 14px; font-weight: 800; border: 2px solid #c9ac77; background: #f3e6c8; color: var(--ink-soft); }
#ui .tab[aria-selected="true"] { background: #fff8e6; color: var(--ink); border-color: #a9793e; box-shadow: inset 0 -3px #e5c98e; }
#ui .tab-panel[hidden] { display: none; }
#ui .user-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0; }
#ui .user-panel .btn { width: 218px; }
#ui .account-box { width: 100%; margin-top: 6px; padding: 8px 10px; min-height: 54px; border: 2px solid #d6bd92; border-radius: 8px; background: #f8eed8; font-size: 12px; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
#ui .account-box div { display: flex; justify-content: space-between; gap: 8px; }
#ui .toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 10px; margin-bottom: 10px; border: 2px solid #d6bd92; border-radius: 8px; background: #f8eed8; font-size: 15px; font-weight: 800; }
#ui .toggle { width: 76px; height: 28px; border-radius: 14px; position: relative; background: #cdbb98; border: 2px solid #a8916a; box-shadow: inset 0 2px 3px #0002; font-size: 12px; font-weight: 900; color: #fff; transition: background .15s ease; }
#ui .toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fffaf0; box-shadow: 0 1px 2px #0004; transition: left .15s ease; }
#ui .toggle[aria-checked="true"] { background: #8fae4c; border-color: #5f7d2c; }
#ui .toggle[aria-checked="true"]::after { left: 50px; }
#ui .toggle span { position: absolute; top: 50%; transform: translateY(-50%); }
#ui .toggle[aria-checked="true"] span { left: 12px; }
#ui .toggle[aria-checked="false"] span { right: 10px; color: #7a6a52; }
#ui .version { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 14px; }

/* 확인·입력(마이 티니 .ask) */
#ui .popup.ask { width: min(340px, 100%); text-align: center; }
#ui .ask p { font-size: 15px; font-weight: 800; padding: 8px 0 14px; white-space: pre-line; }
#ui .ask input { width: 100%; height: 38px; margin-bottom: 14px; padding: 0 10px; border: 2px solid #c9ac77; border-radius: 8px; background: #fffaf0; font: inherit; font-weight: 700; color: var(--ink); user-select: text; }
#ui .ask-buttons { display: flex; justify-content: center; gap: 10px; }
#ui .ask-buttons .btn { min-width: 96px; }
#ui .dim.ask-dim { z-index: 20; }

/* 메뉴(마이 티니 .menu-pop: 오른쪽 위에서 펼치는 버튼 모음, 가로 낮은 화면 7칸) */
#ui .menu-pop {
  position: absolute; z-index: 9; top: var(--menu-top, 58px); right: 12px; width: auto; pointer-events: auto;
  border: 22px solid transparent; border-image: url(assets/ui/panel.webp) 72 fill / 22px stretch; filter: drop-shadow(0 6px 12px #0007);
  display: grid; grid-template-columns: repeat(7, 58px); gap: 6px; transform-origin: top right; animation: menu-in .14s ease-out;
}
#ui .menu-pop[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: scale(.9); } }
#ui .menu-item { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 8px solid transparent; border-image: url(assets/hud/slot.webp) 72 fill / 8px stretch; font-size: 11px; font-weight: 800; white-space: nowrap; transition: transform .1s ease; }
#ui .menu-item:active { transform: scale(.94); }
#ui .menu-item img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 1px #6e4a2a55); }
#ui .menu-item img.pixel { image-rendering: pixelated; }
#ui .white-icon { position: relative; display: inline-grid; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(22,26,32,.45)) drop-shadow(0 0 1px rgba(22,26,32,.55)); }
#ui .white-icon img { opacity: 0; filter: none; }
#ui .white-icon::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#fff 12%, #f7f7f7 44%, #c7c9cc);
  mask: var(--glyph) center / contain no-repeat; -webkit-mask: var(--glyph) center / contain no-repeat; }
#ui .empty-slot-icon { width: 78%; height: 78%; opacity: .55; background: #8d6c47;
  mask: var(--slot-icon) center / contain no-repeat; -webkit-mask: var(--slot-icon) center / contain no-repeat; }

/* 물품(인벤토리): EFZ obj_inventory_window 가로 배치 — 장비창 | 물품 칸 | 아이템 정보 + 동작 줄, 창 min(W−20, 900) x min(H−20, 500) */
#ui .popup.inv { width: min(900px, 100%); height: min(500px, calc(var(--uiH, 100vh) - 20px)); border-width: 18px; border-image: url(assets/ui/panel.webp) 72 fill / 18px stretch; display: flex; flex-direction: column; }
#ui .inv .popup-head { padding-bottom: 6px; margin-bottom: 8px; }
#ui .inv .popup-head h2 { font-size: 17px; }
#ui .inv .close { width: 28px; height: 28px; font-size: 15px; }
#ui .inv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--eq, 218px) 1fr var(--dt, 260px); gap: 8px; }
#ui .inv-pane { min-height: 0; display: flex; flex-direction: column; border: 2px solid #d6bd92; border-radius: 10px; background: #efe0c0; padding: 6px 8px; box-shadow: inset 0 2px 4px #a17c4a40; }
#ui .inv-label { flex: none; display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 800; color: var(--ink-soft); margin-bottom: 4px; }
#ui .inv .tabs { margin-bottom: 6px; gap: 3px; }
#ui .inv .tab { height: 26px; font-size: 12px; border-radius: 7px; }
#ui .inv-preview { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; }
#ui .inv-preview canvas { flex: 1; min-height: 0; max-width: 100%; image-rendering: pixelated; }
#ui .inv-preview b { font-size: 14px; font-weight: 800; }
#ui .inv-preview span { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
#ui .equip-grid { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(4, var(--cell, 40px)); justify-content: center; gap: 4px 8px; align-content: start; }
#ui .equip-cell { width: var(--cell, 40px); height: var(--cell, 40px); position: relative; border-radius: 7px; background: #e3cfa4; border: 2px solid #c9ac77; box-shadow: inset 0 2px #f7ecd2; display: grid; place-items: center; font-size: 9px; font-weight: 800; color: var(--ink-soft); text-align: center; line-height: 1.05; letter-spacing: -.4px; }
#ui .equip-cell.filled { background: #fff8e6; border-color: #a9793e; }
#ui .equip-cell img { width: 66%; height: 66%; object-fit: contain; image-rendering: pixelated; }
#ui .item-grid { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, 52px); gap: 4px; align-content: start; justify-content: center; padding: 4px; border-radius: 8px; background: #e6d3ad; box-shadow: inset 0 1px 3px #a17c4a55; position: relative; }
#ui .item-cell { width: 52px; height: 52px; position: relative; border-radius: 8px; background: #d9c297; border: 2px solid #c4a672; box-shadow: inset 0 2px #ecdcb8; }
#ui .item-cell.has { background: var(--grade, #f4e8cc); border-color: #a9793e; cursor: pointer; }
#ui .item-cell.sel { outline: 2px solid #5e3d22; outline-offset: 2px; }
#ui .item-cell img { position: absolute; left: 17%; top: 10%; width: 66%; height: 66%; object-fit: contain; image-rendering: pixelated; }
#ui .item-cell .cnt { position: absolute; left: 0; right: 0; bottom: 1px; text-align: center; font-size: 10px; font-weight: 900; color: #fff; -webkit-text-stroke: 3px #3b2412; paint-order: stroke; }
#ui .item-cell .tier { position: absolute; right: 2px; top: 2px; width: 0; height: 0; border-style: solid; border-width: 0 9px 9px 0; border-color: transparent var(--tier) transparent transparent; }
#ui .item-cell .worn { position: absolute; left: 2px; top: 2px; font-size: 8px; font-weight: 900; color: #fff; background: #5f7d2c; border-radius: 4px; padding: 0 2px; }
#ui .inv-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--ink-soft); pointer-events: none; }
#ui .inv-foot { flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding-top: 6px; }
#ui .inv-foot .btn, #ui .inv-actions .btn { min-height: 26px; padding: 0 10px; font-size: 12px; border-width: 7px; border-image-width: 7px 18px; }
#ui .weight { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 800; color: var(--ink-soft); text-align: center; }
#ui .weight i { display: block; height: 6px; border-radius: 3px; background: #c9b48a; overflow: hidden; }
#ui .weight i b { display: block; height: 100%; width: 0; background: #7fbf3f; }
#ui .detail { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
#ui .detail-top { display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: center; }
#ui .detail-top .item-cell { width: 58px; height: 58px; }
#ui .detail-name { font-size: 14px; font-weight: 800; }
#ui .detail-sub { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
#ui .detail-rows div { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; padding: 3px 6px; border-radius: 5px; }
#ui .detail-rows div:nth-child(odd) { background: #f8eed8; }
#ui .inv-actions { flex: none; display: flex; justify-content: center; gap: 6px; padding-top: 6px; }
