/* 1.0: restrained, high-contrast controls over the actual world. */
:root{--studio-panel:#152733;--studio-line:#71828a;--studio-ink:#f3f5ee;--studio-accent:#b9edc8;--sat:env(safe-area-inset-top,0px);--sab:env(safe-area-inset-bottom,0px)}
body{font-family:ui-rounded,system-ui,-apple-system,sans-serif;background:#172e39}button,input,select{font:inherit}button{cursor:pointer;touch-action:manipulation}button:disabled{opacity:.45;cursor:default}button:focus-visible,input:focus-visible,a:focus-visible{outline:3px solid #ffd782;outline-offset:3px}#gl{touch-action:none}
#studio{color:var(--studio-ink);font-size:14px}#studio button,#studioSettings button{min-width:44px;min-height:44px;border:1px solid #71828a;border-radius:12px;color:var(--studio-ink);background:#223b48;padding:9px 12px;font-weight:650}#studio button:hover:not(:disabled),#studio button[aria-pressed=true],#studio button.on{background:#35574f;border-color:#b9edc8}#studioNav{position:fixed;right:max(14px,env(safe-area-inset-right));top:calc(14px + var(--sat));z-index:16;display:flex;gap:8px}#studioNav button{box-shadow:0 4px 16px #0003}#toolbar{display:none!important}
#wordmark{position:fixed!important;top:calc(14px + var(--sat))!important;left:66px!important;width:auto!important;max-width:calc(100vw - 370px);color:white!important;pointer-events:auto!important;cursor:pointer;text-shadow:0 2px 8px #1239;z-index:16;display:block!important;font-size:18px!important}#wordmark small{font-size:11px!important;font-weight:400}#modeChip{display:none}#verTag{top:auto!important;bottom:calc(10px + var(--sab));right:14px!important;left:auto!important;font-size:10px!important;color:#fff!important;background:#172c3bcc!important;border:0!important}#statsChip,#questChip,#toolChip{display:none!important}#biomeChip{top:calc(72px + var(--sat))!important;left:16px!important;background:#172c3bcc!important;color:#edf6e8!important;border:0!important}#friendsChip{top:calc(106px + var(--sat))!important;left:16px!important;background:#172c3bcc!important;color:#edf6e8!important;border:0!important}#villChip{top:calc(140px + var(--sat))!important;left:16px!important;background:#172c3bcc!important;color:#edf6e8!important;border:0!important}#help{display:none!important}
#hotbar{position:fixed!important;left:50%!important;bottom:calc(18px + var(--sab))!important;transform:translateX(-50%)!important;display:flex!important;flex-wrap:nowrap!important;gap:6px!important;padding:8px!important;border:1px solid #ffffff70!important;border-radius:18px!important;background:#152733e8!important;max-width:calc(100vw - 20px)!important;width:max-content!important;overflow-x:auto!important;pointer-events:auto!important;z-index:17!important}#hotbar .slot{position:relative;width:52px!important;min-width:44px!important;height:58px!important;flex:0 0 52px;border-radius:10px!important;border:1px solid #72848d!important;background:#29404d!important;color:white!important;display:flex;align-items:center;justify-content:center;padding:5px!important}#hotbar .slot.on{border:2px solid #c2ffcc!important;background:#39624e!important;box-shadow:0 0 0 2px #c2ffcc30!important}#hotbar .slot small{position:absolute;bottom:2px;right:5px;font-size:10px;color:white!important}#hotbar .swatch{color:var(--c)!important;background:none!important;box-shadow:none!important;border:0!important;font-size:29px;display:block;text-shadow:1px 2px 0 #0008;width:auto!important;height:auto!important;transform:none!important}#hotbar .slotKey{position:absolute;top:2px;left:5px;font-size:10px;color:#c5d2d8}#blockName{position:fixed!important;bottom:calc(99px + var(--sab))!important;left:50%!important;transform:translateX(-50%)!important;color:#fff!important;background:#152733cc!important;border-radius:8px!important;padding:5px 12px!important;max-width:80vw;text-align:center;font-size:12px!important;white-space:nowrap;pointer-events:none;z-index:17}
#brushBar{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(136px + var(--sab));display:flex;align-items:center;gap:5px;background:#152733e6;border:1px solid #ffffff65;padding:6px;border-radius:16px;z-index:16;white-space:nowrap}#brushSize{font-weight:800;font-size:19px;min-width:43px;text-align:center}#reachLabel{position:fixed;left:50%;top:calc(50% + 25px);transform:translateX(-50%);font-size:11px;background:#152733c9;padding:5px 9px;border-radius:7px;pointer-events:none;white-space:nowrap}#gearHud{position:fixed;right:14px;top:calc(72px + var(--sat));width:200px;text-align:left;display:flex;flex-direction:column;gap:5px;font-size:12px;z-index:16;background:#152733d9!important}#gearHud small{font-size:10px;font-weight:400;color:#d3dfd5}#gearHud progress{width:100%;height:5px;accent-color:#b9edc8}
.studioPanel{position:fixed;inset:0;z-index:35;background:#07131a99;display:flex;align-items:center;justify-content:center;padding:16px;box-sizing:border-box;backdrop-filter:blur(7px)}.studioPanel[hidden]{display:none}.studioCard{display:flex;flex-direction:column;width:780px;max-width:100%;height:min(720px,calc(100dvh - 32px));background:var(--studio-panel);border:1px solid #a4b7bf;border-radius:24px;padding:22px;box-sizing:border-box;box-shadow:0 24px 100px #0007;overflow:hidden}.studioCard header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.studioCard h2{margin:0;font-size:25px;letter-spacing:-.6px}.studioCard p{font-size:13px;line-height:1.5;color:#cfddd6;margin:7px 0 12px}.inventoryTools{display:flex;gap:12px;align-items:center}.inventoryTools label{display:flex;align-items:center;white-space:nowrap;font-size:13px;min-height:44px}.inventoryTools input[type=checkbox]{width:24px;height:24px;margin-right:8px}#inventorySearch{min-width:0;flex:1;min-height:46px;padding:10px 14px;color:white;background:#243c49;border:1px solid #71828a;border-radius:12px}#inventoryCategories{display:flex;overflow:auto;gap:6px;margin:14px 0;flex-shrink:0}#inventoryCategories button{white-space:nowrap;font-size:12px;padding:7px 11px}#inventoryGrid{overflow:auto;min-height:0;flex:1;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;align-content:start;scrollbar-width:thin}.inventoryCell{position:relative;min-width:0}.inventoryItem{width:100%;height:126px;display:flex;align-items:flex-start;flex-direction:column;text-align:left!important;position:relative;padding:12px!important;gap:6px}.inventoryItem strong{font-size:12px;line-height:1.2;margin-top:auto;max-width:100%;overflow-wrap:anywhere}.inventoryItem small{font-size:11px;color:#c5d6d0}.itemIcon{font-size:30px;color:var(--c);height:32px;line-height:32px;text-shadow:1px 2px 0 #0008}.favorite{position:absolute;right:0;top:0;background:transparent!important;border:0!important;font-size:22px!important;padding:0!important;width:44px;height:44px;color:#ffdf92!important}#inventoryAssign{display:flex;gap:5px;overflow:auto;flex-shrink:0;padding:12px 0 3px}#inventoryAssign button{flex:1;min-width:44px;color:var(--c);font-size:13px;padding:6px 3px}#assignHint{min-height:20px;margin:3px 0;font-size:11px}.studioCard footer{display:flex;gap:6px;flex-wrap:wrap;border-top:1px solid #617784;padding-top:12px}.studioCard footer button{font-size:12px;padding:7px 10px!important}#gearList{overflow:auto;max-height:270px;flex-shrink:0;margin-top:8px}#gearList[hidden]{display:none}.gearCard{display:block;width:100%;text-align:left;margin-bottom:6px;font-size:12px}#rulesText{overflow:auto;font-size:15px}#rulesPanel .studioCard{height:auto;max-height:90dvh}
#pausePanel .panelCard,#startGate .panelCard,#craftPanel .panelCard,#toolsPanel .panelCard,#bookPanel .panelCard,#goalsPanel .panelCard,#mapPanel .panelCard,#worldsPanel .panelCard{background:#152733!important;color:#edf5ee!important;border:1px solid #a4b7bf!important;border-radius:24px!important;max-height:calc(100dvh - 32px)!important;overflow-y:auto!important;box-sizing:border-box;box-shadow:0 20px 80px #0005!important}#pausePanel .panelCard{width:620px!important;max-width:94vw!important}#pausePanel p,#startGate p{color:#c5d6d0!important}#pausePanel .tgl{min-height:44px!important;background:#233d49!important;color:#edf5ee!important;border-color:#71828a!important}#pausePanel button,#startGate button{min-height:44px}#pausePanel h2{margin-top:0}#quadBuildRow{display:none!important}#studioSettings{display:flex;flex-wrap:wrap;gap:8px;padding:8px 0}#studioSettings label{display:flex;justify-content:space-between;align-items:center;gap:10px;width:100%;min-height:44px}#studioSettings input{min-width:120px;accent-color:#b9edc8}#volRow label{color:white!important;min-height:44px}#controlsList{max-height:38vh;overflow:auto}#controlsList button{min-height:44px}#toast{z-index:50!important;max-width:min(520px,90vw)!important;background:#152733f5!important;color:#f4f6ef!important;border:1px solid #b9edc8!important;border-radius:12px!important;pointer-events:none!important;bottom:calc(210px + var(--sab))!important;top:auto!important}#startGate ul{line-height:1.7;padding-left:20px}#startGate h1{font-size:40px;letter-spacing:-1.5px}#touchControls{display:none}.photo #studio{display:none!important}.studio-open #touchControls{visibility:hidden}
@media(pointer:coarse){#touchControls{display:block}#touchStick{position:fixed;bottom:calc(125px + var(--sab));left:max(18px,env(safe-area-inset-left));width:116px;height:116px;background:#15273380;border:2px solid #d7e9d8aa;border-radius:50%;touch-action:none;z-index:18;display:grid;place-items:center}#touchStick span{width:48px;height:48px;border-radius:50%;background:#d7e9d8a0;pointer-events:none}#touchActions{position:fixed;bottom:calc(120px + var(--sab));right:max(14px,env(safe-area-inset-right));width:136px;display:grid;grid-template-columns:1fr 1fr;gap:8px;z-index:18}#touchActions button{min-height:54px;min-width:60px;touch-action:none;padding:5px;font-size:12px;background:#152733dd}#brushBar{bottom:calc(198px + var(--sab))}#brushMode{display:none}#wordmark small{display:none}#friendsChip{display:none!important}#gearHud{width:175px}}
@media(max-width:620px){#studioNav{right:8px;top:calc(8px + var(--sat));gap:5px}#studioNav button{font-size:11px;padding:7px;min-width:44px}#wordmark{font-size:13px!important;left:55px!important;top:calc(16px + var(--sat))!important;max-width:120px}#wordmark small{display:none}#gearHud{width:157px;right:8px;top:calc(64px + var(--sat));font-size:11px}#biomeChip{max-width:130px;font-size:10px!important}#villChip{max-width:130px;font-size:10px!important}#hotbar{gap:4px!important;padding:6px!important;justify-content:flex-start!important}#hotbar .slot{flex-basis:44px;width:44px!important;height:52px!important}#hotbar .slotKey{display:none}#blockName{bottom:calc(86px + var(--sab))!important}#brushBar{gap:3px;padding:4px}#brushBar button{padding:4px;font-size:12px}#brushSize{font-size:17px;min-width:34px}#inventoryGrid{grid-template-columns:repeat(3,minmax(0,1fr))}.studioPanel{padding:8px}.studioCard{border-radius:18px;padding:14px;height:calc(100dvh - 16px)}.studioCard h2{font-size:22px}.inventoryTools{gap:6px}.inventoryTools label{font-size:11px}.inventoryItem{height:115px}.studioCard footer{flex-wrap:nowrap;overflow-x:auto;flex-shrink:0}.studioCard footer button{white-space:nowrap}#inventoryHint{font-size:11px}.studioCard header{gap:6px}#gearList{max-height:230px}#reachLabel{font-size:10px}#toast{bottom:calc(280px + var(--sab))!important}#pausePanel,#startGate{padding:10px!important}#startGate .panelCard{padding:20px!important}#startGate h1{font-size:32px}#mapPanel .panelCard{max-width:96vw!important}#mapCanvas{max-width:100%;height:auto}#worldsBtns{grid-template-columns:repeat(3,1fr)!important}}
@media(pointer:coarse) and (max-width:620px){#touchStick{width:94px;height:94px;bottom:calc(130px + var(--sab));left:12px}#touchActions{width:120px;right:8px}#brushBar{bottom:calc(260px + var(--sab))}#touchActions button{min-width:54px}#gearHud small{font-size:9px}}
@media(max-height:500px){#wordmark small,#biomeChip,#friendsChip,#villChip,#gearHud small{display:none!important}#gearHud{top:calc(62px + var(--sat));width:150px}#hotbar{bottom:5px!important}#blockName{bottom:77px!important}#brushBar{bottom:108px!important}#touchStick{bottom:90px!important}#touchActions{bottom:90px!important}.studioCard{height:calc(100dvh - 16px)}.inventoryItem{height:100px}#inventoryGrid{grid-template-columns:repeat(5,minmax(0,1fr))}#inventoryHint,#assignHint{display:none}#inventoryCategories{margin:6px 0}.studioCard header h2{font-size:19px}#inventoryAssign{padding:6px 0}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}

#wordmark{transform:none!important;text-align:left!important;letter-spacing:.02em!important} .studioCard{touch-action:pan-y} #inventoryGrid,#gearList,#controlsList{touch-action:pan-y} #hotbar,#inventoryCategories,#inventoryAssign{touch-action:pan-x}

#gameExit{position:fixed;top:calc(10px + var(--sat));left:max(10px,env(safe-area-inset-left));width:44px;height:44px;display:grid;place-items:center;border:1px solid #cad9d6;border-radius:12px;background:#152733dd;color:white;text-decoration:none;font-size:32px;z-index:36}.loadtips-active #startGate{visibility:hidden}

html.has-site-up #gameExit{display:none}html.sb-shared-loader #startGate{visibility:hidden}

@media(max-width:380px){#wordmark{max-width:78px!important;font-size:11px!important}#studioNav button{font-size:10px;padding:5px}}

/* 1.0.1 polish: readable states and a usable scroll area in short windows. */
.inventoryEmpty{grid-column:1/-1;padding:20px;text-align:center;border:1px dashed #71828a;border-radius:12px}
#clearInventoryFilters{align-self:flex-start;margin-top:8px;font-size:12px}
#clearInventoryFilters[hidden]{display:none}
#studioSettings output{margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;color:#b9edc8}
.studioCard header,.inventoryTools,.studioCard footer{flex-shrink:0}
@media(max-height:600px){.studioCard{overflow-y:auto;display:block}.studioCard header{display:flex}#inventoryGrid{min-height:180px;max-height:45dvh}#gearList{max-height:none}#inventoryAssign{position:sticky;bottom:0;background:var(--studio-panel);z-index:2}.studioCard footer{display:flex;margin-top:8px}}
/* Keep inherited menu copy readable against the studio's dark cards. */
.panelCard h1,.panelCard h2{color:#b9edc8!important}
.panelCard p,.panelCard ul,#worldsForm,#gateWorld{color:#d5e4dd!important}
.panelCard .btn{color:#f3f5ee;background:#294b40;border-color:#8fcba1;min-height:44px;min-width:44px}
.panelCard .btn.ghost{color:#edf5ee;background:#2b4350}
#villPanel .panelCard{background:#152733;color:#edf5ee;max-height:calc(100dvh - 32px);overflow-y:auto;box-sizing:border-box}
#worldsBtns .btn,#worldsForm .btn,#worldsForm input,#bookTabs button,.mirrorRow button,#rotateBtn{min-width:44px;min-height:44px}
#worldsForm{height:auto;min-height:52px;flex-wrap:wrap;overflow:visible;padding:4px 0}
#worldsForm .wWarn,#worldsForm .wMsg{white-space:normal;color:#ffd5b3}
#gfxRow{height:auto;min-height:48px}
#bookTabs{flex-shrink:0}
#touchActions button.held{background:#35574f;border-color:#b9edc8;box-shadow:inset 0 0 0 2px #b9edc8}
#studio button:active:not(:disabled),.panelCard button:active:not(:disabled){filter:brightness(1.2)}
@media(max-width:620px){#studioSettings label{flex-wrap:wrap}#studioSettings input{flex:1 1 130px;min-width:0}#studioSettings output{font-size:12px}}

/* Round 2: let controls and their explanations size their own rows. */
#inventoryGrid[hidden]{display:none}
#inventoryAssign button{color:var(--studio-ink)}
#bookTabs{height:auto;min-height:44px;flex-wrap:wrap}
#bookTabs button{height:auto;min-height:44px;flex:1 0 auto;padding:6px 10px}
#bookMsg{height:auto;min-height:20px;white-space:normal;overflow:visible;overflow-wrap:anywhere;color:#d5e4dd}
#bookMsg.good{color:#b9edc8}#bookMsg.warn{color:#ffd5b3}
#volRow{height:auto;min-height:44px;flex-wrap:wrap;gap:6px 14px}
#volRow label{flex:1 1 220px;justify-content:space-between;min-width:0}
#volRow input{flex:1;min-width:0;max-width:180px}
#mapPanel .panelCard{max-width:100%!important;min-width:0}
#mapCanvas{max-width:100%;height:auto;aspect-ratio:3/2}
#mapBar{height:auto;min-height:44px;flex-wrap:wrap}
#mapInfo{min-width:100px;color:#d5e4dd}
#mapLegend{height:auto;min-height:34px;color:#d5e4dd}
#mapLegend span.l{white-space:normal;overflow:visible}

/* Keep world-name errors beside the preserved draft, including narrow cards. */
#worldFormStatus{flex-basis:100%;text-align:center;overflow-wrap:anywhere}
#worldFormStatus:empty{display:none}

/* Round 4: reserve the parent-nav corner even when a dialog fills the screen. */
.studioPanel,#pausePanel,#startGate,#worldsPanel,#villPanel,#mapPanel,#bookPanel,#craftPanel,#toolsPanel,#goalsPanel{padding:calc(64px + var(--sat)) max(12px,env(safe-area-inset-right)) max(12px,var(--sab)) max(12px,env(safe-area-inset-left))!important;overflow-y:auto;touch-action:pan-x pan-y}
.studioCard{height:min(720px,calc(100dvh - 80px - var(--sat) - var(--sab)));touch-action:pan-x pan-y}
#rulesPanel .studioCard,#pausePanel .panelCard,#startGate .panelCard,#worldsPanel .panelCard,#villPanel .panelCard,#mapPanel .panelCard,#bookPanel .panelCard,#craftPanel .panelCard,#toolsPanel .panelCard,#goalsPanel .panelCard{max-height:calc(100dvh - 80px - var(--sat) - var(--sab))!important}
.worldRow{flex-basis:48px;min-height:48px;height:auto}
input[type=range]{min-height:44px;touch-action:pan-y}
#studio .inventoryTools label{min-width:44px}
#studioActions{flex-shrink:0;margin:8px 0;max-height:180px;overflow:auto;touch-action:pan-y}
#studioActions summary{min-height:44px;padding:12px;cursor:pointer;border:1px solid var(--studio-line);border-radius:10px}
#studioActionButtons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;padding-top:6px}
#studioActionButtons button{overflow-wrap:anywhere;font-size:12px}
.toolBtn{height:auto;min-height:70px;overflow:visible;overflow-wrap:anywhere}
#vText,#vQuest{height:auto;min-height:84px;flex-shrink:0;overflow:visible;color:#1a2a18}
#vMain,#vTradeView{min-height:auto}#vBtns{height:auto;flex-shrink:0;margin-top:12px}
#vTradeList{grid-template-rows:none;grid-auto-rows:minmax(58px,auto)}
.tradeBtn{height:auto;min-height:58px;white-space:normal;overflow:visible;color:#1a2a18}
#vTradeMsg{height:auto;min-height:20px;color:#d5e4dd}#vWhere,.goalsCount{color:#d5e4dd}
.gateBtns{flex-wrap:wrap}.gateBtns .btn{flex:1 1 130px}
@media(max-width:900px){#wordmark{display:none!important}}
@media(max-width:620px){#studioActionButtons{grid-template-columns:repeat(2,minmax(0,1fr))}#vTradeList{grid-template-columns:1fr}#toolsList{grid-template-columns:repeat(2,minmax(0,1fr))}.mirrorRow{flex-wrap:wrap}.goalRow{height:auto;min-height:48px;grid-template-columns:1fr 60px 36px;grid-template-rows:auto auto}.gName{white-space:normal}.gGift{overflow-wrap:anywhere}}

/* Focus stays visible even when a toggle uses a zero-size native checkbox. */
.tgl:focus-within,summary:focus-visible,canvas:focus-visible,select:focus-visible{outline:3px solid #ffd782;outline-offset:3px}
#gameExit{z-index:60}
#photoExit{display:none;position:fixed;right:max(12px,env(safe-area-inset-right));top:calc(12px + var(--sat));z-index:25;min-height:44px;min-width:44px;padding:10px 16px;background:#152733;color:#f3f5ee;border:1px solid #a4b7bf;border-radius:12px}
body.photo #photoExit{display:block}
#tipPop{top:calc(64px + var(--sat));bottom:auto;right:max(12px,env(safe-area-inset-right));width:min(340px,calc(100vw - 24px));height:auto;max-height:calc(100dvh - 80px - var(--sat));overflow:auto;touch-action:pan-y}
#tipOk{min-width:44px;min-height:44px;padding:10px 16px;border:1px solid #71828a;border-radius:10px}
/* Long names/material lists wrap instead of disappearing from small cards. */
#bookGrid{grid-auto-rows:minmax(108px,auto)}
.bookCard{height:auto;min-height:108px;grid-template-rows:auto auto auto;overflow:visible}
.bName{white-space:normal;overflow:visible;overflow-wrap:anywhere}.bIn{flex-wrap:wrap;white-space:normal;overflow:visible}.bTag{white-space:normal}
.goalRow{color:#1a2a18}#controlsMsg{color:#d5e4dd}.bookEmpty{color:#d5e4dd}
@media(max-width:620px){#bookGrid{grid-template-columns:1fr}}
.goalRow{height:auto;min-height:48px;grid-template-rows:auto auto}
/* Phone portrait: keep the brush row above the three-row touch action pad. */
@media(pointer:coarse) and (max-width:620px) and (min-height:501px){#brushBar{bottom:calc(314px + var(--sab))}}

/* Base grapple feedback: shape as well as color. Existing 54px touch targets. */
#crosshair.grapple-ready{margin:0;transform:translate(-50%,-50%);box-sizing:border-box;display:grid;place-items:center;line-height:1;border:2px solid #82ffe0;border-radius:50%;width:24px;height:24px;box-shadow:0 0 8px #142c24}
#touchGrapple.grapple-ready{border:2px solid #82ffe0;box-shadow:inset 0 0 0 1px #82ffe0}
#brushSize{min-width:76px;font-size:12px}
@media(pointer:coarse){#touchActions{width:196px;grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(pointer:coarse) and (max-width:620px){#touchActions{width:184px}}

/* 1.1.1: readable shortages and three large batch actions per recipe. */
.recipeGroup{min-width:0;display:flex;flex-direction:column;gap:4px}
.recipeGroup .bookCard,.recipeGroup .craftRow{width:100%;height:auto;min-height:112px;color:#edf5ee;background:#243b43;border:2px solid #81959c;opacity:1;display:grid;grid-template-columns:36px 1fr;gap:5px;padding:10px;box-sizing:border-box}
.recipeGroup .ready{border-color:#b9edc8;background:#264b40}
.recipeGroup strong{color:#edf5ee}.recipeAmount{font-weight:700;color:#b9edc8}
.recipeIngredients{grid-column:1/-1;white-space:normal;overflow-wrap:anywhere;color:#edf5ee!important;font-size:12px}
.recipeBulk{display:flex;gap:5px}.recipeBulk button{flex:1;min-width:44px;min-height:44px;border:1px solid #81959c;border-radius:10px;background:#243b43;color:#edf5ee;font:inherit;font-size:13px}
.recipeBulk button[aria-disabled=true]{border-style:dashed;color:#ffd5b3}
#craftMsg{font-size:13px;white-space:normal}#craftMsg.warn{color:#ffd5b3!important}
#creativeQuick[aria-pressed=true]{background:#315d48;border-color:#b9edc8}
@media(max-width:620px){#studioNav{display:grid;grid-template-columns:1fr 1fr;max-width:calc(100vw - 80px)}#creativeQuick{grid-column:1/-1;min-height:44px}#craftList{min-width:0}}
@media(max-width:620px){#gearHud{top:calc(112px + var(--sat))}}
.recipeGroup .recipeAmount{grid-column:1/-1}.recipeGroup .bookCard{grid-template-rows:auto}
.recipeGroup .bookCard:hover,.recipeGroup .craftRow:hover{background:#35574f}
.recipeGroup .recipeAmount{color:#b9edc8}
/* 1.1.1 gate: rows grow to fit card + batch buttons (fixed 108px rows let the next card cover ×10 / Max) */
#bookGrid{grid-auto-rows:auto}

/* Host parent mark and notification bell own the top 64px on both sides. */
#studioNav,#photoExit{top:calc(64px + var(--sat))}
#gearHud{top:calc(122px + var(--sat))}
#gameExit{top:calc(64px + var(--sat))}
@media(max-width:620px){#studioNav,#photoExit{top:calc(64px + var(--sat))}#gearHud{top:calc(122px + var(--sat))}}
@media(max-height:500px){#studioNav,#photoExit{top:calc(64px + var(--sat))}#gearHud{top:calc(122px + var(--sat))}}
/* 1.2.0 gate: landscape phones — the 7-button touch column owns the right edge from y=122, so the gear chip sits left of it, under the nav row. */
@media(pointer:coarse) and (max-height:500px){#gearHud{top:calc(114px + var(--sat));right:calc(max(14px,env(safe-area-inset-right)) + 204px)}}

/* 1.2.1 Random Build: menu, choice chips and the preview bar. */
#randomPanel{position:fixed;inset:0;display:none;align-items:center;justify-content:center;background:#07131a99;z-index:34;padding:16px;box-sizing:border-box;pointer-events:auto}
#randomPanel.on{display:flex}
#randomPanel .panelCard{width:660px;max-width:100%;max-height:calc(100dvh - 32px);overflow-y:auto;background:#152733;color:#edf5ee;border:1px solid #a4b7bf;border-radius:24px;text-align:left;touch-action:pan-y;box-sizing:border-box;padding:18px 20px}
#randomPanel h2{margin-bottom:6px}#randomPanel p{margin:0 0 4px}
.rbLabel{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:#b9edc8;margin:12px 0 6px;font-weight:700}
.rbLabel[hidden],.rbRow[hidden]{display:none}
.rbRow{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.rbChip,#rbSeedNew{min-height:44px;min-width:44px;padding:8px 13px;border-radius:12px;border:1px solid #71828a;background:#223b48;color:#f3f5ee;font-weight:650;display:inline-flex;align-items:center;gap:8px;font-size:14px}
.rbChip:hover,#rbSeedNew:hover{background:#2c4a55}
.rbChip[aria-pressed=true]{background:#35574f;border-color:#b9edc8;box-shadow:inset 0 0 0 2px #b9edc8}
.rbDots{display:inline-flex;gap:2px}.rbDots b{width:10px;height:10px;border-radius:3px;display:block;border:1px solid #0004}
#rbSeed{width:120px;min-height:44px;box-sizing:border-box;border-radius:12px;border:1px solid #71828a;background:#0d1c25;color:#f3f5ee;padding:6px 10px;font-size:16px;font-variant-numeric:tabular-nums;-webkit-user-select:text;user-select:text}
#rbSeedNote{font-size:12px;color:#b8c9c4;flex:1 1 160px}
#rbCost{margin:14px 0 0!important;font-size:13px;color:#d5e4dd!important;min-height:36px}
.rbActions{display:flex;gap:10px;margin-top:10px;flex-wrap:wrap}.rbActions .btn{margin:0;flex:1 1 140px}
#randomGo{background:#3d7a56;border-color:#b9edc8;font-size:16px}
#randomBar{position:fixed;left:50%;transform:translateX(-50%);top:calc(122px + var(--sat));z-index:17;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;background:#152733ee;border:1px solid #b9edc8;border-radius:16px;padding:8px;color:#f3f5ee;font-size:13px;text-align:center}
#randomBar[hidden]{display:none}
#rbInfo{margin:0 4px 8px;line-height:1.3}
#rbButtons{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
#rbButtons button{min-width:64px;min-height:44px;border:1px solid #71828a;border-radius:12px;color:#f3f5ee;background:#223b48;padding:8px 12px;font-weight:650}
#rbButtons button:disabled{opacity:.45}
#rbPlace{background:#3d7a56!important;border-color:#b9edc8!important}
#toolsRandom{display:block;width:100%;margin:0 0 10px}
@media(max-width:620px){#randomPanel h2{padding-left:44px;min-height:34px}#randomPanel{padding:8px}#randomPanel .panelCard{padding:14px;max-height:calc(100dvh - 16px)}.rbChip{padding:8px 10px;font-size:13px}#randomBar{top:calc(170px + var(--sat));font-size:12px}#rbButtons button{min-width:56px;padding:6px 8px}}
@media(max-height:500px){#randomBar{top:calc(58px + var(--sat))}#rbInfo{display:none}}

/* 1.2.1a: the preview bar says how to place, and says clearly when the bag is short. */
#rbHint{margin:0 4px 8px;padding:8px 10px;border-radius:12px;background:#0d1c25;border:1px solid #b9edc8;line-height:1.35}
#rbHint[hidden]{display:none}
#rbHint b{display:inline-block;font-size:16px;letter-spacing:.03em;color:#b9edc8}
#rbHint span{display:block;font-size:12px;color:#d5e4dd;margin-top:2px}
#rbHint kbd{display:inline-block;min-width:18px;padding:1px 6px;border-radius:6px;border:1px solid #71828a;background:#223b48;color:#fff;font:700 12px ui-monospace,monospace}
#rbNeed{margin:0 4px 8px;padding:8px 10px;border-radius:12px;background:#4a2a1c;border:1px solid #ffb38a;color:#ffe6d6;font-size:14px;font-weight:650;line-height:1.35;display:flex;gap:10px;align-items:center;justify-content:center;flex-wrap:wrap}
#rbNeed[hidden]{display:none}
#rbCreative,#rbMenuCreative{min-height:44px;padding:8px 14px;border-radius:12px;border:1px solid #b9edc8;background:#3d7a56;color:#fff;font-weight:700;font-size:14px}
#rbCreative[hidden],#rbMenuCreative[hidden]{display:none}
#rbMenuCreative{margin:8px 0 0;width:100%}
#rbCost.warn{color:#ffe6d6!important;background:#4a2a1c;border:1px solid #ffb38a;border-radius:12px;padding:8px 10px;font-weight:650}
#rbPlace:disabled{background:#3a4a52!important;border-color:#71828a!important}
@media(max-height:500px){#rbHint span{display:none}}

/* 1.2.1b: the site bell (#aePnBell, 44x44, top 60px, flush right) sits over the top-right corner. Keep every top-right control clear of it. */
#studioNav,#photoExit{right:calc(max(14px,env(safe-area-inset-right)) + 48px)}
@media(max-width:620px){#studioNav,#photoExit{right:56px}#studioNav{max-width:calc(100vw - 64px)}}
/* 1.2.1b: on narrow screens the gear card sat on top of the Creative chip (the nav wraps to two rows there). */
@media(max-width:620px){#gearHud{top:calc(164px + var(--sat))}#randomBar{top:calc(232px + var(--sat))}}
#randomButton{display:inline-grid;place-items:center}#randomButton .rbIcon{display:block;pointer-events:none}

/* World-only village shops and enchanting; share the existing modal/focus owner. */
/* Explicit palette: contrast tests read these exact CSS values. */
#villPanel{--society-bg:#152733;--society-ink:#edf5ee;--society-muted:#d5e4dd;--society-card:#f0f6f4;--society-card-ink:#283f3c;--society-button:#294b40;--society-button-ink:#f3f5ee;--society-accent:#b9edc8;--society-avatar:#ffd8b8}
#villPanel.societyOpen .panelCard{width:min(720px,94vw);max-width:94vw;height:calc(100dvh - 88px - var(--sat) - var(--sab));overflow:hidden;padding:16px;background:var(--society-bg);color:var(--society-ink)}
#villPanel .panelCard #vIdentity{display:flex;align-items:center;gap:12px;height:auto;min-height:54px;flex:none;position:sticky;top:0;z-index:2;background:var(--society-bg);text-align:left;padding-bottom:8px}
#vIdentity>div:last-child{min-width:0}
#villPanel #vFace{float:none;flex:none;margin:0;color:var(--society-card-ink);background:var(--society-avatar)}
#villPanel #vName{height:auto;white-space:normal;line-height:1.2;color:var(--society-accent)!important}
#villPanel #vWhere{height:auto;color:var(--society-muted);overflow-wrap:anywhere}
#vSocietyView{flex:1;display:flex;flex-direction:column;min-height:0;gap:8px}
#vSocietyView[hidden],#vBtns .btn[hidden]{display:none}
#vSocietyContent{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;text-align:left}
#vSocietyBack{flex:none;min-height:48px;margin:0}
#vBtns{grid-template-columns:repeat(2,minmax(0,1fr))}
#vSocietyContent .societyHeader{flex:none;position:sticky;top:0;z-index:1;background:var(--society-bg);padding:4px 4px 8px}
#vSocietyContent h3{margin:0 0 4px;color:var(--society-ink);font-size:16px}
#vSocietyContent p{color:var(--society-muted)!important;margin:4px 0;font-size:13px;line-height:1.35}
#vSocietyContent .societyCoins{font-size:22px;font-weight:800;color:var(--society-ink)!important}
#vSocietyContent .societyDust{font-size:16px;font-weight:700;color:var(--society-ink)!important}
#vSocietyContent .societyStatus:empty{display:none}
.societyList{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;align-content:start;min-height:0;max-height:70vh;overflow:auto;overscroll-behavior:contain;padding:4px;scroll-padding:4px}
.societyRow{display:flex;flex-wrap:wrap;align-content:start;align-items:center;gap:8px;padding:12px;background:var(--society-card);border:1px solid #8ab9ac;border-radius:12px;color:var(--society-card-ink);min-width:0}
.societyRow strong{flex:1;min-width:0}
.societyRow p,.societyRow small{flex-basis:100%;margin:0}
#vSocietyContent .societyRow p{color:var(--society-card-ink)!important}
#villPanel .societyRow .btn,#villPanel #vSocietyBack{color:var(--society-button-ink);background:var(--society-button);min-height:48px;height:auto;white-space:normal;line-height:1.3;margin:0;padding:10px 8px;opacity:1}
.societyRow .btn{flex:1 1 42%;min-width:0;font-size:14px}
.societyRow .societySpare{flex-basis:100%}
.societySwatch{width:24px;height:24px;border:2px solid var(--society-card-ink);border-radius:5px;flex:none}
#villPanel .btn:disabled{opacity:1;border-style:dashed}
#bookTabs{flex-wrap:wrap;height:auto;flex-shrink:0}
#bookTabs button{flex:1 1 auto}
@media(max-width:600px){.societyList{grid-template-columns:minmax(0,1fr)}#villPanel.societyOpen .panelCard{padding:12px}#villPanel #vName{font-size:18px}}
@media(max-height:500px){#villPanel.societyOpen .panelCard{display:block;overflow-y:auto}.societyList{min-height:160px}#vSocietyBack{position:sticky;bottom:0;width:100%}}
.enchantedName{text-shadow:0 0 7px #7fe6dc;animation:gearShimmer 2s ease-in-out infinite alternate}
#gearHud .enchantedName,#vSocietyContent .enchantedName,#gearList .enchantedName{color:#96ffe6}
@keyframes gearShimmer{to{text-shadow:0 0 12px #1fb8a7}}
@media(prefers-reduced-motion:reduce){.enchantedName{animation:none}}

#vSocietyContent .enchantedName{color:var(--society-accent)!important}
/* 1.2.8: on narrow screens the shop/enchant sheet starts right under the top-left ‹ exit mark (44px at left 10px); keep the avatar clear of it */
@media(max-width:840px){#villPanel .panelCard #vIdentity{padding-left:46px}}
