:root {
  --bg-primary: #f5f5f5;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f0;
  --text-primary: #000000;
  --text-secondary: #333333;
  --text-muted: #777777;
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-sm:
    0 0.3px 0.7px hsl(0deg 0% 6.7% / 0.021), 0 0.9px 1.8px -0.6px hsl(0deg 0% 6.7% / 0.026),
    0 2px 5.5px -1.2px hsl(0deg 0% 6.7% / 0.031), 0 4.6px 12.8px -1.7px hsl(0deg 0% 6.7% / 0.035);
  --shadow-md: 0 2px 8px hsl(0deg 0% 0%/0.08), 0 12px 30px hsl(0deg 0% 0%/0.16);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 28px;
  --radius-full: 9999px;
  --gap: 14px;
  --gap-lg: 24px;
  --max-width: 580px;
  --font-primary: 'Syne', sans-serif;
  --font-secondary: 'DM Sans', sans-serif;
  --transition-fast: 75ms ease;
  --transition-normal: 250ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #111111;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .shimmer-overlay {
    display: none;
  }
  #asciiRipple {
    display: none;
  }
  .avatar-shimmer {
    display: none;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg-primary);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: var(--font-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

a {
  -webkit-user-drag: none;
  touch-action: manipulation;
}

#asciiRain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.12;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--gap-lg) var(--gap);
  width: 100%;
}

.profile-container {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.profile-bg {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  z-index: -1;
}

.profile-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.08) 100%);
}

@media (prefers-color-scheme: dark) {
  .profile-bg-overlay {
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.3) 100%);
  }
}

.shimmer-overlay {
  --shimmer-duration: 2s;
  --shimmer-width: 60%;
  --shimmer-angle: -20deg;
  --shimmer-opacity: 0.15;
  position: absolute;
  inset: 0;
  overflow: hidden;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.shimmer-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: var(--shimmer-width);
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent,
    color-mix(in srgb, #ffffff calc(var(--shimmer-opacity) * 100%), transparent),
    transparent
  );
  will-change: transform;
  animation: shimmerSweep var(--shimmer-duration) ease-in-out infinite;
}

@keyframes shimmerSweep {
  0% {
    transform: translateX(-160%) skewX(var(--shimmer-angle));
  }
  60%,
  to {
    transform: translateX(260%) skewX(var(--shimmer-angle));
  }
}

#asciiRipple {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
}

.profile-header {
  position: relative;
  z-index: 1;
  padding: var(--gap-lg) var(--gap-lg) var(--gap);
  text-align: center;
  overflow: hidden;
}

.avatar-wrapper {
  position: relative;
  display: inline-flex;
  margin-bottom: var(--gap);
  perspective: 800px;
}

.avatar-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--text-primary) 15%, transparent);
  animation: ringPulse 3s ease-in-out infinite;
}

@keyframes ringPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

.avatar {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

.avatar:hover {
  box-shadow: var(--shadow-md);
}

.avatar-shimmer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.avatar-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent,
    color-mix(in srgb, #ffffff 70%, transparent),
    transparent
  );
  animation: shimmerSweep 3s ease-in-out infinite;
}

.profile-info {
  max-width: 100%;
}

.profile-name {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow-wrap: break-word;
  text-shadow: 0 0 40px color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.profile-bio {
  font-family: var(--font-secondary);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: center;
  overflow-wrap: anywhere;
}

.links {
  padding: var(--gap) var(--gap-lg) var(--gap-lg);
}

.link-group {
  margin-bottom: var(--gap-lg);
}

.link-group:last-child {
  margin-bottom: 0;
}

.link-group-title {
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--gap);
  padding: 0 4px;
}

.link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: var(--gap) var(--gap-lg);
  min-height: 72px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast);
  overflow: hidden;
  pointer-events: auto;
  touch-action: manipulation;
}

.link:not(:last-child) {
  margin-bottom: var(--gap);
}

.link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
  border-color: color-mix(in srgb, var(--text-muted) 50%, transparent);
}

.link:active {
  transform: translateY(0) scale(0.98);
}

.link::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-lg) - 1px);
  padding: 1px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.3),
    transparent 50%,
    rgba(255, 255, 255, 0.3)
  );
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: xor;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

@media (prefers-color-scheme: dark) {
  .link::before {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.15),
      transparent 50%,
      rgba(255, 255, 255, 0.15)
    );
  }
}

.link:hover::before {
  opacity: 1;
}

.link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.08;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.link-rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  opacity: 0.15;
}

.link-badge-img {
  border-radius: 50%;
  object-fit: cover;
}

.link-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1;
}

.link-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  z-index: 1;
}

.link-label {
  font-family: var(--font-secondary);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.link-hint {
  font-family: var(--font-secondary);
  font-weight: 400;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.link-open {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  color: var(--text-primary);
  opacity: 0;
  transform: translateX(-10px);
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
  position: relative;
  z-index: 1;
}

.link:hover .link-open {
  opacity: 1;
  transform: translateX(0);
}

.link-open svg {
  width: 20px;
  height: 20px;
}

.footer {
  padding: var(--gap-lg) var(--gap);
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  position: relative;
  z-index: 1;
}

@media (max-width: 576px) {
  .main {
    padding: var(--gap) var(--gap);
  }
  .profile-container {
    border-radius: var(--radius-md);
  }
  .profile-header {
    padding: var(--gap) var(--gap) calc(var(--gap) / 2);
  }
  .avatar {
    width: 80px;
    height: 80px;
  }
  .avatar-ring {
    inset: -4px;
  }
  .profile-name {
    font-size: 1.375rem;
  }
  .links {
    padding: var(--gap) var(--gap) var(--gap-lg);
  }
  .link {
    padding: var(--gap) 18px;
    border-radius: var(--radius-md);
    min-height: 64px;
  }
  .link-badge {
    width: 40px;
    height: 40px;
  }
  .link-label {
    font-size: 0.9375rem;
  }
  .link-hint {
    font-size: 0.75rem;
  }
}

@media screen and (min-width: 576px) {
  body {
    background: var(--bg-primary);
  }
  .profile-container {
    margin-top: 1rem;
    box-shadow: 0 24px 32px 0px rgba(0, 0, 0, 0.15);
  }
}

@media (pointer: fine) {
  .link:hover {
    background: var(--bg-card-hover);
  }
}
