:root {
  --bg: #0f1724;
  --accent: #06b6d4;
  --muted: #94a3b8;
  --text: #e6eef8;
  --card-bg: rgba(11, 18, 32, 0.35);
  --shadow: rgba(2, 6, 23, 0.7);
  --web-stroke: rgba(255,255,255,0.05);
}

body.light-mode {
  --bg: #f5f9fc;
  --accent: #0284c7;
  --muted: #64748b;
  --text: #1e293b;
  --card-bg: rgba(255, 255, 255, 0.85);
  --shadow: rgba(15, 23, 42, 0.15);
  --web-stroke: rgba(0,0,0,0.03);
}

* { box-sizing: border-box; }
html, body {
  min-height: 100vh;
  margin: 0;
  font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg), #071028);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 40px 20px;
  transition: background 0.6s ease, color 0.6s ease;
}

body.light-mode {
  background: linear-gradient(135deg, #f5f9fc, #e0f2fe);
}

canvas#spiderCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: url('background.jpg') no-repeat center center fixed;
  background-size: cover;
  filter: blur(8px);
}

.mode-toggle-btn {
  position: fixed;
  top: 20px;
  right: 25px;
  z-index: 20;
  width: 50px;
  height: 50px;
  cursor: pointer;
  border-radius: 4px;
  background: #898989; /* Cobblestone color */
  border: none;
  padding: 0;
  transition: all 0.3s ease;
  box-shadow: 
    inset -3px -3px 0px 0px #717171, /* Inner shadow for 3D effect */
    inset 3px 3px 0px 0px #a8a8a8,
    0 0 15px rgba(6,182,212,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 
    inset -3px -3px 0px 0px #717171,
    inset 3px 3px 0px 0px #a8a8a8,
    0 0 25px rgba(6, 182, 212, 0.6);
}

.mode-toggle-btn .lever-handle {
  width: 10px;
  height: 30px;
  background: #8c6649; /* Wood color */
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  transform-origin: bottom center;
  box-shadow: 
    inset -2px -2px 0px 0px #5a412e, /* Inner shadow for 3D effect */
    inset 2px 2px 0px 0px #b1825e;

  /* Dark mode "off" position */
  transform: rotate(40deg);
}

.mode-toggle-btn .lever-handle img {
  display: none; /* Hide the image */
}

body.light-mode .mode-toggle-btn .lever-handle {
  /* Light mode "on" position */
  transform: rotate(-40deg);
}

body.light-mode .mode-toggle-btn img {
  display: none;
}

.card-3d {
  width: 100%;
  max-width: 500px;
  perspective: 1200px;
  z-index: 1;
  position: relative;
}

.card-inner {
  width: 100%;
  min-height: 540px;
  border-radius: 20px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px var(--shadow);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 400ms cubic-bezier(.2, .9, .2, 1), background 0.6s ease, box-shadow 0.6s ease, border-radius 0.8s ease;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
}

.card-inner {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 1s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-inner:hover {
  box-shadow: 0 0 30px var(--shadow);
}

/* Profile Avatar */
.avatar {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--bg), rgba(255, 255, 255, 0.02));
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent);
  box-shadow: 0 8px 25px var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
  transition: all 0.4s ease;
}

.avatar::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6,182,212,0.6) 0%, rgba(6,182,212,0) 60%);
  filter: blur(15px);
  opacity: 0.7;
  animation: pulse 2.5s infinite ease-in-out;
  pointer-events: none;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; }
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.08) brightness(1.05);
  transition: transform 0.3s ease, filter 0.3s ease;
}

.avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 35px var(--shadow);
}

.avatar:hover img {
  filter: contrast(1.15) brightness(1.12);
  transform: scale(1.05);
}

/* Name Styling */
#particleName {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  color: var(--accent);
  position: relative;
  letter-spacing: 1px;
  overflow: visible;
  margin: 15px 0 5px 0;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: nameGlow 2s ease-in-out infinite;
}

@keyframes nameGlow {
  0%, 100% { 
    filter: drop-shadow(0 0 8px rgba(6,182,212,0.4));
    text-shadow: 0 0 15px rgba(6,182,212,0.3);
  }
  50% { 
    filter: drop-shadow(0 0 15px rgba(6,182,212,0.7));
    text-shadow: 0 0 25px rgba(6,182,212,0.6);
  }
}

/* Role/Position Styling */
#particleRole { 
  color: var(--accent); 
  font-size: 20px; 
  font-weight: 700;
  text-align: center; 
  margin-bottom: 15px;
  letter-spacing: 0.5px;
  animation: roleSlideIn 0.8s ease forwards;
}

@keyframes roleSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.bio { 
  font-size: 16px; 
  color: var(--text); 
  line-height: 1.6; 
  text-align: center; 
  margin-bottom: 15px;
  opacity: 0.95;
  animation: fadeIn 1.2s ease-in-out 0.3s forwards;
  animation-fill-mode: both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.meta-panel { 
  display: flex; 
  gap: 10px; 
  align-items: center; 
  justify-content: center; 
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.meta-panel .chip { 
  font-size: 15px; 
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(6,182,212,0.08);
  border: 1px solid var(--accent);
  transition: all 0.3s ease;
  animation: chipPulse 2s ease-in-out infinite;
}

.meta-panel .chip:hover {
  transform: scale(1.1);
  background: rgba(6,182,212,0.15);
  box-shadow: 0 0 15px rgba(6,182,212,0.4);
}

.meta-panel .chip.accent { 
  color: var(--accent); 
  font-weight: 700;
  box-shadow: 0 0 12px rgba(6,182,212,0.3);
}

@keyframes chipPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(6,182,212,0.2); }
  50% { box-shadow: 0 0 15px rgba(6,182,212,0.4); }
}

.social-icons { 
  display: flex; 
  gap: 12px; 
  margin-bottom: 15px; 
  justify-content: center;
  flex-wrap: wrap;
}

.social-icons a { 
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(6,182,212,0.1);
  border: 1.5px solid var(--accent);
  transition: all 0.3s ease;
}

.social-icons img { 
  width: 24px; 
  height: 24px; 
  filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(500%) hue-rotate(180deg);
  transition: all 0.3s ease;
}

body.light-mode .social-icons img {
  filter: brightness(0) saturate(100%);
}

.social-icons a:hover {
  transform: scale(1.15) translateY(-3px);
  background: rgba(6,182,212,0.25);
  box-shadow: 0 5px 20px rgba(6,182,212,0.4);
}

.social-icons a:hover img { 
  transform: rotate(360deg);
}

.skills { margin-bottom: 16px; }

.skills h3 { 
  text-align: center; 
  margin-bottom: 12px; 
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 0.5px;
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { text-shadow: 0 0 8px rgba(6,182,212,0.4); }
  50% { text-shadow: 0 0 20px rgba(6,182,212,0.8); }
}

.skills-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.skills-list span {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid rgba(6,182,212,0.3);
  transition: all 0.3s ease;
  animation: skillFloat 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.15s);
}

.skills-list span:hover {
  transform: scale(1.15) translateY(-3px);
  background: rgba(6, 182, 212, 0.25);
  box-shadow: 0 5px 20px rgba(6, 182, 212, 0.5);
  border-color: var(--accent);
}

@keyframes skillFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

.contact-section { 
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.contact-section h3 {
  color: var(--accent);
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.5px;
}

.contact { 
  display: flex; 
  gap: 10px; 
  justify-content: center; 
  flex-wrap: wrap;
}

.btn {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  padding: 10px 16px;
  border-radius: 12px;
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(6,182,212,0.3);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(6,182,212,0.5);
}

@media (max-width: 480px) {
  .card-inner {
    padding: 20px 16px;
    min-height: auto;
  }
  #particleName {
    font-size: 28px;
  }
  #particleRole {
    font-size: 18px;
  }
  .avatar {
    width: 130px;
    height: 130px;
  }
  .bio { font-size: 14px; }
  .meta-panel .chip { font-size: 13px; }
}

#borderSpider {
  position: absolute;
  width: 45px;
  height: 45px;
  object-fit: contain;
  top: 0;
  left: 0;
  z-index: 10;
  animation: moveSpider 20s linear infinite;
  filter: drop-shadow(0 0 8px var(--accent));
  transform-origin: center center;
  opacity: 0.8;
}

@keyframes moveSpider {
  0%   { top: 0; left: 0; transform: rotate(180deg); }
  12.5% { top: 0; left: 50%; transform: rotate(180deg); }
  25%  { top: 0; left: calc(100% - 45px); transform: rotate(180deg); }
  37.5% { top: 50%; left: calc(100% - 45px); transform: rotate(0deg); }
  50%  { top: calc(100% - 45px); left: calc(100% - 45px); transform: rotate(0deg); }
  62.5% { top: calc(100% - 45px); left: 50%; transform: rotate(0deg); }
  75%  { top: calc(100% - 45px); left: 0; transform: rotate(0deg); }
  87.5% { top: 50%; left: 0; transform: rotate(0deg); }
  100% { top: 0; left: 0; transform: rotate(180deg); }
}

.particle {
  position: absolute;
  font-weight: bold;
  pointer-events: none;
  animation: float 1.5s ease forwards;
  opacity: 0.8;
  font-size: 14px;
  color: var(--accent);
}

@keyframes float {
  0% { transform: translate(0,0) rotate(0deg); opacity: 0.8; }
  100% { transform: translate(0,-40px) rotate(360deg); opacity: 0; }
}

.border-lights {
  position: absolute;
  inset: -15px;
  pointer-events: none;
  z-index: 0;
}

.border-lights span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  animation: floating-lights 3s ease-in-out infinite;
}

@keyframes floating-lights {
  0% { transform: translateY(0) scale(1); opacity: 0.7; }
  50% { transform: translateY(-8px) scale(1.15); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 0.7; }
}

.border-lights span:nth-child(1) { top: -5px; left: 10%; animation-delay: 0s; }
.border-lights span:nth-child(2) { top: -5px; right: 15%; animation-delay: 0.5s; }
.border-lights span:nth-child(3) { bottom: -5px; left: 20%; animation-delay: 1s; }
.border-lights span:nth-child(4) { bottom: -5px; right: 25%; animation-delay: 1.5s; }
.border-lights span:nth-child(5) { top: 40%; left: -5px; animation-delay: 2s; }
.border-lights span:nth-child(6) { top: 60%; right: -5px; animation-delay: 2.5s; }

.modal {
  display: none;
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 15px;
  text-align: center;
  color: var(--text);
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal-content input {
  width: 85%;
  padding: 10px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--accent);
  text-align: center;
  background: transparent;
  color: var(--text);
}

.modal-content button {
  padding: 10px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border: none;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-content button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(6,182,212,0.4);
}

.close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s ease;
}

.close:hover {
  color: var(--accent);
  transform: scale(1.2);
}