.factory-cover-image { display: block; width: 100%; height: auto; }
.catalog-view .card-art.factory-art { background: #dff5f6; display: grid; align-items: center; }
body.minions-game { background: #eaf7fa; color: #314960; }
.minions-game h1, .minions-game h2, .minions-game h3 { font-family: Library, 'Trebuchet MS', sans-serif; }
body.minions-game > .site-header, body.minions-game > footer { display: none; }
body.minions-game #app { max-width: 1100px; width: calc(100% - 32px); margin-inline: auto; min-height: 100dvh; padding-bottom: 16px; }
.factory-toolbar { display: grid; grid-template-columns: 145px minmax(0,1fr) auto 48px; gap: 12px; align-items: center; padding: 10px 0; }
.factory-toolbar h1 { margin: 0 0 4px; font-size: 21px; color: #63518e; }
.factory-toolbar span { font-size: 14px; }
.factory-toolbar a, .factory-toolbar button { font-size: 14px; }
.minions-game button, .minions-game .button { min-height: 48px; }
.minions-game .secondary { background: #fffefa; color: #495d75; }
.minions-game .factory-primary { background: #7460aa; color: white; border: 2px solid #5e4c90; padding: 10px 16px; box-shadow: 0 3px 0 #524078; }
.minions-game .factory-primary:hover { background: #624d99; }
.minions-game button:focus-visible, .minions-game a:focus-visible, .minions-game summary:focus-visible { outline: 3px solid #db921d; outline-offset: 4px; }
.factory-cover, .factory-finish { text-align: center; }
.factory-cover h2, .factory-finish h2 { margin: 20px 0 16px; font-size: 38px; color: #685292; }
.factory-cover > p, .factory-finish > p { max-width: 770px; margin: 16px auto; }
.factory-cover > img { max-width: 900px; margin: 22px auto 0; }
.factory-stages { list-style: none; display: flex; gap: 12px; padding: 0; margin: 0 0 12px; }
.factory-stages li { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; font-size: 14px; border-bottom: 3px solid #cfdaeb; padding: 5px 8px; }
.factory-stages li.active { border-color: #9b81c8; color: #66518e; }
.factory-stages li > span { display: grid; place-items: center; border-radius: 50%; background: #e0d9ee; width: 28px; height: 28px; flex-shrink: 0; }
.factory-layout { display: grid; grid-template-columns: minmax(0,1fr) 230px; gap: 16px; align-items: start; }
.factory-machine { background: #fffefa; border: 2px solid #bdcedc; border-top: 8px solid #b39ad2; border-radius: 8px; padding: 12px 16px; min-height: min(560px,calc(100dvh - 150px)); display: grid; grid-template-rows: auto auto auto auto 104px auto; gap: 8px; }
.factory-machine > h2 { font-size: 22px; text-align: center; margin: 0; line-height: 1.25; }
.factory-expression { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 36px; line-height: 1.2; font-weight: 800; margin: 4px 0; }
.factory-slot { border: 3px dashed #a38ac6; background: #f1edf8; font-size: 32px; min-width: 76px; padding: 4px 8px; color: #64508b; }
.factory-slot:disabled { opacity: 1; }
.factory-model { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); gap: 8px 12px; align-items: stretch; }
.factory-chamber { border: 2px solid #99c5d0; border-radius: 8px; background: #edfafa; padding: 7px 10px; min-width: 0; }
.factory-chamber > strong { display: block; font-size: 14px; color: #347885; margin-bottom: 6px; }
.factory-chamber:nth-child(2) { border-color: #e7cd71; background: #fff9df; }
.factory-chamber:nth-child(2) > strong { color: #8c6e25; }
.factory-material { display: flex; flex-wrap: wrap; gap: 5px; align-items: end; align-content: end; min-height: 109px; }
.unit-material { align-content: end; max-width: 125px; }
.factory-tower { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.factory-cube { display: block; width: 10px; height: 10px; border-radius: 1px; border: 1px solid #278b9b; background: #63cfcc; box-shadow: inset -2px -2px 0 #359fad55; flex-shrink: 0; }
.unit-cube { background: #f8d750; border-color: #bf972e; box-shadow: inset -2px -2px 0 #b98e2c44; }
.factory-empty { align-self: center; font-size: 14px; padding: 8px; border: 1px dashed #c8b674; }
.factory-flow { grid-column: 1 / -1; text-align: center; font-size: 20px; color: #9981be; min-height: 29px; }
.factory-output { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 29px; color: #377b6b; font-size: 15px; }
.factory-output > strong { font-size: 24px; line-height: 1.2; }
.factory-output > span { font-size: 13px; }
.factory-chamber.removed { background: #f0ebf7; border-style: dashed; border-color: #ae99ca; }
.transformed .factory-material { animation: factory-transport 1.5s ease-in-out; }
.factory-chamber.removed .factory-material { animation-name: factory-separate; }
.factory-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; align-self: center; }
.factory-answer { min-height: 56px !important; background: #fff5c5; border: 2px solid #d9bf69; color: #5e562d; font-size: 26px; font-weight: 800; padding: 5px; touch-action: none; user-select: none; }
.factory-answer[aria-pressed='true'] { border-color: #7761aa; background: #e9e1f5; color: #5f488c; box-shadow: 0 0 0 2px #c4b0dd; }
.factory-answer:disabled { opacity: 1; }
.factory-dragging { position: relative; z-index: 5; pointer-events: none; opacity: .85; }
.factory-feedback { display: flex; align-items: center; padding: 10px 12px; border-block: 1px solid #d8e4eb; background: #f2f7fa; font-size: 16px; line-height: 1.4; }
.factory-feedback.error { color: #9d4b3a; }
.factory-feedback.success { color: #2e7664; background: #edf7e8; }
.factory-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.factory-actions button { font-size: 15px; padding: 8px 12px; }
.factory-actions .factory-primary { margin-left: auto; }
.factory-progress { padding-top: 12px; }
.factory-progress h2 { font-size: 19px; margin: 0 0 12px; }
.factory-progress > p { font-size: 14px; margin: 8px 0; }
.factory-lights { display: grid; grid-template-columns: repeat(6,18px); gap: 10px; justify-content: center; margin: 14px auto; }
.factory-light { width: 18px; height: 18px; border-radius: 50%; background: #c9d5de; border: 2px solid #9aabba; }
.factory-light.on { background: #ffe16e; border-color: #d9af33; box-shadow: 0 0 8px #ffd75a99; }
.factory-scene { display: block; width: 100%; height: auto; }
.factory-guide { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.factory-guide .factory-minion { width: 90px; height: 120px; flex-shrink: 0; }
.factory-guide p { font-size: 14px; margin: 0; }
.factory-walkthrough { background: #fff4c9; padding: 10px 12px; border-radius: 6px; min-height: 72px; font-size: 16px; }
.factory-walkthrough p { margin: 5px 0 0; }
.factory-learn { max-width: 800px; margin: 12px auto; padding: 24px; background: #fffefa; border: 1px solid #c8d9e1; border-radius: 8px; text-align: center; }
.factory-learn h2 { font-size: 27px; }
.factory-learn p { margin: 18px auto; }
.factory-learn .factory-model { max-width: 600px; margin: 20px auto; text-align: left; }
.factory-learn .factory-options { max-width: 600px; margin: 16px auto; }
.factory-example-message { min-height: 58px; font-size: 17px; }
.factory-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin: 24px 0; }
.factory-stats > div { display: grid; gap: 4px; background: #fffefa; border: 1px solid #c6d9e1; border-radius: 8px; padding: 16px; }
.factory-stats strong { font-size: 36px; color: #7460aa; }
.factory-stats span { font-size: 15px; }
.factory-finish-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.factory-finish details { text-align: left; max-width: 650px; margin: 24px auto; border-block: 1px solid #bccfdd; padding: 8px 12px; }
.factory-finish summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
#factory-finale { max-width: 900px; margin: 20px auto; position: relative; }
.factory-celebration-sign { position: absolute; left: 30%; right: 30%; bottom: 4%; font-size: 16px; padding: 6px; background: #fff4b7; border: 2px solid #d6b14a; border-radius: 5px; }
.running .factory-gear, .factory-celebrate .factory-gear { animation: factory-spin 6s linear infinite; }
.running .factory-belt, .factory-celebrate .factory-belt { animation: factory-belt 1.5s linear infinite; }
.factory-celebrate .factory-minion { animation: factory-dance 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
.factory-dialog { background: #fffefa; color: #314960; padding: 24px; border: 1px solid #b2c9d9; border-radius: 8px; width: min(600px,calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
.factory-dialog::backdrop { background: #283c5b77; }
@keyframes factory-spin { to { transform: rotate(360deg); } }
@keyframes factory-belt { to { stroke-dashoffset: -26; } }
@keyframes factory-transport { 0% { transform: translateY(-8px); } 50% { transform: translateY(4px); } }
@keyframes factory-separate { from { transform: translateX(-24px); } to { transform: translateX(0); } }
@keyframes factory-dance { 25% { transform: rotate(-5deg) translateY(-4px); } 75% { transform: rotate(5deg); } }
@media (max-width: 1000px) {
  .factory-layout { grid-template-columns: 1fr; }
  .factory-progress { display: grid; grid-template-columns: 1fr 180px; align-items: center; gap: 6px 16px; }
  .factory-progress > h2, .factory-progress > p { grid-column: 1; margin: 0; }
  .factory-progress .factory-lights { grid-column: 1; justify-content: start; margin: 6px 0; }
  .factory-progress > .factory-scene { grid-column: 2; grid-row: 1 / 4; }
  .factory-guide { display: none; }
}
@media (max-width: 700px) {
  .factory-toolbar { grid-template-columns: minmax(0,1fr) auto 48px; gap: 8px; }
  .factory-toolbar > div { grid-column: 1 / -1; grid-row: 2; }
  .factory-toolbar h1 { font-size: 20px; }
  .factory-stages { gap: 5px; }
  .factory-stages li { font-size: 12px; padding: 4px 0; gap: 4px; }
  .factory-stages li > span { width: 22px; height: 22px; }
  .factory-machine { padding: 10px; min-height: 0; grid-template-rows: auto auto auto auto 144px auto; }
  .factory-machine > h2 { font-size: 21px; }
  .factory-expression { font-size: 30px; gap: 8px; }
  .factory-slot { font-size: 28px; min-width: 62px; }
  .factory-options { gap: 8px; }
  .factory-answer { font-size: 25px; }
  .factory-model { gap: 6px; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
  .factory-chamber { padding: 7px 6px; }
  .factory-chamber > strong { font-size: 13px; }
  .factory-feedback { padding: 8px; }
  .factory-actions .factory-primary { margin-left: 0; flex-grow: 1; }
  .factory-actions button { font-size: 14px; padding: 8px 10px; }
  .factory-progress { grid-template-columns: 1fr 130px; gap: 6px; }
  .factory-progress h2 { font-size: 17px; }
  .factory-progress .factory-lights { gap: 6px; grid-template-columns: repeat(6,16px); }
  .factory-light { width: 16px; height: 16px; }
  .factory-cover h2, .factory-finish h2 { font-size: 30px; }
  .factory-learn { padding: 18px 12px; }
  .factory-output { flex-wrap: wrap; gap: 4px 8px; }
  .factory-celebration-sign { font-size: 12px; left: 22%; right: 22%; padding: 3px; }
}
@media (max-width: 400px) {
  body.minions-game #app { width: calc(100% - 24px); }
  .factory-material { gap: 4px; }
  .factory-stats { grid-template-columns: 1fr; }
  .factory-stats > div { display: flex; align-items: center; gap: 14px; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .minions-game *, .minions-game *::before, .minions-game *::after { animation: none !important; transition: none !important; }
}
