/* PR39 — A crate is a physical object; multiplication is demonstrated as
   successive movements. These rules deliberately do not transform the
   scale, its room row, the hand hit target, or ordinary floor objects. */

/* The information belongs to the GROUP, never stamped on each wooden box. */
.crate-contents-note{
  position:absolute;z-index:9;
  left:50%;bottom:136px;
  max-width:calc(100% - 14px);width:max-content;
  transform:translateX(-50%);
  padding:5px 11px;border:1px solid #c4ae77;border-radius:16px;
  background:rgba(29,42,39,.94);color:#f4e8ca;
  font:700 .70rem/1.3 system-ui,sans-serif;text-align:center;
  box-shadow:0 3px 9px #0008;pointer-events:none;
}
.crate-contents-note[hidden]{display:none!important}

/* The sealed crate's wooden face has no x+3 card or algebra stamp. */
.sealed-crate .crate-name{display:none!important}
.sealed-crate .crate-lid{
  transition:transform .52s cubic-bezier(.18,.68,.3,1.05),filter .32s ease;
  transform-origin:7px 100%;
}
.sealed-crate.crate-opened .crate-lid{
  transform:rotate(-63deg) translate(-1px,-4px);
  filter:brightness(1.30);
}
.sealed-crate.crate-opened{
  box-shadow:0 0 17px #e3c18e72,inset 0 0 0 2px #e1b97650;
}
.sealed-crate.crate-opened .crate-window{background:rgba(186,224,213,.035)}
.sealed-crate .crate-content-extracted{
  opacity:.045!important;
  visibility:hidden!important;
  transition:opacity .16s ease;
}
.sealed-crate.crate-empty{
  filter:saturate(.6);opacity:.36;
  transition:opacity .5s ease,filter .5s ease;
}

/* The art itself is carried in the existing articulated hand, and the
   crowbar moves with the fingers to the actual selected crate lid. */
.giant-hand[data-crowbar="true"] .hand-cargo{
  width:84px;height:113px;
  top:77%;left:44%;
  opacity:1!important;overflow:visible;
  transform:translate(-50%,-10px) rotate(-24deg);
  filter:drop-shadow(2px 5px 4px #010a0bad);
}
.giant-hand[data-crowbar="true"][data-phase="grip"] .hand-cargo,
.giant-hand[data-crowbar="true"][data-phase="reach"] .hand-cargo{
  transform:translate(-53%,-7px) rotate(-38deg);
}
.giant-hand[data-crowbar="true"] .hand-art{
  transform:rotate(-6deg);
}
.held-crowbar{
  display:block;position:absolute;
  width:72px;height:110px;left:6px;top:-7px;
  filter:drop-shadow(2px 3px 2px #10191b8e);
}
.giant-hand[data-crowbar="true"].grasping .held-crowbar{
  animation:crate-pry-lever .62s ease-in-out both;
}
@keyframes crate-pry-lever{
  0%{transform:rotate(-15deg) translateY(7px)}
  60%{transform:rotate(12deg) translateY(-4px)}
  100%{transform:rotate(18deg)}
}

/* The distribution shelf is a temporary illustration INSIDE the same room.
   Its full-size sprites and weights never enter #left-items/#right-items
   before the engine commits the complete identity rewrite. */
.crate-expansion-stage{
  position:absolute;inset:0;z-index:9;pointer-events:none;
  --crate-count-accent:#f3d298;
}
.crate-expansion-step{
  position:absolute;z-index:10;left:50%;top:49px;
  max-width:calc(100% - 18px);width:max-content;min-width:160px;
  transform:translateX(-50%);
  display:flex;flex-direction:column;gap:2px;align-items:center;
  padding:6px 10px;border:1px solid #c1a775;border-radius:11px;
  background:rgba(17,32,31,.96);color:#f4e8c9;
  font:700 .72rem/1.24 system-ui,sans-serif;text-align:center;
  box-shadow:0 5px 16px #06100ca3;
}
.crate-expansion-message{font-weight:600;font-size:.67rem;color:#e6e6d2}
.crate-expansion-math{
  font:700 1.12rem/1.2 Georgia,serif;
  letter-spacing:.02em;color:#ffe4aa;
}
.crate-expansion-math[hidden]{display:none!important}
.crate-expansion-stage[data-phase="sprite-total"] .crate-expansion-step,
.crate-expansion-stage[data-phase="weight-total"] .crate-expansion-step{
  border-color:#f5d48b;box-shadow:0 0 0 2px #f7da9c44,0 9px 20px #010a0bab;
}
.crate-expansion-collection{
  position:absolute;left:4%;right:4%;bottom:28px;height:99px;
  z-index:8;display:flex;align-items:flex-end;justify-content:center;
  gap:clamp(5px,1vw,12px);pointer-events:none;
}
.crate-expansion-stage[data-phase="opening"] .crate-expansion-collection{
  opacity:0;visibility:hidden;
}
.crate-release-group{
  display:flex;flex:1 1 0;max-width:140px;min-width:0;
  flex-direction:column;align-items:center;justify-content:flex-end;
  height:98px;padding:3px 4px 5px;
  border:1px solid rgba(211,197,157,.69);border-radius:8px 8px 5px 5px;
  background:linear-gradient(180deg,rgba(36,64,55,.93),rgba(25,44,38,.96));
  box-shadow:inset 0 1px #d5e5cb31,0 5px 8px #010a0870;
  opacity:.95;
}
.crate-release-group.active{
  border-color:#f3d28d;
  box-shadow:inset 0 1px #e9f1d94f,0 0 10px #edc98052,0 5px 8px #010a0870;
}
.crate-release-source{
  order:3;text-align:center;
  font:800 .58rem/1.1 system-ui,sans-serif;letter-spacing:.07em;
  color:#dccd9c;white-space:nowrap;
}
.crate-release-sprites{
  order:1;display:flex;align-items:flex-end;justify-content:center;
  gap:0;min-height:40px;max-width:100%;
}
.crate-release-weights{
  order:2;display:flex;align-items:flex-end;justify-content:center;
  gap:0;min-height:31px;max-width:100%;
}
.crate-release-actor{
  display:inline-flex;position:relative;flex:none;
  align-items:flex-end;justify-content:center;
  opacity:0;visibility:hidden;
}
.crate-release-actor.released{
  opacity:1;visibility:visible;
}
.crate-release-sprite{width:37px;height:39px}
.crate-release-sprite .token.sprite{
  position:relative;flex:none;
  width:46px;height:47px;
  transform:scale(.76);transform-origin:5px 100%;
}
.crate-release-weight{width:26px;height:29px}
.crate-release-weight .token.weight{
  position:relative;flex:none;
  width:29px;height:30px;
}
.crate-release-weight .weight-handle{top:0;left:37%;width:27%;height:9px}
.crate-release-weight .weight-shine{left:8px;top:10px;height:15px}
.crate-expansion-stage[data-phase="sprite-total"] .crate-release-sprites,
.crate-expansion-stage[data-phase="weight-total"] .crate-release-weights{
  filter:drop-shadow(0 0 6px #ffdc92aa);
}
.crate-expansion-stage[data-phase="settle"] .crate-release-group{
  opacity:.72;transition:opacity .45s ease;
}
#crate-controls #unpack-crates{
  border-color:#dfc48d;
  background:linear-gradient(130deg,#506b5c,#364c43);
  color:#ffe6b4;
}
#crate-controls #unpack-crates span{font-size:1.17em}

/* Stay inside the original art and control limits at laptop and mobile sizes.
   The count is always correct; the actor groups scale, never wrap. */
@media (min-width:900px) and (max-height:649px){
  .crate-contents-note{
    bottom:113px;min-width:0;padding:2px 6px;
    border-radius:8px;font-size:.56rem;
  }
  .crate-expansion-step{
    top:32px;padding:4px 7px;font-size:.62rem;
    max-width:calc(100% - 8px);
  }
  .crate-expansion-message{font-size:.58rem}
  .crate-expansion-math{font-size:.91rem}
  .crate-expansion-collection{height:77px;bottom:20px;gap:4px}
  .crate-release-group{height:76px;padding:1px 2px 2px}
  .crate-release-sprites{min-height:30px;transform:scale(.76);transform-origin:50% 100%}
  .crate-release-weights{min-height:25px;transform:scale(.76);transform-origin:50% 100%}
  .crate-release-source{font-size:.51rem}
}
@media(max-width:899px){
  .crate-contents-note{
    bottom:clamp(123px,26vw,136px);
    padding:4px 6px;font-size:.63rem;
  }
  .crate-expansion-step{
    top:31px;max-width:calc(100% - 9px);
    padding:4px 5px;min-width:0;
  }
  .crate-expansion-message{font-size:.59rem}
  .crate-expansion-math{font-size:.93rem}
  .crate-expansion-collection{height:77px;bottom:18px;gap:4px;left:2%;right:2%}
  .crate-release-group{height:77px;padding:1px 2px 3px}
  .crate-release-sprites{min-height:30px;transform:scale(.75);transform-origin:50% 100%}
  .crate-release-weights{min-height:26px;transform:scale(.74);transform-origin:50% 100%}
  .crate-release-source{font-size:.52rem}
}
@media(max-width:600px){
  .crate-contents-note{
    bottom:124px;white-space:normal;
    width:calc(100% - 14px);max-width:100%;
    padding:3px 6px;font-size:.57rem;line-height:1.12;
  }
  .crate-expansion-step{top:25px}
  .crate-expansion-message{font-size:.53rem}
  .crate-expansion-math{font-size:.85rem}
  .crate-release-source{font-size:.48rem}
  .giant-hand[data-crowbar="true"] .hand-cargo{
    transform:translate(-50%,0) scale(.78) rotate(-24deg);
  }
}
@media(prefers-reduced-motion:reduce){
  .sealed-crate .crate-lid{transition:none!important}
  .giant-hand[data-crowbar="true"].grasping .held-crowbar{animation:none!important}
  .crate-expansion-stage .crate-release-actor{animation:none!important}
  .crate-expansion-stage .crate-release-group{transition:none!important}
}
.reduce-motion .sealed-crate .crate-lid{transition:none!important}
.reduce-motion .giant-hand[data-crowbar="true"].grasping .held-crowbar{animation:none!important}

/* The comic distinguishes the two multiplication steps instead of displaying
   a single generic "unpacked" after-image. */
.comic-crate-sequence{
  display:flex;flex-direction:column;gap:5px;
  padding:8px 10px;margin:6px 3px;
  border:1px solid #bd9b67;border-radius:9px;
  background:linear-gradient(155deg,#233c37,#142c2e);
  color:#f6e7c6;font-size:.77rem;line-height:1.28;
}
.comic-crate-beat{display:flex;gap:9px;align-items:center}
.comic-crate-beat strong{font-family:Georgia,serif;color:#ffdc9e}
.comic-crate-beat>span:first-child{
  display:inline-flex;flex:0 0 25px;align-items:center;
  justify-content:center;width:25px;height:25px;border-radius:6px;
  background:#3c5a4e;border:1px solid #bfa57b;color:#ffdfa7;
}
.comic-crate-beat .comic-crowbar-mark{font-size:1.35rem;transform:none}
.comic-crate-beat .comic-sprite-mark{color:#e1e5dc;font-size:1rem}
.comic-crate-beat .comic-weight-mark{color:#eecb83;font-size:1.10rem}
@media(max-width:600px){
  .comic-crate-sequence{padding:6px;font-size:.70rem}
}
