/* Craft screen matched to new ui/craft-items-v1.png. */
#modal-layer:has(.craft-screen-v1){padding:0;background:#11131c url('assets/bg.png') center/cover no-repeat;backdrop-filter:none}
.craft-screen-v1{--craft-edge:clamp(18px,4.5vw,38px);position:relative;width:min(100%,480px);height:min(100dvh,900px);overflow-y:auto;overflow-x:hidden;padding:calc(env(safe-area-inset-top) + 17px) var(--craft-edge) calc(env(safe-area-inset-bottom) + 16px);box-sizing:border-box;background:url('assets/craft/workshop-background.png') center/cover no-repeat;color:#0b3157;font-family:Rajdhani,Sarabun,sans-serif;scrollbar-width:none;animation:craft-in .2s ease-out}.craft-screen-v1::-webkit-scrollbar{display:none}@keyframes craft-in{from{opacity:0}to{opacity:1}}
.craft-header{height:66px;display:grid;grid-template-columns:58px 1fr 124px 58px;gap:7px;align-items:center;margin-bottom:15px}.craft-back,.craft-menu{width:58px;height:58px;border:2px solid #a9faff;border-radius:50%;background:linear-gradient(145deg,rgba(17,126,160,.95),rgba(17,73,111,.97));box-shadow:0 5px 9px rgba(0,51,77,.3),inset 0 0 13px rgba(101,239,255,.5);color:#fff;cursor:pointer}.craft-back{font:700 3.3rem/42px Rajdhani}.craft-menu{border-radius:17px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:0}.craft-menu i{display:block;width:29px;height:5px;border-radius:5px;background:#fff}.craft-title{height:44px;min-width:0;border:1.5px solid #5df6ef;border-radius:23px;background:linear-gradient(100deg,rgba(0,113,119,.92),rgba(0,99,139,.88));display:flex;align-items:center;justify-content:center;color:#fff;font-size:1.42rem;font-weight:700;letter-spacing:.025em;white-space:nowrap}.craft-money{height:44px;border-radius:23px;background:rgba(10,58,98,.9);display:flex;align-items:center;justify-content:center;gap:3px;color:#fff;white-space:nowrap;overflow:hidden}.craft-money img{width:39px;height:39px;object-fit:contain}.craft-money b{font-size:1rem;overflow:hidden}
.craft-catalog,.craft-detail,.craft-action{border:2px solid rgba(213,255,255,.94);border-radius:20px;background:linear-gradient(145deg,rgba(210,249,248,.87),rgba(165,222,236,.85));box-shadow:0 6px 16px rgba(0,63,86,.28),inset 0 0 25px rgba(255,255,255,.4)}.craft-catalog{padding:8px 14px 13px}.craft-catalog h2{margin:0 0 5px;font-size:1.1rem}.craft-catalog hr{border:0;border-top:1px solid rgba(255,255,255,.9);margin:9px 0 7px}.craft-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.craft-item-tile{min-width:0;height:122px;padding:5px;border:2px solid rgba(235,255,255,.95);border-radius:14px;background:linear-gradient(#e9fbff,#cfedfa);color:#0b3157;cursor:pointer;overflow:hidden;box-sizing:border-box}.craft-item-tile>div{position:relative;height:86px;border-radius:11px;background:linear-gradient(145deg,#71cef9,#2799e9);display:grid;place-items:center}.craft-item-tile.rarity-rare{border-color:#7cd8ff;background:linear-gradient(#e7f9ff,#ccecff)}.craft-item-tile.rarity-epic{border-color:#e1a6ff;background:linear-gradient(#f7eaff,#e9cfff)}.craft-item-tile.rarity-epic>div{background:linear-gradient(145deg,#d795f5,#9a52dc)}.craft-item-tile.rarity-legendary{border-color:#fff0a5;background:linear-gradient(#fff9d9,#ffedab)}.craft-item-tile.rarity-legendary>div{background:linear-gradient(145deg,#ffdd75,#eca522)}.craft-item-tile>div>img{width:88px;height:88px;object-fit:contain}.craft-item-tile>b{min-height:24px;margin-top:3px;display:flex;align-items:center;justify-content:center;font-size:.71rem;line-height:1;text-wrap:balance;overflow-wrap:anywhere}.craft-item-tile.selected{border:3px solid #29fff3;box-shadow:0 0 13px rgba(0,255,238,.9)}.craft-owned{position:absolute;right:2px;bottom:2px;height:22px;padding:0 5px 0 2px;border-radius:12px;background:rgba(22,78,111,.86);display:flex;align-items:center;color:#fff;font-size:.61rem}.craft-owned img{width:20px;height:20px;margin-right:2px}
.craft-detail{height:292px;margin-top:10px;padding:12px;display:grid;grid-template-columns:minmax(0,40%) minmax(0,1fr);box-sizing:border-box}.craft-detail-hero{min-width:0;display:grid;place-items:center;background:radial-gradient(circle,rgba(188,93,255,.55),transparent 60%)}.craft-detail-hero img{max-width:100%;width:160px;height:230px;object-fit:contain;filter:drop-shadow(0 8px 10px rgba(64,21,100,.35))}.craft-detail-info{min-width:0;padding-left:8px;box-sizing:border-box;overflow:hidden}.craft-detail-info h2{margin:0;font-size:1.22rem;line-height:1}.craft-rarity{display:inline-block;min-width:63px;margin-top:5px;padding:2px 8px;border-radius:12px;background:#a35df1;color:#fff;text-align:center;font-size:.69rem;font-weight:700}.craft-rarity.legendary{background:#e9a41c}.craft-rarity.rare{background:#258ee1}.craft-detail-info>p{margin:7px 0;padding:6px;border-radius:14px;background:rgba(242,255,255,.65);font-size:.74rem;font-weight:700}.craft-detail-info>h3{margin:4px 0;border-bottom:1px solid rgba(28,99,129,.25);font-size:.9rem}.craft-materials{width:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;box-sizing:border-box}.craft-material{min-width:0;height:145px;padding:4px;border:1.5px solid #eaffff;border-radius:12px;background:rgba(226,251,242,.82);text-align:center;box-sizing:border-box;overflow:hidden}.craft-material.lacking{background:rgba(255,221,228,.88)}.craft-material>div{position:relative;height:78px;border-radius:9px;background:rgba(102,226,154,.34);display:grid;place-items:center}.craft-material.lacking>div{background:rgba(239,133,161,.25)}.craft-material-art{max-width:100%;width:70px;height:70px;object-fit:contain}.craft-material-state{position:absolute;right:0;bottom:0;width:25px;height:25px}.craft-material>b{display:block;height:28px;margin-top:3px;font-size:.61rem;line-height:.9;overflow-wrap:anywhere}.craft-material>strong{font-size:.78rem}.craft-material.lacking>strong{color:#d6243f}
.craft-action{height:99px;margin-top:10px;padding:11px 16px;display:grid;grid-template-columns:1fr 1.7fr;grid-template-rows:52px auto;gap:2px 10px;box-sizing:border-box}.craft-cost{display:flex;align-items:center;gap:4px}.craft-cost img{width:38px;height:38px}.craft-cost b{font-size:.85rem;white-space:nowrap}.craft-main-button{border:2px solid #c6ecff;border-radius:28px;background:linear-gradient(#9db5c8,#6d849b);box-shadow:0 4px 8px rgba(30,62,88,.25),inset 0 2px 4px rgba(255,255,255,.5);color:#edf7ff;font:700 1.22rem Rajdhani,Sarabun,sans-serif}.craft-main-button img{width:34px;height:34px;vertical-align:middle;margin-right:7px}.craft-main-button.ready{background:linear-gradient(#b379fb,#7746e8);cursor:pointer}.craft-main-button.owned{background:linear-gradient(#57d498,#1da767)}.craft-reason{grid-column:1/-1;margin:1px 0 0;text-align:center;font-size:.72rem;font-weight:700;color:#188458}.craft-reason.missing,.craft-reason.money,.craft-reason.full{color:#e52c43}.craft-reason.owned{color:#15865c}
.craft-confirm-layer{position:absolute;z-index:20;inset:0;display:grid;place-items:center;padding:25px;background:rgba(4,35,60,.68);backdrop-filter:blur(3px)}.craft-confirm-card{width:min(100%,330px);padding:20px;box-sizing:border-box;border:2px solid #cfffff;border-radius:24px;background:linear-gradient(145deg,#f2ffff,#d2eeee);box-shadow:0 20px 45px rgba(0,25,50,.5);text-align:center}.craft-confirm-card>img{width:125px;height:125px;object-fit:contain}.craft-confirm-card small{display:block;color:#6e36cc;font-weight:700}.craft-confirm-card h3{margin:2px 0}.craft-confirm-card>b{display:block;margin:7px;color:#a86100}.craft-confirm-card>div{display:grid;grid-template-columns:1fr 1.25fr;gap:8px}.craft-confirm-card button{height:43px;border:1.5px solid #fff;border-radius:18px;background:#dce8ee;font-weight:700;color:#34536c}.craft-confirm-card button:last-child{background:linear-gradient(#b379fb,#7746e8);color:#fff}
.craft-money img{width:37px;height:37px;object-fit:contain;flex:0 0 auto}.craft-money b{min-width:0;font-size:.86rem;overflow:hidden}
@media(max-width:420px){.craft-screen-v1{--craft-edge:9px;padding-top:calc(env(safe-area-inset-top) + 8px)}.craft-header{grid-template-columns:50px minmax(112px,1fr) 103px 50px;height:55px;margin-bottom:8px}.craft-back,.craft-menu{width:50px;height:50px}.craft-title{height:39px;font-size:1.08rem}.craft-money{height:40px}.craft-money img{width:32px;height:32px}.craft-catalog{padding:7px 9px}.craft-row{gap:6px}.craft-item-tile{height:110px}.craft-item-tile>div{height:76px}.craft-item-tile>div>img{width:78px;height:78px}.craft-item-tile>b{font-size:.66rem}.craft-detail{height:275px;padding:8px;grid-template-columns:36% 64%}.craft-detail-hero img{width:128px;height:210px}.craft-detail-info h2{font-size:1.05rem}.craft-material{height:138px}.craft-material-art{width:60px;height:60px}.craft-material>b{font-size:.55rem}.craft-action{height:94px;padding:9px}.craft-cost b{font-size:.73rem}.craft-main-button{font-size:1.05rem}.craft-main-button img{width:29px;height:29px}}
.craft-item-tile{height:130px}
@media(max-width:420px){.craft-item-tile{height:127px}.craft-item-tile>b{min-height:32px;margin-top:2px}}

/* Shared full-screen navigation geometry. Preserve the 941:1672 canvas on every page. */
.craft-screen-v1{--craft-edge:min(14px,2.917vw);--nav-button:min(58px,12.083vw);--nav-money:min(105px,21.875vw);--nav-gap:min(7px,1.458vw);width:min(100%,480px,calc(100dvh * .5628));height:auto;aspect-ratio:941/1672;padding-top:calc(env(safe-area-inset-top) + min(17px,3.542vw))}
.craft-header{height:min(66px,13.75vw);grid-template-columns:var(--nav-button) minmax(0,1fr) var(--nav-money) var(--nav-button);gap:var(--nav-gap)}
.craft-back,.craft-menu{width:var(--nav-button);height:var(--nav-button)}.craft-title{height:min(44px,9.167vw);min-width:0}.craft-money{width:var(--nav-money);height:min(44px,9.167vw)}
.craft-back>img{display:block;width:52%;height:52%;margin:auto;object-fit:contain;pointer-events:none;filter:drop-shadow(0 2px 1px rgba(0,39,69,.42))}

/* One sideways-scrolling row per slot: 3 tiles fill the width, the rest scroll (user 10-10). */
.craft-row{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:calc((100% - 12px) / 3);overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;scrollbar-width:none;cursor:grab}
.craft-row::-webkit-scrollbar{display:none}
.craft-row>.craft-item-tile{scroll-snap-align:start}
.craft-row.dragging{cursor:grabbing;user-select:none;scroll-snap-type:none}
.craft-row img{-webkit-user-drag:none;user-select:none}
.craft-scroll{position:relative;height:10px;margin:6px 4px 2px;border-radius:10px;background:rgba(5,70,112,.65)}
.craft-scroll[hidden]{display:none}
.craft-scroll i{position:absolute;left:2px;top:2px;height:6px;border-radius:10px;background:#e6ffff;box-shadow:0 0 8px #fff;cursor:grab;touch-action:none}
/* 3 tabs over one 2-row grid (user 11-12: craftable accessories) — keeps the catalog the old 2-row height */
.craft-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin:0 0 7px}
.craft-tab{height:34px;padding:0 4px;border:2px solid rgba(235,255,255,.95);border-radius:17px;background:linear-gradient(#e9fbff,#cfedfa);color:#0b3157;font:700 .82rem Rajdhani,Sarabun,sans-serif;white-space:nowrap;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:3px}
.craft-tab .stat-ic{width:20px;height:20px;object-fit:contain}
.craft-tab.active{border-color:#29fff3;background:linear-gradient(#7fe0ff,#2fa6e8);color:#fff;box-shadow:0 0 10px rgba(0,255,238,.6)}
.craft-row.craft-grid{grid-template-rows:repeat(2,auto);row-gap:8px}
@media(max-width:420px){.craft-tab{height:31px;font-size:.74rem}.craft-tab .stat-ic{width:17px;height:17px}}
/* MYTHIC (Final Weapon, 11-13): prismatic — the 5 element colours */
.craft-item-tile.rarity-mythic{border-color:#fff;background:linear-gradient(#fdf7ff,#eef9ff)}
.craft-item-tile.rarity-mythic>div{background:linear-gradient(135deg,#8fd3ff,#9ff2c6,#ffd86b,#ff9a8a,#c9a3ff)}
.craft-rarity.mythic{background:linear-gradient(90deg,#3fa9f5,#2ecc8f,#f5b82e,#f0605a,#9b6cf5);text-shadow:0 1px 1px rgba(0,0,0,.35)}
/* >3 ingredients (Final Weapon, 11-13): one row scrolling sideways, same feel as the item rows */
.craft-materials.many{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:calc((100% - 10px) / 3);overflow-x:auto;overflow-y:hidden;scrollbar-width:none;cursor:grab}
.craft-materials.many::-webkit-scrollbar{display:none}
.craft-materials.many img{-webkit-user-drag:none;user-select:none}
