/* Castle Facilities -- the game's citadel-tech screen (Menu_CastleTech_UGUI) on the research page.
   Blueprint is 1920 units wide; --k is one unit. Square cuts only (no rounded corners). */
.inv-cfac{display:none;position:relative;container-type:inline-size;background:#1a120b url(../images/castle-fac/desk.webp) center/cover no-repeat;color:#e8eef6;font-family:Inter,system-ui,sans-serif;overflow:clip}
.inv-research[data-rtab="castle"] .inv-cfac{display:block}
.inv-research[data-rtab="castle"] .inv-research-main,
.inv-research[data-rtab="castle"] .inv-research-stats,
.inv-research[data-rtab="castle"] .inv-rtabs__tools,
.inv-research[data-rtab="castle"] .inv-tree-detail,
.inv-research[data-rtab="castle"] .inv-tree-detail__backdrop{display:none!important}
.inv-cfac[hidden]{display:none}

/* Top band: OVERVIEW + the next milestone + the facility currency */
/* Full-page flow (user 11-19: no inner scroll box) -- the page scrolls; the band sticks under the header, I / II at the screen foot. */
.inv-cfac__top{position:sticky;z-index:5;top:var(--inv-header-h,64px);display:flex;align-items:center;gap:12px;padding:6px 10px;background:rgba(26,18,11,.92);box-shadow:0 6px 16px rgba(0,0,0,.35)}
/* frame_n_entityreform_02: blue band fading out to the right */
.inv-cfac__band{flex:0 1 auto;min-width:0;display:flex;align-items:center;gap:18px;min-height:76px;padding:4px 120px 4px 18px;background:url(../images/castle-fac/frame_n_entityreform_02.webp) left center/100% 100% no-repeat}
.inv-cfac__ov{flex:none;position:relative;display:flex;flex-direction:column;align-items:center;background:none;border:0;padding:0;cursor:pointer;color:#f2e2b8;font:700 .8rem/1 Georgia,'Times New Roman',serif;letter-spacing:.04em;text-transform:uppercase;text-shadow:0 1px 2px #000}
.inv-cfac__ovic{position:relative;width:62px;height:62px;display:block;margin-bottom:-12px}
.inv-cfac__ovic img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
.inv-cfac__ovic .inv-cfac__ovi{inset:10px;width:42px;height:42px}
.inv-cfac__ov span:last-child{position:relative}
.inv-cfac__ov:hover{filter:brightness(1.2)}
.inv-cfac__stone{display:flex;align-items:center;gap:12px;min-width:0}
.inv-cfac__shield{flex:none;position:relative;display:inline-grid;place-items:center;width:48px;height:48px;background:url(../images/castle-fac/icon_n_entityreform_02c.webp) center/contain no-repeat;color:#7c818b;font:500 1.15rem Inter,sans-serif}
.inv-cfac__shield.is-got{background-image:url(../images/castle-fac/icon_n_entityreform_02a.webp);color:#cfd6e2}
.inv-cfac__shield.is-cur{background-image:url(../images/castle-fac/icon_n_entityreform_02b.webp);color:#f3d27a}
.inv-cfac__shield.is-cur::after{content:"";position:absolute;inset:-3px;background:url(../images/castle-fac/icon_n_entityreform_02_select.webp) center/contain no-repeat}
.inv-cfac__shield b{font-weight:500;position:relative;top:-2px}
.inv-cfac__stxt{font-size:1.02rem;line-height:1.25;color:#f4f7fb}
.inv-cfac__stxt small{display:block;font-size:.75rem;color:#9fb0c6}
.inv-cfac__fold{flex:none;margin-left:12px;width:36px;height:44px;border:0;background:none;cursor:pointer;position:relative}
.inv-cfac__fold::before{content:"";position:absolute;left:12px;top:15px;width:12px;height:12px;border:solid #e8eef6;border-width:3px 3px 0 0;transform:rotate(45deg)}
.inv-cfac__band.is-open .inv-cfac__fold::before{left:16px;transform:rotate(-135deg)}
.inv-cfac__band.is-open .inv-cfac__ov,.inv-cfac__band.is-open .inv-cfac__stone{display:none}
.inv-cfac__track{flex:0 1 auto;min-width:0;overflow-x:auto;scrollbar-width:thin}
.inv-cfac__track[hidden]{display:none}
.inv-cfac__trk{position:relative;display:flex;gap:0;width:max-content;padding:2px 0}
.inv-cfac__trk::before{content:"";position:absolute;left:40px;right:40px;top:25px;height:8px;background:#2f3440;box-shadow:inset 0 1px 0 rgba(0,0,0,.5)}
.inv-cfac__ts{position:relative;display:flex;flex-direction:column;align-items:center;gap:2px;width:120px}
.inv-cfac__ts small{display:flex;align-items:center;gap:3px;font-size:1rem;color:#e8eef6}
.inv-cfac__ts small img{width:20px;height:20px;opacity:.75}
.inv-cfac__ts.is-cur::before{content:"";position:absolute;left:0;right:50%;top:25px;height:8px;background:#e8eef6}
.inv-cfac__ts.is-got::before{content:"";position:absolute;left:0;right:0;top:25px;height:8px;background:#e8eef6}
.inv-cfac__ts .inv-cfac__shield{z-index:1}
.inv-cfac__cur{flex:none;margin-left:auto;display:flex;align-items:center;gap:8px;padding:4px 16px 4px 4px;background:linear-gradient(90deg,rgba(30,40,58,.95),rgba(30,40,58,.6));color:#fff}
.inv-cfac__cur b{font:400 1.35rem Inter,sans-serif;color:#fff}
.inv-cfac__cur img{width:44px;height:44px}

/* The blueprint */
.inv-cfac__scroll{padding:22px 0 0}
.inv-cfac__board{--k:calc(100cqw / 1920);position:relative;width:min(100%,1180px);margin:0 auto;container-type:inline-size;background:center top/100% 100% no-repeat;box-shadow:0 0 40px rgba(0,0,0,.6)}
.inv-cfac__msg{padding:120px 20px;text-align:center;color:#3b2a17;font:600 1rem Georgia,serif;background:#e8dcc0}
.inv-cfac__floor{position:absolute;transform:translate(-50%,-50%);display:grid;place-items:center;width:calc(var(--k) * 64);height:calc(var(--k) * 64);background:url(../images/castle-fac/frame_castletech_08.webp) center/contain no-repeat;color:#e9dfc8;font:700 calc(var(--k) * 34) Georgia,serif}

.inv-cfac__node{position:absolute;display:block;padding:0;margin:0;border:0;background:none;cursor:pointer;color:inherit}
.inv-cfac__pic{position:relative;display:block;width:100%;aspect-ratio:1;background:#2b261e;box-shadow:0 0 0 calc(var(--k) * 3) rgba(70,58,40,.55)}
.inv-cfac__node.is-big .inv-cfac__pic{aspect-ratio:382 / 162}
.inv-cfac__pic > img:first-child{width:100%;height:100%;object-fit:cover;display:block}
.inv-cfac__lock{position:absolute;left:50%;top:50%;width:calc(var(--k) * 64);height:calc(var(--k) * 64);transform:translate(-50%,-50%);display:none}
.inv-cfac__node.is-locked .inv-cfac__pic > img:first-child{filter:grayscale(1) brightness(.72) contrast(.9)}
.inv-cfac__node.is-locked .inv-cfac__lock{display:block}
.inv-cfac__node.is-max .inv-cfac__pic::after{content:"";position:absolute;inset:calc(var(--k) * -10);background:url(../images/castle-fac/frame_castletech_05.webp) center/100% 100% no-repeat;mix-blend-mode:screen;pointer-events:none}
.inv-cfac__lv{position:absolute;right:0;bottom:0;min-width:calc(var(--k) * 74);padding:0 calc(var(--k) * 8) 0 calc(var(--k) * 14);height:calc(var(--k) * 30);display:grid;place-items:center end;background:center/100% 100% no-repeat;color:#fff;font:600 calc(var(--k) * 21)/1 Inter,sans-serif;text-shadow:0 1px 1px rgba(0,0,0,.6)}
.inv-cfac__lv.c-red{background-image:url(../images/castle-fac/frame_n_entityreform_04a.webp)}
.inv-cfac__lv.c-gold{background-image:url(../images/castle-fac/frame_n_entityreform_04b.webp);color:#2a1a08;text-shadow:none}
.inv-cfac__lv.c-blue{background-image:url(../images/castle-fac/frame_n_entityreform_04c.webp)}
.inv-cfac__name{position:absolute;left:50%;top:calc(var(--k) * -34);transform:translateX(-50%);width:calc(var(--k) * 264);height:calc(var(--k) * 70);display:grid;place-items:center;background:url(../images/castle-fac/frame_n_entityreform_05.webp) center/100% 100% no-repeat;pointer-events:none}
/* frame_castletech_01 is solid only in its top 11-51 of 90 px: the text sits on that strip, not the box centre. */
.inv-cfac__node.is-big .inv-cfac__name{top:calc(var(--k) * -40);width:calc(var(--k) * 370);height:calc(var(--k) * 95);align-items:start;padding-top:calc(var(--k) * 15);background-image:url(../images/castle-fac/frame_castletech_01.webp)}
.inv-cfac__node.is-big .inv-cfac__name span{font-size:calc(var(--k) * 27);line-height:1.1;white-space:nowrap}
.inv-cfac__name span{padding:0 calc(var(--k) * 34) calc(var(--k) * 8);color:#2f2416;font:700 calc(var(--k) * 23)/.88 Georgia,'Times New Roman',serif;text-align:center}
.inv-cfac__node:hover .inv-cfac__pic{box-shadow:0 0 0 calc(var(--k) * 4) #d9b45d}
.inv-cfac__node.is-sel .inv-cfac__pic{box-shadow:0 0 0 calc(var(--k) * 5) #f3d27a,0 0 calc(var(--k) * 30) rgba(243,210,122,.7)}

/* I / II */
.inv-cfac__tabs{position:sticky;z-index:5;bottom:10px;display:flex;justify-content:center;gap:0;width:max-content;margin:-80px auto 10px}
/* Game: two plates joined in the middle, left one points left, right one points right (same sprite mirrored);
   the numeral sits on the castle icon. */
.inv-cfac__tab{position:relative;display:grid;place-items:center;width:240px;height:70px;padding:0;border:0;cursor:pointer;background:none;isolation:isolate}
.inv-cfac__tab::before{content:"";position:absolute;inset:0;z-index:-1;background:url(../images/castle-fac/pic_n_castletech_tab_02.webp) center/100% 100% no-repeat}
.inv-cfac__tab.is-on::before{background-image:url(../images/castle-fac/pic_n_castletech_tab_01.webp)}
.inv-cfac__tab[data-part="2"]::before{transform:scaleX(-1)}
.inv-cfac__tab img{grid-area:1 / 1;width:52px;height:52px;object-fit:contain}
.inv-cfac__tab .inv-cfac__tabn{width:30px;height:30px;z-index:1}
.inv-cfac__tab .is-on-i,.inv-cfac__tab.is-on .is-off-i{display:none}
.inv-cfac__tab.is-on .is-on-i{display:block}
.inv-cfac__tab:not(.is-on) .inv-cfac__tabn{opacity:.75}
.inv-cfac__tab:hover::before{filter:brightness(1.15)}

/* Detail panel -- the game's right-hand panel */
.inv-cfac__pop{position:fixed;z-index:60;top:var(--inv-header-h,64px);left:0;right:0;bottom:0;background:linear-gradient(90deg,rgba(8,12,20,0) 0,rgba(8,12,20,.35) 45%)}
.inv-cfac__pop[hidden]{display:none}
.inv-cfac__card{position:absolute;top:0;right:0;bottom:0;width:min(46%,600px);display:flex;flex-direction:column;background:linear-gradient(90deg,rgba(26,38,56,.86),rgba(26,38,56,.97) 18%);box-shadow:-20px 0 40px rgba(0,0,0,.35)}
.inv-cfac__scrollc{flex:1;min-height:0;overflow:auto;padding:22px 26px 18px}
.inv-cfac__x{position:absolute;z-index:2;top:8px;right:8px;width:34px;height:34px;border:0;background:rgba(0,0,0,.35);color:#cfd8e6;font-size:1.4rem;line-height:1;cursor:pointer}
.inv-cfac__hd{display:flex;align-items:flex-start;gap:12px;padding:0 40px 10px 0;border-bottom:1px solid rgba(160,180,205,.35)}
.inv-cfac__hd h3{flex:1;margin:0;color:#e8c47a;font:700 1.75rem/1.05 Georgia,'Times New Roman',serif;font-variant:small-caps;letter-spacing:.01em}
.inv-cfac__type{flex:none;margin-top:4px;padding:5px 22px;background:center/100% 100% no-repeat;color:#fff;font-size:.95rem}
.inv-cfac__type.c-red{background-image:url(../images/castle-fac/frame_n_entityreform_04a.webp)}
.inv-cfac__type.c-blue{background-image:url(../images/castle-fac/frame_n_entityreform_04c.webp)}
.inv-cfac__type.c-gold{background-image:url(../images/castle-fac/frame_n_entityreform_04b.webp);color:#2a1a08}
.inv-cfac__desc{margin:12px 0 10px;color:#eef2f7;font-size:1.02rem}
.inv-cfac__rows{display:grid}
.inv-cfac__row,.inv-cfac__req{display:flex;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid rgba(160,180,205,.28);font-size:1.02rem}
.inv-cfac__row > img,.inv-cfac__row > i:first-child,.inv-cfac__req > img{flex:none;width:34px;height:34px;object-fit:contain}
.inv-cfac__row span,.inv-cfac__req span{flex:1;min-width:0}
.inv-cfac__row b,.inv-cfac__req b,.inv-cfac__pcb b{flex:none;display:inline-flex;align-items:center;gap:4px;font-weight:500;font-size:1.05rem;color:#fff}
.inv-cfac__row em,.inv-cfac__pcb em{font-style:normal;color:#7fdc6a}
.inv-cfac__arr{display:inline-block;width:0;height:0;border:7px solid transparent;border-left:11px solid #5cc84a;border-right:0}
.inv-cfac h4{margin:22px 0 2px;color:#e8c47a;font:700 1.15rem Georgia,'Times New Roman',serif;text-transform:uppercase;letter-spacing:.03em}
.inv-cfac__req.is-bld b{color:#cfd8e6}
.inv-cfac__req.is-rw b{color:#fff}
.inv-cfac__cards{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px 0 4px}
.inv-cfac__pc{background:#1d2a3c;border:1px solid #4b5d77}
.inv-cfac__pch{padding:7px 8px;text-align:center;background:#24344a;color:#e8c47a;font:700 .95rem Georgia,serif;text-transform:uppercase}
.inv-cfac__pcb{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 10px 6px 6px}
.inv-cfac__pcb img{width:62px;height:62px;object-fit:cover}
.inv-cfac__pc.is-ok .inv-cfac__pcb b{color:#7fdc6a}
.inv-cfac__go{display:block;width:100%;padding:7px 0;border:0;cursor:pointer;background:linear-gradient(180deg,#f1d792,#d2a650);color:#2a1a08;font:700 1rem Georgia,serif}
.inv-cfac__go:hover{filter:brightness(1.08)}
.inv-cfac__sum{display:flex;justify-content:space-between;gap:10px;margin-top:18px;padding:10px 12px;background:rgba(0,0,0,.25);color:#cfd8e6;font-size:.9rem}
.inv-cfac__sum b{color:#e7d6a8;font-weight:600}
.inv-cfac__ms{display:grid}
.inv-cfac__m{display:flex;align-items:center;gap:12px;padding:8px 2px;border-bottom:1px solid rgba(160,180,205,.2);font-size:.92rem;opacity:.7}
.inv-cfac__m span:nth-child(2){flex:1}
.inv-cfac__m b{color:#9fb0c6;font-weight:500}
.inv-cfac__m.is-ok{opacity:1}
.inv-cfac__m.is-ok .inv-cfac__shield{background:#7a5b21;box-shadow:inset 0 0 0 2px #f3d27a}
.inv-cfac__m .inv-cfac__shield{width:32px;height:38px;font-size:.85rem}

/* Level bar -- fixed at the panel foot, never in the scroll */
.inv-cfac__bar{flex:none;display:flex;align-items:stretch;gap:0;padding-right:76px;background:linear-gradient(180deg,#f0d48a,#c9993d);box-shadow:0 -6px 18px rgba(0,0,0,.35)}
.inv-cfac__lvl{flex:1;display:flex;align-items:center;justify-content:center;gap:.35em;white-space:nowrap;color:#2a1a08;font:700 1.2rem Georgia,serif;text-transform:uppercase}
.inv-cfac__lvl b{font-size:1.45rem}
.inv-cfac__step{flex:none;width:64px;min-height:56px;border:0;border-right:1px solid rgba(80,50,10,.35);background:rgba(255,255,255,.12);color:#2a1a08;font:700 1.6rem/1 Georgia,serif;cursor:pointer}
.inv-cfac__step[data-d="1"]{border-right:0;border-left:1px solid rgba(80,50,10,.35)}
.inv-cfac__step.is-max{width:auto;padding:0 18px;font-size:1rem;text-transform:uppercase;border-left:1px solid rgba(80,50,10,.35);border-right:0}
.inv-cfac__step:hover:not(:disabled){background:rgba(255,255,255,.3)}
.inv-cfac__step:disabled{opacity:.35;cursor:default}

/* Narrow tab: blueprint keeps a readable width and scrolls sideways inside its box;
   the panel becomes a full sheet over it (bar still pinned at the foot). */
@container (max-width:759.98px){
	.inv-cfac__top{gap:6px;padding:4px 6px}
	.inv-cfac__band{gap:10px;min-height:60px;padding:2px 40px 2px 8px}
	.inv-cfac__ovic{width:46px;height:46px;margin-bottom:-9px}
	.inv-cfac__ovic .inv-cfac__ovi{inset:8px;width:30px;height:30px}
	.inv-cfac__ov{font-size:.62rem}
	.inv-cfac__stxt{font-size:.8rem}
	.inv-cfac__shield{width:38px;height:38px;font-size:.95rem}
	.inv-cfac__fold{width:26px}
	.inv-cfac__fold::before{left:6px}
	.inv-cfac__band.is-open .inv-cfac__fold::before{left:10px}
	.inv-cfac__ts{width:84px}
	.inv-cfac__ts small{font-size:.8rem}
	.inv-cfac__trk::before,.inv-cfac__ts.is-cur::before,.inv-cfac__ts.is-got::before{top:20px;height:6px}
	.inv-cfac__cur{padding:2px 6px 2px 2px;gap:4px}
	.inv-cfac__cur img{width:32px;height:32px}
	.inv-cfac__cur b{font-size:1rem}
	.inv-cfac__scroll{padding:14px 0 0;overflow-x:auto;overscroll-behavior-x:contain}
	.inv-cfac__board{width:720px;min-width:720px}
	.inv-cfac__tabs{bottom:calc(67px + env(safe-area-inset-bottom,0px))}
	.inv-cfac__pop{z-index:1000}
	.inv-cfac__tabs{margin-top:-62px}
	.inv-cfac__tab{width:160px;height:52px}
	.inv-cfac__tab img{width:40px;height:40px}
	.inv-cfac__tab .inv-cfac__tabn{width:24px;height:24px}
	.inv-cfac__pop{background:rgba(8,12,20,.55)}
	.inv-cfac__card{width:100%;left:0}
	.inv-cfac__scrollc{padding:16px 12px 14px}
	.inv-cfac__hd h3{font-size:1.4rem}
	.inv-cfac__row,.inv-cfac__req{padding:10px 2px;font-size:.95rem}
	.inv-cfac__pcb img{width:48px;height:48px}
	.inv-cfac__step{width:54px}
	.inv-cfac__bar{padding-right:0}
}
