/* ===== 设计变量 ===== */
:root {
  --bg-base: #0f172a;
  --accent-1: #6366f1;   /* 靛蓝 */
  --accent-2: #a855f7;   /* 紫 */
  --accent-3: #ec4899;   /* 粉 */
  --accent-4: #22d3ee;   /* 青 */
  --text-main: #f8fafc;
  --text-sub: rgba(248, 250, 252, 0.62);
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
  /* 底色放在 body（canvas）上，仅作兜底；图片需放到 .bg 层才能被卡片高斯模糊 */
  background-color: var(--bg-base, #0f172a);
  -webkit-font-smoothing: antialiased;
}

/* ===== 背景漂浮光球 ===== */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  /* 背景图片 + 黑色遮罩必须放在这个层（真实绘制的元素层），
     卡片 backdrop-filter 的高斯模糊才会对它生效 */
  background-image: linear-gradient(rgba(32, 36, 37, 0.7), rgba(32, 36, 37, 0.7)), var(--bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/*
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(var(--orb-blur, 70px));
  opacity: var(--orb-opacity, 0.55);
  will-change: transform;
}

.orb-1 {
  width: var(--orb-size-1, 340px);
  height: var(--orb-size-1, 340px);
  top: -80px;
  left: -60px;
  background: var(--orb-1-color, #6366f1);
  animation: drift1 16s ease-in-out infinite alternate;
}

.orb-2 {
  width: var(--orb-size-2, 300px);
  height: var(--orb-size-2, 300px);
  bottom: -70px;
  right: -50px;
  background: var(--orb-2-color, #ec4899);
  animation: drift2 20s ease-in-out infinite alternate;
}

.orb-3 {
  width: var(--orb-size-3, 220px);
  height: var(--orb-size-3, 220px);
  top: 55%;
  left: 12%;
  background: var(--orb-3-color, #22d3ee);
  animation: drift3 24s ease-in-out infinite alternate;
}

@keyframes drift1 {
  to { transform: translate(60px, 50px) scale(1.15); }
}
@keyframes drift2 {
  to { transform: translate(-70px, -40px) scale(1.1); }
}
@keyframes drift3 {
  to { transform: translate(40px, -60px) scale(1.2); }
}
*/

/* 细噪点质感 */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== 主容器 ===== */
.container {
  width: 100%;
  max-width: 460px;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 卡片 ===== */
.card {
  position: relative;
  background: linear-gradient(rgba(23, 25, 26, 0.75));
  backdrop-filter: blur(var(--card-blur, 22px)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--card-blur, 22px)) saturate(1.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 44px 34px 32px;
  text-align: center;
  overflow: hidden;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 70px rgba(2, 6, 23, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 卡片顶部渐变光带 */
/*
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-1), var(--accent-3), transparent);
  opacity: 0.9;
}
*/

/* ===== 头像区 ===== */
.header {
  margin-bottom: 30px;
}

.avatar-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 0deg, var(--accent-1), var(--accent-3), var(--accent-4), var(--accent-1));
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
  transition: transform 0.4s ease;
}

.avatar:hover {
  transform: scale(1.06);
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid #0f172a;
}

.avatar-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  border-radius: 50%;
  background: #1e293b;
  border: 3px solid #0f172a;
}

/* 在线小圆点 */
.online-dot {
  position: absolute;
  right: 2px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #34d399;
  border: 3px solid #0f172a;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
  70%  { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.title .grad {
  background: linear-gradient(90deg, var(--accent-4), var(--accent-1), var(--accent-3));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: grad-flow 5s ease-in-out infinite;
}

@keyframes grad-flow {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.subtitle {
  font-size: 14px;
  color: var(--text-sub);
}

/* ===== 访客计数主区 ===== */
.visitor-box {
  padding: 28px 20px;
  margin-bottom: 26px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  position: relative;
}

/* 单行：您是第 [编号] 位访客 */
.visitor-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.prefix,
.unit {
  font-size: 16px;
  color: var(--text-sub);
  font-weight: 500;
  white-space: nowrap;
}

.number {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 30px rgba(99, 102, 241, 0.35);
  transition: transform 0.2s ease;
}

.number.pop {
  animation: pop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.unit {
  font-size: 17px;
  color: var(--text-sub);
  font-weight: 500;
}

.welcome {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-sub);
  min-height: 18px;
  transition: opacity 0.3s ease;
}

.welcome.is-new {
  color: #6ee7b7;
}

.welcome.is-back {
  color: var(--accent-4);
}

/* ===== 次要统计 ===== */
.stats {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 24px;
  margin-bottom: 26px;
  padding: 18px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.stat {
  flex: 1;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-sub);
  letter-spacing: 1px;
}

.stat-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}

/* ===== 刷新按钮 ===== */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 28px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.refresh-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5);
  filter: brightness(1.08);
}

.refresh-btn:active {
  transform: translateY(0) scale(0.97);
}

.refresh-btn.spinning svg {
  animation: rotate 0.8s linear infinite;
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

/* ===== 加载骨架 ===== */
.skeleton .number,
.skeleton .stat-value {
  color: transparent;
  background: linear-gradient(90deg, rgba(255,255,255,0.08) 25%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.08) 75%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ===== 页脚 ===== */
.footer-info {
  margin-top: 22px;
  font-size: 12px;
  color: rgba(248, 250, 252, 0.5);
  text-align: center;
  line-height: 1.9;
  letter-spacing: 0.5px;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  max-width: 86vw;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .card {
    padding: 32px 22px 26px;
  }
  .number {
    font-size: 40px;
  }
  .prefix,
  .unit {
    font-size: 15px;
  }
  .title {
    font-size: 22px;
  }
}
