/* =========================================
   VARIABLES & THEMES
   ========================================= */
:root {
  --card: rgba(255, 255, 255, 0.85);
  --card-hover: rgba(255, 255, 255, 1);
  --bg-color: #3f3b60;
  --star-color: white;
  --glow-color: rgba(136, 204, 255, 0.6);
}

body.theme-day {
  --bg-color: #a8d8ea;
  --card: rgba(255,255,255,0.9);
  --card-hover: rgba(255,255,255,1);
  --star-color: #ffe066;
  --glow-color: rgba(255,200,50,0.7);
}
body.theme-fire {
  --bg-color: #1a0a00;
  --card: rgba(255,120,50,0.25);
  --card-hover: rgba(255,140,70,0.45);
  --star-color: #ff6622;
  --glow-color: rgba(255,80,0,0.8);
}
body.theme-water {
  --bg-color: #00172e;
  --card: rgba(0,180,255,0.2);
  --card-hover: rgba(0,200,255,0.35);
  --star-color: #aaeeff;
  --glow-color: rgba(0,200,255,0.7);
}
body.theme-earth {
  --bg-color: #1a1200;
  --card: rgba(100,180,50,0.25);
  --card-hover: rgba(120,200,60,0.4);
  --star-color: #aaff55;
  --glow-color: rgba(100,200,50,0.7);
}

/* Theme specific overrides */
body.theme-fire .bg-animated { filter: hue-rotate(180deg) saturate(1.5); }
body.theme-water .bg-animated { filter: hue-rotate(200deg) saturate(1.2); }
body.theme-earth .bg-animated { filter: hue-rotate(80deg) saturate(1.3); }
body.theme-fire .link-btn, 
body.theme-water .link-btn, 
body.theme-earth .link-btn { color: #fff; }

/* =========================================
   BASE & LAYOUT
   ========================================= */
body {
  margin: 0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  overflow-x: hidden;
  color: white;
  min-height: 100vh;
}

.wrapper {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 20px;
}

.container {
  width: 100%;
  max-width: 420px;
  text-align: center;
  z-index: 10;
}

/* =========================================
   TYPOGRAPHY & PROFILE
   ========================================= */
#mainTitleEl {
  margin: 0 0 15px 0;
  letter-spacing: 2px;
  text-shadow: 0 3px 10px rgba(0,0,0,0.8);
}

#linksTitleEl {
  margin: 25px 0 10px 0;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.profile-image-main {
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 15px;
  box-shadow: 0 0 30px rgba(0,0,0,0.6);
  border: 3px solid rgba(255,255,255,0.2);
  transition: box-shadow 0.4s ease, transform 0.3s ease;
  position: relative;
  background-color: rgba(0,0,0,0.2);
}

.profile-image-main:hover {
  box-shadow: 0 0 35px var(--glow-color), 0 0 60px var(--glow-color);
  transform: scale(1.05);
}

.profile-text {
  margin: 0 auto 20px auto;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
  white-space: pre-wrap;
  line-height: 1.5;
  text-shadow: 0 2px 5px rgba(0,0,0,0.8);
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 90%;
}

#statusBadge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 14px 0;
  border: 1px solid rgba(255,255,255,0.2);
  letter-spacing: 0.5px;
}

/* =========================================
   COMPONENTS: LINKS & SOCIALS
   ========================================= */
.link-btn {
  display: block;
  margin: 12px 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--card);
  text-decoration: none;
  color: #111;
  font-weight: 600;
  transition: 0.3s;
  backdrop-filter: blur(15px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  animation: slideInUp 0.5s ease both;
  min-height: 48px; /* Accessibility: better touch target */
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-btn:hover {
  transform: translateY(-3px) scale(1.02);
  background: var(--card-hover);
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.5); 
}

.link-btn-inner { display: flex; align-items: center; gap: 10px; justify-content: center; }
.link-btn-icon { font-size: 18px; }

/* Link Styles */
.link-btn.style-glass { background: rgba(255,255,255,0.12) !important; color: white !important; border: 1px solid rgba(255,255,255,0.25) !important; }
.link-btn.style-glass:hover { background: rgba(255,255,255,0.22) !important; }
.link-btn.style-solid { background: rgba(255,255,255,0.95) !important; color: #111 !important; }
.link-btn.style-outline { background: transparent !important; color: white !important; border: 2px solid rgba(255,255,255,0.6) !important; }
.link-btn.style-outline:hover { background: rgba(255,255,255,0.1) !important; }
.link-btn.style-gradient { background: linear-gradient(135deg, var(--glow-color), rgba(100,50,200,0.6)) !important; color: white !important; border: none !important; }
.link-btn.style-sharp { border-radius: 4px !important; background: rgba(255,255,255,0.9) !important; color: #111 !important; }

.socials {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 25px;
  flex-wrap: wrap;
}

.socials a { 
  animation: slideInUp 0.4s ease both; 
  display: inline-block;
}

.socials img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  cursor: pointer;
  transition: 0.3s;
  box-shadow: 0 6px 15px rgba(0,0,0,0.5);
  background: rgba(255,255,255,0.8);
  padding: 2px;
}

.socials img:hover {
  transform: scale(1.15) translateY(-3px);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
}

/* =========================================
   COMPONENTS: SETTINGS PANEL & UI
   ========================================= */
.gear {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 48px; /* slightly larger for touch */
  height: 48px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: 0.2s;
  font-size: 20px;
}

.gear:hover { background: white; transform: rotate(45deg); }

.settings {
  position: fixed;
  top: 0; right: 0;
  width: 380px; max-width: 92vw; height: 100vh;
  background: rgba(10, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  padding: 18px;
  overflow-y: auto;
  color: white;
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}

.settings.open { transform: translateX(0); pointer-events: auto; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 9998;
  opacity: 0;
  transition: 0.4s;
  pointer-events: none;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.section {
  background: rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,0.05);
}

.section h4 {
  margin: 0; font-size: 15px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; /* better touch target */
}

.section-content { margin-top: 12px; display: none; }
.section.open .section-content { display: block; }

/* Form Elements in Settings */
.settings input, .settings button, .settings textarea, .settings select {
  width: 100%; margin: 5px 0; padding: 10px; /* touch friendly */
  border-radius: 8px; border: none; box-sizing: border-box; font-family: inherit;
}

.settings select { background: rgba(255,255,255,0.9); color: #222; cursor: pointer; }
.settings label { font-size: 13px; color: #a9e0ff; font-weight: 600; margin-bottom: 2px; display: block; }
.settings p.info-text { font-size: 12px; color: #d4aaff; margin: 5px 0 10px 0; line-height: 1.4; }

.settings button { background: #388cd9; color: white; font-weight: bold; cursor: pointer; margin-top: 10px; transition: 0.2s; min-height: 44px;}
.settings button:hover { background: #50a0e5; }
.settings button.btn-cancel { background: #a12b2b !important; }
.settings button.btn-cancel:hover { background: #c53838 !important; }

.settings textarea { resize: vertical; background: rgba(255,255,255,0.9); color: #222; }
.settings input[type="text"], .settings input[type="number"], .settings input[type="password"], .settings input[type="url"], .settings input[id^="btn"] {
  background: rgba(255,255,255,0.9); color: #222;
}
.settings input[type="file"] { background: rgba(255,255,255,0.15); color: white; font-size: 12px; padding: 8px; cursor: pointer; }
.settings input[type="color"] { padding: 0; background: transparent; cursor: pointer; border-radius: 8px; height: 44px; }

/* Utility Classes for Settings */
.mt-12 { margin-top: 12px; }
.mt-5 { margin-top: 5px; }
.flex-gap-8 { display: flex; gap: 8px; }
.flex-1 { flex: 1; }
.cursor-default { cursor: default; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0; cursor: pointer; }
.checkbox-label input { width: 20px; height: 20px; margin: 0; padding: 0; cursor: pointer; }
.textarea-custom { resize:vertical; background:rgba(255,255,255,0.9); color:#222; border:none; border-radius:8px; padding:9px; width:100%; box-sizing:border-box; font-family:inherit; margin:5px 0;}
option[data-font] { font-family: attr(data-font); }

/* Drag & Drop Item Boxes */
.itemBox {
  background: rgba(0,0,0,0.3); padding: 10px; border-radius: 10px;
  margin-top: 10px; cursor: grab; transition: transform 0.15s ease;
  border: 1px solid rgba(255,255,255,0.05);
}
.itemBox:active { cursor: grabbing; }
.itemRow { display: flex; gap: 5px; margin-top: 5px; }
.itemRow button { background: #a12b2b; margin-top: 0; }
.itemRow button:hover { background: #c53838; }

.saveMini {
  margin-top: 8px; background: #2f6b31; border-radius: 8px; padding: 10px;
  font-size: 13px; cursor: pointer; text-align: center; font-weight: 600; transition: 0.2s;
}
.saveMini:hover { background: #3c823f; }

/* Settings Grid Buttons */
.theme-grid, .fx-grid, .frame-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }

.theme-btn, .fx-toggle, .style-opt, .frame-opt {
  padding: 10px 6px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.15);
  color: white; font-size: 11px; font-weight: 700; cursor: pointer; transition: 0.2s;
  background: rgba(255,255,255,0.06); text-align: center; font-family: 'Nunito', sans-serif;
  min-height: 44px;
}
.theme-btn:hover, .fx-toggle:hover, .style-opt:hover, .frame-opt:hover { border-color: rgba(255,255,255,0.4); }
.theme-btn.active, .fx-toggle.on, .style-opt.active, .frame-opt.active { border-color: #88ccff; background: rgba(136,204,255,0.15); }
.theme-btn { font-size: 12px; }
.style-opt { font-size: 11px; padding: 10px 4px; }

/* =========================================
   MODALS & POPUPS
   ========================================= */
#pwModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  z-index: 999999; align-items: center; justify-content: center;
}
#pwModal.show { display: flex; }
#pwBox { background: rgba(10,15,25,0.95); border: 1px solid rgba(255,255,255,0.15); border-radius: 18px; padding: 28px; text-align: center; width: 280px; }
#pwBox h3 { margin: 0 0 16px; font-size: 18px; }
#pwBox input { width: 100%; box-sizing: border-box; padding: 12px; border-radius: 10px; border: none; font-size: 15px; margin-bottom: 10px; }
#pwBox button { width: 100% !important; margin: 4px 0 !important; min-height: 44px; }
#pwError { color: #ff6666; font-size: 13px; margin-top: 8px; display: none; }
.pw-hint { font-size:11px; opacity:0.7; margin-top:10px; line-height: 1.4; }

#welcomePopup {
  display: none; position: fixed; inset: 0; z-index: 999990;
  align-items: center; justify-content: center; background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
}
#welcomePopup.show { display: flex; }
#welcomeBox {
  background: linear-gradient(135deg, rgba(20,15,40,0.97), rgba(40,30,80,0.97));
  border: 1px solid rgba(255,255,255,0.15); border-radius: 22px; padding: 36px 28px;
  text-align: center; max-width: 320px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px var(--glow-color);
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
#welcomeBox .welcome-emoji { font-size: 48px; margin-bottom: 12px; }
#welcomeBox h2 { margin: 0 0 10px; font-family: 'Cinzel', serif; font-size: 20px; }
#welcomeBox p  { margin: 0 0 20px; font-size: 15px; opacity: 0.85; line-height: 1.5; }
#welcomeBox button {
  background: linear-gradient(135deg, #5588ff, #aa55ff); color: white; border: none;
  border-radius: 12px; padding: 14px 28px; font-size: 16px; font-weight: 700;
  cursor: pointer; font-family: 'Nunito', sans-serif; transition: 0.2s;
  min-height: 48px;
}
#welcomeBox button:hover { transform: scale(1.05); }

/* =========================================
   MUSIC PLAYER & SPOTIFY
   ========================================= */
#musicBar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10,15,25,0.85); backdrop-filter: blur(18px); border-radius: 30px;
  padding: 9px 18px; display: flex; align-items: center; gap: 12px;
  z-index: 9000; box-shadow: 0 4px 20px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1);
  transition: opacity 0.3s;
}
#musicBar.hidden { display: none; }
#musicBar span { font-size: 13px; opacity: 0.9; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#musicPlayBtn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; padding: 5px; line-height: 1; width: auto !important; margin: 0 !important; }
#musicVolume { width: 80px !important; padding: 0 !important; margin: 0 !important; background: transparent !important; cursor: pointer; }

.spotify-container {
  margin: 20px auto;
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  animation: slideInUp 0.5s ease both;
  display: none;
}
.spotify-container.show { display: block; }
.spotify-container iframe {
  width: 100%;
  border: none;
  display: block;
}

/* =========================================
   REACTIONS
   ========================================= */
#reactionsBar { display: flex; justify-content: center; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.react-btn {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px; padding: 8px 16px; color: white; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; backdrop-filter: blur(8px); transition: 0.2s;
  font-family: 'Nunito', sans-serif; font-weight: 700; min-height: 44px;
}
.react-btn:hover { background: rgba(255,255,255,0.22); transform: scale(1.1); }
.react-btn.reacted { background: rgba(255,255,255,0.28); border-color: rgba(255,255,255,0.5); }
.react-count { font-size: 14px; opacity: 0.9; }

/* =========================================
   VISUAL FX & BACKGROUND ANIMATIONS
   ========================================= */
.bg-animated {
  position: fixed; top: -5%; left: -5%; width: 110vw; height: 110vh;
  background-image: url('appa-mond.png'); background-size: cover; background-position: center;
  z-index: -3; animation: panBackground 15s ease-in-out infinite alternate;
}
.bg-speed-slow { animation-duration: 30s !important; }
.bg-speed-normal { animation-duration: 15s !important; }
.bg-speed-fast { animation-duration: 6s !important; }
.bg-speed-off { animation: none !important; }

.star {
  position: fixed; background: var(--star-color, white); border-radius: 50%;
  z-index: -2; animation: twinkle infinite alternate ease-in-out; pointer-events: none;
}
/* Static stars initial positioning */
.star-1 { width: 2px; height: 2px; top: 15%; left: 20%; animation-duration: 2s; animation-delay: 0s; }
.star-2 { width: 3px; height: 3px; top: 25%; left: 75%; animation-duration: 3.5s; animation-delay: -1s; }
.star-3 { width: 1.5px; height: 1.5px; top: 60%; left: 10%; animation-duration: 1.8s; animation-delay: -2s; }
.star-4 { width: 2.5px; height: 2.5px; top: 80%; left: 85%; animation-duration: 4s; animation-delay: -0.5s; }
.star-5 { width: 2px; height: 2px; top: 40%; left: 90%; animation-duration: 2.5s; animation-delay: -3s; }
.star-6 { width: 3px; height: 3px; top: 70%; left: 30%; animation-duration: 3s; animation-delay: -1.5s; }

#weatherCanvas { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: -1; }
#parallaxLayer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: -2; transition: transform 0.1s ease-out; }

.cursor-dot { position: fixed; border-radius: 50%; pointer-events: none; z-index: 99998; mix-blend-mode: screen; animation: cursorFade 0.8s ease-out forwards; }
.avatar-particle { position: fixed; pointer-events: none; z-index: 99997; border-radius: 50%; animation: particleFall linear forwards; }
.konfetti-piece { position: fixed; width: 10px; height: 10px; pointer-events: none; z-index: 999999; animation: konfettiFall linear forwards; border-radius: 2px; }

/* Avatar Frames */
.avatar-frame-glow { box-shadow: 0 0 0 3px rgba(255,255,255,0.3), 0 0 25px var(--glow-color), 0 0 60px var(--glow-color) !important; }
.avatar-frame-fire { box-shadow: 0 0 0 3px #ff6600, 0 0 20px #ff3300, 0 0 50px #ff6600 !important; animation: fireFlicker 1.2s ease-in-out infinite alternate !important; }
.avatar-frame-rotate { background: conic-gradient(from 0deg, #88ccff, #cc88ff, #ffcc44, #44ffcc, #88ccff) !important; border: none !important; padding: 3px !important; border-radius: 50% !important; animation: spinFrame 3s linear infinite !important; }
.avatar-frame-pulse { animation: pulseFrame 1.8s ease-in-out infinite !important; }

/* Stickers */
#stickerLayer { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 5; pointer-events: none; }
body.edit-mode #stickerLayer { z-index: 9999; }
.sticker-item { position: absolute; pointer-events: none; user-select: none; transition: border 0.2s, background 0.2s; transform-origin: center center;}
body.edit-mode .sticker-item { pointer-events: auto; cursor: grab; border: 2px dashed rgba(255,255,255,0.6); border-radius: 12px; background: rgba(255,255,255,0.1); backdrop-filter: blur(2px); padding: 5px; }
body.edit-mode .sticker-item:active { cursor: grabbing; }

.sticker-text { font-family: 'Nunito', sans-serif; font-weight: bold; white-space: nowrap; text-shadow: 0 2px 5px rgba(0,0,0,0.8); }

/* Appa Easter Egg */
#appaEgg { position: fixed; z-index: 999999; pointer-events: none; width: 220px; height: 220px; top: 50%; left: -260px; transform: translateY(-50%); display: none; animation: appaBodyFloat 0.7s ease-in-out infinite alternate; }
#appaEgg img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: screen; filter: drop-shadow(0 0 14px rgba(180,220,255,1)) drop-shadow(0 0 30px rgba(100,180,255,0.8)) drop-shadow(0 0 50px rgba(140,200,255,0.5)); }
#appaEgg.fly { display: block; animation: appaFly 4s cubic-bezier(0.4,0,0.2,1) forwards, appaBodyFloat 0.7s ease-in-out infinite alternate; }

/* =========================================
   KEYFRAMES
   ========================================= */
@keyframes panBackground { 0% { transform: scale(1) translate(0, 0); } 100% { transform: scale(1.12) translate(-3%, 2%); } }
@keyframes twinkle { 0% { opacity: 0.1; box-shadow: 0 0 0px rgba(255,255,255,0); } 100% { opacity: 1; box-shadow: 0 0 10px rgba(255,255,255,0.8); } }
@keyframes cursorFade { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.1); } }
@keyframes particleFall { 0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); } 100% { opacity: 0; transform: translateY(80px) rotate(720deg) scale(0); } }
@keyframes slideInUp { 0% { opacity: 0; transform: translateY(30px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fireFlicker { 0% { box-shadow: 0 0 0 3px #ff6600, 0 0 15px #ff3300, 0 0 40px #ff6600; } 100% { box-shadow: 0 0 0 3px #ffaa00, 0 0 30px #ff6600, 0 0 70px #ffaa00; } }
@keyframes spinFrame { to { filter: hue-rotate(360deg); } }
@keyframes pulseFrame { 0%,100% { box-shadow: 0 0 0 0 var(--glow-color), 0 0 20px var(--glow-color); } 50% { box-shadow: 0 0 0 10px transparent, 0 0 40px var(--glow-color); } }
@keyframes konfettiFall { 0% { opacity: 1; transform: translateY(-20px) rotate(0deg); } 100% { opacity: 0; transform: translateY(100vh) rotate(720deg); } }
@keyframes appaBodyFloat { 0% { margin-top: 0px; } 100% { margin-top: -12px; } }
@keyframes appaFly { 0% { left: -260px; top: 55%; } 20% { top: 18%; } 50% { top: 35%; } 75% { top: 22%; } 100% { left: 110vw; top: 40%; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.7); } 100% { opacity: 1; transform: scale(1); } }