/* ============ 喵箱 · 弹窗与图鉴高质感样式 (Surfaces & Modals) ============ */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(45, 30, 25, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay.active { display: flex; }

.dialog-panel {
  position: relative;
  width: min(390px, 100%);
  max-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100svh - 32px - var(--safe-top) - var(--safe-bottom));
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  margin: auto;
  overflow-y: auto;
  border-radius: 24px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 245, 230, 0.9) 0%, transparent 60%),
    linear-gradient(180deg, #FFFFFF 0%, #FFF5E4 100%);
  box-shadow:
    var(--shadow-high),
    inset 0 0 0 3px #FFFFFF,
    inset 0 0 0 6px #F5DFC2;
  scrollbar-color: var(--coral) transparent;
  scrollbar-width: thin;
  text-align: center;
  animation: dialog-pop 280ms cubic-bezier(0.18, 0.89, 0.32, 1.15);
}

.end-card, .milestone-card {
  padding: 26px 22px 22px;
}

.dialog-rim {
  width: 54px;
  height: 6px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #E8BF92;
}

.end-card h2, .milestone-card h2 {
  margin: 0;
  color: var(--coral-dark);
  font-family: var(--display);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.1;
  text-shadow: 0 2px 0 #FFF0D9;
}

.end-sub, .milestone-copy {
  max-width: 30ch;
  margin: 8px auto 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
}

.end-bigcat {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 6px auto 0;
}

.end-bigcat::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 100, 0.45) 0%, rgba(255, 220, 100, 0) 70%);
  filter: blur(10px);
}

.end-bigcat::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 12px;
  left: 20px;
  height: 18px;
  border-radius: 50%;
  background: rgba(60, 40, 30, 0.14);
  filter: blur(6px);
}

.end-bigcat canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 160px;
  height: 160px;
  filter: drop-shadow(0 8px 10px rgba(60, 40, 30, 0.18));
  animation: hero-breathe 3.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 280px;
  margin: 8px auto 0;
  gap: 10px;
}

.stat {
  min-height: 72px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 4px 8px rgba(60, 40, 30, 0.05), inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.stat-num {
  color: var(--coral-dark);
  font-family: var(--display);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.stat-label {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.record-badge {
  display: inline-flex;
  min-height: 32px;
  margin-top: 8px;
  padding: 4px 14px;
  align-items: center;
  border-radius: 999px;
  color: #8F5500;
  background: linear-gradient(180deg, #FFE885, #FFB830);
  box-shadow: 0 4px 10px rgba(255, 184, 48, 0.35);
  font-size: 13px;
  font-weight: 900;
  animation: spark-twinkle 2s ease-in-out infinite;
}

.unlock-note {
  min-height: 20px;
  margin-top: 6px;
  color: var(--mint-dark);
  font-size: 14px;
  font-weight: 800;
}

.end-btns, .milestone-actions {
  display: flex;
  margin-top: 14px;
  flex-direction: column;
  gap: 10px;
}

/* 里程碑卡片 */
.milestone-mark {
  position: relative;
  width: 80px;
  height: 66px;
  margin: 0 auto 8px;
}

.milestone-mark::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #FFFDE0 0%, #FFB830 100%);
  box-shadow: 0 6px 14px rgba(255, 184, 48, 0.4);
}

.milestone-mark span {
  position: absolute;
  z-index: 1;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: #FFFFFF;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

.milestone-stat {
  display: flex;
  min-height: 54px;
  margin-top: 14px;
  padding: 8px 16px;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 700;
}

.milestone-stat strong {
  color: var(--coral-dark);
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
}

/* ---------------- 猫猫图鉴 (Atlas) ---------------- */
.atlas-overlay { align-items: stretch; }

.atlas-card {
  display: flex;
  width: min(470px, 100%);
  height: 100%;
  max-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
  padding: 18px 16px 16px;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
}

.atlas-head {
  display: grid;
  flex: none;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.atlas-head h2 {
  margin: 0;
  color: var(--coral-dark);
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
}

.atlas-count {
  color: #FFFFFF;
  background: var(--coral-dark);
  box-shadow: 0 2px 6px rgba(232, 77, 77, 0.35);
}

.atlas-sub {
  flex: none;
  margin: 8px 4px 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.atlas-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  padding: 4px 2px 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--coral) transparent;
  scrollbar-width: thin;
}

/* 拍立得收集卡片 */
.atlas-item {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 204px;
  padding: 12px 10px 14px;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  border-radius: 18px;
  background: #FFFFFF;
  box-shadow: 0 4px 12px rgba(60, 40, 30, 0.08), inset 0 0 0 1px rgba(240, 220, 195, 0.6);
  text-align: center;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.atlas-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(60, 40, 30, 0.12);
}

.atlas-item::before {
  content: "No." attr(data-level);
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: #FFF4E2;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(60, 40, 30, 0.08);
}

.atlas-item canvas {
  display: block;
  width: min(112px, 100%);
  height: auto;
  aspect-ratio: 1;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(60, 40, 30, 0.08);
}

.atlas-item .aname {
  color: var(--ink);
  font-family: var(--display);
  font-size: 20px;
  line-height: 1.15;
}

.atlas-item .aquote {
  min-height: 3em;
  padding: 0 2px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* 未解锁神秘卡片 */
.atlas-item.locked {
  background: linear-gradient(180deg, #F8F4EE 0%, #EDE5D8 100%);
  box-shadow: inset 0 0 0 1px rgba(210, 195, 180, 0.4);
}

.atlas-item.locked canvas {
  filter: drop-shadow(0 4px 8px rgba(80, 60, 70, 0.15));
}

.atlas-item .aname.locked-name {
  color: #9C887E;
}

/* ---------------- Toast 提示 ---------------- */
.toast {
  position: absolute;
  z-index: 30;
  bottom: calc(64px + var(--safe-bottom));
  left: 50%;
  max-width: calc(100% - 32px - var(--safe-left) - var(--safe-right));
  min-height: 42px;
  padding: 8px 18px;
  border-radius: 999px;
  color: #FFFFFF;
  background: linear-gradient(180deg, #48C78E, #238558);
  box-shadow: var(--shadow-high);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 动画与响应式 ---------------- */
@keyframes hero-breathe {
  0%, 100% { transform: translateY(0) rotate(-0.3deg); }
  50% { transform: translateY(-6px) rotate(0.4deg); }
}

@keyframes dialog-pop {
  from { transform: translateY(16px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-height: 760px) {
  #screen-home { padding-top: calc(12px + var(--safe-top)); padding-bottom: calc(12px + var(--safe-bottom)); }
  .home-inner { gap: 10px; }
  .logo-cn { font-size: 52px; }
  .hero-stage { width: min(310px, 92vw); height: 210px; }
  .hero-cat, .hero-cat canvas { width: 190px; height: 190px; }
  .btn { min-height: 50px; font-size: 16px; }
}

@media (max-height: 580px) {
  .tagline, .foot-note { display: none; }
  .logo-cn { font-size: 42px; }
  .hero-stage { width: min(260px, 88vw); height: 140px; }
  .hero-cat { top: -10px; }
  .hero-cat, .hero-cat canvas { width: 140px; height: 140px; }
}

@media (orientation: landscape) {
  #app { width: min(820px, 100vw); }
  .atlas-card { width: min(700px, 100%); }
  .atlas-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
