:root {
  --bg: #FAFAFA;
  /* Paper White */
  --ink: #111111;
  /* Deep Black */
  --muted: #666666;
  --card: #FFFFFF;
  --edge: #E5E5E5;
  --acc: #E60023;
  /* Editorial Red */
  --bad: #ff3333;
  --ok: #008f39;

  --font-heading: 'Syne', sans-serif;

  --font-body: 'Manrope', sans-serif;

  --tab-active-background: var(--ink);
  --tab-active-text: #FFFFFF;
  --tab-inactive-background: #F0F0F0;
  --tab-inactive-text: var(--muted);

  /* bottom sheet sizing */
  --tray-open-h: 76vh;
  --tray-altar-notfilledenough-h: 74vh;
  --tray-altar-filled-h: 66vh;
}


* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font-body);
  letter-spacing: -0.01em;
  /* stop scroll chaining / iOS pull-to-refresh from inner scrollers */
  overscroll-behavior-y: none;
}

/* App-specific layout: flex container with fixed viewport for altar/tray stacking */
body.app-layout {
  display: flex;
  flex-direction: column;
  height: 100svh;
  overflow: hidden;
}

/* While dragging: prevent selection and hint grabbing */
body.dragging,
body.dragging * {
  -webkit-user-select: none !important;
  user-select: none !important;
}

body.dragging .mcard {
  cursor: grabbing;
}

header {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 20px 24px;
  border-bottom: 1px solid var(--edge);
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: var(--ink);
  transform: scaleY(1.2);
}

.logo-img {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

main {
  display: flex;
  flex-direction: column;
  /* Fit content, don't grow */
  flex-shrink: 0;
  overflow: visible;
}

.altar {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* =================== Auth-Based Visibility =================== */
/* 
 * CSS-first content switching: html class is set synchronously in <head>
 * before any content renders, preventing flash of wrong content.
 */

/* Default: hide both until auth class is set (prevents flash) */
.welcome-hero,
.altar,
.sheet {
  visibility: hidden;
}

/* Logged out: show welcome hero, hide logged-in content */
html.logged-out .welcome-hero {
  visibility: visible;
}

html.logged-out .altar,
html.logged-out .sheet {
  display: none;
}

/* Logged out main height adjustment */
html.logged-out main {
  height: auto;
  min-height: calc(100svh - 58px);
}

/* View Fit Mode: Hide welcome hero even if logged out (to show fit immediately) */
html.view-fit .welcome-hero {
  display: none !important;
}

/* Modal Z-Index Fix */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999 !important;
  /* Force on top of everything */
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal.on {
  display: flex;
}

/* Logged in: show altar and sheet, hide welcome hero */
html.logged-in .altar,
html.logged-in .sheet {
  visibility: visible;
}

html.logged-in .welcome-hero {
  display: none;
}

/* User Menu Visibility */
html.logged-out .user-menu-container {
  display: none;
}

html.logged-in #auth-btn {
  display: none;
}

/* =================== Skeleton Loading Styles =================== */
.skeleton-text {
  height: 1em;
  background: linear-gradient(90deg, var(--edge) 25%, #f0f0f0 50%, var(--edge) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 2px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.showcase-card.skeleton .showcase-image .placeholder {
  opacity: 0.5;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.7;
  }
}

/* =================== Showcase Grid Chaos =================== */
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 40px auto;
  max-width: 800px;
  padding: 0 16px;
  overflow: visible;
}

@media (min-width: 520px) {
  .showcase-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}



/* Chaotic Tilts - Desktop Only */
@media (min-width: 768px) {
  .showcase-card:nth-child(1) {
    transform: rotate(-3deg);
    z-index: 2;
  }

  .showcase-card:nth-child(2) {
    transform: rotate(2deg) translateY(-10px);
    z-index: 3;
  }

  .showcase-card:nth-child(3) {
    transform: rotate(-1deg);
    z-index: 1;
  }

  .showcase-card:hover {
    transform: scale(1.05) rotate(0deg) !important;
    z-index: 10;
  }
}

/* Mobile Card Resets */
@media (max-width: 767px) {
  .showcase-card {
    transform: none !important;
    margin-bottom: 0;
  }
}

.showcase-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Strictly square */
  background: #f4f4f4;
  overflow: hidden;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.showcase-image .placeholder .slop-emoji {
  /* For the placeholder icons (Sparkles, Fire, etc) */
  font-size: 80px !important;
  line-height: 1;
}

.showcase-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Make footer inspos bigger */
.card-footer .made-with {
  gap: 6px;
}

.card-footer .made-with img,
.card-footer .made-with .mini-emoji {
  width: 28px !important;
  /* Was likely small default */
  height: 28px !important;
}

.showcase-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
}

.showcase-meta {
  padding: 10px;
}

.showcase-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1em;
}

.showcase-recipe {
  margin-top: 8px;
}

.recipe-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.recipe-inspos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.recipe-inspo {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
}

.recipe-inspo .inspo-name {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid var(--edge);
  background: var(--card);
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ghost {
  opacity: .85
}

.altarBoard {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
  border-radius: 2px;
  transition: box-shadow .15s ease, outline-color .15s ease;
  position: relative;
}

.altarBoard[data-dragging="true"] {
  outline: 1px dashed var(--acc);
  outline-offset: 4px;
  box-shadow: 0 0 0 1px rgba(204, 255, 0, 0.2) inset;
  background: rgba(204, 255, 0, 0.05);
}

/* Drop target highlight when dragging over */
.altarBoard.drop-target {
  outline: 2px solid var(--acc);
  outline-offset: 4px;
  background: rgba(204, 255, 0, 0.15);
  box-shadow: 0 0 20px rgba(204, 255, 0, 0.3) inset;
}

/* Altar generating state - visual feedback that inspos are locked */
.altarBoard.generating {
  pointer-events: none;
  opacity: 0.7;
}

.altarBoard.generating .altar-slot {
  filter: grayscale(0.3);
}

.altarBoard.generating .mcard {
  cursor: not-allowed;
}

.sheet.drop-target {
  box-shadow: 0 -4px 20px rgba(204, 255, 0, 0.3);
  border-top-color: var(--acc);
}

/* Tray dragging state (when dragging from altar back to tray) */
.sheet[data-dragging="true"],
#trayInv[data-dragging="true"] {
  box-shadow: 0 -2px 10px rgba(204, 255, 0, 0.2);
}

/* Legacy Altar Slots - TO BE REMOVED IF CONFIRMED UNUSED */
/* .slot, .slotHeader, .slotBody are not used in current app.js rendering */

.slot[data-hot="true"] {
  outline: 2px solid #4b7bec
}

/* User Area & Auth */
.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Responsive header for small screens */
@media (max-width: 520px) {
  header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }

  header h1 {
    font-size: 16px;
    flex: 1;
    min-width: 0;
  }

  .user-area {
    gap: 6px;
  }

  .user-name {
    display: none;
  }

  .avatar-preview {
    width: 28px;
    height: 28px;
  }

  .auth-btn {
    padding: 4px 10px !important;
    font-size: 12px !important;
  }
}

.avatar-section {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  /* Let trigger handle clicks */
}

.avatar-preview {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  /* Circle avatar */
  background: var(--edge);
  overflow: hidden;
  border: 1px solid var(--edge);
  display: flex;
  /* Ensure content is centered */
  align-items: center;
  justify-content: center;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatar-placeholder {
  font-size: 18px;
  line-height: 1;
}

#avatar-upload {
  display: none;
}

#avatar-upload {
  display: none;
}

.user-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
}

/* User Menu Dropdown */
.user-menu-container {
  position: relative;
  display: flex;
  align-items: center;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.1s ease;
  user-select: none;
}

.user-menu-trigger:hover {
  background: rgba(0, 0, 0, 0.03);
}

.user-menu-trigger .chevron-down {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.user-menu-container.active .user-menu-trigger .chevron-down {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--edge);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 6px;
  display: none;
  /* Hidden by default */
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  transform-origin: top right;
  animation: menuPop 0.15s cubic-bezier(0.2, 0, 0.2, 1);
}

.user-menu-container.active .user-menu-dropdown {
  display: flex;
}

@keyframes menuPop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  transition: background 0.1s ease;
}

.user-menu-item:hover {
  background: #f5f5f5;
}

.user-menu-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.user-menu-item.danger {
  color: var(--bad);
}

.user-menu-item.danger:hover {
  background: rgba(255, 51, 51, 0.05);
}

.menu-divider {
  height: 1px;
  background: var(--edge);
  margin: 4px 6px;
}

.auth-btn {
  padding: 6px 12px !important;
  font-size: 13px !important;
  box-shadow: none !important;
  border-width: 1px !important;
}

/* Credits Badge */
.credits-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 2px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.credits-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* =================== Custom Emoji Images =================== */
.slop-emoji {
  display: inline-block;
  width: 1em;
  height: auto;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  /* vertical-align: -0.1em; */
  color: transparent !important;
  user-select: none;
}

.slop-emoji.fire {
  background-image: url('/images/emojis/fire.webp');
  transform: scale(1.4);
}

.slop-emoji.sparkles {
  background-image: url('/images/emojis/gold_sparkle.webp');
  transform: scale(1.4);
}

.slop-emoji.nail-polish {
  background-image: url('/images/emojis/nail_polish.webp');
  transform: scale(1.3);
}

.slop-emoji.crown {
  background-image: url('/images/emojis/crown.webp');
  transform: scale(1.2);
}

.slop-emoji.skull {
  background-image: url('/images/emojis/skull.webp');
  transform: scale(1.2);
}

.slop-emoji.close {
  background-image: url('/images/emojis/close.webp');
}

.slop-emoji.minimize {
  background-image: url('/images/emojis/minimize.webp');
}

.slop-emoji.bow {
  background-image: url('/images/emojis/bow.webp');
}

.slop-emoji.gem {
  background-image: url('/images/emojis/gem.webp');
  transform: scale(1.3);
}

.slop-emoji.user {
  background-image: url('/images/emojis/user.webp');
  transform: scale(1.3);
}

.slop-emoji.camera {
  background-image: url('/images/emojis/camera.webp');
  transform: scale(1.3);
}

.slop-emoji.door {
  background-image: url('/images/emojis/door.webp');
  transform: scale(1.3);
}

.slop-emoji.dress {
  background-image: url('/images/emojis/dress.webp');
  transform: scale(1.3);
}

.slop-emoji.palette {
  background-image: url('/images/emojis/palette.webp');
  transform: scale(1.3);
}

.slop-emoji.trophy {
  background-image: url('/images/emojis/trophy.webp');
  transform: scale(1.3);
}

.slop-emoji.crafted-first {
  background-image: url('/images/emojis/crafted_first.webp');
  transform: scale(1.5);
}

.slop-emoji.mic {
  background-image: url('/images/emojis/mic.webp');
  transform: scale(1.6);
}

.slop-emoji.trophy {
  /* Using crown or similar if trophy isn't generated, but user asked for replacements */
  /* Wait, user asked to replace "Discoveries 🏆" - I don't have a trophy asset! */
  /* I will use the Crown for now or generate a Trophy? User didn't ignore trophy. */
  /* Re-reading request: "the tabs in profile: 🏆 Discoveries 49" */
  /* The user didn't explicitly ask for a Trophy generation, but asked to REPLACE missing spots. */
  /* I'll use a placeholder or Generate one? */
  /* I'll generate a Trophy quick. */
  /* Update: I will skip adding trophy CSS here and do it after generation */
}

/* Specific overrides */
.placeholder .slop-emoji {
  width: 100%;
  height: 100%;
  transform: none;
  /* Reset scale for full headers */
  background-size: 60%;
}


.tagbox {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1/1;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 4px;
}

.tagbox span {
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--muted);
  font-family: var(--font-heading);
}

.thumb {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
  background: #0a0b10;
  border: 0;
  border-radius: 0;
}

/* Once image has loaded, remove the placeholder background to prevent flashes */
.thumb[src]:not([src=""]) {
  background: transparent;
}

.altarBoard .thumb {
  border: 0px;
  max-width: 240px;
}

.capText {
  font-weight: 700
}

.removeBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 700
}

.removeBtn small {
  opacity: .9
}

.actionWrap {
  display: flex;
  justify-content: center;
  gap: 8px;
}


/* =================== Discovery Cheer =================== */
.discovery-cheer-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cheer-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.cheer-text {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  z-index: 2;
  text-align: center;
  animation: cheerPop 4s ease-out forwards;
}

.cheer-badge {
  background: var(--card);
  border: 1px solid var(--acc);
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(255, 215, 0, 0.3);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cheer-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  color: #111;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.cheer-sub {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--muted);
}

.cheer-fit-name {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 900;
  color: #000;
  margin-top: 4px;
  text-shadow: 0 2px 0 rgba(255, 215, 0, 0.2);
}



.cheer-particle {
  position: absolute;
  width: 60px;
  height: 60px;
  pointer-events: none;
  background-image: url('/images/emojis/crafted_first_sprites.webp');
  background-size: 200% 200%;
  /* 2x2 grid */
  background-repeat: no-repeat;
  will-change: transform, opacity;
  animation: cheerExplode ease-out forwards;
}

/* Sprite variants */
.cheer-particle.sprite-0 {
  background-position: 0 0;
}

.cheer-particle.sprite-1 {
  background-position: 100% 0;
}

.cheer-particle.sprite-2 {
  background-position: 0 100%;
}

.cheer-particle.sprite-3 {
  background-position: 100% 100%;
}


@keyframes cheerPop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  10% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }

  15% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  80% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -60%) scale(0.9);
    opacity: 0;
  }
}


@keyframes cheerExplode {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(720deg);
    opacity: 0;
  }
}


.craftBtn {
  border-radius: 0px;
  padding: 14px 24px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 0;
  background: var(--acc);
  color: #FFFFFF;
  box-shadow: none;
  transition: all .2s ease;
  cursor: pointer;
}

.craftBtn:hover {
  transform: translateY(-2px);
  background: #000;
}

.craftBtn[hidden] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(.98)
}

@keyframes slotNudge {
  0% {
    transform: translate(calc(var(--nX)*-0.05), calc(var(--nY)*-0.05));
    opacity: .8
  }

  50% {
    transform: translate(calc(var(--nX)*0.05), calc(var(--nY)*0.05));
    opacity: .8
  }

  100% {
    transform: translate(calc(var(--nX)*-0.05), calc(var(--nY)*-0.05));
    opacity: .8
  }
}

.slot[data-craft="active"] .thumb,
.slot[data-craft="active"] .tagbox,
.slot[data-craft="active"] .capText {
  animation: slotNudge .9s ease-in-out infinite;
  will-change: transform, opacity
}

.slot[data-craft="active"] .slotHeader {
  display: none;
}

/* Altar Content (New Structure) */
.altar-instructions {
  text-align: center;
  padding: 10px 20px;
  color: var(--muted);
}

.instr-title {
  font-size: 14px;
  margin-bottom: 10px;
}

.instr-subtitle {
  font-size: 12px;
  opacity: 0.7;
}

.altar-slot {
  min-height: 80px;
  border: 2px dashed var(--edge);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  margin: 8px;
}

.altar-inspo {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.altar-inspo:hover {
  background: rgba(255, 255, 255, 0.1);
}

.altar-inspo .remove {
  opacity: 0.5;
  font-size: 24px;
}

.altar-inspo:hover .remove {
  opacity: 1;
}

.inspo-thumb-wrapper {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inspo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.inspo-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  border-radius: 4px;
}

/* Specific Pill Colors */
.pill.vibe {
  background: rgba(255, 107, 107, 0.2);
  border-color: #ff6b6b;
}

.pill.texture {
  background: rgba(78, 205, 196, 0.2);
  border-color: #4ecdc4;
}

.pill.era {
  background: rgba(255, 230, 109, 0.2);
  border-color: #ffe66d;
}

.pill.nature {
  background: rgba(149, 225, 211, 0.2);
  border-color: #95e1d3;
}

.pill.art {
  background: rgba(199, 125, 255, 0.2);
  border-color: #c77dff;
}

.pill.architecture {
  background: rgba(248, 177, 149, 0.2);
  border-color: #f8b195;
}

.spawnCard .cap {
  padding: 8px;
  font-weight: 800
}

/* Legacy spawnCard - UNUSED in app.js */

.mcard {
  background: var(--card);
  border-radius: 0px;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
  border: 1px solid var(--edge);
  transition: border-color 0.2s ease;
  /* Anchor tag reset for <a class="mcard"> */
  display: block;
  text-decoration: none;
  color: inherit;
}

.mcard:hover {
  border-color: var(--ink);
}

.mcard img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  background: #0a0b10;
  pointer-events: none;
  -webkit-user-drag: none;
}

.mcard .placeholder {
  width: 100%;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
}

.mcard.held {
  filter: saturate(.3) brightness(.9);
  opacity: .6;
  pointer-events: none
}

.mcap {
  padding: 8px
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px
}

.seeBtn {
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 700;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer
}

/* Bottom Tray - takes remaining space */
.sheet {
  flex: 1;
  min-height: 200px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--edge);
  backdrop-filter: blur(16px);
  z-index: 50;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheetBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 6px 2px;
  position: relative;
}

.tabs {
  display: flex;
  gap: 8px;
  padding-top: 10px
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab .count {
  opacity: .9
}

.tab.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.chev {
  --size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 2px;
  border: 1px solid var(--edge);
  background: var(--card);
  color: var(--muted);
  font-weight: 900;
  font-size: 14px;
  font-family: var(--font-heading);
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 5;
}

.chev:active {
  transform: translateY(1px);
}

.filters {
  display: none;
  gap: 8px;
  padding: 6px 2px 8px 2px;
  flex-wrap: wrap
}

.filters.on {
  display: flex
}

.chip {
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid var(--edge);
  background: var(--card);
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip {
  padding: 8px 16px;
  border-radius: 0px;
  border: 1px solid var(--edge);
  background: #FFFFFF;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.trayBody {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 2px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.trayPage {
  display: none
}

.trayPage.on {
  display: block
}

.gridTray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 20vh;
}

/* Explicitly revert "Fits" tab (Access Closet) to 2 cols on mobile, 3 on desktop */
#trayClosetGrid {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width:760px) {
  .gridTray {
    grid-template-columns: repeat(4, 1fr)
  }

  /* Fits grid desktop override */
  #trayClosetGrid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.dragGhost {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  width: 140px;
  z-index: 1000;
  pointer-events: none;
  opacity: .95;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .45));
  transition: opacity .08s linear
}

.dragGhost .gcard {
  background: var(--card);
  border-radius: 2px;
  overflow: hidden
}

.dragGhost img {
  width: 100%;
  height: auto;
  aspect-ratio: 1/1;
  object-fit: cover;
  background: #0a0b10;
  display: block
}

.dragGhost .pad {
  padding: 6px
}

.dragGhost .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #cbd5e1
}

.dragGhost .badge {
  border: 1px solid var(--edge);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  color: #cbd5e1;
  background: #1a1b22
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px) saturate(1.1);
  z-index: 800;
  padding: 24px;
}

.modal.on {
  display: flex
}

.panel {
  width: 100%;
  max-width: 1100px;
  height: 95vh;
  overflow-y: auto;
  background: #FFFFFF;
  border-radius: 0;
  border: 1px solid var(--edge);
  box-shadow: none;
  display: flex;
  flex-direction: row;
  position: relative;
}

/* Responsive Panel */
@media (max-width: 768px) {
  .panel {
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
  }
}

/* Full Card Layout */
.fullCard {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

@media (max-width: 768px) {
  .fullCard {
    flex-direction: column;
    overflow-y: auto;
  }
}

/* Full Content Container (scrollable right pane) */
.full {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 768px) {
  .full {
    padding: 20px;
  }
}

.cardHero {
  flex: 0 0 50%;
  position: relative;
  border-radius: 0;
  overflow: hidden;
  background: #F4F4F4;
  min-height: 300px;
}

.cardHero .placeholder {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  /* Match .mcard img aspect ratio if needed, or fill container */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  /* Larger font for hero */
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
}

@media (max-width: 768px) {
  .cardHero {
    flex: 0 0 auto;
    width: 100%;
    max-height: 50vh;
  }
}

.cardHero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.heroMeta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  color: #FFFFFF;
}

/* Override pill in heroMeta to be visible on gradient */
.heroMeta .pill {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

/* Close button in top-right corner of modal panel */
.panel .modalClose {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 810;
  background: #FFFFFF;
  border: 1px solid var(--edge);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  font-size: 16px;
  transition: all 0.2s ease;
  /* Anchor tag reset */
  text-decoration: none;
}

.panel .modalClose:hover {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.heroTitle {
  display: grid;
  gap: 6px;
}

.heroTitle .name {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #FFFFFF;
}

.heroTitle .epi {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-body);
  font-style: italic;
}

.fullSection {
  padding: 20px;
  background: #F8F8F8;
  border-radius: 2px;
}

.fullSection h4 {
  margin: 0 0 12px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 700;
}

.kvGrid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.kv {
  display: grid;
  gap: 4px;
}

.kv .k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-body);
}

.kv .v {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  font-family: var(--font-body);
}

.statRow {
  display: grid;
  gap: 8px;
}

.statChip {
  display: grid;
  gap: 4px;
}

.statChip .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 500;
}

.statChip .bar {
  width: 100%;
  height: 4px;
  border-radius: 0;
  background: #EEE;
  border: 0;
  overflow: hidden;
}

.statChip .bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ink);
}

.tagWrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tagWrap .pill {
  background: #F8F8F8;
  border: 1px solid var(--edge);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 6px 10px;
}

/* Allow pill text in kvGrid to wrap onto multiple lines */
.kvGrid .kv .tagWrap .pill {
  white-space: normal;
  word-break: break-word;
}



.modal .panel {
  -webkit-overflow-scrolling: touch;
}

.modal .mcard,
.modal .mcard img,
.modal .fullCard,
.modal .lineageStrip {
  touch-action: pan-y;
}

.mcard.mini .mcap .row .seeBtn {
  display: none;
}

.full {
  padding: 14px
}

.fullHeader {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(23, 26, 36, .9), rgba(16, 19, 28, .9))
}

.fullHeader .name {
  font-size: 18px;
  font-weight: 800
}

.fullHeader .type {
  font-size: 12px;
  color: #cbd5e1
}

.section {
  margin-top: 12px
}

.section h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #9aa0a6
}

.list {
  display: grid;
  gap: 6px
}

.abilityRow {
  display: grid;
  gap: 4px
}

.metaRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px
}

/* Toast & Fatal */
.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  background: #151622;
  border: 1px solid var(--edge);
  padding: 12px 20px;
  border-radius: 12px;
  color: #cbd5e1;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 1001;
  backdrop-filter: blur(8px);
}

.toast.big-toast {
  top: 80px;
  /* Bit lower than standard toast to avoid header overlap if sticky */
  transform: translateX(-50%);
  width: auto;
  min-width: 280px;
  padding: 24px;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(17, 17, 17, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 20000;
}

.toast.big-toast .toast-img {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  background: #222;
}

.toast.big-toast .toast-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.toast.big-toast .toast-meta {
  font-size: 13px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.toast[data-on="true"] {
  opacity: 1
}

.fatal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(8, 10, 16, .9);
  z-index: 999;
  color: #fff;
  padding: 24px;
  text-align: center
}

.fatal.on {
  display: grid
}

.fatal .box {
  max-width: 560px;
  border: 1px solid var(--edge);
  background: #0f121b;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .4)
}

/* ================= SHOP (Full Page) ================= */
.shop {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 900;
  background: linear-gradient(282deg, rgba(207, 207, 207, 1) 1.26%, rgb(247, 247, 247) 17.65%, rgb(234, 234, 234) 33.61%, rgb(213, 213, 213) 47.9%, rgba(247, 247, 247, 1) 71.01%),
    linear-gradient(210deg, rgba(251, 115, 233, 0.10), rgba(149, 255, 204, 0.10));
  backdrop-filter: blur(10px) saturate(1.05);
  color: var(--ink);
}

.shop.on {
  display: block;
}

.shopWrap {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  padding: 12px;
  gap: 12px;
}

.shopBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--edge);
  background: #0f121b;
  border-radius: 2px;
}

.shopTabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shopClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 2px;
  border: 1px solid var(--edge);
  background: #161720;
  color: #cbd5e1;
  font-weight: 900;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.shopBody {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.gridShop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 20vh;
}

@media (min-width:760px) {
  .gridShop {
    grid-template-columns: repeat(4, 1fr);
  }
}

.buyBtn {
  border-radius: 10px;
  border: 0px solid #ebebeb;
  background: linear-gradient(316deg, #cc2fe1, rgb(215, 195, 239) 37.82%, rgb(192, 235, 218) 64.71%, #00962f);
  color: #1d1d1d;
  font-weight: 800;
  padding: 6px 12px;
  font-size: 20px;
  width: 100%;
  cursor: pointer;
}

.getMoreWrap {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.getMoreBtn {
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
}

/* Big "Get more" as a card */
.mcard.getMoreCard .getMorePad {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--edge);
  background: radial-gradient(520px 260px at 50% -60px, #1a1b22 0%, #0e0f15 60%);
}

.getMoreBigBtn {
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 900;
  border: 1px solid #334155;
  background: #0f121b;
  color: #e2e8f0;
  font-size: 18px;
  cursor: pointer;
}

.getMoreHint {
  margin-top: 6px;
  color: #cbd5e1;
  opacity: .9;
  font-size: 12px;
}

/* ===== Crafting Overlay & Animations ===== */
.craftOverlay {
  position: fixed;
  pointer-events: none;
  z-index: 70;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
}

.craftOverlay .layer {
  position: absolute;
  will-change: transform, opacity, left, top;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .45));
}

.craftOverlay .layer .thumb,
.craftOverlay .layer .tagbox {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  border: 1px solid var(--edge);
  overflow: hidden;
  display: block;
  background: #0a0b10;
}

.craftOverlay .layer.top {
  z-index: 2;
}

.craftOverlay .layer.bottom {
  z-index: 1;
}

.craftOverlay .orbitA {
  animation: craftOrbitA 1.6s ease-in-out infinite alternate;
}

.craftOverlay .orbitB {
  animation: craftOrbitB 1.6s ease-in-out infinite alternate;
}

@keyframes craftOrbitA {
  0% {
    transform: translate(-6px, -2px) rotate(0.001deg);
  }

  50% {
    transform: translate(6px, 4px) rotate(0.001deg);
  }

  100% {
    transform: translate(-4px, 6px) rotate(0.001deg);
  }
}

@keyframes craftOrbitB {
  0% {
    transform: translate(5px, -4px) rotate(0.001deg);
  }

  50% {
    transform: translate(-5px, 4px) rotate(0.001deg);
  }

  100% {
    transform: translate(3px, -6px) rotate(0.001deg);
  }
}

/* Runtime CSS hook for spawn reservation */
.mcard.spawningHide {
  visibility: hidden;
}

/* ===== Recipe strip in full card ===== */
.recipeStrip {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
}

.recipeStrip>* {
  flex: 1 1 0;
  min-width: 0;
}

.recipeStrip .mcard {
  position: relative;
  border-radius: 2px;
}

.recipeStrip .mcard .thumb {
  filter: sepia(1) saturate(.9) contrast(1.05);
  /* sepia look */
}

.recipeCard .mcap {
  padding: 6px;
}

.recipeCard strong {
  font-size: 12px;
}

.recipeBadge,
.typeBadge,
.phaseBadge {
  position: absolute;
  left: 6px;
  top: 6px;
  width: fit-content;
  min-width: 22px;
  padding-left: 6px;
  padding-right: 6px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 12px;
  color: #e8eaed;
  background: #0f121b;
  border: 1px solid var(--edge);
  z-index: 2;
  text-transform: uppercase;
}

/* Larger pill variant for milestone on hero header */
.phaseBadge.big {
  height: 24px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: 999px;
  left: 8px;
  top: 8px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
}

/* Ghost next-step card in recipe strip */
.recipeCard.ghostAction {
  border: 1px dashed var(--edge);
  background: #0d0f16;
  opacity: .9;
  cursor: pointer;
}

.recipeCard.ghostAction .mcap {
  padding: 10px;
}

.recipeCard.ghostAction .hintLine {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  color: #cbd5e1;
}

.recipeCard.ghostAction .hintLine strong {
  color: #e8eaed;
}

.recipeCard.ghostAction:hover {
  filter: brightness(1.05);
}

.recipeLink {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

/* Shop focus flash when jumping from recipe */
@keyframes flashFocus {
  0% {
    box-shadow: 0 0 0 0 rgba(119, 255, 163, 0.00);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(119, 255, 163, 0.35);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(119, 255, 163, 0.00);
  }
}

.gridShop .mcard.flash {
  animation: flashFocus 1.2s ease-in-out 2;
}

/* Soft glow for newly acquired inspos */
@keyframes newInspoGlow {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(180, 140, 255, 0);
  }

  50% {
    box-shadow: 0 0 20px 4px rgba(180, 140, 255, 0.5);
  }
}

.mcard.new-inspo-glow {
  animation: newInspoGlow 2.4s ease-in-out 3;
}

/* Discoverer Badge - positioned in modal header between share and close buttons */
.panel .discoverer-badge {
  position: absolute;
  top: -44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 16px;
  margin: 0;
  font-size: 12px;
  text-align: center;
  background: #FFFFFF;
  border: 1px solid var(--edge);
  border-radius: 20px;
  color: var(--muted);
  white-space: nowrap;
}

.panel .discoverer-badge.you {
  background: linear-gradient(135deg, rgba(120, 80, 180, 0.15), rgba(80, 40, 120, 0.15));
  border-color: rgba(120, 80, 180, 0.4);
  color: #7c3aed;
  font-weight: 600;
}

/* Discoverer badge as link */
.panel a.discoverer-badge {
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.panel a.discoverer-badge:hover {
  background: #f0f0f0;
  transform: translateX(-50%) scale(1.02);
}

/* ================= PROFILE PAGE ================= */
.profile-hero {
  text-align: center;
  padding-top: 30px;
  padding-right: 20px;
  padding-bottom: 26px;
  padding-left: 20px;
  background: #FFFFFF;
}

.profile-name {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--ink);
  font-family: var(--font-heading);
}

.profile-stat {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 14px;
}

.profile-fits {
  max-width: 900px;
  margin: 0 auto 32px;
}

.profile-loading,
.profile-error {
  padding: 60px 24px;
  color: var(--muted);
}

.profile-error h2 {
  margin: 0 0 12px;
  color: var(--ink);
}

.profile-error p {
  margin: 0 0 24px;
}

.back-link {
  display: inline-block;
  margin-top: 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--ink);
}

.no-fits {
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 40px;
}


/* ================= WELCOME HERO (Slop Edition) ================= */
/* SLOP NOISE OVERLAY */
.slop-noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='1'/%3E%3C/svg%3E");
}

/* HERO BACKGROUND ANIMATION */
@keyframes aurora {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.welcome-hero {
  text-align: center;
  padding: 80px 16px 60px;
  background: linear-gradient(-45deg, #e0e0e0, #ffffff, #d4d4d4, #f0f0f0);
  background-size: 400% 400%;
  animation: aurora 15s ease infinite;
  border-radius: 0;
  margin: 0;
  border: 0;
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Was center */
  align-items: center;
  flex: 1;
  position: relative;
  overflow: visible;
  /* Changed to visible to let elements break out */
}

.welcome-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: clamp(50px, 10vw, 130px);
  /* Smaller max size */
  line-height: 0.8;
  letter-spacing: -0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 16px;
  /* Reduced margin */
  transform: scaleY(1.1);
  /* Condensed look */
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.05);
}

.welcome-tagline {
  font-family: var(--font-heading);
  /* Switch to heading font for sharper impact */
  font-weight: 700;
  font-size: clamp(12px, 2.5vw, 16px);
  letter-spacing: 0.1em;
  color: var(--ink);
  background: var(--ink);
  color: white;
  display: inline-block;
  padding: 4px 12px;
  transform: rotate(-2deg);
  margin: 0 auto 24px;
  /* Reduced margin */
  text-transform: uppercase;
}

.showcase-image .placeholder .slop-emoji {
  /* transform: scale(3.5); Removed to avoid blur/clipping issues */
  font-size: 80px !important;
  line-height: 1;
}

.showcase-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =================== Song Manifestos (Embeds) =================== */
.gala-live {
  width: 100%;
  max-width: 900px;
  margin: 60px auto 100px;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  overflow: visible;
}

.live-title {
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  padding: 0;
  margin: 0 0 24px;
  text-align: center;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-transform: uppercase;
}

.blink {
  animation: blinker 1s linear infinite;
  color: var(--acc);
  font-size: 0.8em;
  vertical-align: middle;
}

.blink {
  animation: blinker 1s linear infinite;
  color: red;
}

@keyframes blinker {
  50% {
    opacity: 0;
  }
}

.tape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  justify-content: center;
}

@media (max-width: 600px) {
  .tape-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

.tape-wrapper {
  position: relative;
  width: 100%;
  max-width: 325px;
  /* Match standard mobile embed width to avoid overflow/white bars */
  margin: 0 auto;
  /* aspect-ratio: 9 / 16; Removed to match natural embed height */
  height: auto;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  mix-blend-mode: multiply;
  /* overflow: hidden; Removed to avoid clipping */
}

/* Explicit clean override for the blockquote before/after JS loads */
.tiktok-embed {
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 8px !important;
  overflow: hidden;
  background: transparent !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Clean Embed Rule for TikTok */
.tape-wrapper iframe {
  width: 100% !important;
  /* Remove height override so TikTok script can set inline height.
     Also removing aspect-ratio so it doesn't force anything. */
  border-radius: 4px;
  box-shadow: none !important;
  border: 0 !important;
  background: transparent;
  display: block;
}

/* CTA */
.cta-btn.glitch-btn {
  margin-top: 40px;
  background: var(--acc);
  color: white;
  border: 3px solid var(--ink);
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 24px;
  padding: 20px 40px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  border-radius: 0;
  box-shadow: 6px 6px 0px var(--ink);
  transition: all 0.1s;
  cursor: pointer;
}

.cta-btn.glitch-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 4px 4px 0px var(--ink);
  background: #ff3333;
}

.cta-btn .slop-emoji {
  filter: invert(1);
  /* Make emoji white */
  margin-left: 8px;
}

.welcome-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.welcome-features .feature {
  background: #F8F8F8;
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-body);
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 32px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 2px;
  background: var(--ink);
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cta-btn:hover {
  transform: translateY(-2px);
  background: var(--acc);
  color: #FFFFFF;
}

.cta-btn:active {
  transform: translateY(0);
}

/* Preview section for featured fits */
.preview-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--edge);
}

.preview-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.preview-card {
  aspect-ratio: 1;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--edge);
  background: #FFFFFF;
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.preview-card:nth-child(1) {
  animation-delay: 0.1s;
}

.preview-card:nth-child(2) {
  animation-delay: 0.2s;
}

.preview-card:nth-child(3) {
  animation-delay: 0.3s;
}

.preview-card:nth-child(4) {
  animation-delay: 0.4s;
}

.preview-card:nth-child(5) {
  animation-delay: 0.5s;
}

.preview-card:nth-child(6) {
  animation-delay: 0.6s;
}

.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-card .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #F4F4F4;
  font-size: 24px;
}

/* Unlogged tray state */
.sheet.unlogged {
  background: linear-gradient(210deg, rgba(100, 80, 160, 0.95), rgba(60, 40, 100, 0.95));
}

.unlogged-tray-content {
  text-align: center;
  padding: 20px;
  color: #e5e7eb;
}

.unlogged-tray-content h3 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 800;
}

.unlogged-tray-content p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 16px;
}

.browse-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.browse-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Login required shop button */
.buyBtn.loginRequired {
  background: linear-gradient(135deg, #5865F2, #7289DA);
  color: #fff;
  font-size: 14px;
}

.buyBtn.loginRequired:hover {
  filter: brightness(1.1);
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 4px 20px rgba(88, 101, 242, 0.4);
  }

  50% {
    box-shadow: 0 4px 30px rgba(88, 101, 242, 0.6);
  }
}

.cta-btn.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ================= SHOWCASE FIT (Unlogged Experience) ================= */
.showcase-section {
  margin-bottom: 24px;
}

.showcase-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
}

.showcase-fit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.showcase-image {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: var(--card);
  animation: fadeInUp 0.6s ease-out;
}

.showcase-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.showcase-image .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1a1b22, #0e0f15);
  font-size: 48px;
}

.showcase-name {
  font-size: 20px;
  font-weight: 800;
  color: #e5e7eb;
  text-align: center;
}

.showcase-recipe {
  width: 100%;
  margin-top: 8px;
}

.showcase-recipe .recipe-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  text-align: center;
}

.recipe-inspos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.recipe-inspo {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--edge);
  border-radius: 8px;
  font-size: 11px;
  color: #cbd5e1;
  animation: fadeInUp 0.4s ease-out backwards;
}

.recipe-inspo:nth-child(1) {
  animation-delay: 0.1s;
}

.recipe-inspo:nth-child(2) {
  animation-delay: 0.2s;
}

.recipe-inspo:nth-child(3) {
  animation-delay: 0.3s;
}

.recipe-inspo:nth-child(4) {
  animation-delay: 0.4s;
}

.recipe-inspo .inspo-thumb-wrapper {
  width: 60px;
  height: 60px;
}

.recipe-inspo .inspo-icon {
  width: 12px;
  height: 12px;
  font-size: 7px;
}

.recipe-inspo .inspo-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.showcase-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--muted);
}

.showcase-loading .placeholder {
  font-size: 48px;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Showcase Grid & Cards (Moved from app.js) */
.showcase-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 40px;
  width: 100%;
  flex: 1;
}

@media (min-width: 768px) {
  .showcase-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.showcase-card {
  background: #FFFFFF;
  border: 1px solid var(--edge);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.showcase-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border-color: var(--ink);
}

.showcase-card .showcase-image {
  width: 100%;
  max-width: none;
  aspect-ratio: 3/4;
  background: #F8F8F8;
  position: relative;
}

.showcase-card .showcase-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.showcase-card .showcase-image .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 48px;
  opacity: 0.5;
}

.showcase-meta {
  padding: 12px;
  text-align: left;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.showcase-name {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 4px;
}

.showcase-card .showcase-recipe {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--edge);
}

/* Altar Animations & Mini Cards */
.mcard.mini {
  /* Explicit sizing instead of scale hack */
  width: 90px;
  flex: 0 0 auto;
  margin: 0;
  font-size: 11px;
}

.mcard.mini .thumb {
  border-radius: 8px;
  /* Tighter radius for mini */
}

/* Ensure mini cards fit nicely in the flex/grid layout */
.altar-slot {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px !important;
  /* Proper gap */
  min-height: 120px !important;
  padding: 10px;
}

.mcard.mini .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.mcard.mini:hover .remove-btn {
  background: var(--bad);
  border-color: var(--bad);
  transform: scale(1.1);
}

@keyframes popOut {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
  }

  100% {
    transform: scale(0.4);
    opacity: 0;
    filter: blur(4px);
  }
}

@keyframes popIn {
  0% {
    transform: scale(0.4);
    opacity: 0;
    filter: blur(4px);
  }

  60% {
    transform: scale(1.1);
    opacity: 1;
    filter: blur(0);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.anim-out {
  animation: popOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.anim-in {
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Override existing altar styles for the new card based approach */
.altar-slot .mcard {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.altar-slot .mcard:hover {
  transform: translateY(-2px);
  z-index: 5;
  filter: brightness(1.1);
}

/* Share button aligned with close button */
.panel .modalShare {
  position: absolute;
  top: -48px;
  left: 0;
  z-index: 10;
  background: #FFFFFF;
  border: 1px solid var(--edge);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 16px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.panel .modalShare:hover {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

/* ================= GALA PORTRAIT FEATURE ================= */

/* Gala button in closet cards */
.gala-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #c77dff, #9d4edd);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  /* Anchor tag reset */
  text-decoration: none;
}

.gala-btn:hover {
  background: linear-gradient(135deg, #e0aaff, #c77dff);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(157, 78, 221, 0.4);
}

.gala-row {
  justify-content: flex-start;
}

/* Gala modal styling */
.gala-modal {
  padding: 32px;
  max-width: 500px;
  margin: 0 auto;
}

.gala-modal h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--ink);
  font-family: var(--font-heading);
}

.gala-desc {
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.6;
}

.gala-section {
  margin-bottom: 24px;
}

.gala-section h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}

.gala-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.gala-portraits-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gala-portrait-option {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--edge);
  transition: all 0.2s ease;
}

.gala-portrait-option:hover {
  border-color: var(--acc);
  transform: scale(1.05);
}

.gala-portrait-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gala-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 20px 0;
  position: relative;
}

.gala-divider::before,
.gala-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--edge);
}

.gala-divider::before {
  left: 0;
}

.gala-divider::after {
  right: 0;
}

.gala-upload-input {
  display: none;
}

.gala-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  background: var(--ink);
  color: #fff;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gala-upload-btn:hover {
  background: var(--acc);
}

.gala-generating {
  text-align: center;
  padding: 40px 0;
}

.gala-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--edge);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.gala-generating p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.gala-result {
  text-align: center;
  padding: 20px 0;
}

.gala-result img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--edge);
  margin-bottom: 16px;
}

.gala-success {
  color: var(--ok);
  font-weight: 700;
  font-size: 14px;
  margin: 0;
}

.gala-error {
  text-align: center;
  padding: 24px 0;
}

.gala-error-msg {
  color: var(--bad);
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 8px;
}

.gala-privacy {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--edge);
}

.gala-privacy a {
  color: var(--muted);
  text-decoration: underline;
}

.gala-modal h2 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 24px;
  line-height: 1;
  margin-bottom: 0;
}

.gala-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.gala-header-card {
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gala-header-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* At the Gala section in detail view */
.gala-section-detail {
  background: linear-gradient(135deg, rgba(199, 125, 255, 0.1), rgba(157, 78, 221, 0.1));
  border: 1px solid rgba(157, 78, 221, 0.2);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.gala-section-detail h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #7c3aed;
}

.gala-section-detail .gala-thumbs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.gala-section-detail .gala-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(157, 78, 221, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.gala-section-detail .gala-thumb:hover {
  transform: scale(1.1);
  border-color: #7c3aed;
}

.gala-section-detail .gala-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Gala Modal Improvements */
.gala-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.gala-option {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  background: var(--surface-2);
}

/* removed hover transform */

.gala-option.selected {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.gala-option.ghost {
  border: 2px dashed rgba(124, 58, 237, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.05);
}

.gala-option.ghost:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: #7c3aed;
}

.gala-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gala-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: none;
  padding: 0;
}


.gala-delete-btn:hover {
  transform: scale(1.15);
  background: var(--bad);
}

.gala-delete-btn.confirm {
  width: auto;
  height: auto;
  padding: 5px 10px;
  border-radius: 4px;
  background: var(--acc);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.02em;
  transform: none;
  box-shadow: none;
}

.gala-plus {
  font-size: 24px;
  margin-bottom: 4px;
}

.gala-upload-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.gala-create-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #7c3aed, #9d4edd);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  transition: all 0.2s ease;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.gala-create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--surface-3);
  color: var(--muted);
}

.gala-create-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

/* Gala Credit Warning/Info */
.gala-credit-warning {
  margin: 12px 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ff6b6b22 0%, #ee5a3522 100%);
  border: 1px solid #ff6b6b55;
  border-radius: 8px;
  color: #d63031;
  font-size: 13px;
  text-align: center;
}

.gala-credit-info {
  margin: 12px 0;
  padding: 10px 14px;
  background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
  border: 1px solid #667eea44;
  border-radius: 8px;
  color: #5f27cd;
  font-size: 12px;
  text-align: center;
}

/* Buy Credits Button in Gala */
.gala-buy-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: #fff !important;
  cursor: pointer !important;
  opacity: 1 !important;
}

.gala-buy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

/* Gala Lightbox Gallery */
.gala-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: gala-lb-fade-in 0.2s ease;
}

@keyframes gala-lb-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.gala-lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.gala-lb-close:hover {
  opacity: 1;
}

.gala-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 48px;
  cursor: pointer;
  padding: 16px 24px;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
  border-radius: 8px;
}

.gala-lb-nav:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.gala-lb-prev {
  left: 16px;
}

.gala-lb-next {
  right: 16px;
}

.gala-lb-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gala-lb-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
}

.gala-lb-counter {
  color: white;
  font-size: 14px;
  margin-top: 12px;
  opacity: 0.7;
}

.gala-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #7c3aed, #9d4edd);
  color: white;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  /* Anchor tag reset */
  text-decoration: none;
}

.gala-cta-btn:hover {
  transform: translateY(-2px);
}

/* Gala portrait overlay on closet cards */
.gala-overlay {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

.gala-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =================== Profile Pages =================== */
/* Profile Pages */
.profile-page {
  max-width: 960px;
  width: 100%;
  /* Constrain width to prevent overflow */
  margin: 0 auto;
  padding: 24px 16px;
  min-height: calc(100svh - 58px);
}

.profile-hero {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}



.profile-badge {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(230, 0, 35, 0.1);
  border: 1px solid var(--acc);
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--acc);
  margin-bottom: 12px;
}

.profile-name {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

@media (max-width: 520px) {
  .profile-name {
    font-size: 24px;
  }
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 800;
  color: var(--acc);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.profile-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-share-btn:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

/* My Profile button in header */
.my-profile-btn {
  display: none;
  /* Hidden by default, shown when logged in */
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.my-profile-btn:hover {
  border-color: var(--ink);
  background: rgba(17, 17, 17, 0.05);
}

.my-profile-btn svg {
  stroke: var(--ink);
}

@media (max-width: 520px) {
  .my-profile-btn {
    padding: 4px 8px;
  }

  .my-profile-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Profile Tabs */
.profile-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--edge);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* Firefox */
}

@media (max-width: 520px) {
  .profile-tabs {
    gap: 2px;
  }
}

.profile-tabs::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari */
}

.profile-tab {
  flex-shrink: 0;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .profile-tab {
    padding: 8px 6px;
    font-size: 12px;
  }
}

.profile-tab:hover {
  color: var(--ink);
}

.profile-tab.active {
  color: var(--ink);
  border-bottom-color: var(--acc);
}

.profile-tab .tab-count {
  margin-left: 6px;
  padding: 2px 6px;
  background: rgba(17, 17, 17, 0.1);
  border-radius: 2px;
  font-size: 11px;
}

.profile-tab.active .tab-count {
  background: rgba(230, 0, 35, 0.1);
  color: var(--acc);
}

/* Tab Content - CSS-only show/hide for instant switching */
.profile-tab-content {
  position: relative;
  min-height: 400px;
}

.profile-tab-panel {
  display: none;
  /* Hidden by default */
}

.profile-tab-panel.active {
  display: block;
  /* Instant show when active */
}

/* Profile Grids */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
  /* Padding removed to align with tabs (page has padding) */
}

@media (max-width: 760px) {
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* Prevent overflow with minmax */
  }
}

@media (max-width: 480px) {
  .profile-grid {
    gap: 12px;
  }
}

/* Profile Fit Cards */
.profile-fit-card {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-fit-card:hover {
  transform: translateY(-4px);
  border-color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.profile-fit-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.profile-fit-card .placeholder {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
}

.profile-fit-name {
  padding: 10px;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.discovery-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 215, 0, 0.95);
  border-radius: 50%;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Profile Gala Cards */
.profile-gala-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-gala-card:hover {
  transform: translateY(-4px);
  border-color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.profile-gala-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}

.profile-gala-card .placeholder {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
}

/* Profile Inspo Section */
.profile-inspo-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.profile-inspo-section h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.profile-inspo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 760px) {
  .profile-inspo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .profile-inspo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

.profile-inspo-card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 2px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.profile-inspo-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.profile-inspo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.profile-inspo-card .placeholder {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, #f8f8f8, #e8e8e8);
  color: var(--muted);
}

.profile-inspo-name {
  padding: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-inspo-count {
  padding: 0 8px 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Empty States */
.profile-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

.profile-loading {
  text-align: center;
  padding: 100px 20px;
}

.profile-loading .placeholder {
  font-size: 64px;
  margin-bottom: 16px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.profile-loading p {
  color: var(--muted);
  font-size: 14px;
}

.profile-error {
  text-align: center;
  padding: 100px 20px;
}

.profile-error h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 12px;
}

.profile-error p {
  color: var(--muted);
  margin-bottom: 24px;
}

/* --- Profile Improvements & Creating Gold Badge --- */

/* Reduce Profile Hero Top Space */
.profile-page {
  padding-top: 0;
}

.profile-hero {
  margin-bottom: 6px;
  margin-top: -10px;
}

/* Gold Badge Icon Stack */
.icon-stack-discovery {
  position: absolute;
  top: -12px;
  right: 36px;
  width: 48px;
  height: 48px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-stack-discovery .slop-emoji.crafted-first {
  width: 100%;
  height: 100%;
}

.icon-stack-discovery span {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  line-height: 1;
  user-select: none;
}

.stack-base {
  /* Scissors ✂️ */
  transform: translate(-28%, -75%) rotate(243deg);
  font-size: 24px;
  z-index: 1;
}

.stack-mid {
  /* Needle 🪡 */
  transform: translate(-80%, -80%);
  font-size: 24px;
  z-index: 2;
  margin-top: -2px;
}

.stack-top {
  /* Dizzy 💫 */
  /* Hiding the dizzy emoji */
  opacity: 0;
  transform: translate(-50%, -50%);
  font-size: 18px;
  z-index: 3;
  margin-top: -12px;
  margin-left: 10px;
}

/* =================== Profile Layout Overrides =================== */
/* Fix main scrolling and height for logged-in profile pages */
body.profile-layout main {
  height: auto !important;
  min-height: calc(100svh - 58px);
  overflow: visible !important;
  display: flex !important;
}

/* Ensure no tray elements interfere */
body.profile-layout .altar,
body.profile-layout .sheet {
  display: none !important;
}

/* Profile Name Row - share button inline with name */
.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-name-row .profile-name {
  margin: 0;
}

.profile-name-row .profile-share-btn {
  margin: 0;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--edge);
}

.profile-name-row .profile-share-btn:hover {
  border-color: var(--ink);
}

/* Profile Places Tags - Layout D: Compact inline pills */
.profile-places {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 0 0;
  padding: 0 16px;
}

.places-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  font-family: 'Syne', sans-serif;
}

.places-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.place-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--edge);
  white-space: nowrap;
}

.place-tag.eccentric {
  border-color: rgba(156, 39, 176, 0.3);
  color: #9c27b0;
}