/* PR38 — Glass-fronted bracket crates in the existing physical chamber.
   A crate is one whole object and its miniature contents are decorations:
   the engine never counts these miniature actors as loose tokens. */
.items-grid.floor-track>.token.sealed-crate{
  display:inline-flex;position:relative;flex:none;
  justify-content:center;align-items:stretch;vertical-align:bottom;
  width:104px;height:92px;margin:0;transform:none;
  border:4px solid #ad824f;border-bottom:11px solid #8e633b;
  border-radius:13px 13px 8px 8px;
  background:linear-gradient(90deg,#51402e 0%,#a37b4c 8%,#52402f 12%,
    #314c46b9 16%,#233c3eab 82%,#c49a62 88%,#5e4632 94%);
  box-shadow:0 5px 9px #030b0d95,inset 0 0 0 2px #e1b97650,
    inset 0 -10px 13px #0a211b71;
  overflow:visible;isolation:isolate;box-sizing:border-box;
}
.sealed-crate:after{
  content:"";pointer-events:none;position:absolute;inset:10px 8px 22px;
  border:1px solid #d8e6ce55;border-radius:4px;
  background:linear-gradient(125deg,#ffffff27 0 19%,transparent 20% 76%,#ffffff12 77%);
  z-index:4;
}
.sealed-crate .crate-lid{
  position:absolute;left:-5px;right:-5px;top:-12px;height:13px;
  border:2px solid #e2bf86;border-radius:5px 5px 2px 2px;
  background:linear-gradient(#aa7f4c,#5f442d);
  box-shadow:0 2px 5px #06150eb8;z-index:8;
  transform-origin:6px 100%;
}
.sealed-crate .crate-window{
  display:flex;flex-direction:row;gap:3px;align-items:flex-end;
  justify-content:center;width:100%;min-width:0;padding:15px 3px 20px;
  overflow:hidden;
}
.sealed-crate .crate-mini-sprite{
  display:inline-flex;position:relative;flex:none;justify-content:center;
  align-items:center;width:22px;height:28px;
  background:radial-gradient(circle at 30% 20%,#67716d,#25312f 64%);
  border-radius:44% 45% 40% 40%;
  border:2px solid #7e8883;box-shadow:0 2px 3px #06100a9c;
}
.sealed-crate .crate-mini-sprite i{
  position:relative;width:4px;height:5px;background:#e6eee5;border-radius:50%;
  margin:0 2px 0 0;
}
.sealed-crate .crate-mini-weight{
  width:13px;height:17px;flex:none;
  background:linear-gradient(110deg,#e5c78c,#a9824a 67%,#725438);
  border:1px solid #e1b97e;clip-path:polygon(25% 0,75% 0,100% 100%,0 100%);
  filter:drop-shadow(0 3px 1px #1119);
}
.sealed-crate .crate-name{
  position:absolute;bottom:1px;left:4px;right:4px;
  z-index:6;text-align:center;white-space:nowrap;
  font:700 13px Georgia,serif;line-height:16px;
  color:#fff2ca;text-shadow:0 1px 2px #000,0 0 5px #000;
  letter-spacing:.01em;
}
.sealed-crate .crate-hinge{
  position:absolute;top:8px;right:0;bottom:8px;width:5px;
  background:repeating-linear-gradient(to bottom,#e1bc7e 0 5px,#604529 5px 9px);
  opacity:.8;z-index:5;
}
.room-items:has(.sealed-crate) .floor-track{
  gap:clamp(3px,.7vw,10px);
}
/* The full, still-sealed crate travels into a wicker basket just like a
   sprite: the two original groups move first, then only one group remains. */
.group-basket .token.sealed-crate,
.hand-cargo .basket-in-hand .token.sealed-crate{
  width:104px;height:92px;min-width:104px;flex:none;
  margin:-29px -24px -12px;
  transform:scale(.42);transform-origin:50% 90%;
}
.group-basket .token.sealed-crate .crate-lid{top:-12px}
.mini-token.mini-crate{
  width:auto;height:auto;min-height:22px;
  padding:3px 5px;border:2px solid #97734a;border-radius:5px;
  background:linear-gradient(#4a665e,#24413b);
  color:#fff0c9;font:700 9px Georgia,serif;white-space:nowrap;
  box-shadow:inset 0 0 0 1px #cfbd9877;
}
/* Separate, optional identity rewrite. The standard hand operations still
   act in BOTH rooms, while this explicitly opens only a transparent group. */
#crate-controls{
  display:flex;flex-direction:column;gap:7px;
  padding:11px 12px;
  border:1px solid #b5a070;border-radius:10px;
  background:linear-gradient(135deg,#3c4233,#27382f);
}
#crate-controls[hidden]{display:none!important}
#crate-controls .eyebrow{color:#f5d49d;letter-spacing:.11em;font-size:.66rem}
#crate-controls p{margin:0;font-size:.78rem;line-height:1.32;color:#e3e4d5}
#crate-controls p strong{color:#f6d5a2}
#crate-controls #unpack-crates{
  width:100%;margin:0;min-height:43px;padding:9px 11px;
  font-weight:800;font-size:.82rem;color:#ffedd0;
  background:#4a5d50;border:1px solid #c9af7e;
}
#crate-controls #unpack-crates:hover:not(:disabled){background:#5d7060}
#crate-controls #unpack-crates:focus-visible{
  outline:3px solid #f5d495;outline-offset:2px;
}
/* A real contact animation: first the latch opens, then the contents burst
   upwards and drift out. Only AFTER this phase is the model re-rendered as
   loose objects. */
.sealed-crate.crate-opening{box-shadow:0 0 22px #f4d0908c,inset 0 0 0 2px #e1b97650}
.sealed-crate.crate-opening .crate-lid{
  animation:crate-unlatch .78s cubic-bezier(.22,.76,.37,1) both;
}
.sealed-crate.crate-opening .crate-mini-sprite{
  animation:crate-sprite-out .8s ease-in-out .15s both;
}
.sealed-crate.crate-opening .crate-mini-weight{
  animation:crate-weight-out .8s ease-in-out both;
}
.sealed-crate.crate-opening .crate-mini-weight:nth-of-type(2){animation-delay:.12s}
.sealed-crate.crate-opening .crate-mini-weight:nth-of-type(3){animation-delay:.2s}
.sealed-crate.crate-opening .crate-mini-weight:nth-of-type(4){animation-delay:.28s}
.sealed-crate.crate-locked-rattle{
  animation:crate-locked .48s linear 2;
}
@keyframes crate-unlatch{
  0%{transform:rotate(0);filter:brightness(1)}
  48%{transform:rotate(-18deg);filter:brightness(1.25)}
  100%{transform:rotate(-55deg);filter:brightness(1.3)}
}
@keyframes crate-sprite-out{
  0%,30%{transform:translate(0,0) scale(1);opacity:1}
  75%{transform:translate(-22px,-42px) rotate(-15deg) scale(1.1);opacity:1}
  100%{transform:translate(-29px,-62px) scale(.8);opacity:0}
}
@keyframes crate-weight-out{
  0%,35%{transform:translate(0,0);opacity:1}
  75%{transform:translate(15px,-36px) rotate(12deg);opacity:1}
  100%{transform:translate(19px,-47px) rotate(16deg);opacity:0}
}
@keyframes crate-locked{
  0%,100%{translate:0 0}25%{translate:4px 0}50%{translate:-5px 0}75%{translate:3px 0}
}
/* Compact laptop rail: one line of guidance and a small independent button.
   This is especially important at 1092×540 with a single-screen game. */
@media(min-width:900px) and (max-height:790px){
  #crate-controls{gap:3px;padding:6px 8px}
  #crate-controls p{font-size:.66rem;line-height:1.15}
  #crate-controls #unpack-crates{min-height:33px;padding:5px 8px;font-size:.73rem}
}
@media(min-width:900px) and (max-height:649px){
  #crate-controls p{display:none}
  #crate-controls{padding:4px 7px;gap:2px}
  #crate-controls #unpack-crates{min-height:26px;padding:3px 6px}
}
@media(max-width:899px){
  #crate-controls{margin:5px 0}
  #crate-controls #unpack-crates{min-height:44px}
}
@media(prefers-reduced-motion:reduce){
  .sealed-crate.crate-opening .crate-lid{animation-duration:.01s}
  .sealed-crate.crate-opening :is(.crate-mini-sprite,.crate-mini-weight){animation-duration:.01s}
  .sealed-crate.crate-locked-rattle{animation:none;outline:3px solid #f0cb89}
}
