.world-slot-factory.is-unlocked{cursor:pointer}
.world-slot-factory.is-unlocked:hover .world-slot-halo,
.world-slot-factory.is-unlocked:focus-visible .world-slot-halo{opacity:.78}

.factory-card{
  position:relative;
  width:min(880px,88vw);
  min-height:520px;
  padding:34px;
  border:1px solid rgba(222,239,255,.72);
  border-radius:26px;
  background:
    radial-gradient(ellipse at 12% 5%,rgba(255,255,255,.72),transparent 38%),
    linear-gradient(145deg,#f7f2e8,#e9eef5 58%,#dce7f2);
  color:#183354;
  box-shadow:0 28px 90px rgba(3,12,31,.46);
}

.factory-card .modal-close{
  display:grid;
  place-items:center;
  width:40px;
  height:40px;
  padding:8px;
}

.factory-card .modal-close svg{
  width:100%;
  height:100%;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
}

.factory-heading{
  max-width:650px;
  margin:0 auto 28px;
  text-align:center;
}

.factory-kicker{
  display:block;
  margin-bottom:4px;
  color:#72839b;
  font-size:12px;
  font-weight:850;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.factory-heading h2{
  margin:0;
  font-size:32px;
  line-height:1.1;
}

.factory-heading p{
  margin:10px auto 0;
  color:#52677e;
  font-weight:600;
}

.factory-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}

.factory-panel{
  min-height:285px;
  padding:24px;
  border:1px solid rgba(121,147,176,.28);
  border-radius:20px;
  background:rgba(255,255,255,.54);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.75),0 8px 24px rgba(35,62,92,.08);
}

.factory-panel-topline{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:#708299;
  font-size:12px;
  font-weight:850;
  letter-spacing:.06em;
  text-transform:uppercase;
}

.factory-resource{
  letter-spacing:0;
  text-transform:none;
}

.factory-resource strong{
  color:#183354;
  font-size:14px;
}

.factory-panel h3{
  margin:24px 0 8px;
  font-size:24px;
}

.factory-panel p{
  margin:0;
  color:#586d82;
  font-weight:600;
  line-height:1.5;
}

.factory-primary{
  width:100%;
  margin-top:30px;
  padding:12px 18px;
  border:0;
  border-radius:999px;
  background:linear-gradient(155deg,#6073b8,#2b4d91);
  color:white;
  font:800 15px/1 system-ui,sans-serif;
  box-shadow:0 7px 18px rgba(31,62,119,.22);
}

.factory-primary:disabled{
  cursor:default;
  opacity:.48;
  box-shadow:none;
}

.factory-placeholder{
  display:grid;
  place-items:center;
  min-height:92px;
  margin-top:30px;
  padding:18px;
  border:1px dashed rgba(86,111,137,.34);
  border-radius:16px;
  color:#7b8998;
  font-weight:750;
  text-align:center;
}

@media(max-width:760px){
  .factory-card{width:min(92vw,620px);min-height:0;padding:28px 22px}
  .factory-grid{grid-template-columns:1fr}
  .factory-panel{min-height:220px}
}


.factory-production-state{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  min-height:24px;
  margin-top:24px;
  color:#52677e;
}

.factory-production-state strong{
  color:#183354;
  font-size:15px;
}

#factory-production-timer{
  font-variant-numeric:tabular-nums;
  font-weight:850;
}

.factory-dev-cycle{
  padding:4px 7px;
  border-radius:999px;
  background:rgba(43,77,145,.08);
  color:#66758b;
  font-size:11px;
  font-weight:800;
}

.factory-production-actions{
  display:grid;
  gap:9px;
  margin-top:14px;
}

.factory-production-actions .factory-primary{
  margin-top:0;
}

.factory-secondary{
  width:100%;
  padding:11px 16px;
  border:1px solid rgba(43,77,145,.25);
  border-radius:999px;
  background:rgba(255,255,255,.66);
  color:#29466f;
  font:800 14px/1 system-ui,sans-serif;
  cursor:pointer;
}

.factory-secondary:hover{
  background:rgba(255,255,255,.92);
}

.factory-secondary:disabled{
  cursor:default;
  opacity:.48;
}

.factory-production-message{
  min-height:18px;
  margin-top:10px;
  color:#8a4e58;
  font-size:12px;
  font-weight:700;
}


.factory-recipe{
  display:grid;
  grid-template-columns:104px minmax(0,1fr);
  grid-template-areas:
    "visual copy"
    "visual action";
  gap:10px 16px;
  align-items:center;
  margin-top:24px;
  padding:16px;
  border:1px solid rgba(121,147,176,.28);
  border-radius:18px;
  background:rgba(255,255,255,.54);
}

.factory-garland-preview{
  --bulb-color:#ffd84d;
  position:relative;
  grid-area:visual;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  width:104px;
  height:48px;
  padding-top:18px;
}

.factory-garland-preview::before{
  content:"";
  position:absolute;
  left:4px;
  right:4px;
  top:13px;
  height:2px;
  border-radius:999px;
  background:#536273;
  transform:rotate(-3deg);
  transform-origin:center;
}

.factory-garland-preview i{
  position:relative;
  z-index:1;
  width:12px;
  height:16px;
  border-radius:45% 45% 55% 55%;
  background:var(--bulb-color);
  box-shadow:
    0 0 5px color-mix(in srgb,var(--bulb-color) 72%,white),
    0 0 11px color-mix(in srgb,var(--bulb-color) 45%,transparent);
}

.factory-garland-preview i:nth-child(even){
  margin-top:5px;
}

.factory-garland-preview i::before{
  content:"";
  position:absolute;
  left:4px;
  top:-5px;
  width:4px;
  height:6px;
  border-radius:2px 2px 0 0;
  background:#65717e;
}

.factory-recipe-copy{
  grid-area:copy;
  display:grid;
  gap:4px;
  min-width:0;
}

.factory-recipe-copy h4{
  margin:0;
  color:#183354;
  font-size:16px;
}

.factory-recipe-copy span{
  color:#63768a;
  font-size:12px;
  font-weight:700;
}

.factory-recipe-owned strong{
  color:#183354;
}

.factory-craft-button{
  grid-area:action;
  margin-top:2px;
}

.factory-craft-button:disabled{
  cursor:default;
  opacity:.45;
}

@media(max-width:760px){
  .factory-recipe{
    grid-template-columns:90px minmax(0,1fr);
  }
  .factory-garland-preview{
    width:90px;
  }
}


.factory-recipe-list{
  display:grid;
  gap:10px;
  margin-top:20px;
}

.factory-recipe-list .factory-recipe{
  margin-top:0;
}

.factory-color-recipes{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
}

.factory-recipe-wide{
  grid-template-columns:96px minmax(0,1fr);
}

.factory-recipe-compact{
  grid-template-columns:1fr;
  grid-template-areas:
    "visual"
    "copy"
    "action";
  justify-items:center;
  gap:7px;
  min-height:176px;
  padding:12px 10px;
  text-align:center;
}

.factory-recipe-compact .factory-garland-preview{
  width:78px;
  height:38px;
  padding-top:14px;
}

.factory-recipe-compact .factory-recipe-copy{
  justify-items:center;
}

.factory-recipe-compact .factory-recipe-copy h4{
  font-size:14px;
}

.factory-recipe-compact .factory-recipe-copy span{
  font-size:11px;
}

.factory-recipe-compact .factory-craft-button{
  padding:9px 11px;
  font-size:12px;
}

.factory-garland-preview.red,
.decor-garland-shape.red{
  --bulb-color:#f05c67;
}

.factory-garland-preview.blue,
.decor-garland-shape.blue{
  --bulb-color:#5d8ff0;
}

.factory-garland-preview.green,
.decor-garland-shape.green{
  --bulb-color:#55b978;
}

.factory-garland-preview.multicolor i:nth-child(1),
.decor-garland-shape.multicolor i:nth-child(1){
  --bulb-color:#f05c67;
}
.factory-garland-preview.multicolor i:nth-child(2),
.decor-garland-shape.multicolor i:nth-child(2){
  --bulb-color:#5d8ff0;
}
.factory-garland-preview.multicolor i:nth-child(3),
.decor-garland-shape.multicolor i:nth-child(3){
  --bulb-color:#55b978;
}
.factory-garland-preview.multicolor i:nth-child(4),
.decor-garland-shape.multicolor i:nth-child(4){
  --bulb-color:#ffd84d;
}
.factory-garland-preview.multicolor i:nth-child(5),
.decor-garland-shape.multicolor i:nth-child(5){
  --bulb-color:#f05c67;
}

@media(max-width:760px){
  .factory-color-recipes{
    grid-template-columns:1fr;
  }
  .factory-recipe-compact{
    grid-template-columns:86px minmax(0,1fr);
    grid-template-areas:
      "visual copy"
      "visual action";
    justify-items:stretch;
    min-height:0;
    text-align:left;
  }
  .factory-recipe-compact .factory-recipe-copy{
    justify-items:start;
  }
}


.factory-recipe-divider{
  display:flex;
  align-items:center;
  gap:10px;
  margin:4px 0 0;
  color:#72839b;
  font-size:11px;
  font-weight:850;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.factory-recipe-divider::before,
.factory-recipe-divider::after{
  content:"";
  flex:1;
  height:1px;
  background:rgba(121,147,176,.25);
}

.factory-fringe-recipes{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}

.factory-fringe-card{
  grid-template-columns:1fr;
  grid-template-areas:
    "visual"
    "copy"
    "action";
  justify-items:center;
  gap:8px;
  min-height:205px;
  padding:14px 12px;
  text-align:center;
}

.factory-fringe-card .factory-recipe-copy{
  justify-items:center;
}

.factory-fringe-preview{
  --bulb-color:#ffd84d;
  position:relative;
  grid-area:visual;
  display:flex;
  justify-content:space-between;
  width:112px;
  height:62px;
  padding:0 5px;
}

.factory-fringe-preview::before{
  content:"";
  position:absolute;
  left:3px;
  right:3px;
  top:8px;
  height:2px;
  border-radius:999px;
  background:#536273;
}

.factory-fringe-preview i{
  --drop:28px;
  position:relative;
  width:2px;
  height:var(--drop);
  margin-top:8px;
  border-radius:999px;
  background:#65717e;
}

.factory-fringe-preview i:nth-child(2),
.factory-fringe-preview i:nth-child(6){--drop:38px}
.factory-fringe-preview i:nth-child(3),
.factory-fringe-preview i:nth-child(5){--drop:47px}
.factory-fringe-preview i:nth-child(4){--drop:54px}

.factory-fringe-preview i::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-7px;
  width:10px;
  height:13px;
  border-radius:45% 45% 55% 55%;
  background:var(--bulb-color);
  transform:translateX(-50%);
  box-shadow:
    0 0 5px color-mix(in srgb,var(--bulb-color) 72%,white),
    0 0 11px color-mix(in srgb,var(--bulb-color) 45%,transparent);
}

.factory-fringe-preview.multicolor i:nth-child(1){--bulb-color:#f05c67}
.factory-fringe-preview.multicolor i:nth-child(2){--bulb-color:#5d8ff0}
.factory-fringe-preview.multicolor i:nth-child(3){--bulb-color:#55b978}
.factory-fringe-preview.multicolor i:nth-child(4){--bulb-color:#ffd84d}
.factory-fringe-preview.multicolor i:nth-child(5){--bulb-color:#f05c67}
.factory-fringe-preview.multicolor i:nth-child(6){--bulb-color:#5d8ff0}
.factory-fringe-preview.multicolor i:nth-child(7){--bulb-color:#55b978}

.factory-workshop{
  max-height:560px;
  overflow-y:auto;
  scrollbar-gutter:stable;
}

@media(max-width:760px){
  .factory-workshop{
    max-height:none;
    overflow:visible;
  }
  .factory-fringe-recipes{
    grid-template-columns:1fr;
  }
}


.factory-final-recipe{
  display:grid;
  grid-template-columns:110px minmax(0,1fr);
  grid-template-areas:
    "visual copy"
    "action action";
  gap:12px 16px;
  align-items:center;
  padding:18px;
  border:1px solid rgba(183,143,62,.34);
  border-radius:20px;
  background:
    radial-gradient(circle at 18% 20%,rgba(255,235,166,.36),transparent 34%),
    rgba(255,250,235,.72);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.82),
    0 7px 18px rgba(96,72,29,.08);
}

.factory-final-garland-preview{
  --final-bulb:#ffd56b;
  position:relative;
  grid-area:visual;
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:106px;
  height:64px;
  padding:0 5px;
}

.factory-final-garland-preview::before{
  content:"";
  position:absolute;
  left:4px;
  right:4px;
  top:31px;
  height:1.5px;
  border-radius:999px;
  background:#7c7158;
  transform:rotate(-5deg);
}

.factory-final-garland-preview i{
  position:relative;
  z-index:1;
  width:8px;
  height:8px;
  border-radius:50%;
  background:#fff8dc;
  box-shadow:
    0 0 4px #fff,
    0 0 10px var(--final-bulb),
    0 0 18px color-mix(in srgb,var(--final-bulb) 58%,transparent);
}

.factory-final-garland-preview i:nth-child(2n){transform:translateY(5px)}
.factory-final-garland-preview i:nth-child(3n){transform:translateY(-4px)}

.factory-final-copy{
  grid-area:copy;
  display:grid;
  gap:5px;
  min-width:0;
}

.factory-final-copy h4{
  margin:0;
  color:#183354;
  font-size:17px;
}

.factory-final-copy>span{
  color:#63768a;
  font-size:11px;
  font-weight:750;
  line-height:1.35;
}

.factory-final-kicker{
  display:block;
  margin-bottom:2px;
  color:#a17d35;
  font-size:10px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.factory-final-progress strong{
  color:#183354;
}

.factory-final-status{
  color:#9a7227!important;
  font-weight:900!important;
}

.factory-final-recipe .factory-craft-button{
  grid-area:action;
  margin-top:0;
}

@media(max-width:760px){
  .factory-final-recipe{
    grid-template-columns:88px minmax(0,1fr);
  }
  .factory-final-garland-preview{
    width:84px;
  }
}


.factory-final-recipes{
  display:grid;
  gap:9px;
}

.factory-final-recipe.is-unlocked{
  border-color:rgba(91,120,164,.34);
  background:
    radial-gradient(circle at 18% 20%,rgba(229,239,255,.48),transparent 34%),
    rgba(248,251,255,.76);
}

.factory-final-recipe.is-active{
  border-color:rgba(176,135,49,.6);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 0 0 2px rgba(231,197,119,.13),
    0 8px 22px rgba(96,72,29,.11);
}

.factory-final-garland-preview.multicolor i:nth-child(4n+1){--final-bulb:#f05c67}
.factory-final-garland-preview.multicolor i:nth-child(4n+2){--final-bulb:#55b978}
.factory-final-garland-preview.multicolor i:nth-child(4n+3){--final-bulb:#5d8ff0}
.factory-final-garland-preview.multicolor i:nth-child(4n){--final-bulb:#ffd84d}

.factory-final-garland-preview.cycle i{
  --final-bulb:#f05c67;
  animation:factory-final-cycle-preview 4s linear infinite;
}

@keyframes factory-final-cycle-preview{
  0%{filter:hue-rotate(0deg)}
  25%{filter:hue-rotate(95deg)}
  50%{filter:hue-rotate(205deg)}
  75%{filter:hue-rotate(285deg)}
  100%{filter:hue-rotate(360deg)}
}

@media(prefers-reduced-motion:reduce){
  .factory-final-garland-preview.cycle i{animation:none}
}


.factory-topper-recipes{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:9px;
}

.factory-topper-recipe{
  display:grid;
  grid-template-columns:88px minmax(0,1fr);
  grid-template-areas:"visual copy" "action action";
  gap:10px 14px;
  align-items:center;
  padding:16px;
  border:1px solid rgba(183,143,62,.34);
  border-radius:20px;
  background:rgba(255,250,235,.72);
}

.factory-topper-recipe.is-unlocked{
  border-color:rgba(91,120,164,.34);
  background:rgba(248,251,255,.76);
}

.factory-topper-recipe.is-active{
  border-color:rgba(176,135,49,.6);
  box-shadow:0 0 0 2px rgba(231,197,119,.13);
}

.factory-topper-preview{
  grid-area:visual;
  display:grid;
  place-items:center;
  width:88px;
  height:88px;
}

.factory-topper-preview img{
  display:block;
  width:82px;
  height:82px;
  object-fit:contain;
}

.factory-topper-recipe .factory-craft-button{
  grid-area:action;
  margin-top:0;
}

@media(max-width:760px){
  .factory-topper-recipes{grid-template-columns:1fr}
}


.factory-recipe-actions{
  grid-area:action;
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:7px;
  width:100%;
}

.factory-recipe-actions .factory-craft-button,
.factory-recipe-actions .factory-dismantle-button{
  grid-area:auto;
  margin-top:0;
}

.factory-dismantle-button{
  border-color:rgba(137,93,93,.24);
  color:#7a4a4f;
  background:rgba(255,255,255,.58);
}

.factory-dismantle-button:hover{
  background:rgba(255,249,249,.95);
}

.factory-dismantle-button:disabled{
  cursor:default;
  opacity:.38;
}

.factory-final-actions .factory-primary{
  margin-top:0;
}

@media(max-width:760px){
  .factory-recipe-compact .factory-recipe-actions{
    grid-template-columns:1fr;
  }
}


/* Factory v2: shared ice / frosted-glass language used by the wheel and game UI. */
#factory-modal{
  position:fixed;
  padding:18px;
  background:#07132a66;
}
#factory-modal .factory-card{
  position:relative;
  display:flex;
  flex-direction:column;
  width:min(1040px,94vw);
  max-width:100%;
  height:min(860px,94vh);
  min-height:0;
  padding:24px 26px 20px;
  overflow:hidden;
  border:1px solid #dceeffa6;
  border-radius:28px;
  background:var(--elka-glass-surface);
  color:#f5f8ff;
  backdrop-filter:blur(24px) saturate(1.35);
  -webkit-backdrop-filter:blur(24px) saturate(1.35);
  box-shadow:var(--elka-glass-rim),0 24px 80px #0613316e;
}
#factory-modal .modal-close{
  position:absolute;
  right:18px;
  top:18px;
  z-index:20;
  display:grid;
  place-items:center;
  width:36px;
  height:36px;
  padding:0;
  border:1px solid #e1edffb3;
  border-radius:50%;
  background:var(--elka-control-surface);
  color:#f8faff;
  box-shadow:var(--elka-control-glow);
}
#factory-modal .modal-close svg{
  width:18px;
  height:18px;
  stroke-width:2.6;
}
#factory-modal .modal-close:hover{
  filter:brightness(1.12);
  box-shadow:var(--elka-control-hover);
}
#factory-modal .factory-heading{
  flex:0 0 auto;
  max-width:none;
  margin:0 54px 14px;
  text-align:center;
}
#factory-modal .factory-heading h2{
  margin:0;
  color:#fff;
  font:800 27px/1.08 system-ui,sans-serif;
  letter-spacing:.01em;
  text-shadow:0 2px 9px #17366f66;
}
#factory-modal .factory-intro{
  margin:4px 0 0;
  color:#dce8fb;
  font:600 13px/1.35 system-ui,sans-serif;
  text-align:center;
  text-shadow:0 2px 8px #20366c55;
}
.factory-production-bar{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:minmax(250px,1.15fr) auto minmax(230px,.85fr);
  grid-template-areas:
    "copy stock actions"
    "message message message";
  align-items:center;
  gap:10px 22px;
  min-height:112px;
  padding:18px 20px 10px;
  border:1px solid #dceeff85;
  border-radius:21px;
  background:
    radial-gradient(ellipse at 8% 5%,#f6fbff2b,transparent 55%),
    var(--elka-soft-cell);
  box-shadow:inset 0 1px 0 #ffffff73,inset 0 -8px 22px #203d7a20,0 8px 24px #0b1c4930;
}
.factory-production-copy{grid-area:copy;min-width:0}
.factory-section-label{
  display:block;
  color:#d7e4ff;
  font:800 10px/1.2 system-ui,sans-serif;
  letter-spacing:.13em;
  text-transform:uppercase;
  opacity:.78;
}
#factory-modal .factory-production-state{
  display:flex;
  align-items:baseline;
  flex-wrap:wrap;
  justify-content:flex-start;
  gap:8px 12px;
  min-height:30px;
  margin:7px 0 0;
  color:#eef5ff;
}
#factory-modal .factory-production-state strong{
  color:#fff;
  font-size:16px;
  text-shadow:0 1px 5px #173a7466;
}
#factory-production-timer{
  padding:5px 10px;
  border:1px solid #dceeff73;
  border-radius:999px;
  background:#183a7052;
  color:#fff;
  font-size:15px;
  letter-spacing:.05em;
  box-shadow:inset 0 0 7px #e5f4ff2b;
}
#factory-modal .factory-dev-cycle{
  background:#ddecff1a;
  color:#dce8ff;
}
.factory-bulb-stock{
  grid-area:stock;
  display:grid;
  grid-template-columns:auto auto;
  grid-template-areas:"icon label" "icon number";
  align-items:center;
  column-gap:10px;
  min-width:138px;
  padding:10px 14px;
  border:1px solid #e5efff66;
  border-radius:17px;
  background:#dce9ff1a;
  box-shadow:inset 0 0 12px #eef8ff1f;
}
.factory-bulb-stock>.factory-bulb-icon{grid-area:icon}
.factory-bulb-stock>span:not(.factory-bulb-icon){
  grid-area:label;
  color:#d9e6fb;
  font-size:11px;
  font-weight:700;
}
.factory-bulb-stock strong{
  grid-area:number;
  color:#fff;
  font-size:16pt;
  line-height:1;
}
.factory-bulb-icon{
  position:relative;
  display:inline-block;
  width:22px;
  height:27px;
  border:1px solid #fff8c9;
  border-radius:48% 48% 54% 54%;
  background:radial-gradient(circle at 36% 27%,#fff 0 10%,#fff3a8 32%,#f4c84d 72%,#c79527);
  box-shadow:0 0 4px #fff9d9,0 0 12px #ffd96899;
}
.factory-bulb-icon::after{
  content:"";
  position:absolute;
  left:6px;
  bottom:-6px;
  width:8px;
  height:7px;
  border-radius:0 0 3px 3px;
  background:linear-gradient(90deg,#71849f,#dce7f5,#71849f);
}
#factory-modal .factory-production-actions{
  grid-area:actions;
  display:grid;
  gap:7px;
  margin:0;
}
#factory-modal .factory-production-actions .factory-primary,
#factory-modal .factory-production-actions .factory-secondary{
  margin:0;
  min-height:40px;
}
#factory-modal .factory-production-message{
  grid-area:message;
  min-height:16px;
  margin:0;
  color:#ffd8df;
  font-size:11px;
}
.factory-tabs{
  flex:0 0 auto;
  display:flex;
  justify-content:center;
  gap:6px;
  margin:15px auto 12px;
  padding:4px;
  border:1px solid #dceeff73;
  border-radius:999px;
  background:#18336a42;
  box-shadow:inset 0 0 10px #ddecff21;
}
.factory-tab{
  min-width:150px;
  padding:9px 22px;
  border:1px solid transparent;
  border-radius:999px;
  background:transparent;
  color:#d9e5fa;
  font:800 14px/1 system-ui,sans-serif;
  cursor:pointer;
  transition:background .16s,border-color .16s,box-shadow .16s,filter .16s;
}
.factory-tab:hover{filter:brightness(1.12)}
.factory-tab.active{
  border-color:#e7f1ff9c;
  background:var(--elka-control-surface);
  color:#fff;
  box-shadow:inset 0 0 8px #e8f1ff66,0 0 10px #9dc1ff4d;
}
.factory-tab-body{flex:1 1 auto;min-height:0}
.factory-tab-panel{height:100%;min-height:0}
.factory-tab-panel[hidden]{display:none}
.factory-scroll{
  height:100%;
  overflow-y:auto;
  padding:2px 8px 18px 2px;
  scrollbar-width:thin;
  scrollbar-color:#b9d2ff7a transparent;
}
.factory-scroll::-webkit-scrollbar{width:8px}
.factory-scroll::-webkit-scrollbar-thumb{border-radius:999px;background:#b9d2ff69}
.factory-scroll::-webkit-scrollbar-track{background:transparent}
.factory-workshop-section,.factory-stock-section{
  margin:0 0 20px;
  padding:18px;
  border:1px solid #dceeff52;
  border-radius:22px;
  background:linear-gradient(145deg,#eef6ff16,#b9ccff0d);
  box-shadow:inset 0 1px 0 #ffffff45,0 8px 25px #0a1c4826;
}
.factory-section-heading{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}
.factory-section-heading h3{
  margin:3px 0 0!important;
  color:#fff;
  font-size:21px!important;
  line-height:1.1;
  text-shadow:0 1px 5px #17376c66;
}
.factory-workshop-grid{
  display:grid;
  gap:10px;
}
.factory-workshop-grid--threads{grid-template-columns:repeat(3,minmax(0,1fr))}
.factory-workshop-grid--fringe{grid-template-columns:repeat(2,minmax(0,1fr))}
.factory-craft-card,.factory-final-craft,.factory-star-craft,.factory-stock-card{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  min-width:0;
  padding:14px;
  border:1px solid #e2eeff59;
  border-radius:18px;
  background:
    radial-gradient(ellipse at 20% 0%,#ffffff26,transparent 48%),
    linear-gradient(150deg,#dbe8ff26,#a8bdeb15);
  box-shadow:inset 0 1px 0 #ffffff5e,inset 0 -12px 25px #263d7614;
}
.factory-craft-card--wide{grid-column:span 2}
.factory-result-visual{
  display:grid;
  place-items:center;
  width:100%;
  height:65px;
  margin-bottom:4px;
}
#factory-modal :is(.factory-craft-card,.factory-final-craft,.factory-star-craft,.factory-stock-card) h4{
  margin:5px 0 10px;
  color:#fff;
  font-size:15px;
  line-height:1.2;
  text-align:center;
}
.factory-owned-note,.factory-final-availability{
  margin:7px 0 9px;
  color:#cfddf3;
  font-size:11px;
  font-weight:700;
}
.factory-owned-note strong,.factory-final-availability strong{color:#fff}
.factory-formula{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  width:100%;
  min-height:54px;
  padding:7px 9px;
  border:1px solid #dceeff40;
  border-radius:14px;
  background:#102b5a29;
}
.factory-component,.factory-formula-result{
  position:relative;
  display:grid;
  place-items:center;
  min-width:64px;
  min-height:38px;
}
.factory-component b,.factory-formula--fringe-mix>b{
  color:#fff;
  font-size:14px;
}
.factory-component em{
  position:absolute;
  right:-2px;
  top:-5px;
  min-width:19px;
  padding:2px 5px;
  border:1px solid #cfe3ff66;
  border-radius:999px;
  background:#21447ebd;
  color:#dff1ff;
  font:800 9px/1.15 system-ui,sans-serif;
  text-align:center;
  font-style:normal;
  box-shadow:0 2px 7px #0a183b52;
}
.factory-component em.is-short{
  border-color:#ffbfc980;
  background:#74344fc4;
  color:#ffe6eb;
}
.factory-component--bulb{
  grid-template-columns:auto auto;
  gap:8px;
}
.factory-component--bulb em{right:-9px}
.factory-formula-arrow,.factory-formula-plus{
  color:#d6e5ff;
  font-size:18px;
  font-weight:800;
  opacity:.82;
}
.factory-formula--triple{gap:4px}
.factory-formula--triple .factory-component{min-width:46px}
.factory-formula--fringe-mix{gap:3px}
.factory-formula--fringe-mix .factory-component{min-width:51px}
.factory-formula--fringe-mix>b{margin-left:5px}
#factory-modal .factory-primary,
#factory-modal .factory-secondary{
  border:1px solid #e1edff9e;
  border-radius:999px;
  color:#f8faff;
  font:800 13px/1 system-ui,sans-serif;
  text-shadow:0 1px 3px #152c7766;
  cursor:pointer;
  transition:filter .16s,box-shadow .16s,transform .16s;
}
#factory-modal .factory-primary{
  width:100%;
  margin-top:auto;
  padding:11px 14px;
  background:var(--elka-control-surface);
  box-shadow:var(--elka-control-glow);
}
#factory-modal .factory-secondary{
  padding:10px 13px;
  background:#cddcff20;
  box-shadow:inset 0 0 7px #f2f7ff30,0 3px 9px #0a1e4928;
}
#factory-modal :is(.factory-primary,.factory-secondary):hover:not(:disabled){
  filter:brightness(1.14);
  box-shadow:var(--elka-control-hover);
}
#factory-modal :is(.factory-primary,.factory-secondary):active:not(:disabled){transform:translateY(1px)}
#factory-modal :is(.factory-primary,.factory-secondary):disabled{
  cursor:default;
  opacity:.38;
  box-shadow:inset 0 0 6px #e8f1ff24;
}
#factory-modal .factory-garland-preview{
  width:92px;
  height:46px;
  padding-top:17px;
}
#factory-modal .factory-garland-preview.mini{
  width:58px;
  height:29px;
  padding-top:11px;
}
#factory-modal .factory-garland-preview.mini::before{top:8px;height:1px}
#factory-modal .factory-garland-preview.mini i{
  width:7px;
  height:9px;
}
#factory-modal .factory-garland-preview.mini i::before{
  left:2px;
  top:-3px;
  width:3px;
  height:4px;
}
#factory-modal .factory-fringe-preview{
  width:88px;
  height:57px;
  transform:scale(.88);
  transform-origin:center;
}
#factory-modal .factory-fringe-preview.mini{
  width:57px;
  height:42px;
  transform:scale(.63);
  transform-origin:center;
  margin:-8px -10px;
}
.factory-final-showcase{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
}
.factory-final-craft{padding-top:10px}
.factory-final-tree-preview{
  position:relative;
  display:grid;
  place-items:center;
  width:100%;
  height:190px;
  overflow:hidden;
  border-radius:15px;
  background:radial-gradient(ellipse at 50% 62%,#cce6ff1c,transparent 62%);
}
.factory-final-tree-preview>img{
  display:block;
  width:178px;
  height:178px;
  object-fit:contain;
  filter:drop-shadow(0 7px 9px #071a3b6b);
}
.factory-tree-lights{position:absolute;inset:0;pointer-events:none}
.factory-tree-lights i{
  --factory-light:#ffd76f;
  position:absolute;
  width:5px;
  height:5px;
  border-radius:50%;
  background:#fff9df;
  box-shadow:0 0 3px #fff,0 0 8px var(--factory-light),0 0 14px var(--factory-light);
  animation:factoryTreeTwinkle 2.4s ease-in-out infinite;
}
.factory-tree-lights i:nth-child(1){left:49%;top:24%;animation-delay:-.2s}
.factory-tree-lights i:nth-child(2){left:43%;top:31%;animation-delay:-1.1s}
.factory-tree-lights i:nth-child(3){left:56%;top:32%;animation-delay:-1.7s}
.factory-tree-lights i:nth-child(4){left:37%;top:39%;animation-delay:-.7s}
.factory-tree-lights i:nth-child(5){left:50%;top:40%;animation-delay:-1.9s}
.factory-tree-lights i:nth-child(6){left:63%;top:40%;animation-delay:-.4s}
.factory-tree-lights i:nth-child(7){left:32%;top:48%;animation-delay:-1.4s}
.factory-tree-lights i:nth-child(8){left:43%;top:49%;animation-delay:-.1s}
.factory-tree-lights i:nth-child(9){left:56%;top:50%;animation-delay:-2s}
.factory-tree-lights i:nth-child(10){left:68%;top:49%;animation-delay:-.9s}
.factory-tree-lights i:nth-child(11){left:27%;top:58%;animation-delay:-1.8s}
.factory-tree-lights i:nth-child(12){left:39%;top:59%;animation-delay:-.5s}
.factory-tree-lights i:nth-child(13){left:51%;top:60%;animation-delay:-1.3s}
.factory-tree-lights i:nth-child(14){left:63%;top:59%;animation-delay:-2.1s}
.factory-tree-lights i:nth-child(15){left:74%;top:58%;animation-delay:-.8s}
.factory-final-tree-preview.multicolor .factory-tree-lights i:nth-child(4n+1){--factory-light:#f05c67;background:#ffdadd}
.factory-final-tree-preview.multicolor .factory-tree-lights i:nth-child(4n+2){--factory-light:#55c37d;background:#dcffe7}
.factory-final-tree-preview.multicolor .factory-tree-lights i:nth-child(4n+3){--factory-light:#6598ff;background:#e0ebff}
.factory-final-tree-preview.multicolor .factory-tree-lights i:nth-child(4n){--factory-light:#ffd84d;background:#fff8ca}
.factory-final-tree-preview.cycle .factory-tree-lights i{
  --factory-light:#f05c67;
  animation:factoryTreeCycle 8s linear infinite,factoryTreeTwinkle 2.4s ease-in-out infinite;
}
@keyframes factoryTreeTwinkle{
  0%,100%{opacity:.35;transform:scale(.75)}
  45%{opacity:1;transform:scale(1.25)}
  68%{opacity:.58;transform:scale(.9)}
}
@keyframes factoryTreeCycle{
  0%{filter:hue-rotate(0deg)}
  25%{filter:hue-rotate(100deg)}
  50%{filter:hue-rotate(205deg)}
  75%{filter:hue-rotate(285deg)}
  100%{filter:hue-rotate(360deg)}
}
.factory-final-status{
  min-height:18px;
  margin:0 0 8px;
  color:#ffe4a6!important;
  font-size:11px!important;
  font-weight:850!important;
}
.factory-final-craft.is-unlocked,.factory-star-craft.is-unlocked{
  border-color:#b9d7ff8a;
}
.factory-final-craft.is-active,.factory-star-craft.is-active{
  box-shadow:inset 0 0 16px #f4fbff3b,0 0 0 1px #dcecff8f,0 0 18px #91baff45;
}
.factory-star-showcase{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.factory-star-live{
  position:relative;
  display:grid;
  place-items:center;
  width:150px;
  height:150px;
  isolation:isolate;
}
.factory-star-live::before{
  content:"";
  position:absolute;
  inset:10%;
  z-index:-1;
  border-radius:50%;
  background:radial-gradient(circle,#ffd3bd68 0%,#ff6a7240 35%,transparent 72%);
  filter:blur(4px);
  animation:factoryStarHalo 2.8s ease-in-out infinite;
}
.factory-star-live.diamond::before{
  background:radial-gradient(circle,#fff9db73 0%,#d7e9ff48 38%,transparent 72%);
}
.factory-star-live::after{
  content:"";
  position:absolute;
  left:72%;
  top:23%;
  width:24px;
  height:24px;
  background:radial-gradient(circle,#fff 0 8%,#fff6d9d9 19%,transparent 62%);
  clip-path:polygon(50% 0,58% 40%,100% 50%,58% 58%,50% 100%,42% 58%,0 50%,42% 42%);
  animation:factoryStarGlint 2.7s -1.2s ease-in-out infinite;
}
.factory-star-live img{
  display:block;
  width:132px;
  height:132px;
  object-fit:contain;
  filter:drop-shadow(0 4px 5px #071a3b66);
  animation:factoryStarBreathe 2.8s ease-in-out infinite;
}
.factory-star-live.small{width:74px;height:74px}
.factory-star-live.small img{width:67px;height:67px}
.factory-star-live.small::after{width:15px;height:15px}
@keyframes factoryStarHalo{0%,100%{opacity:.45;transform:scale(.9)}50%{opacity:1;transform:scale(1.08)}}
@keyframes factoryStarGlint{0%,55%,100%{opacity:0;transform:scale(.3) rotate(-12deg)}70%{opacity:1;transform:scale(1)}84%{opacity:0;transform:scale(.5) rotate(10deg)}}
@keyframes factoryStarBreathe{0%,100%{filter:brightness(1) drop-shadow(0 4px 5px #071a3b66)}50%{filter:brightness(1.13) drop-shadow(0 4px 7px #071a3b66)}}
.factory-stock{padding-top:2px}
.factory-stock-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
}
.factory-stock-card{
  min-height:204px;
  transition:opacity .18s,filter .18s,border-color .18s;
}
.factory-stock-card.is-missing{
  opacity:.48;
  filter:saturate(.4);
}
.factory-stock-visual{
  display:grid;
  place-items:center;
  height:70px;
}
.factory-stock-count{
  position:absolute;
  right:10px;
  top:10px;
  min-width:34px;
  padding:4px 8px;
  border:1px solid #e1edff6b;
  border-radius:999px;
  background:#1c4077a8;
  color:#fff;
  font-size:12px;
  text-align:center;
}
.factory-stock-meta{
  display:grid;
  gap:3px;
  width:100%;
  margin:0 0 10px;
  color:#c8d8ef;
  font-size:10px;
  font-weight:700;
  text-align:center;
}
.factory-stock-meta b{color:#fff}
.factory-stock-final-grid{display:grid;gap:8px}
.factory-stock-final-card{
  display:grid;
  grid-template-columns:92px minmax(0,1fr) minmax(235px,auto);
  align-items:center;
  gap:12px;
  padding:11px 13px;
  border:1px solid #dceeff52;
  border-radius:17px;
  background:linear-gradient(145deg,#edf5ff22,#9fb8f012);
}
.factory-stock-final-card.is-missing{opacity:.48}
.factory-stock-final-icon{
  display:grid;
  place-items:center;
  height:50px;
}
.factory-stock-final-icon>span{
  position:relative;
  display:flex;
  justify-content:space-between;
  width:78px;
}
.factory-stock-final-icon>span::before{
  content:"";
  position:absolute;
  left:0;right:0;top:50%;
  height:1px;
  background:#c8d9ec8a;
}
.factory-stock-final-icon i{
  --stock-light:#ffd66b;
  position:relative;
  z-index:1;
  width:5px;height:5px;border-radius:50%;
  background:#fff8db;
  box-shadow:0 0 6px var(--stock-light);
}
.factory-stock-final-icon.multicolor i:nth-child(4n+1){--stock-light:#f05c67}
.factory-stock-final-icon.multicolor i:nth-child(4n+2){--stock-light:#55b978}
.factory-stock-final-icon.multicolor i:nth-child(4n+3){--stock-light:#5d8ff0}
.factory-stock-final-icon.multicolor i:nth-child(4n){--stock-light:#ffd84d}
.factory-stock-final-icon.cycle i{animation:factoryTreeCycle 6s linear infinite}
.factory-stock-final-copy h4,.factory-stock-star-card h4{
  margin:0 0 4px;
  color:#fff;
  font-size:14px;
}
.factory-stock-final-copy span,.factory-stock-star-card>div:nth-child(2)>span{
  color:#cbdaf1;
  font-size:11px;
  font-weight:700;
}
.factory-stock-final-card.is-active,.factory-stock-star-card.is-active{
  border-color:#dcecff9c;
  box-shadow:inset 0 0 14px #eaf5ff2d,0 0 13px #93b9ff38;
}
.factory-stock-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
.factory-stock-actions .factory-primary{margin:0!important}
.factory-stock-star-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.factory-stock-star-card{
  display:grid;
  grid-template-columns:78px minmax(0,1fr) 120px;
  align-items:center;
  gap:12px;
  min-height:90px;
  padding:9px 12px;
  border:1px solid #dceeff52;
  border-radius:17px;
  background:linear-gradient(145deg,#edf5ff22,#9fb8f012);
}
.factory-stock-star-card.is-missing{opacity:.48}
.factory-stock-star-card .factory-primary{margin:0!important}
.factory-sr-status{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  padding:0!important;
  margin:-1px!important;
  overflow:hidden!important;
  clip:rect(0 0 0 0)!important;
  clip-path:inset(50%)!important;
  white-space:nowrap!important;
  border:0!important;
}
@media(max-width:900px){
  #factory-modal .factory-card{width:96vw;padding:20px}
  .factory-production-bar{grid-template-columns:1fr auto;grid-template-areas:"copy stock" "actions actions" "message message"}
  .factory-production-actions{grid-template-columns:1fr 1fr}
  .factory-workshop-grid--threads{grid-template-columns:repeat(2,minmax(0,1fr))}
  .factory-craft-card--wide{grid-column:span 2}
  .factory-final-showcase{grid-template-columns:1fr}
  .factory-final-tree-preview{height:160px}
  .factory-stock-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media(max-width:650px){
  #factory-modal{padding:8px}
  #factory-modal .factory-card{height:97vh;padding:18px 14px}
  #factory-modal .factory-heading{margin:0 42px 10px}
  #factory-modal .factory-intro{margin:4px 0 0;font-size:12px}
  .factory-production-bar{padding:14px;gap:9px}
  .factory-tabs{width:100%}
  .factory-tab{flex:1;min-width:0}
  .factory-workshop-grid--threads,.factory-workshop-grid--fringe,.factory-star-showcase,.factory-stock-star-grid{grid-template-columns:1fr}
  .factory-craft-card--wide{grid-column:auto}
  .factory-stock-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .factory-stock-final-card{grid-template-columns:70px minmax(0,1fr)}
  .factory-stock-actions{grid-column:1/-1}
  .factory-stock-star-card{grid-template-columns:70px minmax(0,1fr)}
  .factory-stock-star-card .factory-primary{grid-column:1/-1}
}
@media(prefers-reduced-motion:reduce){
  .factory-tree-lights i,.factory-star-live::before,.factory-star-live::after,.factory-star-live img,.factory-stock-final-icon.cycle i{animation:none!important}
}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  #factory-modal .factory-card{background:linear-gradient(135deg,#758bc4f5,#344d8ff5)}
}


/* Factory artwork: glass bulbs, threads and fringe from the approved local reference.
   These rules only replace the drawings inside the existing factory v2 layout. */
#factory-modal .factory-art-host{
  position:relative;
  display:grid;
  place-items:center;
  padding:0;
  background:none;
}
#factory-modal .factory-art-host::before,
#factory-modal .factory-art-host::after,
#factory-modal .factory-art-host>i{
  display:none!important;
}
#factory-modal .factory-art-host .factory-drawing{
  display:block;
  width:100%;
  height:100%;
  overflow:visible;
}
#factory-modal .factory-art-host--bulb{
  width:31px;
  height:38px;
  border:0;
  border-radius:0;
  box-shadow:none;
}
#factory-modal .factory-art-host--bulb::after{
  content:none;
}
#factory-modal .factory-art-host--garland{
  width:104px;
  height:58px;
}
#factory-modal .factory-art-host--garland.mini{
  width:64px;
  height:40px;
}
#factory-modal .factory-art-host--fringe{
  width:112px;
  height:72px;
  transform:none;
}
#factory-modal .factory-art-host--fringe.mini{
  width:70px;
  height:48px;
  margin:0;
  transform:none;
}
#factory-modal .factory-art-host .factory-drawing-lamp{
  animation:factoryReferenceLampGlow 2.7s var(--phase) ease-in-out infinite;
  /* The SVG already contains a radial light halo. Animating a filter on
     every bulb would rasterize that glow again on every scrolling frame. */
  filter:none;
}
@keyframes factoryReferenceLampGlow{
  0%,100%{opacity:.55}
  40%{opacity:1}
  65%{opacity:.85}
}
@media(prefers-reduced-motion:reduce){
  #factory-modal .factory-art-host .factory-drawing-lamp{
    animation:none;
  }
}

/* Hard reset so legacy remote preview CSS cannot affect the local artwork. */

#factory-modal .factory-art-host{
  box-sizing:border-box;
  border:0;
  border-radius:0;
  background:none;
  box-shadow:none;
  padding:0;
  transform:none;
  overflow:visible;
}


/* Local factory artwork sizing: keep the remote popup layout, but give the
   locally-approved bulbs, threads and fringe their original visual scale. */
#factory-modal .factory-result-visual{
  height:104px;
}
#factory-modal .factory-result-visual > .factory-art-host--garland,
#factory-modal .factory-result-visual > .factory-art-host--fringe{
  width:min(310px,95%);
  height:100px;
}
#factory-modal .factory-formula .factory-art-host--garland.mini,
#factory-modal .factory-formula .factory-art-host--fringe.mini{
  width:65px;
  height:43px;
  margin:0;
}
#factory-modal .factory-stock-visual > .factory-art-host--garland{
  width:min(170px,95%);
  height:65px;
}
#factory-modal .factory-stock-visual > .factory-art-host--fringe{
  width:min(145px,88%);
  height:52px;
}
#factory-modal .factory-art-host--bulb{
  width:31px;
  height:38px;
}


/* Factory start row v3: production + first recipe as equal glass cards. */
#factory-modal .factory-start-grid{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
#factory-modal .factory-start-card{
  box-sizing:border-box;
  min-width:0;
  min-height:220px;
  padding:16px 18px;
  border:1px solid #dceeff85;
  border-radius:21px;
  background:
    radial-gradient(ellipse at 8% 5%,#f6fbff2b,transparent 55%),
    var(--elka-soft-cell);
  box-shadow:inset 0 1px 0 #ffffff73,inset 0 -8px 22px #203d7a20,0 8px 24px #0b1c4930;
}
#factory-modal .factory-production-bar{
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:220px;
  padding:16px 18px;
}
#factory-modal .factory-production-head{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:start;
  gap:12px;
}
#factory-modal .factory-production-copy{
  min-width:0;
}
#factory-modal .factory-production-state{
  min-height:38px;
  margin-top:5px;
  gap:8px 12px;
}
#factory-modal .factory-production-state strong{
  font-size:16px;
}
#factory-modal #factory-production-timer{
  padding:3px 0;
  border:0;
  border-radius:0;
  background:none;
  box-shadow:none;
  color:#fff3ce;
  font-size:29px;
  font-weight:750;
  line-height:1;
  letter-spacing:.04em;
  font-variant-numeric:tabular-nums;
  text-shadow:0 0 10px #ffe5ab55;
}
#factory-modal .factory-bulb-stock{
  grid-area:auto;
  min-width:132px;
  padding:8px 12px;
}
#factory-modal .factory-bulb-stock>.factory-art-host--bulb{
  grid-area:icon;
  width:31px;
  height:38px;
}
#factory-modal .factory-bulb-stock>span:not(.factory-art-host--bulb){
  grid-area:label;
  color:#d9e6fb;
  font-size:11px;
  font-weight:700;
}
#factory-modal .factory-progress-lamps{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:1px;
  min-height:66px;
  margin:auto 0 0;
}
#factory-modal .factory-progress-lamp{
  display:grid;
  place-items:center;
  width:39px;
  height:58px;
  opacity:.2;
  filter:grayscale(1) brightness(.7);
  transition:opacity .25s ease,filter .25s ease,transform .25s ease;
}
#factory-modal .factory-progress-lamp .factory-art-host--progress-bulb{
  width:39px;
  height:58px;
}
#factory-modal .factory-progress-lamp .factory-drawing{
  display:block;
  width:100%;
  height:100%;
  overflow:visible;
}
#factory-modal .factory-progress-lamp .factory-drawing-lamp{
  animation:none;
}
#factory-modal .factory-progress-lamp.is-lit{
  opacity:1;
  filter:brightness(1.08) drop-shadow(0 0 5px #ffd78580);
}
#factory-modal .factory-progress-lamp.is-working{
  opacity:.72;
  filter:brightness(1.15) drop-shadow(0 0 6px #ffd7859c);
  animation:factoryProgressLampBlink .9s ease-in-out infinite;
}
@keyframes factoryProgressLampBlink{
  0%,100%{opacity:.38;transform:scale(.97);filter:brightness(.8) drop-shadow(0 0 2px #ffd78555)}
  50%{opacity:1;transform:scale(1.03);filter:brightness(1.45) drop-shadow(0 0 8px #ffe1a9)}
}
#factory-modal .factory-production-actions{
  display:block;
  margin:0;
}
#factory-modal #factory-production-action{
  min-height:40px;
  margin:0;
  background:var(--elka-control-surface);
  box-shadow:var(--elka-control-glow);
}
#factory-modal #factory-production-action.is-positive{
  background:var(--elka-positive-surface);
  box-shadow:var(--elka-control-glow);
  opacity:1;
}
#factory-modal #factory-production-action.is-running:disabled{
  background:var(--elka-control-surface);
  box-shadow:inset 0 0 7px #f2f7ff30,0 3px 9px #0a1e4928;
  opacity:.72;
}
#factory-modal .factory-production-message{
  min-height:14px;
  margin:0;
}

#factory-modal .factory-simple-garland-card{
  display:grid;
  grid-template-columns:minmax(120px,.8fr) minmax(0,1.2fr);
  grid-template-rows:auto minmax(0,1fr) auto;
  align-items:center;
  gap:5px 16px;
  padding:16px 18px;
  border-color:#dceeff85;
  border-radius:21px;
  background:
    radial-gradient(ellipse at 8% 5%,#f6fbff2b,transparent 55%),
    var(--elka-soft-cell);
  box-shadow:inset 0 1px 0 #ffffff73,inset 0 -8px 22px #203d7a20,0 8px 24px #0b1c4930;
}
#factory-modal .factory-simple-garland-card>.factory-section-label{
  grid-column:1/-1;
  align-self:start;
}
#factory-modal .factory-simple-recipe-main{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-width:0;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual{
  height:78px;
  margin:0;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual>.factory-art-host--garland{
  width:180px;
  height:78px;
}
#factory-modal .factory-simple-garland-card h4{
  margin:2px 0 0;
}
#factory-modal .factory-simple-garland-card>.factory-formula{
  align-self:center;
  margin:0;
}
#factory-modal .factory-simple-recipe-footer{
  grid-column:1/-1;
  display:grid;
  grid-template-columns:auto minmax(150px,220px);
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
#factory-modal .factory-simple-recipe-footer .factory-owned-note{
  margin:0;
}
#factory-modal .factory-simple-recipe-footer .factory-primary{
  width:100%;
  margin:0;
}
#factory-modal .factory-workshop-grid--threads .factory-craft-card--wide{
  grid-column:1/-1;
}

@media(max-width:900px){
  #factory-modal .factory-start-grid{
    grid-template-columns:1fr;
  }
  #factory-modal .factory-start-card{
    min-height:210px;
  }
}
@media(max-width:650px){
  #factory-modal .factory-simple-garland-card{
    grid-template-columns:1fr;
  }
  #factory-modal .factory-simple-garland-card>.factory-section-label,
  #factory-modal .factory-simple-recipe-footer{
    grid-column:auto;
  }
  #factory-modal .factory-simple-recipe-footer{
    grid-template-columns:1fr;
  }
}
@media(prefers-reduced-motion:reduce){
  #factory-modal .factory-progress-lamp.is-working{
    animation:none;
  }
}


/* Production card layout: heading/stock on top, lamps/status with timer beside them. */
#factory-modal .factory-production-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}
#factory-modal .factory-production-head>.factory-section-label{
  padding-top:2px;
}
#factory-modal .factory-production-progress-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:14px;
  min-height:86px;
  margin:auto 0 0;
}
#factory-modal .factory-production-progress-main{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-width:0;
}
#factory-modal .factory-production-progress-main .factory-progress-lamps{
  margin:0;
}
#factory-modal .factory-production-status{
  display:block;
  min-height:18px;
  margin-top:2px;
  color:#fff;
  font-size:14px;
  font-weight:750;
  line-height:1.2;
  text-align:center;
  text-shadow:0 1px 5px #173a7466;
}
#factory-modal .factory-production-progress-row #factory-production-timer{
  align-self:center;
  min-width:76px;
  text-align:right;
}
#factory-modal .factory-bulb-stock .factory-drawing-lamp{
  animation:none!important;
  opacity:1!important;
  filter:none!important;
}


/* Production card alignment polish. */
#factory-modal .factory-production-head{
  width:calc(100% + 16px);
  margin:0 -8px;
}
#factory-modal .factory-production-head>.factory-section-label{
  flex:0 0 auto;
  margin:0;
  padding-top:2px;
  text-align:left;
}
#factory-modal .factory-production-head>.factory-bulb-stock{
  flex:0 0 auto;
  margin-left:auto;
}
#factory-modal .factory-production-progress-row{
  align-items:start;
}
#factory-modal .factory-production-progress-main{
  align-items:center;
}
#factory-modal .factory-production-progress-row #factory-production-timer{
  align-self:start;
  margin-top:18px;
}


/* Timer sits directly under the production heading. */
#factory-modal .factory-production-title{
  display:inline-flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  width:max-content;
  max-width:100%;
  min-width:0;
}
#factory-modal .factory-production-title #factory-production-timer{
  min-width:0;
  margin:0;
  text-align:center;
}
#factory-modal .factory-production-progress-row{
  grid-template-columns:1fr;
}


/* Production bulbs: one visual size everywhere without enlarging the stock badge. */
#factory-modal .factory-progress-lamp{
  width:62px;
  height:86px;
}
#factory-modal .factory-progress-lamp .factory-art-host--progress-bulb{
  width:62px;
  height:86px;
}
#factory-modal .factory-bulb-stock>.factory-art-host--bulb{
  position:relative;
  width:31px;
  height:38px;
  overflow:visible;
}
#factory-modal .factory-bulb-stock>.factory-art-host--bulb>.factory-drawing{
  position:absolute;
  left:50%;
  top:50%;
  width:53px;
  height:73px;
  max-width:none;
  transform:translate(-50%,-50%);
  overflow:visible;
}


/* Recipe equations stay static; only the main artwork in each card animates.
   The artwork supplies its own radial halo: a blur per bulb makes scrolling
   expensive even when its animation is paused. */
#factory-modal .factory-formula .factory-drawing-lamp{
  animation:none!important;
  opacity:1;
  filter:none;
}


/* Top simple-garland recipe follows the same visual rhythm as the thread cards. */
#factory-modal .factory-simple-garland-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:0;
  min-height:220px;
  height:auto;
}
#factory-modal .factory-simple-garland-card>.factory-section-label{
  align-self:flex-start;
  width:100%;
  margin:0 0 2px;
}
#factory-modal .factory-simple-recipe-main{
  display:contents;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual{
  flex:0 0 62px;
  height:62px;
  margin:0;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual>.factory-art-host--garland{
  width:170px;
  height:72px;
}
#factory-modal .factory-simple-garland-card h4{
  margin:2px 0 6px;
}
#factory-modal .factory-simple-garland-card>.factory-formula{
  flex:0 0 auto;
  width:100%;
  min-height:48px;
  margin:0;
  padding:5px 9px;
}
#factory-modal .factory-simple-garland-card>.factory-formula .factory-component{
  min-width:72px;
}
#factory-modal .factory-simple-recipe-footer{
  display:grid;
  grid-template-columns:auto minmax(150px,220px);
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
  margin-top:auto;
}
#factory-modal .factory-simple-recipe-footer .factory-owned-note{
  margin:0;
}
#factory-modal .factory-simple-recipe-footer .factory-primary{
  width:100%;
  margin:0;
}

/* Ingredient rows no longer repeat the finished decoration on the right. */
#factory-modal .factory-formula{
  justify-content:center;
}


/* Match the top simple-garland card to the regular thread-card composition. */
#factory-modal .factory-simple-garland-card{
  justify-content:flex-start;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual{
  flex:0 0 100px;
  height:100px;
  width:100%;
  margin:0 0 4px;
}
#factory-modal .factory-simple-recipe-main .factory-result-visual>.factory-art-host--garland{
  width:min(310px,95%);
  height:100px;
}
#factory-modal .factory-simple-garland-card h4{
  margin:5px 0 8px;
}
#factory-modal .factory-simple-garland-card>.factory-formula{
  width:auto;
  min-width:126px;
  min-height:54px;
  padding:7px 12px;
  margin:0 auto;
}
#factory-modal .factory-simple-garland-card>.factory-formula .factory-component{
  min-width:72px;
}
#factory-modal .factory-simple-recipe-footer{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:7px;
  width:100%;
  margin-top:auto;
}
#factory-modal .factory-simple-recipe-footer .factory-owned-note{
  margin:0;
  text-align:center;
}
#factory-modal .factory-simple-recipe-footer .factory-primary{
  width:min(220px,100%);
  margin:0 auto;
}


/* Top simple-garland card: stock in header, recipe equation in the main preview. */
#factory-modal .factory-simple-garland-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  min-height:220px;
  padding:16px 18px;
}
#factory-modal .factory-simple-card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  width:calc(100% + 16px);
  margin:0 -8px;
}
#factory-modal .factory-simple-card-head>.factory-section-label{
  flex:0 0 auto;
  margin:0;
  padding-top:2px;
  text-align:left;
}
#factory-modal .factory-simple-card-head>.factory-owned-note{
  flex:0 0 auto;
  margin:2px 0 0 auto;
  text-align:right;
}
#factory-modal .factory-simple-equation{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  width:100%;
  min-height:100px;
  margin:auto 0 0;
}
#factory-modal .factory-simple-equation-bulb{
  flex:0 0 53px;
  width:53px;
  height:73px;
}
#factory-modal .factory-simple-equation-bulb>.factory-drawing{
  display:block;
  width:53px;
  height:73px;
  overflow:visible;
}
#factory-modal .factory-simple-equation-bulb .factory-drawing-lamp{
  animation:none!important;
  opacity:1!important;
  filter:none!important;
}
#factory-modal .factory-simple-equation-times,
#factory-modal .factory-simple-equation-equals{
  flex:0 0 auto;
  color:#f7fbff;
  font-size:24px;
  font-weight:800;
  line-height:1;
  text-shadow:0 1px 5px #173a7466;
}
#factory-modal .factory-simple-equation-garland{
  flex:0 1 210px;
  width:210px;
  height:90px;
}
#factory-modal .factory-simple-equation-garland>.factory-drawing{
  display:block;
  width:100%;
  height:100%;
  overflow:visible;
}
#factory-modal .factory-simple-garland-card>h4{
  margin:-5px 0 0;
}
#factory-modal .factory-simple-recipe-footer{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  margin-top:auto;
}
#factory-modal .factory-simple-recipe-footer .factory-primary{
  width:min(220px,100%);
  min-height:40px;
  margin:0 auto;
}
#factory-modal .factory-simple-card-message-spacer{
  flex:0 0 14px;
  width:100%;
  min-height:14px;
}


/* Equalize the visible spacing in the simple-garland equation.
   The SVGs have transparent padding inside their viewBoxes. */
#factory-modal .factory-simple-equation-bulb{
  margin-right:-9px;
}
#factory-modal .factory-simple-equation-garland{
  margin-left:-28px;
}


/* Nudge the multiplier closer to the bulb in the simple-garland equation. */
#factory-modal .factory-simple-equation-times{
  margin-left:-8px;
}


/* Threads: four equal cards in one desktop row with compact single-line recipes. */
#factory-modal .factory-workshop-grid--threads{
  grid-template-columns:repeat(4,minmax(0,1fr));
}
#factory-modal .factory-workshop-grid--threads .factory-craft-card{
  padding:12px 10px;
}
#factory-modal .factory-workshop-grid--threads .factory-formula{
  flex-wrap:nowrap;
  gap:4px;
  min-height:50px;
  padding:6px 5px;
  white-space:nowrap;
}
#factory-modal .factory-workshop-grid--threads .factory-formula--triple{
  gap:2px;
}
#factory-modal .factory-workshop-grid--threads .factory-formula--triple .factory-component{
  min-width:42px;
}
#factory-modal .factory-workshop-grid--threads .factory-formula .factory-art-host--garland.mini{
  width:58px;
  height:39px;
}
#factory-modal .factory-workshop-grid--threads .factory-formula--triple .factory-art-host--garland.mini{
  width:50px;
  height:36px;
}
#factory-modal .factory-workshop-grid--threads .factory-craft-card>.factory-primary{
  margin-top:auto;
}
@media(max-width:900px){
  #factory-modal .factory-workshop-grid--threads{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}
@media(max-width:560px){
  #factory-modal .factory-workshop-grid--threads{
    grid-template-columns:1fr;
  }
}


/* Thread ingredient previews: no ingredient badges; monochrome recipes stay horizontal. */
#factory-modal .factory-workshop-grid--threads
  :is(
    [data-factory-item="garland_simple_red"],
    [data-factory-item="garland_simple_green"],
    [data-factory-item="garland_simple_blue"]
  )
  .factory-formula .factory-component{
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-width:0;
  white-space:nowrap;
}
#factory-modal .factory-workshop-grid--threads
  :is(
    [data-factory-item="garland_simple_red"],
    [data-factory-item="garland_simple_green"],
    [data-factory-item="garland_simple_blue"]
  )
  .factory-formula .factory-component b{
  flex:0 0 auto;
  margin:0;
}
#factory-modal .factory-workshop-grid--threads .factory-owned-note{
  margin:7px 0 9px;
  text-align:center;
}


/* Threads heading uses the compact section-label style only. */
#factory-modal .factory-workshop-grid--threads{
  margin-top:0;
}

/* Monochrome thread recipe: image × 2 with visually even spacing. */
#factory-modal .factory-workshop-grid--threads
  :is(
    [data-factory-item="garland_simple_red"],
    [data-factory-item="garland_simple_green"],
    [data-factory-item="garland_simple_blue"]
  )
  .factory-thread-recipe{
  display:grid;
  grid-template-columns:58px auto auto;
  align-items:center;
  justify-content:center;
  column-gap:10px;
}
#factory-modal .factory-workshop-grid--threads
  :is(
    [data-factory-item="garland_simple_red"],
    [data-factory-item="garland_simple_green"],
    [data-factory-item="garland_simple_blue"]
  )
  .factory-thread-recipe>.factory-art-host--garland{
  margin-right:-10px;
}
#factory-modal .factory-thread-times,
#factory-modal .factory-thread-count{
  margin:0;
  line-height:1;
}


/* Fringe cards use the same compact horizontal recipe style as thread cards. */
#factory-modal .factory-workshop-grid--fringe .factory-formula{
  flex-wrap:nowrap;
  min-height:50px;
  padding:6px 8px;
  white-space:nowrap;
}
#factory-modal .factory-workshop-grid--fringe .factory-fringe-recipe{
  display:grid;
  grid-template-columns:58px auto auto;
  align-items:center;
  justify-content:center;
  column-gap:10px;
  min-width:0;
}
#factory-modal .factory-workshop-grid--fringe
  .factory-fringe-recipe>.factory-art-host--garland{
  width:58px;
  height:39px;
  margin-right:-10px;
}
#factory-modal .factory-fringe-times,
#factory-modal .factory-fringe-count{
  margin:0;
  line-height:1;
}
#factory-modal .factory-workshop-grid--fringe .factory-owned-note{
  text-align:center;
}

/* Keep the full fringe visible inside its card. */
#factory-modal .factory-workshop-grid--fringe .factory-result-visual{
  height:92px;
}
#factory-modal .factory-workshop-grid--fringe
  .factory-result-visual>.factory-art-host--fringe{
  width:min(230px,86%);
  height:86px;
}


/* Pull fringe previews closer to the top of their cards. */
#factory-modal .factory-workshop-grid--fringe .factory-result-visual{
  transform:translateY(-10px);
  margin-bottom:-6px;
}


/* Fringe stock label sits in the top-right corner like the simple-garland card. */
#factory-modal .factory-workshop-grid--fringe .factory-owned-note{
  position:absolute;
  top:12px;
  right:14px;
  z-index:2;
  margin:0;
  text-align:right;
}

/* Smaller fringe preview with clear space before the card title. */
#factory-modal .factory-workshop-grid--fringe .factory-result-visual{
  height:80px;
  transform:translateY(-4px);
  margin-bottom:2px;
}
#factory-modal .factory-workshop-grid--fringe
  .factory-result-visual>.factory-art-host--fringe{
  width:min(190px,74%);
  height:72px;
}


/* Fringe title spacing and aligned formula/action row. */
#factory-modal .factory-workshop-grid--fringe .factory-craft-card>h4{
  margin-top:14px;
  margin-bottom:10px;
}
#factory-modal .factory-fringe-action-row{
  display:grid;
  grid-template-columns:190px 180px;
  align-items:center;
  justify-content:center;
  gap:18px;
  width:auto;
  max-width:100%;
  margin:14px auto 0;
}
#factory-modal .factory-fringe-action-row .factory-formula{
  width:190px;
  min-height:50px;
  margin:0;
}
#factory-modal .factory-fringe-action-row .factory-primary{
  grid-area:auto;
  width:180px;
  min-height:50px;
  margin:0;
}
@media(max-width:700px){
  #factory-modal .factory-fringe-action-row{
    grid-template-columns:1fr;
  }
}


/* Rosa recipe count: keep × visually centered between fringe and 15. */
#factory-modal .factory-workshop-section--final .factory-final-times,
#factory-modal .factory-workshop-section--final .factory-final-count{
  margin:0;
  line-height:1;
}
#factory-modal .factory-workshop-section--final .factory-final-times{
  margin-left:14px;
  margin-right:14px;
}


/* Keep a deliberate gap between Rosa recipe formula and its action button. */
#factory-modal .factory-workshop-section--final .factory-final-craft>.factory-primary{
  margin-top:14px;
}


/* Rosa cards use the real final-tree garland renderer, matching the local factory preview. */
#factory-modal .factory-final-tree-preview[data-live-garland]{
  box-sizing:border-box;
  display:grid;
  place-items:center;
  height:190px;
  min-height:190px;
  padding:0;
  overflow:hidden;
  border:1px solid #bcd8ff45;
  border-radius:15px;
  background:
    radial-gradient(120% 145% at 5% 50%,rgba(92,117,181,.42) 0%,rgba(80,103,162,.18) 32%,rgba(67,86,126,0) 62%),
    radial-gradient(105% 115% at 78% 108%,rgba(78,103,164,.30) 0%,rgba(73,94,143,.12) 34%,rgba(62,80,112,0) 67%),
    linear-gradient(118deg,#4e5c8c 0%,#495e94 18%,#415372 51%,#43557c 73%,#495c8f 100%);
  box-shadow:
    inset 0 0 18px rgba(28,39,64,.16),
    inset 0 1px 0 rgba(231,245,255,.10);
}
#factory-modal .factory-final-tree-preview[data-live-garland] .factory-preview-tree{
  position:relative;
  width:570px;
  height:792px;
  flex:none;
  transform:translate(-90px,-230px);
  transform-origin:50% 50%;
}
#factory-modal .factory-final-tree-preview[data-live-garland]
  .factory-preview-tree>.stage-five-tree{
  display:block;
  visibility:visible;
  position:absolute;
  left:0;
  bottom:0;
  width:100%;
  height:auto;
  transform:none;
  object-fit:contain;
  z-index:0;
}
#factory-modal .factory-final-tree-preview[data-live-garland]
  .factory-preview-tree>.tree-special-decor{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
}


/* Stars follow the same compact recipe treatment as Rosa. */
#factory-modal .factory-star-craft .factory-topper-times,
#factory-modal .factory-star-craft .factory-topper-count{
  margin:0;
  line-height:1;
}
#factory-modal .factory-star-craft .factory-topper-times{
  margin-left:14px;
  margin-right:14px;
}
#factory-modal .factory-star-craft>.factory-primary{
  margin-top:14px;
}

/* Use the real animated tree-topper renderer, matching the local factory preview. */
#factory-modal .factory-star-craft .factory-real-star{
  position:relative;
  display:grid;
  place-items:center;
  width:100%;
  height:190px;
  min-height:190px;
  overflow:visible;
}
#factory-modal .factory-star-craft .factory-preview-star{
  position:relative;
  width:190px;
  height:190px;
  flex:none;
  --topper-x:50%;
  --topper-y:88%;
  --topper-width:88%;
}
#factory-modal .factory-star-craft .factory-preview-star>.stage-five-tree{
  display:none;
}
#factory-modal .factory-star-craft .factory-preview-star>.tree-special-decor{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
}


/* Unified stock: every decoration lives in the same card grid. */
#factory-modal .factory-stock-grid--all{
  grid-template-columns:repeat(4,minmax(0,1fr));
  align-items:stretch;
}
#factory-modal .factory-stock-grid--all .factory-stock-card{
  min-height:204px;
}
#factory-modal .factory-stock-card--live{
  opacity:1;
}
#factory-modal .factory-stock-card--live.is-missing{
  opacity:.48;
  filter:saturate(.4);
}
#factory-modal .factory-stock-card--live.is-active{
  border-color:#dcecff9c;
  box-shadow:inset 0 0 14px #eaf5ff2d,0 0 13px #93b9ff38;
}
#factory-modal .factory-stock-visual--live{
  position:relative;
  width:100%;
  height:82px;
  overflow:hidden;
  border-radius:12px;
  background:#18345f24;
}
#factory-modal .factory-stock-live-preview{
  position:relative;
  display:grid;
  place-items:center;
  width:100%;
  height:82px;
  overflow:hidden;
}
#factory-modal .factory-stock-live-preview[data-live-garland] .factory-preview-tree{
  position:relative;
  width:235px;
  height:327px;
  flex:none;
  transform:translate(-38px,-96px);
  transform-origin:50% 50%;
}
#factory-modal .factory-stock-live-preview[data-live-garland]
  .factory-preview-tree>.stage-five-tree{
  display:block;
  visibility:visible;
  position:absolute;
  left:0;
  bottom:0;
  width:100%;
  height:auto;
  transform:none;
  object-fit:contain;
  z-index:0;
}
#factory-modal .factory-stock-live-preview[data-live-garland]
  .factory-preview-tree>.tree-special-decor{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
}
#factory-modal .factory-stock-live-star{
  overflow:visible;
  background:none;
}
#factory-modal .factory-stock-live-star .factory-preview-star{
  position:relative;
  width:70px;
  height:70px;
  flex:none;
  --topper-x:50%;
  --topper-y:88%;
  --topper-width:88%;
}
#factory-modal .factory-stock-live-star .factory-preview-star>.stage-five-tree{
  display:none;
}
#factory-modal .factory-stock-live-star .factory-preview-star>.tree-special-decor{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
}
#factory-modal .factory-stock-state{
  position:absolute;
  right:10px;
  top:10px;
  max-width:calc(100% - 20px);
  padding:4px 8px;
  border:1px solid #e1edff6b;
  border-radius:999px;
  background:#1c4077a8;
  color:#fff;
  font-size:10px;
  font-weight:750;
  line-height:1.15;
  text-align:center;
}
#factory-modal .factory-stock-card--live>.factory-stock-actions{
  width:100%;
  margin-top:auto;
}
#factory-modal .factory-stock-card--live>.factory-stock-actions--single{
  grid-template-columns:1fr;
}
#factory-modal .factory-stock-card--live>.factory-stock-actions .factory-primary,
#factory-modal .factory-stock-card--live>.factory-stock-actions .factory-secondary{
  min-width:0;
  width:100%;
}
@media(max-width:900px){
  #factory-modal .factory-stock-grid--all{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
}
@media(max-width:650px){
  #factory-modal .factory-stock-grid--all{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}
@media(max-width:460px){
  #factory-modal .factory-stock-grid--all{
    grid-template-columns:1fr;
  }
}


/* The production/first-recipe row belongs only to the Workshop tab. */
#factory-modal .factory-start-grid[hidden]{
  display:none;
}

/* Tabs now sit above the workshop-only production row. */
#factory-modal .factory-tabs{
  margin:0 auto 12px;
}


/* Keep the two familiar start cards, without empty message rows or tall gaps. */
#factory-modal .factory-start-card,
#factory-modal .factory-production-bar,
#factory-modal .factory-simple-garland-card{
  min-height:0;
  padding:12px 18px;
  gap:6px;
}
#factory-modal .factory-production-progress-row{
  min-height:0;
  margin:0;
}
#factory-modal .factory-progress-lamps{
  min-height:0;
}
#factory-modal .factory-progress-lamp,
#factory-modal .factory-progress-lamp .factory-art-host--progress-bulb{
  width:54px;
  height:70px;
}
#factory-modal .factory-production-status{
  margin-top:0;
}
#factory-modal #factory-production-message:empty,
#factory-modal .factory-simple-card-message-spacer{
  display:none;
}
#factory-modal .factory-simple-equation{
  min-height:80px;
  margin:auto 0 0;
}
#factory-modal .factory-simple-garland-card>h4{
  margin:0;
}
#factory-modal .factory-simple-recipe-footer{
  margin-top:0;
}

/* A single observer pauses previews outside the clipped scroll area. */
#factory-modal .factory-motion-paused,
#factory-modal .factory-motion-paused *,
#factory-modal .factory-motion-paused *::before,
#factory-modal .factory-motion-paused *::after{
  animation-play-state:paused!important;
}
/* The scenery behind frosted glass need not repaint while the factory is open. */
body:has(#factory-modal:not([hidden])) :is(#tree,.factory-building),
body:has(#factory-modal:not([hidden])) :is(#tree,.factory-building) *,
body:has(#factory-modal:not([hidden])) :is(#tree,.factory-building) *::before,
body:has(#factory-modal:not([hidden])) :is(#tree,.factory-building) *::after{
  animation-play-state:paused!important;
}
@media(min-width:651px) and (max-width:900px){
  #factory-modal .factory-start-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #factory-modal .factory-start-card{
    padding-inline:12px;
  }
  #factory-modal .factory-production-head,
  #factory-modal .factory-simple-card-head{
    width:100%;
    margin:0;
    gap:8px;
  }
  #factory-modal .factory-bulb-stock{
    min-width:98px;
    padding:8px;
    column-gap:5px;
  }
  #factory-modal .factory-simple-equation{
    gap:10px;
  }
  #factory-modal .factory-simple-equation-times,
  #factory-modal .factory-simple-equation-equals{
    font-size:20px;
  }
}
@media(max-width:650px){
  /* Both start cards and recipes remain reachable on a short phone screen. */
  #factory-modal .factory-card{
    overflow-y:auto;
    scrollbar-width:thin;
    scrollbar-color:#b9d2ff7a transparent;
  }
  #factory-modal .factory-tab-body{
    flex:0 0 auto;
  }
  #factory-modal .factory-tab-panel,
  #factory-modal .factory-scroll{
    height:auto;
  }
  #factory-modal .factory-scroll{
    overflow:visible;
    padding-right:2px;
  }
}


/* Factory tutorial and action feedback. */
#factory-modal .factory-production-button.is-tutorial-pulse{
  animation:factoryTutorialCtaPulse 1.05s ease-in-out infinite;
}
#factory-modal #factory-bulb-count{
  transform-origin:left center;
}
#factory-modal #factory-bulb-count.is-count-updated{
  animation:factoryBulbCountUpdated .82s cubic-bezier(.2,.78,.24,1);
}
#factory-modal :is(.factory-craft-card,.factory-final-craft,.factory-star-craft,.factory-stock-card).factory-craft-success{
  overflow:hidden;
}
#factory-modal .factory-craft-success>:not(.factory-craft-success-label){
  filter:blur(4px);
  opacity:.3;
  pointer-events:none;
  transition:filter .42s ease,opacity .42s ease;
}
#factory-modal .factory-craft-success-label{
  position:absolute;
  inset:0;
  z-index:20;
  display:grid;
  place-items:center;
  border:1px solid #dceeffa6;
  border-radius:inherit;
  background:#304a8c70;
  color:#f7fbff;
  font:800 19px/1 system-ui,sans-serif;
  text-shadow:0 0 10px #dceeff99;
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  animation:factoryCraftFeedbackIn .18s ease-out;
  transition:opacity .42s ease;
}
#factory-modal .factory-craft-success.is-fading>:not(.factory-craft-success-label){
  filter:blur(0);
  opacity:1;
}
#factory-modal .factory-craft-success.is-fading .factory-craft-success-label{
  animation:none;
  opacity:0;
}
@keyframes factoryCraftFeedbackIn{
  from{
    opacity:0;
  }
  to{
    opacity:1;
  }
}
@keyframes factoryTutorialCtaPulse{
  0%,100%{
    filter:brightness(1);
    box-shadow:var(--elka-control-glow);
    transform:scale(1);
  }
  50%{
    filter:brightness(1.16);
    box-shadow:var(--elka-control-hover),0 0 18px #bfffd08c;
    transform:scale(1.025);
  }
}
@keyframes factoryBulbCountUpdated{
  0%,100%{
    color:#fff;
    transform:scale(1);
    text-shadow:none;
  }
  36%{
    color:#aef7bd;
    transform:scale(1.2);
    text-shadow:0 0 11px #7fffa47d;
  }
  68%{
    color:#caffd5;
    transform:scale(1.08);
    text-shadow:0 0 6px #7fffa455;
  }
}
@media(prefers-reduced-motion:reduce){
  #factory-modal .factory-production-button.is-tutorial-pulse,
  #factory-modal #factory-bulb-count.is-count-updated,
  #factory-modal .factory-craft-success-label{
    animation:none!important;
  }
  #factory-modal .factory-craft-success>:not(.factory-craft-success-label),
  #factory-modal .factory-craft-success-label{
    transition:none!important;
  }
}


/* Disabled factory create buttons explain the missing resource on hover. */
#factory-modal .factory-create-action-wrap{
  position:relative;
  display:block;
  width:100%;
  min-width:0;
}
#factory-modal .factory-create-action-wrap>.factory-primary{
  width:100%;
}
#factory-modal .factory-workshop-grid--threads
  .factory-craft-card>.factory-create-action-wrap{
  margin-top:auto;
}
#factory-modal .factory-workshop-section--final
  .factory-final-craft>.factory-create-action-wrap,
#factory-modal .factory-star-craft>.factory-create-action-wrap{
  margin-top:14px;
}
#factory-modal .factory-create-action-wrap[data-tooltip]::after{
  content:attr(data-tooltip);
  position:absolute;
  left:50%;
  bottom:calc(100% + 7px);
  z-index:40;
  transform:translate(-50%,4px);
  width:142px;
  box-sizing:border-box;
  white-space:normal;
  padding:6px 8px;
  border-radius:8px;
  background:#183354;
  color:#fff;
  font:600 10px/1.25 system-ui,sans-serif;
  text-align:center;
  box-shadow:0 5px 14px #10253f42;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:
    opacity .15s ease,
    transform .15s ease,
    visibility .15s;
}
#factory-modal .factory-create-action-wrap[data-tooltip]::before{
  content:"";
  position:absolute;
  left:50%;
  bottom:calc(100% + 3px);
  z-index:41;
  width:7px;
  height:7px;
  background:#183354;
  transform:translateX(-50%) rotate(45deg);
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .15s ease,visibility .15s;
}
#factory-modal .factory-create-action-wrap[data-tooltip]:hover::after,
#factory-modal .factory-create-action-wrap[data-tooltip]:hover::before,
#factory-modal .factory-create-action-wrap[data-tooltip]:focus-visible::after,
#factory-modal .factory-create-action-wrap[data-tooltip]:focus-visible::before{
  opacity:1;
  visibility:visible;
}
#factory-modal .factory-create-action-wrap[data-tooltip]:hover::after,
#factory-modal .factory-create-action-wrap[data-tooltip]:focus-visible::after{
  transform:translate(-50%,0);
}
#factory-modal .factory-create-action-wrap:focus-visible{
  outline:none;
}
@media(prefers-reduced-motion:reduce){
  #factory-modal .factory-create-action-wrap[data-tooltip]::after,
  #factory-modal .factory-create-action-wrap[data-tooltip]::before{
    transition:none;
  }
}
