/* Final visual cleanup and lightweight interaction polish. */

.category-rail.panel,
.wardrobe.panel {
  border-color: rgba(242, 196, 88, 0.62);
  border-radius: 20px;
  background-clip: padding-box;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(36, 18, 12, 0.72),
    inset 0 0 0 3px rgba(255, 214, 115, 0.055);
}

.category-rail.panel::before,
.wardrobe.panel::before {
  inset: 6px;
  border-color: rgba(255, 225, 145, 0.1);
  border-radius: 14px;
}

.category-btn,
.item-card,
.profile-card,
.personality-btn,
.item-icon.item-visual,
.personality-visual {
  background-clip: padding-box;
}

.category-btn {
  border-color: rgba(255, 219, 133, 0.31);
  border-radius: 14px;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.055),
    0 4px 10px rgba(15, 8, 5, 0.34);
}

.category-btn.is-active,
.category-btn.active,
.category-btn[aria-current="true"],
.category-btn[aria-pressed="true"] {
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.16),
    0 4px 11px rgba(28, 11, 8, 0.38),
    0 0 15px rgba(230, 87, 54, 0.16);
}

.item-grid,
.personality-grid {
  gap: 8px;
}

.item-card {
  border-color: rgba(243, 207, 120, 0.42);
  border-radius: 14px;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.07),
    0 5px 12px rgba(25, 12, 8, 0.4);
  -webkit-user-drag: none;
}

.item-card:hover:not(:disabled) {
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.1),
    0 8px 18px rgba(20, 10, 6, 0.42),
    0 0 13px rgba(255, 215, 120, 0.09);
  transform: translateY(-2px);
}

.item-card.is-selected,
.item-card.active,
.item-card[aria-pressed="true"],
.item-card[data-selected="true"] {
  box-shadow:
    inset 0 0 0 1px rgba(125, 231, 228, 0.17),
    0 0 0 1px var(--cocoa),
    0 5px 14px rgba(8, 25, 22, 0.38),
    0 0 15px rgba(125, 231, 228, 0.22);
}

.item-icon.item-visual {
  border-radius: 11px;
  box-shadow:
    inset 0 0 0 1px rgba(38, 17, 10, 0.56),
    inset 0 1px rgba(255, 246, 207, 0.13),
    0 3px 8px rgba(0, 0, 0, 0.22);
}

.item-icon.item-visual::after {
  border-color: rgba(255, 231, 166, 0.09);
  border-radius: 8px;
}

.item-card.is-selected .item-icon.item-visual,
.item-card[aria-pressed="true"] .item-icon.item-visual,
.item-card[data-selected="true"] .item-icon.item-visual {
  box-shadow:
    inset 0 0 0 1px rgba(125, 231, 228, 0.19),
    0 0 0 1px rgba(31, 16, 10, 0.88),
    0 0 14px rgba(125, 231, 228, 0.27);
}

.item-grid[data-category="eyes"] {
  scroll-padding-block-end: 12px;
}

.eye-color-picker {
  position: relative;
  grid-column: 1 / -1;
  min-inline-size: 0;
  margin: 3px 0 1px;
  padding: 7px 10px 10px;
  border: 1px solid rgba(239, 184, 63, 0.58);
  border-radius: 14px 17px 13px 18px;
  color: var(--cream);
  background:
    radial-gradient(circle at 86% 18%, rgba(125, 231, 228, 0.13), transparent 28%),
    linear-gradient(155deg, rgba(26, 78, 62, 0.96), rgba(8, 34, 31, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(37, 18, 11, 0.72),
    inset 0 1px rgba(255, 248, 215, 0.08),
    0 5px 12px rgba(20, 10, 6, 0.34);
}

.eye-color-picker::after {
  position: absolute;
  top: 8px;
  right: 10px;
  content: "\2726";
  color: var(--brass-light);
  font-size: 0.7rem;
  text-shadow: 0 0 7px rgba(255, 223, 132, 0.72);
}

.eye-color-picker__legend {
  padding: 0 7px;
  color: var(--brass-light);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.eye-color-picker__hint {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  margin: 0 18px 8px 0;
  gap: 8px;
  color: rgba(255, 240, 207, 0.78);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.eye-color-current {
  min-width: 0;
  padding: 3px 7px;
  overflow: hidden;
  border: 1px solid rgba(125, 231, 228, 0.35);
  border-radius: 999px;
  color: #dffffb;
  font-size: 0.59rem;
  letter-spacing: 0.025em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(4, 34, 31, 0.7);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07);
}

.eye-color-options {
  display: grid;
  grid-template-columns: repeat(6, minmax(32px, 40px));
  justify-content: space-between;
  gap: 6px;
}

.eye-color-option {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
}

.eye-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.eye-color-swatch {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  max-width: 100%;
  place-items: center;
  cursor: pointer;
  border: 2px solid rgba(255, 226, 153, 0.48);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(38, 91, 71, 0.98), rgba(4, 29, 27, 0.98));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.11),
    0 3px 7px rgba(0, 0, 0, 0.38);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.eye-color-swatch__gem {
  display: block;
  width: 27px;
  height: 27px;
  border: 2px solid var(--eye-outline);
  border-radius: 50%;
  background:
    radial-gradient(circle at 31% 25%, #fff 0 7%, var(--eye-highlight) 8% 22%, transparent 23%),
    radial-gradient(circle at 42% 36%, var(--eye-highlight), var(--eye-color) 55%, var(--eye-outline) 100%);
  box-shadow:
    inset -3px -4px 5px rgba(22, 13, 15, 0.22),
    inset 2px 2px 3px rgba(255, 255, 255, 0.2);
}

.eye-color-swatch:hover {
  z-index: 2;
  border-color: var(--brass-light);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.14),
    0 5px 10px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(239, 184, 63, 0.17);
  transform: translateY(-1px) scale(1.06);
}

.eye-color-input:checked + .eye-color-swatch {
  border-color: var(--cyan);
  box-shadow:
    0 0 0 2px var(--cocoa),
    0 0 0 4px rgba(125, 231, 228, 0.78),
    0 0 13px rgba(125, 231, 228, 0.38),
    inset 0 1px rgba(255, 255, 255, 0.17);
  transform: rotate(-2deg) scale(1.02);
}

.eye-color-input:checked + .eye-color-swatch::after {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  content: "\2713";
  border: 2px solid var(--cocoa);
  border-radius: 50%;
  color: var(--cocoa);
  font-size: 0.58rem;
  font-weight: 1000;
  line-height: 1;
  background: var(--cyan);
}

.eye-color-input:focus-visible + .eye-color-swatch {
  outline: 3px solid #fff4c6;
  outline-offset: 4px;
}

.eye-color-picker:disabled {
  opacity: 0.58;
}

.eye-color-picker:disabled .eye-color-swatch {
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* Keep one clear drop-target color for the whole custom pointer drag. */
.stage-card.drag-ready,
.stage-card.drag-over {
  border-color: var(--cyan);
  box-shadow:
    var(--shadow),
    inset 0 0 0 3px var(--cocoa),
    inset 0 0 0 6px rgba(125, 231, 228, 0.28),
    0 0 28px rgba(125, 231, 228, 0.25);
}

.drag-magic-canvas {
  position: fixed;
  inset: 0;
  z-index: 199;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  contain: strict;
}

.drag-magic-canvas.is-active {
  visibility: visible;
  opacity: 1;
}

.drag-ghost {
  border-color: var(--cyan);
  box-shadow:
    0 13px 25px rgba(0, 0, 0, 0.35),
    0 0 20px rgba(125, 231, 228, 0.42);
}

.profile-card {
  border-color: rgba(255, 215, 119, 0.48);
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 1px rgba(31, 15, 10, 0.58),
    0 8px 19px rgba(0, 0, 0, 0.25);
}

.personality-btn {
  border-color: rgba(255, 218, 133, 0.34);
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(25, 12, 8, 0.36);
}

.personality-btn.is-active,
.personality-btn.active,
.personality-btn[aria-pressed="true"] {
  box-shadow:
    0 0 0 1px var(--cocoa),
    0 5px 13px rgba(27, 13, 8, 0.35),
    0 0 14px rgba(255, 205, 98, 0.18);
}

.personality-btn > .personality-visual,
.personality-visual {
  border-radius: 11px;
}

.speech-bubble {
  --speech-rest-angle: -5deg;
  top: clamp(101px, calc(22.5% - 15px), 182px);
  width: min(300px, 48%);
  max-height: none;
  padding: 14px 18px;
  overflow: visible;
  border-radius: 20px 20px 8px 20px;
  font-size: clamp(0.9rem, 1.35vw, 1.08rem);
  line-height: 1.22;
  box-shadow:
    0 0 0 2px rgba(255, 227, 153, 0.74),
    0 11px 24px rgba(0, 0, 0, 0.3);
  transform-origin: bottom right;
  animation: polished-bubble-float 4.2s ease-in-out infinite;
}

.speech-bubble.is-speaking-a,
.speech-bubble.is-speaking-b {
  will-change: transform, opacity;
}

.speech-bubble.is-speaking-a {
  animation: speech-bubble-pop-a 700ms cubic-bezier(0.2, 0.9, 0.22, 1.18) both;
}

.speech-bubble.is-speaking-b {
  animation: speech-bubble-pop-b 700ms cubic-bezier(0.2, 0.9, 0.22, 1.18) both;
}

.stage-card.buddy-dragging .speech-bubble,
.stage-card.buddy-dragging .speech-bubble.is-speaking-a,
.stage-card.buddy-dragging .speech-bubble.is-speaking-b {
  visibility: hidden;
  animation: none;
}

@keyframes polished-bubble-float {
  0%,
  100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-4px) rotate(-4deg); }
}

@keyframes speech-bubble-pop-a {
  0% {
    opacity: 0.68;
    transform: translateY(7px) rotate(calc(var(--speech-rest-angle) - 3deg)) scale(0.86);
  }
  22% {
    opacity: 1;
    transform: translateY(-5px) rotate(calc(var(--speech-rest-angle) + 4deg)) scale(1.14);
  }
  42% { transform: translate(-3px, -2px) rotate(calc(var(--speech-rest-angle) - 3deg)) scale(1.08); }
  61% { transform: translate(2px, -1px) rotate(calc(var(--speech-rest-angle) + 2deg)) scale(1.045); }
  79% { transform: translate(-1px, 0) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(1.02); }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--speech-rest-angle)) scale(1);
  }
}

@keyframes speech-bubble-pop-b {
  0% {
    opacity: 0.68;
    transform: translateY(7px) rotate(calc(var(--speech-rest-angle) - 3deg)) scale(0.86);
  }
  22% {
    opacity: 1;
    transform: translateY(-5px) rotate(calc(var(--speech-rest-angle) + 4deg)) scale(1.14);
  }
  42% { transform: translate(-3px, -2px) rotate(calc(var(--speech-rest-angle) - 3deg)) scale(1.08); }
  61% { transform: translate(2px, -1px) rotate(calc(var(--speech-rest-angle) + 2deg)) scale(1.045); }
  79% { transform: translate(-1px, 0) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(1.02); }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--speech-rest-angle)) scale(1);
  }
}

@keyframes speech-bubble-pop-mobile-a {
  0% {
    opacity: 0.74;
    transform: translateY(5px) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(0.94);
  }
  28% {
    opacity: 1;
    transform: translateY(-3px) rotate(calc(var(--speech-rest-angle) + 1.5deg)) scale(1.045);
  }
  58% { transform: translateY(-1px) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(1.025); }
  80% { transform: translateY(0) rotate(calc(var(--speech-rest-angle) + 0.5deg)) scale(1.01); }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--speech-rest-angle)) scale(1);
  }
}

@keyframes speech-bubble-pop-mobile-b {
  0% {
    opacity: 0.74;
    transform: translateY(5px) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(0.94);
  }
  28% {
    opacity: 1;
    transform: translateY(-3px) rotate(calc(var(--speech-rest-angle) + 1.5deg)) scale(1.045);
  }
  58% { transform: translateY(-1px) rotate(calc(var(--speech-rest-angle) - 1deg)) scale(1.025); }
  80% { transform: translateY(0) rotate(calc(var(--speech-rest-angle) + 0.5deg)) scale(1.01); }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(var(--speech-rest-angle)) scale(1);
  }
}

.coming-soon-action {
  position: relative;
  display: flex;
  min-width: 0;
}

.coming-soon-action > .coming-soon-btn {
  width: 100%;
}

.life-action > #life-btn {
  min-height: 50px;
}

.talk-action > #talk-btn {
  min-height: 48px;
}

.talk-btn-icon {
  color: var(--brass-light);
  font-size: 1.05rem;
  line-height: 1;
  filter: drop-shadow(0 1px 0 var(--cocoa));
  transform: rotate(-8deg);
}

.coming-soon-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  z-index: 8;
  width: max-content;
  max-width: min(190px, 75vw);
  padding: 9px 14px;
  pointer-events: none;
  visibility: hidden;
  border: 2px solid var(--cocoa);
  border-radius: 14px 14px 5px 14px;
  color: var(--paper-ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(145deg, #fff8df, #efd59d);
  box-shadow:
    0 0 0 2px rgba(255, 224, 142, 0.52),
    0 9px 18px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, 7px) rotate(-5deg) scale(0.92);
  transform-origin: bottom center;
  transition:
    opacity 150ms ease,
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0s linear 180ms;
}

.coming-soon-popover::after {
  position: absolute;
  right: 24px;
  bottom: -8px;
  width: 13px;
  height: 13px;
  content: "";
  border-right: 2px solid var(--cocoa);
  border-bottom: 2px solid var(--cocoa);
  background: #efd59d;
  transform: rotate(45deg);
}

.coming-soon-action:focus-within .coming-soon-popover,
.coming-soon-action.is-showing .coming-soon-popover {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0) rotate(-5deg) scale(1);
  transition-delay: 0s;
}

@media (hover: hover) and (pointer: fine) {
  .coming-soon-action:hover .coming-soon-popover {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0) rotate(-5deg) scale(1);
    transition-delay: 0s;
  }
}

@media (hover: none) and (pointer: coarse) and (max-width: 960px) {
  .eye-color-options {
    grid-template-columns: repeat(6, 44px);
    justify-content: center;
  }

  .eye-color-swatch {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 720px) {
  .eye-color-options {
    grid-template-columns: repeat(6, 44px);
    justify-content: center;
    gap: 9px;
  }

  .eye-color-swatch {
    width: 44px;
    height: 44px;
  }

  .eye-color-swatch__gem {
    width: 30px;
    height: 30px;
  }

  .speech-bubble {
    --speech-rest-angle: -4deg;
    top: clamp(87px, calc(26% - 15px), 125px);
    right: auto;
    bottom: auto;
    left: clamp(12px, 4.5vw, 26px);
    width: min(58%, 235px);
    max-height: none;
    padding: 10px 13px;
    overflow: visible;
    border-radius: 17px 17px 7px 17px;
    font-size: clamp(0.74rem, 2.7vw, 0.86rem);
    line-height: 1.2;
    transform: rotate(-4deg);
    transform-origin: bottom right;
    animation: none;
  }

  .speech-bubble.is-speaking-a {
    animation: speech-bubble-pop-mobile-a 540ms cubic-bezier(0.2, 0.88, 0.22, 1.12) both;
  }

  .speech-bubble.is-speaking-b {
    animation: speech-bubble-pop-mobile-b 540ms cubic-bezier(0.2, 0.88, 0.22, 1.12) both;
  }

  .life-action > #life-btn {
    min-height: 44px;
  }
}

@media (max-width: 430px) {
  .eye-color-picker {
    padding-inline: 12px;
  }

  .eye-color-picker__hint {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .eye-color-options {
    grid-template-columns: repeat(3, 44px);
    gap: 9px 34px;
  }

  .speech-bubble {
    width: min(61%, 225px);
    font-size: clamp(0.72rem, 3.1vw, 0.82rem);
  }

  .coming-soon-popover {
    max-width: min(170px, 76vw);
    font-size: 0.86rem;
  }

  .talk-action .coming-soon-popover {
    right: 0;
    left: auto;
    transform: translate(0, 7px) rotate(-5deg) scale(0.92);
    transform-origin: bottom right;
  }

  .talk-action:focus-within .coming-soon-popover,
  .talk-action.is-showing .coming-soon-popover {
    transform: translate(0, 0) rotate(-5deg) scale(1);
  }
}

@media (max-width: 430px) and (hover: hover) and (pointer: fine) {
  .talk-action:hover .coming-soon-popover {
    transform: translate(0, 0) rotate(-5deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .eye-color-swatch {
    transition: none;
  }

  .speech-bubble,
  .speech-bubble.is-speaking-a,
  .speech-bubble.is-speaking-b {
    transform: rotate(-4deg);
    animation: none;
  }

  .coming-soon-popover {
    transition: none;
  }
}

html[data-motion="gentle"] .speech-bubble,
html[data-motion="gentle"] .speech-bubble.is-speaking-a,
html[data-motion="gentle"] .speech-bubble.is-speaking-b,
html[data-background-motion="off"] .speech-bubble,
html[data-background-motion="off"] .speech-bubble.is-speaking-a,
html[data-background-motion="off"] .speech-bubble.is-speaking-b {
  transform: rotate(-4deg);
  animation: none;
}
