/* ============ Reset & Base ============ */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR",
    sans-serif;
  background: linear-gradient(180deg, #0f1217 0%, #07101a 100%);
  color: #e5e7eb;
  min-height: 100vh;
}

/* ============ Layout ============ */
.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(15, 18, 23, 0.8);
  backdrop-filter: blur(8px);
  padding: 16px 72px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.4px;
}

main {
  padding: 24px 72px;
  max-width: 1200px;
  margin: 0 auto;
}

.section {
  margin: 24px 0 56px;
}
.section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
.section-desc {
  color: #9ca3af;
  margin: 0 0 16px;
}

/* ============ Right Bookmarks ============ */
.bookmarks {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 10px;
  z-index: 35;
}
.bookmark {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: #11151b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  border-radius: 10px;
  color: #e5e7eb;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.2s ease;
  cursor: pointer;
}
.bookmark:hover,
.bookmark.active {
  transform: translateX(-2px);
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.3);
}

/* ============ Controls ============ */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.chip {
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:focus {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.chip.active,
.chip:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.search input,
#search {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  padding: 8px 10px;
  border-radius: 8px;
  min-width: 200px;
}
.search input:focus,
#search:focus {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-color: rgba(59, 130, 246, 0.3);
}

/* ============ Back Button ============ */
.collection-controls,
.synthesis-controls {
  margin-bottom: 20px;
}

.btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn.primary {
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  color: #fff;
}
.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}
.btn.primary:disabled {
  background: rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

/* ============ Stamp Grid ============ */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(90px, 1fr)
  ); /* 180px → 90px로 축소 */
  gap: 10px; /* 16px → 10px로 축소 */
  margin-top: 6px;
  grid-auto-rows: auto;
}

.stamp {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px; /* 12px → 8px로 축소 */
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3/4; /*수정부분*/
  height: auto;
  min-height: 40px; /* 120px → 60px로 축소 */
  padding: 0px; /* 패딩 추가 */
}

.stamp:focus,
.stamp:hover {
  transform: translateY(-3px); /* -6px → -3px로 축소 */
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.4);
}

.stamp-art {
  width: 100%;
  height: auto;
  min-height: 40px; /* 80px → 40px로 축소 */
  border-radius: 6px; /* 8px → 6px로 축소 */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.02)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #e5e7eb;
  font-size: 10px; /* 18px → 10px로 축소 */
  margin-bottom: 0px; /* 8px → 4px로 축소 */
  background-size: cover;
  background-position: center;
  transition: filter 0.3s ease;
}

/* 이미지가 있는 경우 비율 유지 */
.stamp-art[style*="background-image"] {
  aspect-ratio: 23.5/34;
  height: auto;
}

/* 이미지가 없는 경우 정사각형 유지 */
.stamp-art:not([style*="background-image"]) {
  aspect-ratio: 1;
  height: 40px; /* 80px → 40px로 축소 */
}

.stamp-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px; /* 12px → 8px로 축소 */
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px; /* 16px → 8px로 축소 */
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
  z-index: 10;
}

.stamp:hover .stamp-overlay,
.stamp:focus .stamp-overlay {
  opacity: 1;
}

.stamp-info > div {
  display: flex;
  text-align: center;
  align-items: center;
  margin: 3px 0; /* 6px → 3px로 축소 */
  opacity: 1;
  visibility: visible;
}

.stamp-title {
  font-size: 12px; /* 14px → 10px로 축소 */
  font-weight: 600;
  justify-content: center;
  color: #ffffff;
}

.stamp-rarity {
  position: absolute;
  bottom: 8px; /* 바닥에서의 거리(px는 자유롭게 조절) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  min-width: 72px; /* 고정된 최소 너비 */
  max-width: 72px; /* 고정된 최대 너비 → 너비 고정 */
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  user-select: none;
  vertical-align: middle;
  margin: 0;
  color: #fff; /* 항상 흰색! */
  background: rgba(22, 22, 26, 0.8); /* 어두운 베이스, glow 부각 */
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); /* 기본은 glow 없음 */
  transition: all 0.3s ease;
}

.stamp.common {
  background: linear-gradient(145deg, #f9fafb, #656566);
  border: 1px solid rgba(107, 114, 128, 0.18); /* 얇은 테두리 */
  color: #4b5563;
  transition: all 0.3s ease;
}

.stamp.common:hover {
  box-shadow: 0 0 22px 4px #f0f4facc,
    /* hover에 더 밝은 glow */ 0 8px 20px rgba(107, 114, 128, 0.15),
    inset 0 1px 3px rgba(255, 255, 255, 0.8);
  border-color: #93a1ba; /* 테두리 살짝 강조 */
}

.stamp.rare {
  background: linear-gradient(135deg, #dbeafe, #3b82f6);
  border: 1px solid #60a5fa; /* 얇은 파랑 테두리 */
  box-shadow: 0 0 16px 3px #60a5fac4,
    /* 푸른 glow */ 0 0 20px rgba(59, 130, 246, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #1e40af;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
  transition: all 0.4s ease;
}

.stamp.rare:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 34px 7px #60a5face, 0 10px 25px rgba(59, 130, 246, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.stamp.epic {
  background: linear-gradient(135deg, #ede9fe, #8b5cf6);
  border: 1px solid #a78bfa; /* 얇은 보라 테두리 */
  box-shadow: 0 0 18px 4px #a78bfad2,
    /* 보라 glow */ 0 0 30px rgba(139, 92, 246, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #5b21b6;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.4);
  animation: epic-glow 3s ease-in-out infinite alternate;
  transition: all 0.4s ease;
}

.stamp.epic:hover {
  border-color: #8b5cf6;
  box-shadow: 0 0 40px 12px #a78bfaf0, 0 15px 35px rgba(139, 92, 246, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.stamp.legendary {
  background: linear-gradient(135deg, #fef3c7, #f59e0b) padding-box,
    linear-gradient(45deg, #fbbf24, #f59e0b, #fbbf24) border-box;
  border: 1px solid #fbbf24; /* 얇은 금색 테두리 */
  box-shadow: 0 0 28px 10px #f59e0bcc,
    /* 금색 glow */ 0 0 40px rgba(251, 191, 36, 0.19),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
  color: #92400e;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5),
    0 0 10px rgba(251, 191, 36, 0.8);
  animation: legendary-shine 2.5s ease-in-out infinite alternate;
  transition: all 0.5s ease;
  position: relative;
  overflow: hidden;
}

.stamp.legendary:hover {
  border-color: #f59e0b;
  box-shadow: 0 0 54px 16px #fbbf24ec, 0 20px 40px rgba(251, 191, 36, 0.4),
    inset 0 3px 6px rgba(255, 255, 255, 0.4);
}

/* 희귀도별 pill glow 효과 (hover 시 더 강하게!) */

/* Common */
.stamp.common .stamp-rarity {
  box-shadow: 0 0 8px #93a1ba;
  color: #fff;
}
.stamp.common:hover .stamp-rarity {
  box-shadow: 0 0 16px 2px #93a1ba, 0 0 32px #fff;
}

/* Rare */
.stamp.rare .stamp-rarity {
  box-shadow: 0 0 10px #3b82f6;
  color: #fff;
}
.stamp.rare:hover .stamp-rarity {
  box-shadow: 0 0 22px 6px #60a5fa, 0 0 38px #3b82f6;
  animation: rarity-pulse-blue 2.1s infinite alternate;
}

/* Epic */
.stamp.epic .stamp-rarity {
  box-shadow: 0 0 12px #8b5cf6;
  color: #fff;
}
.stamp.epic:hover .stamp-rarity {
  box-shadow: 0 0 28px 8px #a78bfa, 0 0 44px #8b5cf6;
  animation: rarity-pulse-purple 2.2s infinite alternate;
}

/* Legendary */
.stamp.legendary .stamp-rarity {
  box-shadow: 0 0 16px #fbbf24;
  color: #fff;
}
.stamp.legendary:hover .stamp-rarity {
  box-shadow: 0 0 36px 8px #fbbf24, 0 0 62px #f59e0b, 0 0 16px #fff;
  animation: rarity-glow-gold 2.8s infinite alternate;
}

/* 애니메이션 (hover에서만 동작) */
@keyframes rarity-pulse-blue {
  0% {
    box-shadow: 0 0 18px #60a5fa, 0 0 22px #3b82f6;
  }
  100% {
    box-shadow: 0 0 28px 8px #60a5fa, 0 0 38px #3b82f6;
  }
}
@keyframes rarity-pulse-purple {
  0% {
    box-shadow: 0 0 22px #a78bfa, 0 0 18px #6d28d9;
  }
  100% {
    box-shadow: 0 0 44px 8px #a78bfa, 0 0 38px #8b5cf6;
  }
}
@keyframes rarity-glow-gold {
  0% {
    box-shadow: 0 0 24px #fbbf24, 0 0 32px #f59e0b;
  }
  100% {
    box-shadow: 0 0 62px 8px #fbbf24, 0 0 82px #f59e0b;
  }
}

/* ============ Collection Sets ============ */
.set-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 6px;
}

.set-card {
  padding: 16px;
  border-radius: 12px;
  background: #151820;
  border: 2px solid #383e47;
  transition: border-color 0.3s;
  margin-bottom: 24px;
}

.set-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(2, 6, 23, 0.4);
}

.set-card h4 {
  margin: 0 0 8px;
  color: #e5e7eb;
  font-size: 16px;
}

.set-card p {
  margin: 4px 0;
  color: #9ca3af;
  font-size: 13px;
}

.set-card .reward {
  color: #fbbf24;
  font-weight: 500;
}

.set-card.completed {
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.1);
}

.collection-stamps-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.collection-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  position: relative;
}

.collection-stamp img {
  /* width: 64px;
  height: 64px; */
  border-radius: 6px;
  object-fit: cover;
  transition: opacity 0.2s;
}
.collection-stamp.owned img,
.collection-stamp.owned div {
  opacity: 1;
  filter: none;
}
.collection-stamp.missing img,
.collection-stamp.missing div {
  opacity: 0.2;
  filter: grayscale(80%);
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 6px 2px rgba(255, 255, 180, 0.4);
  }
  50% {
    box-shadow: 0 0 8px 3px rgba(255, 255, 180, 0.65);
  }
}

.collection-stamp.owned {
  position: relative;
  animation: glow 2s infinite ease-in-out;
  border-radius: 6px;
}

.collection-stamp.owned::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 12px 4px rgba(255, 255, 180, 0.5);
  animation: glow 3s infinite ease-in-out;
  z-index: -1;
}

/* 미보유 텍스트 우표 */
.collection-stamp div {
  width: 48px;
  height: 64px;
  border-radius: 6px;
  background: #111827;
  color: #8b949e;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

/* 컬렉션 진행률 바 */
.collection-progress {
  margin: 8px 0;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: #9ca3af;
}

/* ============ Synthesis Area ============ */
.synthesis-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.owned-stamps,
.recipe-area {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px;
}

.owned-stamps h3,
.recipe-area h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #e5e7eb;
}

.owned-grid,
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
}

.owned-grid::-webkit-scrollbar,
.recipe-grid::-webkit-scrollbar {
  width: 6px;
}

.owned-grid::-webkit-scrollbar-track,
.recipe-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.owned-grid::-webkit-scrollbar-thumb,
.recipe-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* 작은 우표 카드 */
.mini-stamp {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mini-stamp:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}

.mini-stamp.selected {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.1);
}

.mini-stamp .stamp-name {
  font-size: 11px;
  margin-top: 4px;
  color: #9ca3af;
}

.mini-stamp .stamp-count {
  font-size: 10px;
  color: #fbbf24;
  font-weight: 600;
}

/* ============ Compose Box ============ */
.compose-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}

.selected-ingredients h4 {
  margin: 0 0 12px;
  color: #e5e7eb;
}

.ingredient-slots {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.compose-slot {
  width: 100px;
  height: 80px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
  transition: all 0.15s ease;
}

.compose-slot.filled {
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
  border-style: solid;
}

.compose-slot.filled .slot-stamp {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.compose-slot .slot-stamp-name {
  font-size: 10px;
  color: #e5e7eb;
  margin-top: 4px;
}

/* === Synthesis Pentagon Layout=== */
.ingredient-pentagon {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(9, 80);
  gap: 4px;
  column-gap: 6px;
  row-gap: 4px;
  align-items: center;
  justify-items: center;
}

.ingredient-pentagon .compose-slot:nth-child(1) {
  grid-column: 6;
  grid-row: 1;
}
.ingredient-pentagon .compose-slot:nth-child(2) {
  grid-column: 9;
  grid-row: 2;
}
.ingredient-pentagon .compose-slot:nth-child(3) {
  grid-column: 8;
  grid-row: 4;
}
.ingredient-pentagon .compose-slot:nth-child(4) {
  grid-column: 4;
  grid-row: 4;
}
.ingredient-pentagon .compose-slot:nth-child(5) {
  grid-column: 3;
  grid-row: 2;
}

.btn.big {
  font-size: 18px;
  padding: 14px 22px;
}

/* Mini-stamp selected/disabled visuals */
.mini-stamp {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.mini-stamp.selected {
  border-color: #60a5fa; /* blue-400 */
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
  transform: translateY(-2px);
}
.mini-stamp.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Compose slot filled look */
.compose-slot.filled .slot-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.compose-slot.filled {
  border-color: #22c55e; /* green-500 */
}

/* Synthesis success effect */
.synthesis-effect {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 999;
}
.synthesis-burst {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.95),
    rgba(59, 130, 246, 0.4) 60%,
    transparent 70%
  );
  animation: burstFade 900ms ease-out forwards;
  filter: drop-shadow(0 6px 24px rgba(59, 130, 246, 0.6));
}
@keyframes burstFade {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
/* confetti */
.synthesis-confetti {
  position: absolute;
  width: 6px;
  height: 12px;
  top: -20px;
  animation: confettiFall 900ms ease-in forwards;
}
@keyframes confettiFall {
  to {
    transform: translateY(220px) rotate(180deg);
    opacity: 0.1;
  }
}

/* ============ CLEAR 도장 ============ */
.clear-stamp {
  text-align: center;
  margin: 40px 0;
  padding: 24px;
  background: linear-gradient(135deg, #ffd700, #ffa500);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
  animation: clear-pulse 2s ease-in-out infinite alternate;
}

@keyframes clear-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
  }
  100% {
    transform: scale(1.02);
    box-shadow: 0 12px 48px rgba(255, 215, 0, 0.4);
  }
}

.clear-badge {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #7c2d12;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.clear-stamp p {
  margin: 0;
  color: #7c2d12;
  font-weight: 600;
  font-size: 16px;
}

/* ============ 모달 ============ */
.stamp-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stamp-modal.show {
  opacity: 1;
}

.stamp-modal .modal-content {
  background: linear-gradient(
    180deg,
    rgba(15, 18, 23, 0.95),
    rgba(7, 16, 26, 0.95)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.stamp-modal.show .modal-content {
  transform: scale(1);
}

/* X 버튼을 오른쪽 상단에 절대 위치로 고정 */
.stamp-modal .close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 28px;
  font-weight: bold;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
  z-index: 10;
  user-select: none;
}

.stamp-modal .close:hover {
  color: #e5e7eb;
}

.stamp-detail {
  text-align: center;
}

/* 우표 표준 세로형(예시: 80x106px)으로 비율 및 크기 조정 */
.stamp-detail-image {
  width: 90px;
  height: 90px;
  border-radius: 14px;
  object-fit: cover;
  margin: 0 auto 16px auto;
  background: #181d2b;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.11);
  aspect-ratio: 80/106;
}

/* 제목 */
.stamp-detail h3 {
  margin: 0 0 8px;
  color: #e5e7eb;
}

/* rarity - 충분한 길이, 줄바꿈·흐름 대응 */
.stamp-rarity-modal {
  display: inline-flex;
  align-items: center; /* 세로 중앙 정렬 */
  justify-content: center; /* 가로 중앙 정렬 */
  min-height: 28px; /* height 대신 min-height로 충분히 여유 있게 */
  min-width: 35px;
  max-width: 120px; /* 좀 더 넉넉한 최대 너비 */
  padding: 0 12px; /* 좌우 여백 넉넉히 */
  font-size: 12px; /* 너무 작으면 글씨가 밀릴 수 있음 */
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  user-select: none;
  margin: 0 auto;
}

.stamp-rarity-modal.common {
  background: linear-gradient(90deg, #5c6670 30%, #93a1ba 90%);
  color: #e5e7eb;
}
.stamp-rarity-modal.rare {
  background: linear-gradient(90deg, #3369bf 30%, #60a5fa 90%);
  color: #e0f2fe;
}
.stamp-rarity-modal.epic {
  background: linear-gradient(90deg, #883af5 40%, #a78bfa 100%);
  color: #ede9fe;
}
.stamp-rarity-modal.legendary {
  background: linear-gradient(90deg, #fbbf24 30%, #f59e0b 90%);
  color: #fffbe5;
}

/* 필요시 여러 줄도 pill 모양 내에서 자연스럽게 보임 */

/* 설명, 획득일, 출처 등 */
.stamp-description,
.stamp-obtained,
.stamp-source {
  color: #9ca3af;
  margin: 8px 0;
  font-size: 14px;
}

/* ============ 컬렉션 모달 기본셋팅 ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 18, 23, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(180deg, #1a1f2e 0%, #0f1419 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px 32px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
  color: #e5e7eb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR",
    sans-serif;
  position: relative;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform: scale(1);
}

/* 닫기 버튼 */
.close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 28px;
  font-weight: 600;
  color: #9ca3af;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.3s ease;
  user-select: none;
}

.close-btn:hover {
  color: #3b82f6;
}

/* 제목 */
#modalCollectionName {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #f3f4f6;
  text-align: center;
}

/* 설명 */
#modalCollectionDesc {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 16px;
  line-height: 1.4;
  text-align: center;
}

/* 필요 우표 목록 */
#modalRequiredStamps {
  list-style-type: none;
  padding: 0;
  margin: 0 0 24px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

#modalRequiredStamps li {
  background: rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 13px;
  color: #93c5fd;
  font-weight: 600;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.3);
  transition: background 0.3s ease;
}

#modalRequiredStamps li:hover {
  background: rgba(59, 130, 246, 0.3);
}

/* 컬렉션 모달 안 우표 썸네일 그리드 (확대, 간격 증가) */
.required-stamps-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px; /* 간격 더 넉넉하게 */
  justify-content: center;
  margin: 24px 0;
  padding: 0;
  list-style: none;
}

.required-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 92px; /* 넓이 증가 */
}

.required-stamp-img {
  width: 80px;
  height: 106px;
  border-radius: 12px;
  background: #0e1020 linear-gradient(135deg, #222844 70%, #151820 100%);
  object-fit: cover;
  box-shadow: 0 4px 18px 1px rgba(55, 111, 200, 0.17),
    0 1px 12px rgba(0, 0, 0, 0.21) inset;
  border: 3px solid #383e47;
  display: block;
  margin-bottom: 8px;
  transition: box-shadow 0.25s, border-color 0.25s, filter 0.25s, transform 0.2s;
}

.required-stamp.collected .required-stamp-img {
  border-color: #22c55e;
  filter: none;
  box-shadow: 0 0 16px #22c55e80;
}

.required-stamp.missing .required-stamp-img {
  opacity: 0.18;
  filter: grayscale(1);
  border-color: #23272e;
}

.required-stamp-label {
  margin-top: 2px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.13), 0 0 #fff;
}

.required-stamp.collected .required-stamp-label {
  color: #93e6a3;
  font-weight: 600;
}

.required-stamp.missing .required-stamp-label {
  color: #8992a6;
  text-shadow: none;
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 6px 2px rgba(255, 255, 180, 0.4);
  }
  50% {
    box-shadow: 0 0 8px 3px rgba(255, 255, 180, 0.65);
  }
}

.required-stamp.collected {
  position: relative;
  animation: glow 3s infinite ease-in-out;
  border-radius: 6px;
}

/* 모달에서 마우스 올리면 살짝 올라오며 강조 */
.required-stamp:hover .required-stamp-img {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 6px 32px #3b82f699, 0 2px 14px #111827ee inset;
  border-color: #3b82f6;
}

/* 보상 텍스트 */
#modalCollectionReward {
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.8);
}

/* ============ 알림 ============ */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stamp-notification,
.collection-completed-notification {
  background: linear-gradient(
    135deg,
    rgba(15, 18, 23, 0.95),
    rgba(7, 16, 26, 0.95)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  backdrop-filter: blur(8px);
}

.stamp-notification.show,
.collection-completed-notification.show {
  transform: translateX(0);
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notification-content img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.notification-text h4 {
  margin: 0 0 4px;
  color: #22c55e;
  font-size: 14px;
}

.notification-text p {
  margin: 0;
  color: #e5e7eb;
  font-size: 13px;
}

.completion-icon {
  font-size: 32px;
  animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

/* ============ Footer ============ */
.footer {
  padding: 32px 72px;
  border-top: none; /*수정부분*/
  color: #9ca3af;
  text-align: center;
  position: relative;
}

.footer::before {
  /* 수정부분: 좌우 여백 */
  content: "";
  position: absolute;
  top: 0;
  left: 100px;
  right: 100px;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.06);
}

/* ============ Hamburger / Side panel ============ */
.nav-toggle {
  display: none;
}
.hamburger {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 36px;
  display: grid;
  place-items: center;
  gap: 5px;
  cursor: pointer;
  z-index: 50;
}
.hamburger span {
  display: block;
  width: 26px;
  height: 2px;
  background: #e5e7eb;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* X animation */
.nav-toggle:checked + .hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
  position: relative;
  z-index: 80;
}
.nav-toggle:checked + .hamburger span:nth-child(2) {
  opacity: 0;
  position: relative;
  z-index: 80;
}
.nav-toggle:checked + .hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
  position: relative;
  z-index: 80;
}

.side-panel {
  position: fixed;
  left: 8px;
  top: 72px; /* 기존 상단 위치 유지 */
  bottom: 8px; /* 하단까지 확장 (약간의 여백) */
  width: 300px;
  max-width: calc(100% - 32px);

  background: linear-gradient(135deg, #1a1f2e, #0f1419);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 16px;
  transform: translateX(-120%);
  transition: transform 0.22s ease;
  z-index: 60;

  /* 높이 관련 설정 */
  height: auto; /* 자동 높이 */
  overflow-y: auto; /* 내용이 많으면 스크롤 */
  box-sizing: border-box; /* 패딩 포함 크기 계산 */
}
/* 스크롤바 스타일링 (선택사항) */
.side-panel::-webkit-scrollbar {
  width: 6px;
}
.side-panel.open {
  transform: translateX(0) !important;
}

/* 프로필을 강제로 3줄 세로 배치 */
/* profile area - 아바타 왼쪽, 텍스트 오른쪽에 3줄로 */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  background: rgba(15, 18, 23, 0.9);
  padding: 12px 16px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

/* 텍스트들을 세로로 3줄 배치 */
.profile-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.username {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.title {
  margin: 0 0 4px 0;
  color: #d1d5db;
  font-size: 13px;
  line-height: 1.2;
}

#mini_title {
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
  padding: 6px 14px;
  background: linear-gradient(90deg, #3b82f6, #818cf8, #60a5fa);
  color: white;
  border-radius: 20px;
  display: inline-block;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.7);
  user-select: none;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.stats {
  margin: 0;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.2;
}

/* badges */
/* 공통 스타일 */
#badgeList {
  display: flex;
  flex-direction: column;
  gap: 8px; /* 각 아이템 사이 간격 */
}

#badgeList span {
  display: inline-block; /* 뱃지 형태 유지 위해 블록보다 inline-block 추천 */
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: default;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: background-color 0.3s ease, color 0.3s ease;
  /* 한 줄로 보이던 문제 완화 위해 flex 부모 환경이면 아래가 필요할 수 있음 */
  width: max-content;
}

/* 마우스 오버 효과 유지 */
#badgeList span:hover {
  background-color: #2563eb;
  color: white;
}

@keyframes glitter {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.represent #representbadge {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(90deg, #f43f5e, #e879f9, #60a5fa, #34d399);
  background-size: 200% 200%;
  color: white;
  font-weight: 700;
  font-size: 15px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.5);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  user-select: none;
  cursor: default;
  animation: glitter 3s ease-in-out infinite;
}
/* ============ 화면 전환용 ============ */
.hidden {
  display: none !important;
}

/* ============ 반응형 ============ */
@media (max-width: 900px) {
  main {
    padding: 20px;
  }
  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 8px;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .topbar h1 {
    font-size: 15px;
    margin: 0 0 6px 40px; /* 왼쪽에 햄버거 공간 확보 */
    text-align: center;
  }
  .profile {
    padding: 6px 8px;
    gap: 8px;
  }
  .hamburger {
    top: 8px;
    left: 8px;
    z-index: 60;
  }
  .side-panel {
    width: 280px;
  }
  .synthesis-area {
    grid-template-columns: 1fr;
  }
  .ingredient-slots {
    justify-content: center;
  }
  .stamp-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 600px) {
  .stamp-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }

  .stamp {
    min-height: 55px;
    padding: 4px;
  }

  .stamp-art {
    min-height: 35px;
    font-size: 9px;
    margin-bottom: 3px;
  }

  .stamp-info > div {
    font-size: 7px;
  }

  .stamp-rarity {
    min-width: 30px;
    max-width: 70px;
    height: 16px;
    padding: 0 6px;
    font-size: 7px;
  }
  .bookmarks {
    right: 8px;
  }
  .bookmark {
    font-size: 12px;
    padding: 8px 6px;
  }
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .filters {
    justify-content: center;
  }
}

.stamp {
  position: relative;
  border-radius: 12px;
  padding: 8px;
  background: radial-gradient(circle at 20% 30%, #fff 0%, #f7f7f7 100%);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.4),
    0 4px 10px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transition: transform 0.2s;
}
.stamp:hover {
  transform: scale(1.05);
}

/*수정부분 시작*/

.stamp.legendary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3; /*::before/::after보다 위에 */
  pointer-events: none;

  /* 스펙트럼색 */
  background-image: linear-gradient(
    -45deg,
    rgba(255, 0, 0, 0.7) 0%,
    rgba(255, 165, 0, 0.7) 20%,
    rgba(255, 255, 0, 0.7) 40%,
    rgba(0, 255, 0, 0.7) 60%,
    rgba(0, 0, 255, 0.7) 80%,
    rgba(138, 43, 226, 0.7) 100%
  );
  background-size: 300% 300%;
  mix-blend-mode: screen;
  opacity: 0.6;

  /* 이중 마스크
     1) 대각선 ‘두꺼운 띠’ (단일 띠 두께: 60px)
     2) 삼각형 패턴(면 안에서만 보이도록)
     두 마스크를 교차 합성해 띠가 삼각형 면 내부에서만 보입니다. */
  -webkit-mask-image: linear-gradient(
      -45deg,
      transparent calc(50% - 10px),
      rgba(255, 0, 0, 0.7) calc(50% - 10px),
      rgb(255, 165, 0, 0.7) calc(50% + 10px),
      rgb(255, 255, 0, 0.7) calc(50% + 10px),
      rgb(0, 255, 0, 0.7) calc(50% + 10px),
      rgb(0, 0, 255, 0.7) calc(50% + 10px),
      rgb(138, 43, 226, 0.7) calc(50% + 10px),
      transparent calc(50% + 10px)
    ),
    url("data:image/svg+xml;utf8,\<svg xmlns='http://www.w3.org/2000/svg' width='30' height='52' viewBox='0 0 30 52'>\<polygon points='30,0 30,52 0,52' fill='white'/>\</svg>");
  -webkit-mask-repeat: no-repeat, repeat;
  -webkit-mask-size: 200% 200%, 7px 9px; /* 삼각형 타일 크기(패턴과 동일) */
  -webkit-mask-position: 0 0, 0 0;
  -webkit-mask-composite: source-in; /* 띠 ∩ 삼각형 */

  mask-image: linear-gradient(
      -45deg,
      transparent calc(50% - 10px),
      /*띠 두께 조정*/ rgba(255, 0, 0, 0.7) calc(50% - 10px),
      rgb(255, 165, 0, 0.7) calc(50% + 10px),
      rgb(255, 255, 0, 0.7) calc(50% + 10px),
      rgb(0, 255, 0, 0.7) calc(50% + 10px),
      rgb(0, 0, 255, 0.7) calc(50% + 10px),
      rgb(138, 43, 226, 0.7) calc(50% + 10px),
      transparent calc(50% + 10px)
    ),
    url("data:image/svg+xml;utf8,\<svg xmlns='http://www.w3.org/2000/svg' width='30' height='52' viewBox='0 0 30 52'>\<polygon points='30,0 30,52 0,52' fill='white'/>\</svg>");
  mask-repeat: no-repeat, repeat;
  mask-size: 200% 200%, 6px 8px;
  mask-position: 0 0, 0 0;
  mask-composite: intersect;

  /*  대각선으로 슬라이드 */
  animation: holoStripeMove 3s linear infinite;
  will-change: -webkit-mask-position, mask-position, background-position;
}

/*수정부분 끝*/

.stamp::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,\<svg xmlns='http://www.w3.org/2000/svg' width='60' height='52' viewBox='0 0 60 52'>\<polygon points='30,0 60,52 0,52' fill='white' fill-opacity='0.2' stroke='white' stroke-opacity='0.5' stroke-width='1'/>\</svg>");
  background-size: 7px 9px;
  mix-blend-mode: screen;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 0, 0, 0.7) 0%,
    /* 빨강 */ rgba(255, 165, 0, 0.7) 20%,
    /* 주황 */ rgba(255, 255, 0, 0.7) 40%,
    /* 노랑 */ rgba(0, 255, 0, 0.7) 60%,
    /* 초록 */ rgba(0, 0, 255, 0.7) 80%,
    /* 파랑 */ rgba(138, 43, 226, 0.7) 100% /* 보라 */
  );
  mix-blend-mode: overlay;
}

.stamp.common::before {
  opacity: 0.1;
}
.stamp.rare::before {
  opacity: 0.4;
}
.stamp.epic::before {
  opacity: 0.6;
}
.stamp.legendary::before {
  opacity: 0.8;
}

.stamp.common::after {
  opacity: 0;
}
.stamp.rare::after {
  opacity: 0.1;
}
.stamp.epic::after {
  opacity: 0.3;
}
.stamp.legendary::after {
  opacity: 0.8;
}

/* 메인 화면 중앙 로고, 사진 */
.stamp .stamp-logo {
  width: 90px;
  height: 90px;
  margin-top: 0px;
  margin-bottom: auto;
  display: block;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-color: #fff;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.2) inset;
  z-index: 5;
}

.stamp-inner {
  display: flex;
  flex-direction: column;
  justify-content: center; /* 세로 중앙 정렬 */
  align-items: center; /* 가로 중앙 정렬 */
  height: 100%; /* 부모 높이 꽉 채우기 */
}

/* 대각선 ‘무지개 두꺼운 띠’가 삼각형 면을 따라 이동 - legendary 전용 */
@keyframes holoStripeMove {
  0% {
    -webkit-mask-position: 0 0, 0 0;
    mask-position: 0 0, 0 0;
  }
  100% {
    -webkit-mask-position: 200% 200%, 0 0;
    mask-position: 200% 200%, 0 0;
  }
}

.stamp-name {
  font-size: 13px;
  font-weight: 1000;
}
