/* Integration polish layered over the workshop stylesheet. */

#game-shell {
  grid-template-columns: minmax(0, 1fr);
}

.personality-btn > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.personality-btn strong {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  overflow: visible;
  line-height: 1.05;
  text-overflow: clip;
  text-wrap: balance;
  overflow-wrap: anywhere;
  white-space: normal;
}

.personality-btn small {
  display: none;
}

.selected-mark {
  display: none;
}

.stage-sparkles > span {
  top: var(--y, 50%);
  left: var(--x, 50%);
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: var(--brass-light);
  font-size: 16px;
  line-height: 1;
  background: none;
  text-shadow: 0 0 12px currentColor;
  animation-delay: var(--delay, 0ms);
}

.stage-card.drag-ready .drop-hint,
.stage-card.is-dragging .drop-hint {
  color: var(--cocoa);
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 26px rgba(125, 231, 228, 0.5);
}

.drag-ghost {
  position: fixed;
  top: -31px;
  left: -31px;
  z-index: 200;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  pointer-events: none;
  contain: layout paint style;
  will-change: transform;
  border: 2px solid var(--brass-light);
  border-radius: 19px;
  color: var(--cream);
  font: 900 1rem var(--font-body);
  background: rgba(14, 66, 53, 0.96);
  box-shadow: 0 13px 25px rgba(0, 0, 0, 0.35), 0 0 18px rgba(125, 231, 228, 0.28);
}


.stage-card.finishing::before {
  z-index: 6;
  opacity: 1;
  background: radial-gradient(circle at 50% 42%, rgba(255, 242, 180, 0.4), rgba(7, 23, 23, 0.78) 73%);
  animation: reveal-light 1s ease both;
}

.intro-overlay.opening .workshop-door {
  animation: door-open 850ms cubic-bezier(0.5, 0, 0.18, 1) forwards;
}

.portrait-frame {
  align-self: start;
}

.portrait-frame canvas {
  height: auto;
  aspect-ratio: 4 / 5;
}

/* Surprise leads a four-action row on desktop; narrower layouts become a
   balanced two-by-two control deck. */
.workbench-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 1fr));
}

.workbench-controls > #surprise-btn,
.workbench-controls > .coming-soon-action,
.workbench-controls > #reset-btn,
.workbench-controls > #finish-btn {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

.finish-cta {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  min-width: 0;
}

.finish-cta > #finish-btn {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  height: 100%;
}

.finish-certificate-peek {
  position: absolute;
  top: auto;
  right: clamp(30px, 15%, 36px);
  bottom: 13px;
  z-index: 1;
  width: clamp(72px, 6.9vw, 90px);
  aspect-ratio: 17 / 22;
  padding: 0;
  border: 0;
  min-width: 0;
  appearance: none;
  color: inherit;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transform: translateY(0) rotate(15deg);
  transform-origin: 50% 90%;
  filter: drop-shadow(0 6px 5px rgba(19, 9, 5, 0.45));
  animation: certificate-teaser-wiggle 9s ease-in-out infinite;
}

.finish-certificate-peek canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 230, 166, 0.92);
  border-radius: 3px;
  background: #f4dfad;
  box-shadow: 0 0 0 2px rgba(72, 34, 18, 0.75), 0 0 0 3px rgba(213, 160, 62, 0.85);
}

.finish-certificate-peek:not(:disabled):hover,
.finish-certificate-peek:not(:disabled):focus-visible {
  animation-play-state: paused;
  transform: translateY(-4px) rotate(11deg);
  filter: drop-shadow(0 8px 7px rgba(19, 9, 5, 0.55)) drop-shadow(0 0 8px rgba(120, 228, 231, 0.55));
}

.finish-certificate-peek:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

.finish-certificate-peek:disabled {
  cursor: default;
  pointer-events: none;
}

@keyframes certificate-teaser-wiggle {
  0%, 72%, 88%, 100% { transform: translateY(0) rotate(15deg); }
  76% { transform: translateY(-3px) rotate(11.5deg); }
  80% { transform: translateY(-1px) rotate(17deg); }
  84% { transform: translateY(-3px) rotate(13deg); }
}

.keepsake-actions button {
  min-height: 44px;
}

.keepsake-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}


@keyframes reveal-light {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 960px) {
  .workbench-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench-controls > #surprise-btn {
    grid-column: auto;
  }

  .finish-certificate-peek {
    top: auto;
    right: 14px;
    bottom: 0;
    width: 32px;
  }
}

@media (min-width: 721px) {
  .item-note {
    display: none;
  }

  .item-card {
    min-height: 108px;
  }
}

@media (max-width: 720px) {
  #game-shell,
  .topbar,
  .workspace,
  .category-rail,
  .stage-wrap,
  .stage-card,
  .workbench-controls,
  .wardrobe,
  .item-grid,
  .profile-card,
  .name-row,
  .personality-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .topbar,
  .workspace {
    overflow: hidden;
  }

  .brand {
    min-width: 0;
  }

  .utility-actions {
    flex: 0 0 auto;
  }

  .stage-card {
    min-height: clamp(380px, 57svh, 480px);
  }

  .workbench-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench-controls > #reset-btn,
  .workbench-controls > #finish-btn {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }

  .lever {
    min-width: 0;
    max-width: none;
  }

  .wardrobe {
    grid-template-columns: none;
  }

  .portrait-frame canvas {
    min-height: 0;
    max-height: none;
  }

  .keepsake-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .brand {
    max-width: calc(100vw - 194px);
  }

  .utility-actions {
    gap: 2px;
  }

  .personality-btn {
    min-height: 50px;
  }

  .finish-certificate-peek {
    top: auto;
    right: 12px;
    bottom: 0;
    width: 32px;
  }

  .keepsake-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .keepsake-actions > :last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 360px) {
  .keepsake-actions {
    grid-template-columns: 1fr;
  }

  .keepsake-actions > :last-child {
    grid-column: auto;
  }
}

@media (max-height: 560px) and (orientation: landscape) and (min-width: 961px) {
  .workbench-controls {
    min-height: 54px;
    padding: 5px;
    gap: 6px;
  }

  .workbench-controls button {
    min-height: 48px;
    padding-block: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-card.finishing::before,
  .intro-overlay.opening .workshop-door,
  .finish-certificate-peek {
    animation: none !important;
  }
}

html[data-motion="gentle"] .finish-certificate-peek {
  animation: none !important;
}
/* Expanded customization rail: Mittens, Magic Aura, and Pose. */
.category-rail {
  min-height: 0;
  max-height: calc(100svh - 127px);
}

.category-rail-scroll {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scroll-snap-type: y proximity;
}

.category-btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.category-btn[data-category="mittens"] .category-label {
  line-height: 1.02;
  white-space: normal;
}

@media (max-width: 960px) and (min-width: 721px) {
  .category-rail {
    height: clamp(360px, calc(100svh - 130px), 700px);
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .category-rail {
    height: auto;
    min-height: 60px;
    max-height: none;
  }

  .category-rail-scroll {
    height: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 7px;
    scroll-snap-type: x proximity;
    scrollbar-gutter: auto;
    -webkit-overflow-scrolling: touch;
  }

  .category-btn[data-category="mittens"] {
    min-width: 124px;
  }
}
