/* 3D unboxing: the host fills the opening screen's stage row; the canvas is transparent so the
   palette-tinted backdrop (and the light-mode backdrops) show through. */
.opening-3d { grid-template-rows: 1fr auto; }
.opening-3d.is-revealed { grid-template-rows: minmax(38dvh, 1fr) auto; }
.unbox-host { position: relative; min-height: 0; }
.unbox { position: relative; width: 100%; height: 100%; min-height: 320px; overflow: hidden; outline: none; isolation: isolate;
  background: radial-gradient(ellipse at 50% 32%, color-mix(in oklab, var(--box) 70%, #fff) 0%, color-mix(in oklab, var(--box) 45%, var(--paper)) 62%, color-mix(in oklab, var(--box) 30%, var(--paper)) 100%);
  transition: background .6s; }
.unbox[data-lights="warm"] { background: radial-gradient(ellipse at 50% 30%, #fbe9cf 0%, #e6b57e 60%, #b97b45 100%); }
.unbox[data-lights="neon"] { background: radial-gradient(ellipse at 50% 30%, #2a1a4f 0%, #120c24 55%, #05040a 100%); }
.unbox-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; opacity: 1; transition: opacity .5s; }
.unbox.is-loading .unbox-canvas { opacity: 0; }
.unbox-canvas:active { cursor: grabbing; }

.unbox-ui { position: absolute; inset: 0; pointer-events: none; display: grid; grid-template-rows: 1fr auto; padding: calc(12px + env(safe-area-inset-top)) 16px 14px; }
.unbox-ui > * { pointer-events: none; }
.unbox-loading { grid-row: 1; align-self: center; justify-self: center; margin: 0; font-family: var(--display); font-weight: 600; font-size: 18px; color: var(--sink); opacity: 0; transition: opacity .3s .4s; }
.unbox.is-loading .unbox-loading { opacity: .8; animation: unbox-breathe 1.4s ease-in-out infinite; }
.unbox:not(.is-loading) .unbox-loading { display: none; }
@keyframes unbox-breathe { 50% { opacity: .35; } }

.unbox-prompt { grid-row: 2; margin: 0; text-align: center; font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1.2; min-height: 26px; color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 0 18px color-mix(in oklab, var(--box) 60%, transparent); }
.unbox[data-lights="neon"] .unbox-prompt, .unbox[data-lights="neon"] .unbox-help { color: #f4ecff; text-shadow: 0 0 12px #b48cf2; }
.unbox-prompt[data-hold]::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%; background: var(--accent); animation: unbox-breathe .6s ease-in-out infinite; vertical-align: middle; }
.unbox-progress { grid-row: 3; height: 6px; margin: 8px auto 0; width: 150px; background: rgba(0, 0, 0, .14); border-radius: 3px; overflow: hidden; }
.unbox-progress i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform .05s linear; }
.unbox-help { grid-row: 4; margin: 8px 0 0; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--ink-2); opacity: .85; }
.unbox-hint { position: absolute; left: 50%; top: calc(18% + env(safe-area-inset-top)); transform: translateX(-50%) rotate(-1.5deg); margin: 0; max-width: 78%; padding: 10px 16px; border-radius: 16px 16px 16px 4px;
  background: #FFF8C7; color: #3B3000; font-family: var(--hand); font-size: 22px; line-height: 1.2; box-shadow: var(--shadow); animation: unbox-pop .35s cubic-bezier(.2, 1.4, .4, 1); z-index: 2; }
@keyframes unbox-pop { from { transform: translateX(-50%) scale(.6) rotate(-6deg); opacity: 0; } }

.unbox-tools { position: absolute; right: 10px; top: calc(60px + env(safe-area-inset-top)); display: grid; gap: 8px; pointer-events: auto; animation: unbox-pop .4s cubic-bezier(.2, 1.4, .4, 1); }
.unbox-tools > * { pointer-events: auto; }
.unbox-tool { display: grid; place-items: center; gap: 1px; width: 68px; height: 56px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, .72); color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.unbox-tool span { font-size: 9.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); }
.unbox-tool:active { transform: scale(.94); }
.unbox[data-lights="neon"] .unbox-tool { background: rgba(40, 24, 80, .75); color: #f4ecff; }
.unbox[data-lights="neon"] .unbox-tool span { color: #cbb8ff; }

/* the flat fallback (no WebGL): the sprite, one tap */
.unbox-fallback { height: 100%; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; cursor: pointer; }
.unbox-fallback img { width: min(60vw, 260px); transition: filter .6s; }
.unbox-fallback img.is-silhouette { filter: brightness(0) opacity(.5); }
.unbox-fallback .unbox-prompt { grid-row: auto; }

/* the reveal panel sits under the stage as before, but the stage keeps most of the screen */
.opening-3d .reveal { max-height: 52dvh; overflow: auto; }

@media (prefers-reduced-motion: reduce) {
  .unbox-hint, .unbox-tools, .unbox.is-loading .unbox-loading { animation: none; }
  .unbox-canvas, .unbox { transition: none; }
}
@media (min-width: 700px) {
  .unbox-prompt { font-size: 24px; }
}
