* { margin:0; padding:0; box-sizing:border-box; }

/* 系统字体栈 + 科幻感等宽字体 */
:root {
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  
  /* 颜色变量 */
  --star-white: #fff9e6;
  --star-gold: #ffd700;
  --star-blue: #87ceeb;
  --star-pink: #ffb6c1;
  --star-purple: #da70d6;
  
  /* 弹性缓动 */
  --bounce-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --smooth-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-stack);
  height: 100dvh;
  background: 
    /* 极微弱星云层 */
    radial-gradient(ellipse at 20% 30%, rgba(138, 43, 226, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(30, 144, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 215, 0, 0.03) 0%, transparent 60%),
    /* 基础深色背景 */
    radial-gradient(ellipse at bottom, #0d001a 0%, #000 100%);
  overflow: hidden;
}

/* 加载动画 - 星空渐显 */
#stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  animation: sky-fade-in 1.2s ease-out forwards;
}

@keyframes sky-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 星星基础样式 */
.star {
  position: absolute;
  color: var(--star-white);
  text-shadow: 
    /* inner glow */
    0 0 4px currentColor,
    0 0 8px currentColor,
    /* middle glow */
    0 0 16px rgba(255, 249, 230, 0.6),
    /* outer glow */
    0 0 32px rgba(201, 168, 255, 0.4),
    0 0 64px rgba(167, 139, 255, 0.2);
  animation: breathe 4s ease-in-out infinite;
  user-select: none;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform, opacity;
  transition: transform 0.3s var(--smooth-ease), filter 0.3s var(--smooth-ease);
}

/* 星星发光 - 根据年龄分层 */
.star.new-star {
  text-shadow: 
    0 0 6px currentColor,
    0 0 12px currentColor,
    0 0 24px rgba(255, 249, 230, 0.8),
    0 0 48px rgba(201, 168, 255, 0.6),
    0 0 96px rgba(167, 139, 255, 0.4);
}

.star.old-star {
  text-shadow: 
    0 0 2px currentColor,
    0 0 6px rgba(255, 249, 230, 0.4),
    0 0 12px rgba(201, 168, 255, 0.2);
  opacity: 0.85;
}

/* 鼠标悬停 - 微妙缩放 */
.star:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.star:hover .info {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 星星符号 */
.star-symbol {
  display: block;
  animation: rotate 20s linear infinite;
}

/* 涟漪效果 */
.star {
  position: relative;
}

.star::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, currentColor 0%, transparent 60%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.star.clicked::before {
  animation: ripple 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0.5;
  }
  100% {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

/* 信息提示 - 精致的排版 */
.info {
  position: absolute;
  top: 140%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  font-size: 0.65rem;
  color: rgba(213, 192, 255, 0.85);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s var(--smooth-ease), transform 0.4s var(--smooth-ease);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.info strong {
  display: block;
  font-weight: 500;
  color: #fff;
  margin-bottom: 0.15rem;
  font-size: 0.7rem;
}

.info .meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: rgba(180, 160, 220, 0.7);
  letter-spacing: 0.05em;
}

.info .message {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-style: italic;
  color: rgba(230, 210, 255, 0.9);
  max-width: 150px;
  white-space: normal;
}

/* 新星星出现动画 - 弹性缓动 */
.animate {
  opacity: 0;
  left: 50vw !important;
  top: 50vh !important;
  transform: scale(0.3);
  animation: 
    appear-scale 0.8s var(--bounce-ease) forwards,
    meteor 1.5s 0.6s var(--smooth-ease) forwards,
    breathe 4s 2.1s ease-in-out infinite;
}

/* 其他星星入场 */
.enter-anim {
  opacity: 0;
  transform: scale(0.8);
  animation: fade-enter 0.6s var(--smooth-ease) forwards;
}

@keyframes appear-scale { 
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); } 
}

@keyframes meteor {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(calc(-50vw + var(--left)), calc(-50vh + var(--top))) scale(1); }
}

@keyframes fade-enter {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* 呼吸闪烁 - 正弦波效果 */
@keyframes breathe {
  0%, 100% { opacity: 0.75; transform: scale(0.95); }
  25% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
  75% { opacity: 0.92; transform: scale(1.02); }
}

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

/* ===== 模态框样式 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--smooth-ease);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(145deg, rgba(20, 10, 40, 0.95), rgba(10, 5, 20, 0.98));
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 16px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(138, 100, 200, 0.15);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.4s var(--bounce-ease), opacity 0.4s var(--smooth-ease);
  opacity: 0;
}

.modal.active .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* 欢迎面板 */
.welcome-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 0%, #d5c0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-content > p {
  text-align: center;
  color: rgba(213, 192, 255, 0.8);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* 自定义区域 */
.customize-section {
  margin-bottom: 1.2rem;
}

.customize-section label {
  display: block;
  font-size: 0.75rem;
  color: rgba(180, 160, 220, 0.9);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#nickname-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#nickname-input:focus {
  outline: none;
  border-color: rgba(138, 100, 200, 0.6);
  box-shadow: 0 0 0 3px rgba(138, 100, 200, 0.15);
}

#nickname-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* 颜色选项 */
.color-options {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s var(--bounce-ease), box-shadow 0.2s;
  border: 2px solid transparent;
}

.color-option:hover {
  transform: scale(1.15);
}

.color-option.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(138, 100, 200, 0.5), 0 0 15px currentColor;
}

/* 昵称选项 */
.nickname-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nickname-option {
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s var(--bounce-ease);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.nickname-option:hover {
  transform: scale(1.05);
  border-color: rgba(138, 100, 200, 0.6);
  background: rgba(138, 100, 200, 0.2);
}

.nickname-option.selected {
  background: rgba(138, 100, 200, 0.4);
  border-color: rgba(138, 100, 200, 0.8);
  color: #fff;
  box-shadow: 0 0 15px rgba(138, 100, 200, 0.3);
}

/* 留言选项 */
.message-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.message-option {
  padding: 0.7rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(138, 100, 200, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--bounce-ease);
  font-size: 0.9rem;
  color: rgba(230, 210, 255, 0.9);
  text-align: center;
}

.message-option:hover {
  border-color: rgba(138, 100, 200, 0.5);
  background: rgba(138, 100, 200, 0.15);
  transform: translateX(4px);
}

.message-option.selected {
  background: rgba(138, 100, 200, 0.3);
  border-color: rgba(138, 100, 200, 0.8);
  color: #fff;
  box-shadow: 0 0 15px rgba(138, 100, 200, 0.2);
}

/* 符号选项 */
.symbol-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.symbol-option {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--bounce-ease);
}

.symbol-option:hover {
  transform: scale(1.1);
  border-color: rgba(138, 100, 200, 0.6);
}

.symbol-option.selected {
  background: rgba(138, 100, 200, 0.3);
  border-color: rgba(138, 100, 200, 0.8);
  box-shadow: 0 0 15px rgba(138, 100, 200, 0.3);
}

/* 按钮 */
.btn-primary {
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(135deg, rgba(138, 100, 200, 0.9), rgba(100, 70, 160, 0.9));
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s var(--bounce-ease), box-shadow 0.2s;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(138, 100, 200, 0.4);
}

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

/* 留言面板 */
.message-content {
  position: relative;
}

.close-btn {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(138, 100, 200, 0.3);
  color: #fff;
  transform: rotate(90deg);
}

.message-content h3 {
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 1.2rem;
  color: #fff;
}

/* 星星信息 */
.star-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.star-symbol-large {
  font-size: 2rem;
  text-shadow: 0 0 20px currentColor;
}

.owner-info strong {
  display: block;
  color: #fff;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.owner-info span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(180, 160, 220, 0.7);
}

/* 留言显示 */
.message-display {
  min-height: 60px;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.existing-message {
  color: rgba(230, 210, 255, 0.9);
  font-size: 0.9rem;
  line-height: 1.5;
  font-style: italic;
}

.no-message {
  color: rgba(180, 160, 220, 0.5);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

/* 留言输入 */
#message-input {
  width: 100%;
  min-height: 80px;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(138, 100, 200, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 1rem;
}

#message-input:focus {
  outline: none;
  border-color: rgba(138, 100, 200, 0.6);
  box-shadow: 0 0 0 3px rgba(138, 100, 200, 0.15);
}

#message-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Toast 提示 */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 10, 40, 0.95);
  border: 1px solid rgba(138, 100, 200, 0.4);
  padding: 0.8rem 1.5rem;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--smooth-ease), transform 0.3s var(--bounce-ease);
  z-index: 2000;
}

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

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: rgba(138, 100, 200, 0.4);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(138, 100, 200, 0.6);
}

/* 响应式优化 */
@media (max-width: 480px) {
  .modal-content {
    padding: 1.5rem;
    width: 95%;
  }
  
  .info {
    font-size: 0.6rem;
  }
  
  .info strong {
    font-size: 0.65rem;
  }
  
  .info .meta {
    font-size: 0.55rem;
  }
}
