/* The frame is outside the coordinate plane. Home and editor MUST use this
   same borderless 16:10 canvas; do not add breakpoint-specific layer sizes. */
.tamami-stage-frame,
.dashboard-hero-shell .dashboard-hero {
  --tamami-stage-frame: url("/images/pixel_frame_decoration_quiet.svg?v=1");
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  padding: 0;
  border: 14px solid transparent;
  border-image-source: var(--tamami-stage-frame);
  border-image-slice: 14 fill;
  border-image-width: 1;
  border-image-repeat: stretch;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  overflow: visible;
  image-rendering: pixelated;
}

.dashboard-hero-shell .pixel-sky { position: relative; inset: auto; overflow: visible; }
.dashboard-hero-shell .dashboard-cat-speech-wrap { z-index: 10; }

.tamami-stage-scene {
  position: relative;
  isolation: isolate;
}

/* Only the scenery bleeds into the frame's filled interior. Keep the canvas
   and every object exactly 14px inside the frame, as before. This polygon
   follows the INSIDE of pixel_frame_decoration_quiet.svg's 14px end caps;
   it clips the image, never the frame's outline/highlight/shadow pixels. */
.tamami-stage-backdrop {
  position: absolute;
  inset: -14px;
  z-index: 0;
  pointer-events: none;
  background-color: #f6f0fe;
  background-image: var(--decor-background-image, url("/images/dashboard_hero_bg.png"));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  clip-path: polygon(
    14px 4px, calc(100% - 10px) 4px,
    calc(100% - 10px) 6px, calc(100% - 6px) 6px,
    calc(100% - 6px) 10px, calc(100% - 4px) 10px,
    calc(100% - 4px) calc(100% - 12px), calc(100% - 6px) calc(100% - 12px),
    calc(100% - 6px) calc(100% - 8px), calc(100% - 10px) calc(100% - 8px),
    calc(100% - 10px) calc(100% - 6px), calc(100% - 14px) calc(100% - 6px),
    calc(100% - 14px) calc(100% - 4px), 10px calc(100% - 4px),
    10px calc(100% - 6px), 6px calc(100% - 6px),
    6px calc(100% - 10px), 4px calc(100% - 10px),
    4px 12px, 6px 12px,
    6px 8px, 10px 8px,
    10px 6px, 14px 6px
  );
}

.tamami-stage[data-tamami-canvas] {
  position: relative;
  z-index: 1;
  inset: auto;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: 16 / 10;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  overflow: hidden;
}

.tamami-stage[data-tamami-canvas] :is([data-placement-key], [data-follow-tamami]) {
  top: var(--placement-y);
  left: var(--placement-x);
  width: var(--layer-width);
  height: var(--layer-height);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: translate(-50%, -50%);
  opacity: 1;
}

.tamami-stage[data-tamami-canvas] [hidden] { display: none; }
.tamami-stage[data-tamami-canvas] > .tamami-layer > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
}

/* Clip the source PNG's transparent registration canvas to the measured art. */
.tamami-wearable-art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.tamami-wearable-art > img {
  position: absolute;
  display: block;
  left: var(--wearable-source-left, 0%);
  top: var(--wearable-source-top, 0%);
  width: var(--wearable-source-width, 100%);
  height: var(--wearable-source-height, 100%);
  max-width: none;
  object-fit: fill;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
}

.tamami-stage[data-tamami-canvas] .tamami-layer--effect {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
}
.tamami-stage[data-tamami-canvas] :is(.tamami-layer--effect, .tamami-layer--crystal-effect) > img {
  animation: none;
  filter: none;
}

.tamami-crystal-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tamami-crystal-particles > img { width: 100%; height: 100%; object-fit: contain; }
.tamami-crystal-particle {
  position: absolute;
  display: block;
  transform: translate(-50%, -50%);
  opacity: 0.85;
  pointer-events: none;
}
.tamami-crystal-art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.tamami-crystal-art > img {
  position: absolute;
  display: block;
  left: var(--crystal-source-left, 0%);
  top: var(--crystal-source-top, 0%);
  width: var(--crystal-source-width, 100%);
  height: var(--crystal-source-height, 100%);
  max-width: none;
  object-fit: fill;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
}

/* Each glint has its own phase and a tiny drift; the glass stays untouched. */
@keyframes tamami-crystal-particle-glimmer {
  0%, 100% { opacity: 0; translate: 0 1px; }
  24%, 42% { opacity: 1; }
  68% { opacity: 0.4; }
  86% { opacity: 0; translate: var(--crystal-drift-x, 0px) -2px; }
}

/* The shop icon is a single, steady-position sample of the same artwork. */
@keyframes tamami-crystal-twinkle {
  0%, 100% { opacity: 0.5; }
  30%, 65% { opacity: 1; }
  50% { opacity: 0.72; }
  85% { opacity: 0.6; }
}

/* Each four-pixel sweep advances in whole pixels to keep the artwork crisp. */
@keyframes tamami-effect-vertical {
  from { translate: 0 -2px; }
  to { translate: 0 2px; }
}

@keyframes tamami-effect-horizontal {
  from { translate: -2px 0; }
  to { translate: 2px 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .tamami-stage[data-tamami-canvas] .tamami-layer--effect[data-effect-motion="vertical"] > img {
    animation: tamami-effect-vertical 1.8s steps(4, end) infinite alternate;
  }

  .tamami-stage[data-tamami-canvas] .tamami-layer--effect[data-effect-motion="horizontal"] > img {
    animation: tamami-effect-horizontal 2.2s steps(4, end) infinite alternate;
  }

  .tamami-stage[data-tamami-canvas] .tamami-crystal-particle {
    animation: tamami-crystal-particle-glimmer var(--crystal-duration, 5s) steps(3, end) var(--crystal-delay, 0s) infinite;
  }
}

.tamami-stage[data-tamami-canvas].is-editing .is-placement-active {
  outline-color: #5a43bc;
}

/* Selection is persistent state, independent of the global focus-outline reset. */
.tamami-stage[data-tamami-canvas].is-editing .is-placement-active::after {
  position: absolute;
  inset: 0;
  border: 3px solid var(--tamami-section-title, #5a43bc);
  content: "";
  pointer-events: none;
}
