:root {
  --night-1: #2b1055;
  --night-2: #1a0b3a;
  --night-3: #07041a;
  --glow: #e0b3ff;
  --pink: #ff6ad5;
  --violet: #c774ff;
  --muted: #cbb8e6;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(ellipse at top, var(--night-1) 0%, var(--night-2) 45%, var(--night-3) 100%);
  background-attachment: fixed;
  color: #fff;
  overflow: hidden;
}

/* 三维舞台：透视只在这一层生效 */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  perspective: 1000px;
  perspective-origin: 50% 50%;
  touch-action: none;
  cursor: grab;
}

.sky.dragging {
  cursor: grabbing;
}

/* 平面背景：流星 */
.bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 球心位于屏幕中央，所有文字和星星都挂在它上面 */
.scene {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.star {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
}

/* 球面上的文字：背面隐藏，不会镜像显示 */
.node {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(255, 214, 255, 0.7);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.node.small {
  font-weight: 500;
  color: #f3e6ff;
}

/* 长句自动换行，不伸出屏幕 */
.node.big {
  white-space: normal;
  width: 200px;
  text-align: center;
  line-height: 1.5;
}

.node.heart {
  color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
  cursor: default;
}

.node:hover {
  color: #ffd6ff;
}

.node.heart:hover {
  color: var(--pink);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

@keyframes glow {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes beat {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.meteor {
  position: absolute;
  width: 140px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));
  opacity: 0;
  animation: meteor 7s linear infinite;
}

@keyframes meteor {
  0% { transform: translate(0, 0) rotate(-30deg); opacity: 0; }
  4% { opacity: 1; }
  14% { transform: translate(-420px, 240px) rotate(-30deg); opacity: 0; }
  100% { transform: translate(-420px, 240px) rotate(-30deg); opacity: 0; }
}

/* 顶部标题：A866 和「生日快乐，名字！」 */
.title {
  position: fixed;
  top: 24px;
  left: 0;
  right: 0;
  z-index: 1;
  text-align: center;
  pointer-events: none;
  padding: 0 16px;
}

.code {
  margin: 0 0 6px;
  color: var(--glow);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 2px;
  text-shadow: 0 0 8px var(--violet);
}

.title h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 52px);
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #ffd6ff, var(--pink), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 106, 213, 0.5));
}

/* 底部名字栏已隐藏；名字固定为「小琳」（输入框仍在页面里，供脚本使用） */
.bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.bar input {
  width: min(220px, 60vw);
  padding: 6px 2px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  font-size: 16px;
  text-align: center;
  outline: none;
}

.bar input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.bar input:focus-visible {
  border-bottom-color: #ffd6ff;
  box-shadow: 0 1px 0 #ffd6ff;
}

/* 缩放按钮 */
.zoom {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.zoom:hover {
  box-shadow: 0 0 14px rgba(255, 106, 213, 0.45);
}

.zoom:focus-visible {
  outline: 3px solid rgba(255, 106, 213, 0.5);
  outline-offset: 2px;
}

/* 背景音乐开关 */
.music {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3;
  appearance: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.music[aria-pressed="true"] {
  box-shadow: 0 0 14px rgba(255, 106, 213, 0.45);
}

.music:focus-visible {
  outline: 3px solid rgba(255, 106, 213, 0.5);
  outline-offset: 2px;
}

/* B站官方播放器（音乐开启时显示） */
.bili {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  z-index: 2;
  width: min(360px, calc(100vw - 24px));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(199, 116, 255, 0.35);
}

.bili[hidden] {
  display: none;
}

.bili iframe {
  display: block;
  width: 100%;
  height: 90px;
  border: 0;
}

/* 点击复制后的提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  z-index: 2;
  margin: 0;
  transform: translateX(-50%);
  color: #ffd6ff;
  font-size: 14px;
  text-shadow: 0 0 8px var(--violet);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 手机上去掉文字阴影，省渲染 */
@media (pointer: coarse) {
  .node { text-shadow: none; }
  .node.heart { text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .star, .node, .node.heart { animation: none; }
  .node { opacity: 0.9; }
  .meteor { display: none; }
}
